From 99a6db9f7c4aca399e240ee3aeceb4a84d70d063 Mon Sep 17 00:00:00 2001 From: BenjaminZehowlt Date: Tue, 14 Nov 2023 23:56:37 -0500 Subject: [PATCH] Fix Desktop Notifications --- .github/workflows/github_actions.yml | 2 +- Dotnet/AppApi/AppApi.cs | 29 ++++++++++++++-------------- Properties/AssemblyInfo.cs | 2 ++ VRCX.csproj | 6 +++--- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/.github/workflows/github_actions.yml b/.github/workflows/github_actions.yml index 344760a9c..1d6c0af36 100644 --- a/.github/workflows/github_actions.yml +++ b/.github/workflows/github_actions.yml @@ -34,7 +34,7 @@ jobs: run: cd ${{ github.workspace }}/html && npm run production && cd ${{ github.workspace }} - name: Build .NET Application - run: dotnet build -p:Configuration=Release -p:Platform=x64 -p:TargetFramework=net8-windows -p:EnableWindowsTargeting=true + run: dotnet build -p:Configuration=Release -p:Platform=x64 -p:EnableWindowsTargeting=true - name: Copy Web UI run: cp -r ${{ github.workspace }}/html/dist ${{ github.workspace }}/bin/x64/Release/html diff --git a/Dotnet/AppApi/AppApi.cs b/Dotnet/AppApi/AppApi.cs index 5f50833c0..bbaf13bee 100644 --- a/Dotnet/AppApi/AppApi.cs +++ b/Dotnet/AppApi/AppApi.cs @@ -16,6 +16,7 @@ using System.Windows.Forms; using CefSharp; using librsync.net; +using Microsoft.Toolkit.Uwp.Notifications; using Microsoft.Win32; using NLog; @@ -179,23 +180,21 @@ public string GetImage(string url, string fileId, string version) /// The bold text to display in the notification. /// The optional text to display in the notification. /// The optional image to display in the notification. - /*public void DesktopNotification(string BoldText, string Text = "", string Image = "") + public void DesktopNotification(string BoldText, string Text = "", string Image = "") { - var toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastImageAndText02); - var stringElements = toastXml.GetElementsByTagName("text"); - var imagePath = Path.Combine(Program.BaseDirectory, "VRCX.ico"); - if (!string.IsNullOrEmpty(Image)) - { - imagePath = Image; - } + ToastContentBuilder builder = new ToastContentBuilder(); + + if (Uri.TryCreate(Image, UriKind.Absolute, out Uri uri)) + builder.AddAppLogoOverride(uri); - stringElements[0].AppendChild(toastXml.CreateTextNode(BoldText)); - stringElements[1].AppendChild(toastXml.CreateTextNode(Text)); - var imageElements = toastXml.GetElementsByTagName("image"); - imageElements[0].Attributes.GetNamedItem("src").NodeValue = imagePath; - var toast = new ToastNotification(toastXml); - ToastNotificationManager.CreateToastNotifier("VRCX").Show(toast); - }*/ + if (!string.IsNullOrEmpty(BoldText)) + builder.AddText(Image); + + if (!string.IsNullOrEmpty(Text)) + builder.AddText(Text); + + builder.Show(); + } /// /// Restarts the VRCX application for an update by launching a new process with the "/Upgrade" argument and exiting the current process. diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 130d7001b..4fb72ab17 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -1,6 +1,7 @@ using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; +using System.Runtime.Versioning; // ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 // 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 @@ -9,3 +10,4 @@ // 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. [assembly: Guid("d9f66f2e-3ed9-4d53-a6ac-adcc1513562a")] +[assembly: SupportedOSPlatform("windows")] diff --git a/VRCX.csproj b/VRCX.csproj index c35ac4424..de63acab7 100644 --- a/VRCX.csproj +++ b/VRCX.csproj @@ -1,7 +1,7 @@  WinExe - net8-windows + net8-windows10.0.19041.0 x64 true 0 @@ -120,10 +120,10 @@ - + @@ -132,7 +132,7 @@ - +