cleanup code

This commit is contained in:
Holger Börchers 2018-05-18 20:00:56 +02:00
parent e68f256d80
commit 6d086205d4
2 changed files with 25 additions and 18 deletions

View File

@ -1,6 +1,8 @@
using System;
using System.Runtime.InteropServices;
// ReSharper disable InconsistentNaming
namespace Katteker.Gui
{
/// <summary>
@ -8,6 +10,16 @@ namespace Katteker.Gui
/// </summary>
public static class NativeMethods
{
/// <summary>
/// Hit Test Caption
/// </summary>
public const int HTCAPTION = 0x2;
/// <summary>
/// Posted when the user presses the left mouse button while the cursor is within the nonclient area of a window.
/// </summary>
public const int WM_NCLBUTTONDOWN = 0xA1;
/// <summary>
/// Release the capture
/// </summary>
@ -25,6 +37,5 @@ namespace Katteker.Gui
/// </summary>
[DllImport("user32.dll")]
public static extern bool SetProcessDPIAware();
}
}

View File

@ -8,10 +8,8 @@ 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;
/// <summary>
/// The Update Window
@ -38,10 +36,7 @@ namespace Katteker.Gui
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
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
{