Skip to content

Commit

Permalink
Fix Desktop Notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminZehowlt committed Nov 15, 2023
1 parent 6adfd44 commit 99a6db9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/github_actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 14 additions & 15 deletions Dotnet/AppApi/AppApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using System.Windows.Forms;
using CefSharp;
using librsync.net;
using Microsoft.Toolkit.Uwp.Notifications;
using Microsoft.Win32;
using NLog;

Expand Down Expand Up @@ -179,23 +180,21 @@ public string GetImage(string url, string fileId, string version)
/// <param name="BoldText">The bold text to display in the notification.</param>
/// <param name="Text">The optional text to display in the notification.</param>
/// <param name="Image">The optional image to display in the notification.</param>
/*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();
}

/// <summary>
/// Restarts the VRCX application for an update by launching a new process with the "/Upgrade" argument and exiting the current process.
Expand Down
2 changes: 2 additions & 0 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;

// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에
// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면
Expand All @@ -9,3 +10,4 @@

// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다.
[assembly: Guid("d9f66f2e-3ed9-4d53-a6ac-adcc1513562a")]
[assembly: SupportedOSPlatform("windows")]
6 changes: 3 additions & 3 deletions VRCX.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFrameworks>net8-windows</TargetFrameworks>
<TargetFrameworks>net8-windows10.0.19041.0</TargetFrameworks>
<Platforms>x64</Platforms>
<UseWindowsForms>true</UseWindowsForms>
<ApplicationRevision>0</ApplicationRevision>
Expand Down Expand Up @@ -120,10 +120,10 @@
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="CefSharp.OffScreen" Version="119.1.20" />
<PackageReference Include="CefSharp.OffScreen.NETCore" Version="119.1.20" />
<PackageReference Include="CefSharp.WinForms.NETCore" Version="119.1.20" />
<PackageReference Include="DiscordRichPresence" Version="1.2.1.24" />
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.1.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NLog" Version="5.2.5" />
<PackageReference Include="SharpDX.D3DCompiler" Version="4.2.0" />
Expand All @@ -132,7 +132,7 @@
<PackageReference Include="SharpDX.Direct3D11" Version="4.2.0" />
<PackageReference Include="SharpDX.Mathematics" Version="4.2.0" />
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.118" />
<PackageReference Include="System.Text.Json" Version="7.0.3" />
<PackageReference Include="System.Text.Json" Version="8.0.0" />
</ItemGroup>

<Target Name="CefSharpAfterBuildDebug" AfterTargets="AfterBuild">
Expand Down

0 comments on commit 99a6db9

Please sign in to comment.