Converted the StatusStrip of the MainWindow to a clickthrough StatusStrip.

So the user can click it immediately without having to bring the window into focus first.

Signed-off-by: Konstantina Chremmou <Konstantina.Chremmou@cloud.com>
This commit is contained in:
Konstantina Chremmou 2023-09-08 14:56:11 +01:00
parent 451afe6d93
commit 56628d4b83
5 changed files with 613 additions and 932 deletions

View File

@ -0,0 +1,63 @@
/* Copyright (c) Cloud Software Group, Inc.
*
* Redistribution and use in source and binary forms,
* with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above
* copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the
* following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
using System;
using System.Windows.Forms;
namespace XenAdmin.Controls
{
/// <summary>
/// A System.Windows.Forms.StatusStrip with the option of click-through
/// (see https://learn.microsoft.com/en-us/archive/blogs/rickbrew/how-to-enable-click-through-for-net-2-0-toolstrip-and-menustrip)
/// </summary>
public class StatusStripEx : StatusStrip
{
/// <summary>
/// Gets or sets whether the StatusStripEx honors item clicks when its containing form does
/// not have input focus.
/// </summary>
/// <remarks>
/// Default value is false, which is the same behavior provided by the base StatusStrip class.
/// </remarks>
public bool ClickThrough { get; set; }
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if (ClickThrough &&
m.Msg == NativeConstants.WM_MOUSEACTIVATE &&
m.Result == (IntPtr)NativeConstants.MA_ACTIVATEANDEAT)
{
m.Result = (IntPtr)NativeConstants.MA_ACTIVATE;
}
}
}
}

View File

@ -35,12 +35,10 @@ namespace XenAdmin.Controls
{ {
/// <summary> /// <summary>
/// A System.Windows.Forms.ToolStrip with the option of click-through /// A System.Windows.Forms.ToolStrip with the option of click-through
/// (see http://blogs.msdn.com/rickbrew/archive/2006/01/09/511003.aspx) /// (see https://learn.microsoft.com/en-us/archive/blogs/rickbrew/how-to-enable-click-through-for-net-2-0-toolstrip-and-menustrip)
/// </summary> /// </summary>
public class ToolStripEx : ToolStrip public class ToolStripEx : ToolStrip
{ {
private bool clickThrough = false;
/// <summary> /// <summary>
/// Gets or sets whether the ToolStripEx honors item clicks when its containing form does /// Gets or sets whether the ToolStripEx honors item clicks when its containing form does
/// not have input focus. /// not have input focus.
@ -48,22 +46,13 @@ namespace XenAdmin.Controls
/// <remarks> /// <remarks>
/// Default value is false, which is the same behavior provided by the base ToolStrip class. /// Default value is false, which is the same behavior provided by the base ToolStrip class.
/// </remarks> /// </remarks>
public bool ClickThrough public bool ClickThrough { get; set; }
{
get
{
return this.clickThrough;
}
set
{
this.clickThrough = value;
}
}
protected override void WndProc(ref Message m) protected override void WndProc(ref Message m)
{ {
base.WndProc(ref m); base.WndProc(ref m);
if (this.clickThrough &&
if (ClickThrough &&
m.Msg == NativeConstants.WM_MOUSEACTIVATE && m.Msg == NativeConstants.WM_MOUSEACTIVATE &&
m.Result == (IntPtr)NativeConstants.MA_ACTIVATEANDEAT) m.Result == (IntPtr)NativeConstants.MA_ACTIVATEANDEAT)
{ {

View File

@ -287,13 +287,13 @@ namespace XenAdmin
this.relNotesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.relNotesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.securityGroupsToolStripMenuItem = new XenAdmin.Commands.CommandToolStripMenuItem(); this.securityGroupsToolStripMenuItem = new XenAdmin.Commands.CommandToolStripMenuItem();
this.MenuPanel = new System.Windows.Forms.Panel(); this.MenuPanel = new System.Windows.Forms.Panel();
this.StatusStrip = new System.Windows.Forms.StatusStrip(); this.StatusStrip = new XenAdmin.Controls.StatusStripEx();
this.statusProgressBar = new System.Windows.Forms.ToolStripProgressBar(); this.statusProgressBar = new System.Windows.Forms.ToolStripProgressBar();
this.statusLabel = new System.Windows.Forms.ToolStripStatusLabel(); this.statusLabel = new System.Windows.Forms.ToolStripStatusLabel();
this.statusButtonProgress = new System.Windows.Forms.ToolStripSplitButton(); this.statusButtonProgress = new System.Windows.Forms.ToolStripSplitButton();
this.statusButtonErrors = new System.Windows.Forms.ToolStripSplitButton(); this.statusButtonErrors = new System.Windows.Forms.ToolStripSplitButton();
this.statusButtonCdnUpdates = new System.Windows.Forms.ToolStripSplitButton();
this.statusButtonUpdates = new System.Windows.Forms.ToolStripSplitButton(); this.statusButtonUpdates = new System.Windows.Forms.ToolStripSplitButton();
this.statusButtonCdnUpdates = new System.Windows.Forms.ToolStripSplitButton();
this.statusButtonAlerts = new System.Windows.Forms.ToolStripSplitButton(); this.statusButtonAlerts = new System.Windows.Forms.ToolStripSplitButton();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel1.SuspendLayout();
@ -2002,6 +2002,7 @@ namespace XenAdmin
// StatusStrip // StatusStrip
// //
resources.ApplyResources(this.StatusStrip, "StatusStrip"); resources.ApplyResources(this.StatusStrip, "StatusStrip");
this.StatusStrip.ClickThrough = true;
this.StatusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.StatusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.statusProgressBar, this.statusProgressBar,
this.statusLabel, this.statusLabel,
@ -2046,15 +2047,6 @@ namespace XenAdmin
this.statusButtonErrors.Name = "statusButtonErrors"; this.statusButtonErrors.Name = "statusButtonErrors";
this.statusButtonErrors.Click += new System.EventHandler(this.statusButtonErrors_Click); this.statusButtonErrors.Click += new System.EventHandler(this.statusButtonErrors_Click);
// //
// statusButtonCdnUpdates
//
this.statusButtonCdnUpdates.DropDownButtonWidth = 0;
this.statusButtonCdnUpdates.ForeColor = System.Drawing.SystemColors.ControlDarkDark;
this.statusButtonCdnUpdates.Image = global::XenAdmin.Properties.Resources.notif_updates_16;
resources.ApplyResources(this.statusButtonCdnUpdates, "statusButtonCdnUpdates");
this.statusButtonCdnUpdates.Name = "statusButtonCdnUpdates";
this.statusButtonCdnUpdates.Click += new System.EventHandler(this.statusButtonCdnUpdates_Click);
//
// statusButtonUpdates // statusButtonUpdates
// //
this.statusButtonUpdates.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; this.statusButtonUpdates.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
@ -2065,6 +2057,15 @@ namespace XenAdmin
this.statusButtonUpdates.Name = "statusButtonUpdates"; this.statusButtonUpdates.Name = "statusButtonUpdates";
this.statusButtonUpdates.Click += new System.EventHandler(this.statusButtonUpdates_Click); this.statusButtonUpdates.Click += new System.EventHandler(this.statusButtonUpdates_Click);
// //
// statusButtonCdnUpdates
//
this.statusButtonCdnUpdates.DropDownButtonWidth = 0;
this.statusButtonCdnUpdates.ForeColor = System.Drawing.SystemColors.ControlDarkDark;
this.statusButtonCdnUpdates.Image = global::XenAdmin.Properties.Resources.notif_updates_16;
resources.ApplyResources(this.statusButtonCdnUpdates, "statusButtonCdnUpdates");
this.statusButtonCdnUpdates.Name = "statusButtonCdnUpdates";
this.statusButtonCdnUpdates.Click += new System.EventHandler(this.statusButtonCdnUpdates_Click);
//
// statusButtonAlerts // statusButtonAlerts
// //
this.statusButtonAlerts.DropDownButtonWidth = 0; this.statusButtonAlerts.DropDownButtonWidth = 0;
@ -2318,7 +2319,7 @@ namespace XenAdmin
private System.Windows.Forms.ToolStripMenuItem customTemplatesToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem customTemplatesToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem templatesToolStripMenuItem1; private System.Windows.Forms.ToolStripMenuItem templatesToolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem localStorageToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem localStorageToolStripMenuItem;
private System.Windows.Forms.StatusStrip StatusStrip; private XenAdmin.Controls.StatusStripEx StatusStrip;
private System.Windows.Forms.ToolStripStatusLabel statusLabel; private System.Windows.Forms.ToolStripStatusLabel statusLabel;
private System.Windows.Forms.ToolStripProgressBar statusProgressBar; private System.Windows.Forms.ToolStripProgressBar statusProgressBar;
private XenAdmin.Commands.CommandToolStripMenuItem reclaimFreedSpacetripMenuItem; private XenAdmin.Commands.CommandToolStripMenuItem reclaimFreedSpacetripMenuItem;

File diff suppressed because it is too large Load Diff

View File

@ -199,6 +199,9 @@
<Compile Include="Controls\DiskSpinner.Designer.cs"> <Compile Include="Controls\DiskSpinner.Designer.cs">
<DependentUpon>DiskSpinner.cs</DependentUpon> <DependentUpon>DiskSpinner.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Controls\StatusStripEx.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Controls\TreeViews\FolderChangeDialogTreeView.cs"> <Compile Include="Controls\TreeViews\FolderChangeDialogTreeView.cs">
<SubType>Component</SubType> <SubType>Component</SubType>
</Compile> </Compile>