diff --git a/Handlers/SnapcastHandler.cs b/Handlers/SnapcastHandler.cs index f3e4f47..59d1a88 100644 --- a/Handlers/SnapcastHandler.cs +++ b/Handlers/SnapcastHandler.cs @@ -1,4 +1,5 @@ -using System; +using Hardcodet.Wpf.TaskbarNotification; +using System; using System.Diagnostics; using System.Windows; @@ -18,6 +19,13 @@ namespace unison Start(); } + private void UpdateSystray() + { + TaskbarIcon Systray = (TaskbarIcon)Application.Current.Properties["systray"]; + SystrayViewModel DataContext = Systray.DataContext as SystrayViewModel; + DataContext.OnPropertyChanged("SnapcastText"); + } + public void Start() { if (!Started) @@ -37,11 +45,13 @@ namespace unison return; } Started = true; + UpdateSystray(); } else { _snapcast.Kill(); Started = false; + UpdateSystray(); } } @@ -51,6 +61,7 @@ namespace unison { _snapcast.Kill(); Started = false; + UpdateSystray(); } } } diff --git a/Views/SystrayViewModel.cs b/Views/SystrayViewModel.cs index 3e4946b..77354c2 100644 --- a/Views/SystrayViewModel.cs +++ b/Views/SystrayViewModel.cs @@ -33,7 +33,7 @@ namespace unison CanExecuteFunc = () => true }; - public static string SnapcastText + public string SnapcastText { get { @@ -75,7 +75,7 @@ namespace unison public event PropertyChangedEventHandler PropertyChanged; - protected virtual void OnPropertyChanged(string propertyName) + public virtual void OnPropertyChanged(string propertyName) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); }