diff --git a/GUI/Gadget.cs b/GUI/Gadget.cs index 6d385a6..f8ff0be 100644 --- a/GUI/Gadget.cs +++ b/GUI/Gadget.cs @@ -137,7 +137,16 @@ namespace OpenHardwareMonitor.GUI { remove { window.HitTest -= value; } - } + } + + public event MouseEventHandler MouseDoubleClick { + add { + window.MouseDoubleClick += value; + } + remove { + window.MouseDoubleClick -= value; + } + } private void CreateBuffer() { this.buffer = new Bitmap(window.Size.Width, window.Size.Height, diff --git a/GUI/GadgetWindow.cs b/GUI/GadgetWindow.cs index 96068a2..6493db1 100644 --- a/GUI/GadgetWindow.cs +++ b/GUI/GadgetWindow.cs @@ -132,6 +132,11 @@ namespace OpenHardwareMonitor.GUI { } } break; case WM_NCLBUTTONDBLCLK: { + if (MouseDoubleClick != null) { + MouseDoubleClick(this, new MouseEventArgs(MouseButtons.Left, 2, + Macros.GET_X_LPARAM(message.LParam) - location.X, + Macros.GET_Y_LPARAM(message.LParam) - location.Y, 0)); + } message.Result = IntPtr.Zero; } break; case WM_NCRBUTTONDOWN: { @@ -360,6 +365,8 @@ namespace OpenHardwareMonitor.GUI { public event HitTestEventHandler HitTest; + public event MouseEventHandler MouseDoubleClick; + [StructLayout(LayoutKind.Sequential, Pack = 1)] private struct BlendFunction { public byte BlendOp; diff --git a/GUI/MainForm.cs b/GUI/MainForm.cs index 56f7d98..2e2f86d 100644 --- a/GUI/MainForm.cs +++ b/GUI/MainForm.cs @@ -129,6 +129,8 @@ namespace OpenHardwareMonitor.GUI { minCloseMenuItem.Visible = false; } else { // Windows gadget = new SensorGadget(computer, settings, unitManager); + gadget.HideShowCommand += hideShowClick; + wmiProvider = new WmiProvider(computer); } diff --git a/GUI/SensorGadget.cs b/GUI/SensorGadget.cs index 9602892..d7486c7 100644 --- a/GUI/SensorGadget.cs +++ b/GUI/SensorGadget.cs @@ -194,6 +194,10 @@ namespace OpenHardwareMonitor.GUI { settings.SetValue("sensorGadget.Width", Size.Width); Redraw(); }; + + MouseDoubleClick += delegate(object obj, MouseEventArgs args) { + SendHideShowCommand(); + }; } public override void Dispose() { @@ -304,6 +308,13 @@ namespace OpenHardwareMonitor.GUI { Resize(); } + public event EventHandler HideShowCommand; + + public void SendHideShowCommand() { + if (HideShowCommand != null) + HideShowCommand(this, null); + } + private Font CreateFont(float size, FontStyle style) { try { return new Font(SystemFonts.MessageBoxFont.FontFamily, size, style);