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,30 +1,41 @@
using System;
using System.Runtime.InteropServices;
// ReSharper disable InconsistentNaming
namespace Katteker.Gui
{
/// <summary>
/// Native methods.
/// Native methods.
/// </summary>
public static class NativeMethods
{
/// <summary>
/// Release the capture
/// 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>
[DllImport("User32.dll")]
public static extern bool ReleaseCapture();
/// <summary>
/// Send message
/// Send message
/// </summary>
[DllImport("User32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
/// <summary>
/// Set Process API aware
/// Set Process API aware
/// </summary>
[DllImport("user32.dll")]
public static extern bool SetProcessDPIAware();
}
}

View File

@ -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;
/// <summary>
/// The Update Window
/// The Update Window
/// </summary>
public UpdateWindow(UpdateManager updateManager, ReleaseEntry entry)
{
@ -30,18 +28,15 @@ namespace Katteker.Gui
private string Changelog => _updateManager.ChangelogFilename;
private string PublishPath => _updateManager.UrlOrPath;
/// <inheritdoc />
/// <summary>
/// Clean up any resources being used.
/// Clean up any resources being used.
/// </summary>
/// <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
{