From 78994c71f5f1fee3250ced72eef2b7b799459458 Mon Sep 17 00:00:00 2001 From: Paul Hebble Date: Fri, 11 Oct 2024 20:07:11 -0500 Subject: [PATCH] Minor tray icon improvements --- GUI/Main/Main.Designer.cs | 4 ++++ GUI/Main/Main.cs | 3 ++- GUI/Main/Main.resx | 1 - GUI/Main/MainTrayIcon.cs | 32 +++++++++++++++++++++++--------- 4 files changed, 29 insertions(+), 11 deletions(-) diff --git a/GUI/Main/Main.Designer.cs b/GUI/Main/Main.Designer.cs index 85f59cdb7..057afb431 100644 --- a/GUI/Main/Main.Designer.cs +++ b/GUI/Main/Main.Designer.cs @@ -713,6 +713,7 @@ private void InitializeComponent() // this.minimizeNotifyIcon.ContextMenuStrip = this.minimizedContextMenuStrip; this.minimizeNotifyIcon.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.minimizeNotifyIcon_MouseDoubleClick); + this.minimizeNotifyIcon.MouseClick += new System.Windows.Forms.MouseEventHandler(this.minimizeNotifyIcon_MouseClick); this.minimizeNotifyIcon.BalloonTipClicked += new System.EventHandler(this.minimizeNotifyIcon_BalloonTipClicked); this.minimizeNotifyIcon.Icon = EmbeddedImages.AppIcon; resources.ApplyResources(this.minimizeNotifyIcon, "minimizeNotifyIcon"); @@ -740,12 +741,14 @@ private void InitializeComponent() this.updatesToolStripMenuItem.Name = "updatesToolStripMenuItem"; this.updatesToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.updatesToolStripMenuItem.Click += new System.EventHandler(this.updatesToolStripMenuItem_Click); + this.updatesToolStripMenuItem.Visible = false; resources.ApplyResources(this.updatesToolStripMenuItem, "updatesToolStripMenuItem"); // // toolStripSeparator4 // this.toolStripSeparator4.Name = "toolStripSeparator4"; this.toolStripSeparator4.Size = new System.Drawing.Size(177, 6); + this.toolStripSeparator4.Visible = false; // // refreshToolStripMenuItem // @@ -771,6 +774,7 @@ private void InitializeComponent() this.openCKANToolStripMenuItem.Name = "openCKANToolStripMenuItem"; this.openCKANToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.openCKANToolStripMenuItem.Click += new System.EventHandler(this.openCKANToolStripMenuItem_Click); + this.openCKANToolStripMenuItem.Visible = false; resources.ApplyResources(this.openCKANToolStripMenuItem, "openCKANToolStripMenuItem"); // // openGameToolStripMenuItem diff --git a/GUI/Main/Main.cs b/GUI/Main/Main.cs index 978a3ef7b..274c0e1e2 100644 --- a/GUI/Main/Main.cs +++ b/GUI/Main/Main.cs @@ -416,7 +416,8 @@ private void CurrentInstanceUpdated() Util.Invoke(this, () => { - Text = $"CKAN {Meta.GetVersion()} - {CurrentInstance.game.ShortName} {CurrentInstance.Version()} -- {Platform.FormatPath(CurrentInstance.GameDir())}"; + Text = $"{Meta.GetProductName()} {Meta.GetVersion()} - {CurrentInstance.game.ShortName} {CurrentInstance.Version()} -- {Platform.FormatPath(CurrentInstance.GameDir())}"; + minimizeNotifyIcon.Text = $"{Meta.GetProductName()} - {CurrentInstance.Name}"; UpdateStatusBar(); }); diff --git a/GUI/Main/Main.resx b/GUI/Main/Main.resx index 14ed8d3a5..199876145 100644 --- a/GUI/Main/Main.resx +++ b/GUI/Main/Main.resx @@ -154,7 +154,6 @@ Unmanaged Files Installation History CKAN - N available updates Refresh Pause Open CKAN diff --git a/GUI/Main/MainTrayIcon.cs b/GUI/Main/MainTrayIcon.cs index 011a7d4f4..4a1cde6bf 100644 --- a/GUI/Main/MainTrayIcon.cs +++ b/GUI/Main/MainTrayIcon.cs @@ -38,11 +38,13 @@ private void UpdateTrayState() // Remove our taskbar entry Hide(); } + openCKANToolStripMenuItem.Visible = true; } else { // Save the window state configuration.IsWindowMaximised = WindowState == FormWindowState.Maximized; + openCKANToolStripMenuItem.Visible = false; } } else @@ -65,6 +67,8 @@ private void UpdateTrayInfo() updatesToolStripMenuItem.Enabled = true; updatesToolStripMenuItem.Text = string.Format(Properties.Resources.MainTrayUpdatesAvailable, count); } + toolStripSeparator4.Visible = true; + updatesToolStripMenuItem.Visible = true; } /// @@ -74,11 +78,23 @@ public void OpenWindow() { Show(); WindowState = configuration?.IsWindowMaximised ?? false ? FormWindowState.Maximized : FormWindowState.Normal; + openCKANToolStripMenuItem.Visible = false; + } + + private void minimizeNotifyIcon_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + OpenWindow(); + } } private void minimizeNotifyIcon_MouseDoubleClick(object sender, MouseEventArgs e) { - OpenWindow(); + if (e.Button == MouseButtons.Left) + { + OpenWindow(); + } } private void updatesToolStripMenuItem_Click(object? sender, EventArgs? e) @@ -134,9 +150,9 @@ private void minimizedContextMenuStrip_Opening(object? sender, CancelEventArgs? { // The menu location can be partly off-screen by default. // Fix it. - minimizedContextMenuStrip.Location = Util.ClampedLocation( - minimizedContextMenuStrip.Location, - minimizedContextMenuStrip.Size); + minimizedContextMenuStrip.Location = + Util.ClampedLocation(minimizedContextMenuStrip.Location, + minimizedContextMenuStrip.Size); } private void minimizeNotifyIcon_BalloonTipClicked(object? sender, EventArgs? e) @@ -149,11 +165,9 @@ private void minimizeNotifyIcon_BalloonTipClicked(object? sender, EventArgs? e) // Install Wait.StartWaiting(InstallMods, PostInstallMods, true, - new InstallArgument( - ManageMods.ComputeUserChangeSet() - .ToList(), - RelationshipResolverOptions.DependsOnlyOpts()) - ); + new InstallArgument(ManageMods.ComputeUserChangeSet() + .ToList(), + RelationshipResolverOptions.DependsOnlyOpts())); } #endregion }