public void Enable() { if (this.Enabled) { return; } try { ToastNotificationHelper.Install(); ToastNotificationHelper.Invoke(new Action( () => { if (Publication.IsPortable) { this.ToastNotifier = ToastNotificationManager.CreateToastNotifier(ToastNotificationHelper.ID); } else { this.ToastNotifier = ToastNotificationManager.CreateToastNotifier(); } } ), null); this.PlaybackManager.CurrentStreamChanged += this.OnCurrentStreamChanged; } catch (Exception e) { Logger.Write(this, LogLevel.Warn, "Failed to enable: {0}", e.Message); } }
protected virtual void ShowNotification() { var outputStream = this.PlaybackManager.CurrentStream; if (outputStream == null) { return; } try { var notification = this.CreateNotification(outputStream); ToastNotificationHelper.Invoke(new Action(() => this.ToastNotifier.Show(notification)), null); } catch (Exception e) { Logger.Write(this, LogLevel.Warn, "Failed to show notification: {0}", e.Message); } }