Skip to content

Commit ffeb0ae

Browse files
blackspherefollowerqdot
authored andcommitted
Adding a toast event handler
C;icking the toast notification will now raise the GUI to the front. Fixes #266
1 parent 28b12c4 commit ffeb0ae

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

Buttplug.Apps.WebsocketServerGUI/WebsocketServerControl.xaml.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ private void ExceptionLogged(object aObj, [NotNull] LogExceptionEventArgs aEvent
129129
toastXml.SelectSingleNode("//*[@id='1']").InnerText = "Buttplug Error";
130130
toastXml.SelectSingleNode("//*[@id='2']").InnerText = aEvent.ErrorMessage;
131131
var toast = new ToastNotification(toastXml);
132+
toast.Activated += OnActivatedToast;
132133
var appId = (string)Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AppID\" + AppDomain.CurrentDomain.FriendlyName, "AppId", string.Empty);
133134
if (appId != null && appId.Length > 0)
134135
{
@@ -138,6 +139,11 @@ private void ExceptionLogged(object aObj, [NotNull] LogExceptionEventArgs aEvent
138139
}
139140
}
140141

142+
private void OnActivatedToast(ToastNotification sender, object args)
143+
{
144+
Dispatcher.Invoke(() => { Window.GetWindow(this).Activate(); });
145+
}
146+
141147
public void StartServer()
142148
{
143149
try

0 commit comments

Comments
 (0)