Added option to minimize to system tray on closing, fixes #545

This commit is contained in:
Faryan Rezagholi
2019-10-01 09:31:11 +02:00
parent 8b060745ef
commit 31f637bc51
10 changed files with 75 additions and 18 deletions

View File

@@ -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

View File

@@ -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;
}
}
}
}

View File

@@ -734,5 +734,8 @@
<Setting Name="ConDefaultUseEnhancedMode" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="CloseToTray" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@@ -1514,6 +1514,17 @@ namespace mRemoteNG
}
}
/// <summary>
/// Looks up a localized string similar to Close to notification area.
/// </summary>
internal static string strCloseToSysTray
{
get
{
return ResourceManager.GetString("strCloseToSysTray", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Collapse all folders.
/// </summary>

View File

@@ -2690,4 +2690,7 @@ Development umfasst Alphas, Betas und Release Candidates.</value>
<data name="strPropertyDescriptionPasswordProtect" xml:space="preserve">
<value>Legen Sie ein Kennwort fest, mit dem die Verbindungsdatei verschlüsselt werden soll. Sie werden aufgefordert Ihr Passwort einzugeben, bevor Sie mRemoteNG starten.</value>
</data>
<data name="strCloseToSysTray" xml:space="preserve">
<value>In den System Tray schließen</value>
</data>
</root>

View File

@@ -2837,4 +2837,7 @@ Development Channel includes Alphas, Betas &amp; Release Candidates.</value>
<data name="strPropertyDescriptionRedirectMicrophones" xml:space="preserve">
<value>Select whether microphones should be shared.</value>
</data>
<data name="strCloseToSysTray" xml:space="preserve">
<value>Close to notification area</value>
</data>
</root>

View File

@@ -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;
}
}

View File

@@ -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;
}
}
}

View File

@@ -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;

View File

@@ -760,6 +760,9 @@
<setting name="ConDefaultUseEnhancedMode" serializeAs="String">
<value>False</value>
</setting>
<setting name="CloseToTray" serializeAs="String">
<value>False</value>
</setting>
</mRemoteNG.Settings>
</userSettings>
<applicationSettings>