From 6d086205d488e5c22d703bad4b75596a5390a243 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Holger=20B=C3=B6rchers?= Date: Fri, 18 May 2018 20:00:56 +0200 Subject: [PATCH] cleanup code --- Katteker.Gui/NativeMethods.cs | 21 ++++++++++++++++----- Katteker.Gui/UpdateWindow.cs | 22 +++++++++------------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/Katteker.Gui/NativeMethods.cs b/Katteker.Gui/NativeMethods.cs index b4d395f..3a57b26 100644 --- a/Katteker.Gui/NativeMethods.cs +++ b/Katteker.Gui/NativeMethods.cs @@ -1,30 +1,41 @@ using System; using System.Runtime.InteropServices; +// ReSharper disable InconsistentNaming + namespace Katteker.Gui { /// - /// Native methods. + /// Native methods. /// public static class NativeMethods { /// - /// Release the capture + /// Hit Test Caption + /// + public const int HTCAPTION = 0x2; + + /// + /// Posted when the user presses the left mouse button while the cursor is within the nonclient area of a window. + /// + public const int WM_NCLBUTTONDOWN = 0xA1; + + /// + /// Release the capture /// [DllImport("User32.dll")] public static extern bool ReleaseCapture(); /// - /// Send message + /// Send message /// [DllImport("User32.dll")] public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); /// - /// Set Process API aware + /// Set Process API aware /// [DllImport("user32.dll")] public static extern bool SetProcessDPIAware(); - } } \ No newline at end of file diff --git a/Katteker.Gui/UpdateWindow.cs b/Katteker.Gui/UpdateWindow.cs index 1c03690..1185cda 100644 --- a/Katteker.Gui/UpdateWindow.cs +++ b/Katteker.Gui/UpdateWindow.cs @@ -8,13 +8,11 @@ namespace Katteker.Gui { public sealed partial class UpdateWindow : Form { - private readonly UpdateManager _updateManager; private readonly ReleaseEntry _entry; - private const int HTCAPTION = 0x2; - private const int WM_NCLBUTTONDOWN = 0xA1; + private readonly UpdateManager _updateManager; /// - /// The Update Window + /// The Update Window /// public UpdateWindow(UpdateManager updateManager, ReleaseEntry entry) { @@ -30,18 +28,15 @@ namespace Katteker.Gui private string Changelog => _updateManager.ChangelogFilename; private string PublishPath => _updateManager.UrlOrPath; - + /// /// - /// Clean up any resources being used. + /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { - if (disposing) - { - components?.Dispose(); - } + if (disposing) components?.Dispose(); base.Dispose(disposing); } @@ -67,9 +62,10 @@ namespace Katteker.Gui MaximizeBtn_Click(sender, e); return; } + if (e.Button != MouseButtons.Left) return; NativeMethods.ReleaseCapture(); - NativeMethods.SendMessage(Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0); + NativeMethods.SendMessage(Handle, NativeMethods.WM_NCLBUTTONDOWN, NativeMethods.HTCAPTION, 0); } @@ -128,9 +124,9 @@ namespace Katteker.Gui } catch (Exception ex) { - MessageBox.Show(Resources.CouldNotUpdateYourApplication + Environment.NewLine + ex.Message, Gui.Properties.Resources.Updater, MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show(Resources.CouldNotUpdateYourApplication + Environment.NewLine + ex.Message, + Resources.Updater, MessageBoxButtons.OK, MessageBoxIcon.Error); WriteTitle(Resources.Updater); - } finally {