Fixed Systray NotifyPropertyChanged, shortcut setting window
This commit is contained in:
		
							
								
								
									
										1
									
								
								App.xaml
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								App.xaml
									
									
									
									
									
								
							| @@ -3,7 +3,6 @@ | |||||||
|              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||||||
|              xmlns:local="clr-namespace:unison" |              xmlns:local="clr-namespace:unison" | ||||||
|              ShutdownMode="OnExplicitShutdown"> |              ShutdownMode="OnExplicitShutdown"> | ||||||
|     <!--StartupUri="MainWindow.xaml"--> |  | ||||||
|     <Application.Resources> |     <Application.Resources> | ||||||
|  |  | ||||||
|         <ResourceDictionary> |         <ResourceDictionary> | ||||||
|   | |||||||
| @@ -61,7 +61,7 @@ namespace unison | |||||||
|  |  | ||||||
|             if (msg == WM_HOTKEY && wParam.ToInt32() == HOTKEY_ID) |             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; |                 MainWindow AppWindow = (MainWindow)Application.Current.MainWindow; | ||||||
|                 switch (vkey) |                 switch (vkey) | ||||||
|                 { |                 { | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ | |||||||
|         xmlns:local="clr-namespace:unison" |         xmlns:local="clr-namespace:unison" | ||||||
|         mc:Ignorable="d" |         mc:Ignorable="d" | ||||||
|         Title="unison" |         Title="unison" | ||||||
|         Closing="Window_Closing" Icon="/unison.ico" ResizeMode="CanMinimize" SizeToContent="WidthAndHeight"> |         Closing="Window_Closing" Icon="/images/unison.ico" ResizeMode="CanMinimize" SizeToContent="WidthAndHeight"> | ||||||
|  |  | ||||||
|     <Grid Background="{DynamicResource {x:Static SystemColors.ControlLightLightBrushKey}}" MinHeight="270"> |     <Grid Background="{DynamicResource {x:Static SystemColors.ControlLightLightBrushKey}}" MinHeight="270"> | ||||||
|         <Grid x:Name="TopLayout" Margin="10,0,10,0" VerticalAlignment="Stretch" Width="Auto" Height="Auto"> |         <Grid x:Name="TopLayout" Margin="10,0,10,0" VerticalAlignment="Stretch" Width="Auto" Height="Auto"> | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ | |||||||
|         xmlns:emoji="clr-namespace:Emoji.Wpf;assembly=Emoji.Wpf" |         xmlns:emoji="clr-namespace:Emoji.Wpf;assembly=Emoji.Wpf" | ||||||
|         xmlns:local="clr-namespace:unison" |         xmlns:local="clr-namespace:unison" | ||||||
|         mc:Ignorable="d" |         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"> | ||||||
|     <Grid> |     <Grid> | ||||||
|         <StackPanel Orientation="Vertical"> |         <StackPanel Orientation="Vertical"> | ||||||
|             <TabControl Margin="10"> |             <TabControl Margin="10"> | ||||||
| @@ -68,6 +68,47 @@ | |||||||
|                     </DockPanel> |                     </DockPanel> | ||||||
|                 </TabItem> |                 </TabItem> | ||||||
|  |  | ||||||
|  |                 <TabItem Header="Shortcuts"> | ||||||
|  |                     <DockPanel Margin="8"> | ||||||
|  |                         <GroupBox DockPanel.Dock="Top" Padding="0,4,0,0"> | ||||||
|  |                             <GroupBox.Header> | ||||||
|  |                                 <StackPanel Orientation="Horizontal"> | ||||||
|  |                                     <emoji:TextBlock Text="⌨️ Shortcuts"/> | ||||||
|  |                                 </StackPanel> | ||||||
|  |                             </GroupBox.Header> | ||||||
|  |                             <Grid> | ||||||
|  |                                 <Grid MinWidth="220"> | ||||||
|  |                                     <Grid.ColumnDefinitions> | ||||||
|  |                                         <ColumnDefinition/> | ||||||
|  |                                         <ColumnDefinition/> | ||||||
|  |                                     </Grid.ColumnDefinitions> | ||||||
|  |                                     <Grid.RowDefinitions> | ||||||
|  |                                         <RowDefinition/> | ||||||
|  |                                         <RowDefinition/> | ||||||
|  |                                         <RowDefinition/> | ||||||
|  |                                         <RowDefinition/> | ||||||
|  |                                         <RowDefinition/> | ||||||
|  |                                         <RowDefinition/> | ||||||
|  |                                     </Grid.RowDefinitions> | ||||||
|  |                                     <TextBlock Text="Next track" TextWrapping="Wrap" Grid.Column="0" Grid.Row="0" Margin="1"/> | ||||||
|  |                                     <TextBlock Text="Previous track" TextWrapping="Wrap" Grid.Column="0" Grid.Row="1" Margin="1"/> | ||||||
|  |                                     <TextBlock Text="Play / Pause" TextWrapping="Wrap" Grid.Column="0" Grid.Row="2" Margin="1"/> | ||||||
|  |                                     <TextBlock Text="Volume up" TextWrapping="Wrap" Grid.Column="0" Grid.Row="3" Margin="1"/> | ||||||
|  |                                     <TextBlock Text="Volume down" TextWrapping="Wrap" Grid.Column="0" Grid.Row="4" Margin="1"/> | ||||||
|  |                                     <TextBlock Text="Show window" TextWrapping="Wrap" Grid.Column="0" Grid.Row="5" Margin="1"/> | ||||||
|  |  | ||||||
|  |                                     <TextBlock Text="ctrl + media_next" TextWrapping="Wrap" Grid.Column="1" Grid.Row="0" Margin="1" HorizontalAlignment="Right" FontWeight="Bold"/> | ||||||
|  |                                     <TextBlock Text="ctrl + media_prev" TextWrapping="Wrap" Grid.Column="1" Grid.Row="1" Margin="1" HorizontalAlignment="Right" FontWeight="Bold"/> | ||||||
|  |                                     <TextBlock Text="ctrl + media_play" TextWrapping="Wrap" Grid.Column="1" Grid.Row="2" Margin="1" HorizontalAlignment="Right" FontWeight="Bold"/> | ||||||
|  |                                     <TextBlock Text="ctrl + volume_up" TextWrapping="Wrap" Grid.Column="1" Grid.Row="3" Margin="1" HorizontalAlignment="Right" FontWeight="Bold"/> | ||||||
|  |                                     <TextBlock Text="ctrl + volume_down" TextWrapping="Wrap" Grid.Column="1" Grid.Row="4" Margin="1" HorizontalAlignment="Right" FontWeight="Bold"/> | ||||||
|  |                                     <TextBlock Text="ctrl + alt + enter" TextWrapping="Wrap" Grid.Column="1" Grid.Row="5" Margin="1" HorizontalAlignment="Right" FontWeight="Bold"/> | ||||||
|  |                                 </Grid> | ||||||
|  |                             </Grid> | ||||||
|  |                         </GroupBox> | ||||||
|  |                     </DockPanel> | ||||||
|  |                 </TabItem> | ||||||
|  |  | ||||||
|                 <TabItem Header="About" Height="20" VerticalAlignment="Bottom"> |                 <TabItem Header="About" Height="20" VerticalAlignment="Bottom"> | ||||||
|                     <DockPanel Margin="8"> |                     <DockPanel Margin="8"> | ||||||
|                         <GroupBox DockPanel.Dock="Top" Padding="0,4,0,0"> |                         <GroupBox DockPanel.Dock="Top" Padding="0,4,0,0"> | ||||||
|   | |||||||
| @@ -1,16 +1,15 @@ | |||||||
| <ResourceDictionary  | <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||||||
|                     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |  | ||||||
|                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||||||
|                     xmlns:tb="http://www.hardcodet.net/taskbar" |                     xmlns:tb="http://www.hardcodet.net/taskbar" | ||||||
|                     xmlns:local="clr-namespace:unison"> |                     xmlns:local="clr-namespace:unison"> | ||||||
|  |  | ||||||
|     <tb:TaskbarIcon x:Name="SystrayTaskbar" xmlns:emoji="clr-namespace:Emoji.Wpf;assembly=Emoji.Wpf" |     <tb:TaskbarIcon x:Name="SystrayTaskbar" xmlns:emoji="clr-namespace:Emoji.Wpf;assembly=Emoji.Wpf" | ||||||
|             IconSource="/unison.ico" ToolTipText="{Binding GetAppText}" DoubleClickCommand="{Binding ShowWindowCommand}" x:Key="SystrayTaskbar"> |             IconSource="/images/unison.ico" ToolTipText="{Binding GetAppText}" DoubleClickCommand="{Binding ShowWindowCommand}" x:Key="SystrayTaskbar"> | ||||||
|         <tb:TaskbarIcon.ContextMenu> |         <tb:TaskbarIcon.ContextMenu> | ||||||
|             <ContextMenu> |             <ContextMenu> | ||||||
|                 <MenuItem IsEnabled="False"> |                 <MenuItem IsEnabled="False"> | ||||||
|                     <MenuItem.Icon> |                     <MenuItem.Icon> | ||||||
|                         <Image Source="/unison.ico" Width="16" Height="16"/> |                         <Image Source="/images/unison.ico" Width="16" Height="16"/> | ||||||
|                     </MenuItem.Icon> |                     </MenuItem.Icon> | ||||||
|                     <MenuItem.Header> |                     <MenuItem.Header> | ||||||
|                         <TextBlock Text="{Binding GetAppText}" /> |                         <TextBlock Text="{Binding GetAppText}" /> | ||||||
| @@ -46,7 +45,7 @@ | |||||||
|             </ContextMenu> |             </ContextMenu> | ||||||
|         </tb:TaskbarIcon.ContextMenu> |         </tb:TaskbarIcon.ContextMenu> | ||||||
|         <tb:TaskbarIcon.DataContext> |         <tb:TaskbarIcon.DataContext> | ||||||
|             <local:NotifyIconViewModel /> |             <local:SystrayViewModel /> | ||||||
|         </tb:TaskbarIcon.DataContext> |         </tb:TaskbarIcon.DataContext> | ||||||
|     </tb:TaskbarIcon> |     </tb:TaskbarIcon> | ||||||
|  |  | ||||||
|   | |||||||
| @@ -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)); |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| }*/ |  | ||||||
| @@ -3,23 +3,13 @@ using System.Windows.Input; | |||||||
| using System.Reflection; | using System.Reflection; | ||||||
| using System.ComponentModel; | using System.ComponentModel; | ||||||
| using System; | using System; | ||||||
| using System.Windows.Threading; |  | ||||||
| 
 | 
 | ||||||
| namespace unison | namespace unison | ||||||
| { | { | ||||||
|     public class NotifyIconViewModel : INotifyPropertyChanged |     public class SystrayViewModel : INotifyPropertyChanged | ||||||
|     { |     { | ||||||
|         private DispatcherTimer timer; |         public SystrayViewModel() | ||||||
| 
 |  | ||||||
|         public NotifyIconViewModel() |  | ||||||
|         { |         { | ||||||
|             //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<AssemblyInformationalVersionAttribute>().InformationalVersion; |         public string GetAppText => "unison v" + Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion; | ||||||
| @@ -51,7 +41,6 @@ namespace unison | |||||||
|         { |         { | ||||||
|             get |             get | ||||||
|             { |             { | ||||||
|                 //Application.Current.Dispatcher.BeginInvoke(new Action(() => OnPropertyChanged("SnapcastText"))); |  | ||||||
|                 SnapcastHandler snapcast = (SnapcastHandler)Application.Current.Properties["snapcast"]; |                 SnapcastHandler snapcast = (SnapcastHandler)Application.Current.Properties["snapcast"]; | ||||||
|                 return snapcast.Started ? "Stop Snapcast" : "Start Snapcast"; |                 return snapcast.Started ? "Stop Snapcast" : "Start Snapcast"; | ||||||
|             } |             } | ||||||
| @@ -61,11 +50,13 @@ namespace unison | |||||||
|         { |         { | ||||||
|             get |             get | ||||||
|             { |             { | ||||||
|                 Application.Current.Dispatcher.BeginInvoke(new Action(() => OnPropertyChanged("SnapcastText"))); |  | ||||||
|                 NotifyPropertyChanged("SnapcastText"); |  | ||||||
|                 return new DelegateCommand |                 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 |                     CanExecuteFunc = () => true | ||||||
|                 }; |                 }; | ||||||
|             } |             } | ||||||
| @@ -77,26 +68,15 @@ namespace unison | |||||||
|             { |             { | ||||||
|                 return new DelegateCommand |                 return new DelegateCommand | ||||||
|                 { |                 { | ||||||
|                     CommandAction = () => ((MainWindow)Application.Current.MainWindow).Settings_Clicked(null, null), |                     CommandAction = () => | ||||||
|  |                     { | ||||||
|  |                         ((MainWindow)Application.Current.MainWindow).Settings_Clicked(null, null); | ||||||
|  |                     }, | ||||||
|                     CanExecuteFunc = () => true |                     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; |         public event PropertyChangedEventHandler PropertyChanged; | ||||||
| 
 | 
 | ||||||
|         protected virtual void OnPropertyChanged(string propertyName) |         protected virtual void OnPropertyChanged(string propertyName) | ||||||
| @@ -104,11 +84,5 @@ namespace unison | |||||||
|             PropertyChangedEventHandler handler = PropertyChanged; |             PropertyChangedEventHandler handler = PropertyChanged; | ||||||
|             if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName)); |             if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName)); | ||||||
|         } |         } | ||||||
| 
 |  | ||||||
|         private void NotifyPropertyChanged(string propertyName = "") |  | ||||||
|         { |  | ||||||
|             if (PropertyChanged != null) |  | ||||||
|                 PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); |  | ||||||
|         } |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @@ -4,7 +4,7 @@ | |||||||
|     <OutputType>WinExe</OutputType> |     <OutputType>WinExe</OutputType> | ||||||
|     <TargetFramework>net5.0-windows</TargetFramework> |     <TargetFramework>net5.0-windows</TargetFramework> | ||||||
|     <UseWPF>true</UseWPF> |     <UseWPF>true</UseWPF> | ||||||
|     <ApplicationIcon>unison.ico</ApplicationIcon> |     <ApplicationIcon>images\unison.ico</ApplicationIcon> | ||||||
|     <Win32Resource></Win32Resource> |     <Win32Resource></Win32Resource> | ||||||
|     <StartupObject>unison.App</StartupObject> |     <StartupObject>unison.App</StartupObject> | ||||||
|     <Version>0.0.1</Version> |     <Version>0.0.1</Version> | ||||||
| @@ -13,6 +13,7 @@ | |||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <None Remove="images\nocover-test.png" /> |     <None Remove="images\nocover-test.png" /> | ||||||
|     <None Remove="images\nocover.png" /> |     <None Remove="images\nocover.png" /> | ||||||
|  |     <None Remove="images\unison.ico" /> | ||||||
|     <None Remove="LICENSE" /> |     <None Remove="LICENSE" /> | ||||||
|     <None Remove="snapclient_0.25.0-1_win64\FLAC.dll" /> |     <None Remove="snapclient_0.25.0-1_win64\FLAC.dll" /> | ||||||
|     <None Remove="snapclient_0.25.0-1_win64\ogg.dll" /> |     <None Remove="snapclient_0.25.0-1_win64\ogg.dll" /> | ||||||
| @@ -21,7 +22,6 @@ | |||||||
|     <None Remove="snapclient_0.25.0-1_win64\snapclient.exe" /> |     <None Remove="snapclient_0.25.0-1_win64\snapclient.exe" /> | ||||||
|     <None Remove="snapclient_0.25.0-1_win64\soxr.dll" /> |     <None Remove="snapclient_0.25.0-1_win64\soxr.dll" /> | ||||||
|     <None Remove="snapclient_0.25.0-1_win64\vorbis.dll" /> |     <None Remove="snapclient_0.25.0-1_win64\vorbis.dll" /> | ||||||
|     <None Remove="unison.ico" /> |  | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|  |  | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
| @@ -37,7 +37,7 @@ | |||||||
|     <Content Include="snapclient_0.25.0-1_win64\README.txt"> |     <Content Include="snapclient_0.25.0-1_win64\README.txt"> | ||||||
|       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||||||
|     </Content> |     </Content> | ||||||
|     <Resource Include="unison.ico"> |     <Resource Include="images\unison.ico"> | ||||||
|       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||||||
|     </Resource> |     </Resource> | ||||||
|     <Content Include="snapclient_0.25.0-1_win64\FLAC.dll"> |     <Content Include="snapclient_0.25.0-1_win64\FLAC.dll"> | ||||||
|   | |||||||
							
								
								
									
										
											BIN
										
									
								
								unison.ico
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								unison.ico
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							| Before Width: | Height: | Size: 20 KiB | 
		Reference in New Issue
	
	Block a user