From 31f637bc51d409c272d553a5dce80684c9da7c13 Mon Sep 17 00:00:00 2001 From: Faryan Rezagholi Date: Tue, 1 Oct 2019 09:31:11 +0200 Subject: [PATCH] Added option to minimize to system tray on closing, fixes #545 --- CHANGELOG.md | 1 + mRemoteV1/Properties/Settings.Designer.cs | 14 ++++++++- mRemoteV1/Properties/Settings.settings | 3 ++ .../Resources/Language/Language.Designer.cs | 11 +++++++ mRemoteV1/Resources/Language/Language.de.resx | 3 ++ mRemoteV1/Resources/Language/Language.resx | 3 ++ .../OptionsPages/AppearancePage.Designer.cs | 31 +++++++++++++------ .../UI/Forms/OptionsPages/AppearancePage.cs | 5 ++- mRemoteV1/UI/Forms/frmMain.cs | 19 +++++++----- mRemoteV1/app.config | 3 ++ 10 files changed, 75 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e2fa378..37fcd554 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] ### Added +- #545: Option to minimize to system tray on closing ### Changed - #1460: Updated GeckoFX to v60 ### Fixed diff --git a/mRemoteV1/Properties/Settings.Designer.cs b/mRemoteV1/Properties/Settings.Designer.cs index b0272218..fb52b47c 100644 --- a/mRemoteV1/Properties/Settings.Designer.cs +++ b/mRemoteV1/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace mRemoteNG { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.2.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.3.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); @@ -2950,5 +2950,17 @@ namespace mRemoteNG { this["ConDefaultUseEnhancedMode"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool CloseToTray { + get { + return ((bool)(this["CloseToTray"])); + } + set { + this["CloseToTray"] = value; + } + } } } diff --git a/mRemoteV1/Properties/Settings.settings b/mRemoteV1/Properties/Settings.settings index 1eb721ba..233fe66c 100644 --- a/mRemoteV1/Properties/Settings.settings +++ b/mRemoteV1/Properties/Settings.settings @@ -734,5 +734,8 @@ False + + False + \ No newline at end of file diff --git a/mRemoteV1/Resources/Language/Language.Designer.cs b/mRemoteV1/Resources/Language/Language.Designer.cs index cf8c675f..abf98505 100644 --- a/mRemoteV1/Resources/Language/Language.Designer.cs +++ b/mRemoteV1/Resources/Language/Language.Designer.cs @@ -1514,6 +1514,17 @@ namespace mRemoteNG } } + /// + /// Looks up a localized string similar to Close to notification area. + /// + internal static string strCloseToSysTray + { + get + { + return ResourceManager.GetString("strCloseToSysTray", resourceCulture); + } + } + /// /// Looks up a localized string similar to Collapse all folders. /// diff --git a/mRemoteV1/Resources/Language/Language.de.resx b/mRemoteV1/Resources/Language/Language.de.resx index bb688231..8694e1c6 100644 --- a/mRemoteV1/Resources/Language/Language.de.resx +++ b/mRemoteV1/Resources/Language/Language.de.resx @@ -2690,4 +2690,7 @@ Development umfasst Alphas, Betas und Release Candidates. Legen Sie ein Kennwort fest, mit dem die Verbindungsdatei verschlüsselt werden soll. Sie werden aufgefordert Ihr Passwort einzugeben, bevor Sie mRemoteNG starten. + + In den System Tray schließen + \ No newline at end of file diff --git a/mRemoteV1/Resources/Language/Language.resx b/mRemoteV1/Resources/Language/Language.resx index 00d21305..ebf44072 100644 --- a/mRemoteV1/Resources/Language/Language.resx +++ b/mRemoteV1/Resources/Language/Language.resx @@ -2837,4 +2837,7 @@ Development Channel includes Alphas, Betas & Release Candidates. Select whether microphones should be shared. + + Close to notification area + \ No newline at end of file diff --git a/mRemoteV1/UI/Forms/OptionsPages/AppearancePage.Designer.cs b/mRemoteV1/UI/Forms/OptionsPages/AppearancePage.Designer.cs index 05b35647..ec5b0105 100644 --- a/mRemoteV1/UI/Forms/OptionsPages/AppearancePage.Designer.cs +++ b/mRemoteV1/UI/Forms/OptionsPages/AppearancePage.Designer.cs @@ -37,6 +37,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages this.chkShowDescriptionTooltipsInTree = new mRemoteNG.UI.Controls.Base.NGCheckBox(); this.chkShowSystemTrayIcon = new mRemoteNG.UI.Controls.Base.NGCheckBox(); this.chkMinimizeToSystemTray = new mRemoteNG.UI.Controls.Base.NGCheckBox(); + this.chkCloseToSystemTray = new mRemoteNG.UI.Controls.Base.NGCheckBox(); this.SuspendLayout(); // // lblLanguageRestartRequired @@ -70,7 +71,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages // // chkShowFullConnectionsFilePathInTitle // - this.chkShowFullConnectionsFilePathInTitle._mice = mRemoteNG.UI.Controls.Base.NGCheckBox.MouseState.HOVER; + this.chkShowFullConnectionsFilePathInTitle._mice = mRemoteNG.UI.Controls.Base.NGCheckBox.MouseState.OUT; this.chkShowFullConnectionsFilePathInTitle.AutoSize = true; this.chkShowFullConnectionsFilePathInTitle.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.chkShowFullConnectionsFilePathInTitle.Location = new System.Drawing.Point(3, 127); @@ -82,7 +83,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages // // chkShowDescriptionTooltipsInTree // - this.chkShowDescriptionTooltipsInTree._mice = mRemoteNG.UI.Controls.Base.NGCheckBox.MouseState.HOVER; + this.chkShowDescriptionTooltipsInTree._mice = mRemoteNG.UI.Controls.Base.NGCheckBox.MouseState.OUT; this.chkShowDescriptionTooltipsInTree.AutoSize = true; this.chkShowDescriptionTooltipsInTree.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.chkShowDescriptionTooltipsInTree.Location = new System.Drawing.Point(3, 104); @@ -94,32 +95,45 @@ namespace mRemoteNG.UI.Forms.OptionsPages // // chkShowSystemTrayIcon // - this.chkShowSystemTrayIcon._mice = mRemoteNG.UI.Controls.Base.NGCheckBox.MouseState.HOVER; + this.chkShowSystemTrayIcon._mice = mRemoteNG.UI.Controls.Base.NGCheckBox.MouseState.OUT; this.chkShowSystemTrayIcon.AutoSize = true; this.chkShowSystemTrayIcon.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.chkShowSystemTrayIcon.Location = new System.Drawing.Point(3, 173); this.chkShowSystemTrayIcon.Name = "chkShowSystemTrayIcon"; - this.chkShowSystemTrayIcon.Size = new System.Drawing.Size(177, 17); + this.chkShowSystemTrayIcon.Size = new System.Drawing.Size(178, 17); this.chkShowSystemTrayIcon.TabIndex = 5; this.chkShowSystemTrayIcon.Text = "Always show System Tray Icon"; this.chkShowSystemTrayIcon.UseVisualStyleBackColor = true; // // chkMinimizeToSystemTray // - this.chkMinimizeToSystemTray._mice = mRemoteNG.UI.Controls.Base.NGCheckBox.MouseState.HOVER; + this.chkMinimizeToSystemTray._mice = mRemoteNG.UI.Controls.Base.NGCheckBox.MouseState.OUT; this.chkMinimizeToSystemTray.AutoSize = true; this.chkMinimizeToSystemTray.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.chkMinimizeToSystemTray.Location = new System.Drawing.Point(3, 196); this.chkMinimizeToSystemTray.Name = "chkMinimizeToSystemTray"; - this.chkMinimizeToSystemTray.Size = new System.Drawing.Size(146, 17); + this.chkMinimizeToSystemTray.Size = new System.Drawing.Size(147, 17); this.chkMinimizeToSystemTray.TabIndex = 6; this.chkMinimizeToSystemTray.Text = "Minimize to System Tray"; this.chkMinimizeToSystemTray.UseVisualStyleBackColor = true; // + // chkCloseToSystemTray + // + this.chkCloseToSystemTray._mice = mRemoteNG.UI.Controls.Base.NGCheckBox.MouseState.OUT; + this.chkCloseToSystemTray.AutoSize = true; + this.chkCloseToSystemTray.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.chkCloseToSystemTray.Location = new System.Drawing.Point(3, 219); + this.chkCloseToSystemTray.Name = "chkCloseToSystemTray"; + this.chkCloseToSystemTray.Size = new System.Drawing.Size(129, 17); + this.chkCloseToSystemTray.TabIndex = 7; + this.chkCloseToSystemTray.Text = "Close to System Tray"; + this.chkCloseToSystemTray.UseVisualStyleBackColor = true; + // // AppearancePage // this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; + this.Controls.Add(this.chkCloseToSystemTray); this.Controls.Add(this.lblLanguageRestartRequired); this.Controls.Add(this.cboLanguage); this.Controls.Add(this.lblLanguage); @@ -127,7 +141,6 @@ namespace mRemoteNG.UI.Forms.OptionsPages this.Controls.Add(this.chkShowDescriptionTooltipsInTree); this.Controls.Add(this.chkShowSystemTrayIcon); this.Controls.Add(this.chkMinimizeToSystemTray); - this.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.Name = "AppearancePage"; this.Size = new System.Drawing.Size(610, 490); this.ResumeLayout(false); @@ -141,6 +154,6 @@ namespace mRemoteNG.UI.Forms.OptionsPages internal Controls.Base.NGCheckBox chkShowDescriptionTooltipsInTree; internal Controls.Base.NGCheckBox chkShowSystemTrayIcon; internal Controls.Base.NGCheckBox chkMinimizeToSystemTray; - - } + internal Controls.Base.NGCheckBox chkCloseToSystemTray; + } } diff --git a/mRemoteV1/UI/Forms/OptionsPages/AppearancePage.cs b/mRemoteV1/UI/Forms/OptionsPages/AppearancePage.cs index ad9f6101..6d7c7f58 100644 --- a/mRemoteV1/UI/Forms/OptionsPages/AppearancePage.cs +++ b/mRemoteV1/UI/Forms/OptionsPages/AppearancePage.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Windows.Forms; using mRemoteNG.App; using mRemoteNG.Tools; @@ -31,6 +31,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages chkShowFullConnectionsFilePathInTitle.Text = Language.strShowFullConsFilePath; chkShowSystemTrayIcon.Text = Language.strAlwaysShowSysTrayIcon; chkMinimizeToSystemTray.Text = Language.strMinimizeToSysTray; + chkCloseToSystemTray.Text = Language.strCloseToSysTray; } public override void LoadSettings() @@ -58,6 +59,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages chkShowFullConnectionsFilePathInTitle.Checked = Settings.Default.ShowCompleteConsPathInTitle; chkShowSystemTrayIcon.Checked = Settings.Default.ShowSystemTrayIcon; chkMinimizeToSystemTray.Checked = Settings.Default.MinimizeToTray; + chkCloseToSystemTray.Checked = Settings.Default.CloseToTray; } public override void SaveSettings() @@ -95,6 +97,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages } Settings.Default.MinimizeToTray = chkMinimizeToSystemTray.Checked; + Settings.Default.CloseToTray = chkCloseToSystemTray.Checked; } } } \ No newline at end of file diff --git a/mRemoteV1/UI/Forms/frmMain.cs b/mRemoteV1/UI/Forms/frmMain.cs index 038431ac..cf17ea9b 100644 --- a/mRemoteV1/UI/Forms/frmMain.cs +++ b/mRemoteV1/UI/Forms/frmMain.cs @@ -355,13 +355,8 @@ namespace mRemoteNG.UI.Forms { if (!Settings.Default.CheckForUpdatesOnStartup) return; - var nextUpdateCheck = Convert.ToDateTime( - Settings.Default.CheckForUpdatesLastCheck.Add( - TimeSpan - .FromDays(Convert - .ToDouble(Settings - .Default - .CheckForUpdatesFrequencyDays)))); + var nextUpdateCheck = + Convert.ToDateTime(Settings.Default.CheckForUpdatesLastCheck.Add(TimeSpan.FromDays(Convert.ToDouble(Settings.Default.CheckForUpdatesFrequencyDays)))); if (!Settings.Default.UpdatePending && DateTime.UtcNow <= nextUpdateCheck) return; if (!IsHandleCreated) @@ -372,6 +367,16 @@ namespace mRemoteNG.UI.Forms private void frmMain_FormClosing(object sender, FormClosingEventArgs e) { + if (Settings.Default.CloseToTray) + { + if (Runtime.NotificationAreaIcon == null) + Runtime.NotificationAreaIcon = new NotificationAreaIcon(); + + Hide(); + e.Cancel = true; + return; + } + if (!(Runtime.WindowList == null || Runtime.WindowList.Count == 0)) { var openConnections = 0; diff --git a/mRemoteV1/app.config b/mRemoteV1/app.config index aa501356..14621f90 100644 --- a/mRemoteV1/app.config +++ b/mRemoteV1/app.config @@ -760,6 +760,9 @@ False + + False +