diff --git a/App.xaml b/App.xaml index 37926a2..1d28055 100644 --- a/App.xaml +++ b/App.xaml @@ -3,7 +3,6 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:unison" ShutdownMode="OnExplicitShutdown"> - diff --git a/Handlers/HotkeyHandler.cs b/Handlers/HotkeyHandler.cs index 4cb7f85..8bdaf86 100644 --- a/Handlers/HotkeyHandler.cs +++ b/Handlers/HotkeyHandler.cs @@ -61,7 +61,7 @@ namespace unison if (msg == WM_HOTKEY && wParam.ToInt32() == HOTKEY_ID) { - uint vkey = (((uint)lParam >> 16) & 0xFFFF); + uint vkey = ((uint)lParam >> 16) & 0xFFFF; MainWindow AppWindow = (MainWindow)Application.Current.MainWindow; switch (vkey) { diff --git a/windowless/DelegateCommand.cs b/Views/DelegateCommand.cs similarity index 100% rename from windowless/DelegateCommand.cs rename to Views/DelegateCommand.cs diff --git a/Views/MainWindow.xaml b/Views/MainWindow.xaml index b85b0dd..465016e 100644 --- a/Views/MainWindow.xaml +++ b/Views/MainWindow.xaml @@ -8,7 +8,7 @@ xmlns:local="clr-namespace:unison" mc:Ignorable="d" Title="unison" - Closing="Window_Closing" Icon="/unison.ico" ResizeMode="CanMinimize" SizeToContent="WidthAndHeight"> + Closing="Window_Closing" Icon="/images/unison.ico" ResizeMode="CanMinimize" SizeToContent="WidthAndHeight"> diff --git a/Views/Settings.xaml b/Views/Settings.xaml index 83151d4..07ff685 100644 --- a/Views/Settings.xaml +++ b/Views/Settings.xaml @@ -6,7 +6,7 @@ xmlns:emoji="clr-namespace:Emoji.Wpf;assembly=Emoji.Wpf" xmlns:local="clr-namespace:unison" mc:Ignorable="d" - Closing="Window_Closing" Title="Settings" ResizeMode="CanMinimize" Icon="/unison.ico" WindowStyle="ToolWindow" SizeToContent="WidthAndHeight"> + Closing="Window_Closing" Title="Settings" ResizeMode="CanMinimize" Icon="/images/unison.ico" WindowStyle="ToolWindow" SizeToContent="WidthAndHeight"> @@ -68,6 +68,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Views/Systray.xaml b/Views/Systray.xaml index cf55984..17c2a8f 100644 --- a/Views/Systray.xaml +++ b/Views/Systray.xaml @@ -1,16 +1,15 @@ - + IconSource="/images/unison.ico" ToolTipText="{Binding GetAppText}" DoubleClickCommand="{Binding ShowWindowCommand}" x:Key="SystrayTaskbar"> - + @@ -46,7 +45,7 @@ - + diff --git a/Views/Systray.xaml.cs b/Views/Systray.xaml.cs deleted file mode 100644 index 1454eec..0000000 --- a/Views/Systray.xaml.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.ComponentModel; -using System.Diagnostics; -using System.Windows; -using System.Windows.Controls; - -/*namespace unison -{ - public partial class Systray : ResourceDictionary, INotifyPropertyChanged - { - public Systray() - { - } - - public event PropertyChangedEventHandler PropertyChanged; - - private void NotifyPropertyChanged(string propertyName = "") - { - if (PropertyChanged != null) - PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); - } - } -}*/ \ No newline at end of file diff --git a/windowless/NotifyIconViewModel.cs b/Views/SystrayViewModel.cs similarity index 54% rename from windowless/NotifyIconViewModel.cs rename to Views/SystrayViewModel.cs index 6fabf33..4f5a529 100644 --- a/windowless/NotifyIconViewModel.cs +++ b/Views/SystrayViewModel.cs @@ -3,23 +3,13 @@ using System.Windows.Input; using System.Reflection; using System.ComponentModel; using System; -using System.Windows.Threading; namespace unison { - public class NotifyIconViewModel : INotifyPropertyChanged + public class SystrayViewModel : INotifyPropertyChanged { - private DispatcherTimer timer; - - public NotifyIconViewModel() + public SystrayViewModel() { - //timer = new DispatcherTimer(TimeSpan.FromSeconds(1), DispatcherPriority.Normal, OnTimerTick, Application.Current.Dispatcher); - } - - private void OnTimerTick(object sender, EventArgs e) - { - //fire a property change event for the timestamp - //Application.Current.Dispatcher.BeginInvoke(new Action(() => OnPropertyChanged("SnapcastText"))); } public string GetAppText => "unison v" + Assembly.GetEntryAssembly().GetCustomAttribute().InformationalVersion; @@ -51,7 +41,6 @@ namespace unison { get { - //Application.Current.Dispatcher.BeginInvoke(new Action(() => OnPropertyChanged("SnapcastText"))); SnapcastHandler snapcast = (SnapcastHandler)Application.Current.Properties["snapcast"]; return snapcast.Started ? "Stop Snapcast" : "Start Snapcast"; } @@ -61,11 +50,13 @@ namespace unison { get { - Application.Current.Dispatcher.BeginInvoke(new Action(() => OnPropertyChanged("SnapcastText"))); - NotifyPropertyChanged("SnapcastText"); return new DelegateCommand { - CommandAction = () => ((MainWindow)Application.Current.MainWindow).Snapcast_Clicked(null, null), + CommandAction = () => + { + Application.Current.Dispatcher.BeginInvoke(new Action(() => OnPropertyChanged("SnapcastText"))); + ((MainWindow)Application.Current.MainWindow).Snapcast_Clicked(null, null); + }, CanExecuteFunc = () => true }; } @@ -77,26 +68,15 @@ namespace unison { return new DelegateCommand { - CommandAction = () => ((MainWindow)Application.Current.MainWindow).Settings_Clicked(null, null), + CommandAction = () => + { + ((MainWindow)Application.Current.MainWindow).Settings_Clicked(null, null); + }, CanExecuteFunc = () => true }; } } - public string GetSnapcastText - { - get - { - /*if (Application.Current.MainWindow != null) - { - SnapcastHandler snapcast = (SnapcastHandler)Application.Current.Properties["snapcast"]; - return snapcast.Started ? "Stop Snapcast" : "Start Snapcast"; - } - return "not initialized";*/ - return SnapcastText; - } - } - public event PropertyChangedEventHandler PropertyChanged; protected virtual void OnPropertyChanged(string propertyName) @@ -104,11 +84,5 @@ namespace unison PropertyChangedEventHandler handler = PropertyChanged; if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName)); } - - private void NotifyPropertyChanged(string propertyName = "") - { - if (PropertyChanged != null) - PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); - } } -} +} \ No newline at end of file diff --git a/unison.csproj b/unison.csproj index 1ccd801..91162df 100644 --- a/unison.csproj +++ b/unison.csproj @@ -4,7 +4,7 @@ WinExe net5.0-windows true - unison.ico + images\unison.ico unison.App 0.0.1 @@ -13,6 +13,7 @@ + @@ -21,7 +22,6 @@ - @@ -37,7 +37,7 @@ PreserveNewest - + PreserveNewest diff --git a/unison.ico b/unison.ico deleted file mode 100644 index 8bf76f8..0000000 Binary files a/unison.ico and /dev/null differ