diff --git a/README.md b/README.md index 6e6e7e2..fbd2116 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ # RGBSyncPlus Tool to syncronize RGB devices + +If you've issues with the configuration window not opening when clicking the Tray-Icon you can disable Tray-Minimization by changing ```"MinimizeToTray":true``` to ```"MinimizeToTray":false``` in _Settings.json_ in the installation directory. (If this entry isn't already included delete the file and start/close the program once.) \ No newline at end of file diff --git a/RGBSync+/App.xaml.cs b/RGBSync+/App.xaml.cs index cb651cb..5fe5f46 100644 --- a/RGBSync+/App.xaml.cs +++ b/RGBSync+/App.xaml.cs @@ -55,6 +55,12 @@ namespace RGBSyncPlus ApplicationManager.Instance.Settings = settings; ApplicationManager.Instance.Initialize(); + + if (!settings.MinimizeToTray) //HACK DarthAffe 02.12.2018: Workaround to create the window + { + ApplicationManager.Instance.OpenConfigurationCommand.Execute(null); + ApplicationManager.Instance.HideConfigurationCommand.Execute(null); + } } catch (Exception ex) { diff --git a/RGBSync+/ApplicationManager.cs b/RGBSync+/ApplicationManager.cs index c5fb75d..0c70c0a 100644 --- a/RGBSync+/ApplicationManager.cs +++ b/RGBSync+/ApplicationManager.cs @@ -39,6 +39,9 @@ namespace RGBSyncPlus private ActionCommand _openConfiguration; public ActionCommand OpenConfigurationCommand => _openConfiguration ?? (_openConfiguration = new ActionCommand(OpenConfiguration)); + private ActionCommand _hideConfiguration; + public ActionCommand HideConfigurationCommand => _hideConfiguration ?? (_hideConfiguration = new ActionCommand(HideConfiguration)); + private ActionCommand _exitCommand; public ActionCommand ExitCommand => _exitCommand ?? (_exitCommand = new ActionCommand(Exit)); @@ -133,10 +136,26 @@ namespace RGBSyncPlus } } + private void HideConfiguration() + { + if (Settings.MinimizeToTray) + { + if (_configurationWindow.IsVisible) + _configurationWindow.Hide(); + } + else + _configurationWindow.WindowState = WindowState.Minimized; + } + private void OpenConfiguration() { if (_configurationWindow == null) _configurationWindow = new ConfigurationWindow(); - _configurationWindow.Show(); + + if (!_configurationWindow.IsVisible) + _configurationWindow.Show(); + + if (_configurationWindow.WindowState == WindowState.Minimized) + _configurationWindow.WindowState = WindowState.Normal; } private void Exit() diff --git a/RGBSync+/Configuration/Settings.cs b/RGBSync+/Configuration/Settings.cs index c9f4981..3d82981 100644 --- a/RGBSync+/Configuration/Settings.cs +++ b/RGBSync+/Configuration/Settings.cs @@ -17,6 +17,8 @@ namespace RGBSyncPlus.Configuration public double UpdateRate { get; set; } = 30.0; + public bool MinimizeToTray { get; set; } = true; + public List SyncGroups { get; set; } = new List(); #endregion diff --git a/RGBSync+/Controls/BlurredDecorationWindow.cs b/RGBSync+/Controls/BlurredDecorationWindow.cs index ec0efc8..f7afd9d 100644 --- a/RGBSync+/Controls/BlurredDecorationWindow.cs +++ b/RGBSync+/Controls/BlurredDecorationWindow.cs @@ -76,7 +76,7 @@ namespace RGBSyncPlus.Controls closeButton.Click += (sender, args) => ApplicationManager.Instance.ExitCommand.Execute(null); if (GetTemplateChild("PART_MinimizeButton") is Button minimizeButton) - minimizeButton.Click += (sender, args) => Hide(); + minimizeButton.Click += (sender, args) => ApplicationManager.Instance.HideConfigurationCommand.Execute(null); //HACK DarthAffe 02.12.2018: This is a really dirty hack - hopefully this will never get more than one window ... if (GetTemplateChild("PART_IconButton") is Button iconButton) iconButton.Click += (sender, args) => IconCommand?.Execute(null);