Fixed restoring of chosen tray icon image

This commit is contained in:
Travis Nickles 2019-12-26 21:15:55 -06:00
parent 4282485801
commit a4936eb5a0
3 changed files with 8 additions and 5 deletions

View File

@ -14,7 +14,7 @@
mc:Ignorable="d"
Title="DS4Windows" Height="500" Width="800" Closing="MainDS4Window_Closing" Closed="MainDS4Window_Closed" StateChanged="MainDS4Window_StateChanged" SizeChanged="MainDS4Window_SizeChanged" LocationChanged="MainDS4Window_LocationChanged">
<DockPanel>
<tb:TaskbarIcon x:Name="notifyIcon" IconSource="{Binding IconSource}" ToolTipText="{Binding TooltipText}" MenuActivation="RightClick" TrayRightMouseUp="NotifyIcon_TrayRightMouseUp" TrayMiddleMouseDown="NotifyIcon_TrayMiddleMouseDown" TrayMouseDoubleClick="NotifyIcon_TrayMouseDoubleClick">
<tb:TaskbarIcon x:Name="notifyIcon" IconSource="{Binding IconSource,Mode=OneWay}" ToolTipText="{Binding TooltipText,Mode=OneWay}" MenuActivation="RightClick" TrayRightMouseUp="NotifyIcon_TrayRightMouseUp" TrayMiddleMouseDown="NotifyIcon_TrayMiddleMouseDown" TrayMouseDoubleClick="NotifyIcon_TrayMouseDoubleClick">
<!--<tb:TaskbarIcon.ContextMenu>
<ContextMenu>
<MenuItem Header="Open" />

View File

@ -77,8 +77,6 @@ namespace DS4WinWPF.DS4Forms
ChangeControllerPanel();
trayIconVM = new TrayIconViewModel(App.rootHub, profileListHolder);
notifyIcon.DataContext = trayIconVM;
notifyIcon.Icon = Global.UseWhiteIcon ? Properties.Resources.DS4W___White :
Properties.Resources.DS4W;
if (Global.StartMinimized || parser.Mini)
{
@ -1066,7 +1064,7 @@ Properties.Resources.DS4Update, MessageBoxButton.YesNo, MessageBoxImage.Question
private void UseWhiteDS4IconCk_Click(object sender, RoutedEventArgs e)
{
bool status = useWhiteDS4IconCk.IsChecked == true;
notifyIcon.Icon = status ? Properties.Resources.DS4W___White : Properties.Resources.DS4W;
trayIconVM.IconSource = status ? TrayIconViewModel.ICON_WHITE : TrayIconViewModel.ICON_COLOR;
}
private void CheckDrivers()

View File

@ -9,7 +9,9 @@ namespace DS4WinWPF.DS4Forms.ViewModels
public class TrayIconViewModel
{
private string tooltipText = "DS4Windows";
private string iconSource = "/DS4Windows;component/Resources/DS4W.ico";
public const string ICON_COLOR = "/DS4Windows;component/Resources/DS4W.ico";
public const string ICON_WHITE = "/DS4Windows;component/Resources/DS4W - White.ico";
private string iconSource = ICON_COLOR;
public const string ballonTitle = "DS4Windows";
public static string trayTitle = $"DS4Windows v{Global.exeversion}";
private ContextMenu contextMenu;
@ -57,6 +59,9 @@ namespace DS4WinWPF.DS4Forms.ViewModels
this.profileListHolder = profileListHolder;
this.controlService = service;
contextMenu = new ContextMenu();
iconSource = Global.UseWhiteIcon ? "/DS4Windows;component/Resources/DS4W - White.ico" :
"/DS4Windows;component/Resources/DS4W.ico";
PopulateControllerList();
PopulateToolText();
PopulateContextMenu();