mirror of
https://github.com/LorenzCK/OnTopReplica.git
synced 2024-05-21 04:43:55 +12:00
Clean up
This commit is contained in:
parent
27b1b4d5da
commit
1ac70ff5ec
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
|
@ -16,7 +16,7 @@ namespace OnTopReplica {
|
|||
partial class MainForm : AspectRatioForm {
|
||||
|
||||
//GUI elements
|
||||
ThumbnailPanel _thumbnailPanel;
|
||||
private ThumbnailPanel _thumbnailPanel;
|
||||
|
||||
//Managers
|
||||
readonly MessagePumpManager _msgPumpManager = new MessagePumpManager();
|
||||
|
@ -30,13 +30,13 @@ namespace OnTopReplica {
|
|||
|
||||
FullscreenManager = new FullscreenFormManager(this);
|
||||
_quickRegionDrawingHandler = new ThumbnailPanel.RegionDrawnHandler(HandleQuickRegionDrawn);
|
||||
|
||||
|
||||
//WinForms init pass
|
||||
InitializeComponent();
|
||||
|
||||
//Store default values
|
||||
DefaultNonClickTransparencyKey = this.TransparencyKey;
|
||||
DefaultBorderStyle = this.FormBorderStyle;
|
||||
DefaultNonClickTransparencyKey = TransparencyKey;
|
||||
DefaultBorderStyle = FormBorderStyle;
|
||||
|
||||
//Thumbnail panel
|
||||
_thumbnailPanel = new ThumbnailPanel {
|
||||
|
@ -52,7 +52,7 @@ namespace OnTopReplica {
|
|||
);
|
||||
|
||||
//Set to Key event preview
|
||||
this.KeyPreview = true;
|
||||
KeyPreview = true;
|
||||
|
||||
Log.Write("Main form constructed");
|
||||
}
|
||||
|
@ -456,6 +456,6 @@ namespace OnTopReplica {
|
|||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ using WindowsFormsAero.TaskDialog;
|
|||
using OnTopReplica.SidePanels;
|
||||
|
||||
namespace OnTopReplica {
|
||||
|
||||
partial class MainForm {
|
||||
|
||||
private void Menu_opening(object sender, CancelEventArgs e) {
|
||||
|
@ -58,11 +59,11 @@ namespace OnTopReplica {
|
|||
|
||||
private void Menu_Opacity_opening(object sender, CancelEventArgs e) {
|
||||
ToolStripMenuItem[] items = {
|
||||
toolStripMenuItem1,
|
||||
toolStripMenuItem2,
|
||||
toolStripMenuItem3,
|
||||
toolStripMenuItem4
|
||||
};
|
||||
toolStripMenuItem1,
|
||||
toolStripMenuItem2,
|
||||
toolStripMenuItem3,
|
||||
toolStripMenuItem4
|
||||
};
|
||||
|
||||
foreach (ToolStripMenuItem i in items) {
|
||||
if (((double)i.Tag) == this.Opacity)
|
||||
|
|
|
@ -78,12 +78,15 @@ namespace OnTopReplica.Native {
|
|||
|
||||
[Flags]
|
||||
public enum WindowExStyles : long {
|
||||
AppWindow = 0x40000,
|
||||
AcceptFiles = 0x00000010L,
|
||||
AppWindow = 0x00040000L,
|
||||
Layered = 0x80000,
|
||||
NoActivate = 0x8000000L,
|
||||
NoRedirectionBitmap = 0x00200000L,
|
||||
ToolWindow = 0x80,
|
||||
TopMost = 8,
|
||||
Transparent = 0x20
|
||||
Transparent = 0x20,
|
||||
WindowEdge = 0x00000100L
|
||||
}
|
||||
|
||||
public static IntPtr GetWindowLong(IntPtr hWnd, WindowLong i) {
|
||||
|
|
|
@ -3,14 +3,14 @@ using System.Collections.Generic;
|
|||
using System.Text;
|
||||
|
||||
namespace OnTopReplica.Platforms {
|
||||
|
||||
|
||||
#if DEBUG
|
||||
|
||||
/// <summary>
|
||||
/// Fake platform for debugging.
|
||||
/// </summary>
|
||||
class DebugPlatform : PlatformSupport {
|
||||
|
||||
|
||||
public override bool CheckCompatibility() {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -4,8 +4,9 @@ using System.Text;
|
|||
using System.Windows.Forms;
|
||||
|
||||
namespace OnTopReplica.Platforms {
|
||||
|
||||
class Other : PlatformSupport {
|
||||
|
||||
|
||||
public override bool CheckCompatibility() {
|
||||
MessageBox.Show(Strings.ErrorNoDwm, Strings.ErrorNoDwmTitle,
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
|
@ -13,4 +14,5 @@ namespace OnTopReplica.Platforms {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using OnTopReplica.Native;
|
||||
namespace OnTopReplica.Platforms {
|
||||
|
||||
namespace OnTopReplica.Platforms {
|
||||
class WindowsEight : WindowsSeven {
|
||||
|
||||
// Equivalent to Windows 7 :)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
using System;
|
||||
using System.Windows.Forms;
|
||||
using OnTopReplica.Native;
|
||||
using OnTopReplica.Native;
|
||||
using WindowsFormsAero.Dwm;
|
||||
|
||||
namespace OnTopReplica.Platforms {
|
||||
|
@ -10,8 +8,7 @@ namespace OnTopReplica.Platforms {
|
|||
private double? PreviousOpacity { get; set; }
|
||||
|
||||
public override void PreHandleFormInit() {
|
||||
//Set Application ID
|
||||
WindowsSevenMethods.SetCurrentProcessExplicitAppUserModelID("LorenzCunoKlopfenstein.OnTopReplica.MainForm");
|
||||
WindowsSevenMethods.SetCurrentProcessExplicitAppUserModelID(Program.ApplicationId);
|
||||
}
|
||||
|
||||
public override void PostHandleFormInit(MainForm form) {
|
||||
|
@ -34,7 +31,7 @@ namespace OnTopReplica.Platforms {
|
|||
form.Opacity = PreviousOpacity.GetValueOrDefault(1.0);
|
||||
PreviousOpacity = null;
|
||||
}
|
||||
|
||||
|
||||
form.Show();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms;
|
||||
using WindowsFormsAero.Dwm;
|
||||
|
||||
namespace OnTopReplica.Platforms {
|
||||
|
||||
class WindowsVista : PlatformSupport {
|
||||
|
||||
|
||||
public override bool CheckCompatibility() {
|
||||
if (!WindowsFormsAero.OsSupport.IsCompositionEnabled) {
|
||||
MessageBox.Show(Strings.ErrorDwmOffContent, Strings.ErrorDwmOff, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
|
@ -24,7 +23,7 @@ namespace OnTopReplica.Platforms {
|
|||
form.ShowInTaskbar = false;
|
||||
|
||||
DwmManager.SetWindowFlip3dPolicy(form, WindowsFormsAero.Flip3DPolicy.ExcludeAbove);
|
||||
|
||||
|
||||
_icon = new NotificationIcon(form);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace OnTopReplica.Platforms {
|
||||
|
||||
class WindowsXp : PlatformSupport {
|
||||
|
||||
|
||||
public override bool CheckCompatibility() {
|
||||
MessageBox.Show(Strings.ErrorNoDwm, Strings.ErrorNoDwmTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,14 +3,17 @@ using System.IO;
|
|||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using OnTopReplica.Platforms;
|
||||
using OnTopReplica.Properties;
|
||||
using OnTopReplica.StartupOptions;
|
||||
using OnTopReplica.Update;
|
||||
|
||||
namespace OnTopReplica {
|
||||
|
||||
|
||||
static class Program {
|
||||
|
||||
public const string ApplicationId = "LorenzCunoKlopfenstein.OnTopReplica.MainForm";
|
||||
|
||||
public static PlatformSupport Platform { get; private set; }
|
||||
|
||||
public static UpdateManager Update { get; private set; }
|
||||
|
@ -60,7 +63,7 @@ namespace OnTopReplica {
|
|||
}
|
||||
if (options.Status == CliStatus.Information || options.Status == CliStatus.Error)
|
||||
return;
|
||||
|
||||
|
||||
//Load language
|
||||
Thread.CurrentThread.CurrentUICulture = Settings.Default.Language;
|
||||
|
||||
|
|
|
@ -1,79 +1,77 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using OnTopReplica.Native;
|
||||
|
||||
namespace OnTopReplica {
|
||||
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// Helper class that keeps a window handle (HWND),
|
||||
/// the title of the window and can load its icon.
|
||||
/// </summary>
|
||||
public class WindowHandle : System.Windows.Forms.IWin32Window {
|
||||
|
||||
public class WindowHandle : System.Windows.Forms.IWin32Window {
|
||||
|
||||
IntPtr _handle;
|
||||
string _title;
|
||||
string _title;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new WindowHandle instance. The handle pointer must be valid, the title
|
||||
/// may be null or empty and will be updated as requested.
|
||||
/// </summary>
|
||||
public WindowHandle(IntPtr p, string title) {
|
||||
_handle = p;
|
||||
_title = title;
|
||||
}
|
||||
public WindowHandle(IntPtr p, string title) {
|
||||
_handle = p;
|
||||
_title = title;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new WindowHandle instance. Additional features of the handle will be queried as needed.
|
||||
/// </summary>
|
||||
/// <param name="p"></param>
|
||||
public WindowHandle(IntPtr p) {
|
||||
_handle = p;
|
||||
_title = null;
|
||||
}
|
||||
|
||||
public string Title {
|
||||
get {
|
||||
public string Title {
|
||||
get {
|
||||
if (_title == null) {
|
||||
_title = WindowMethods.GetWindowText(_handle) ?? string.Empty;
|
||||
}
|
||||
|
||||
return _title;
|
||||
}
|
||||
}
|
||||
return _title;
|
||||
}
|
||||
}
|
||||
|
||||
Icon _icon = null;
|
||||
bool _iconFetched = false;
|
||||
public Icon Icon {
|
||||
get {
|
||||
if (!_iconFetched) {
|
||||
//Fetch icon from window
|
||||
IntPtr hIcon;
|
||||
Icon _icon = null;
|
||||
bool _iconFetched = false;
|
||||
public Icon Icon {
|
||||
get {
|
||||
if (!_iconFetched) {
|
||||
//Fetch icon from window
|
||||
IntPtr hIcon;
|
||||
|
||||
if (MessagingMethods.SendMessageTimeout(_handle, WM.GETICON, new IntPtr(2), new IntPtr(0),
|
||||
MessagingMethods.SendMessageTimeoutFlags.AbortIfHung | MessagingMethods.SendMessageTimeoutFlags.Block, 500, out hIcon) == IntPtr.Zero) {
|
||||
hIcon = IntPtr.Zero;
|
||||
}
|
||||
|
||||
if (hIcon != IntPtr.Zero) {
|
||||
_icon = Icon.FromHandle(hIcon);
|
||||
}
|
||||
else {
|
||||
//Fetch icon from window class
|
||||
if (hIcon != IntPtr.Zero) {
|
||||
_icon = Icon.FromHandle(hIcon);
|
||||
}
|
||||
else {
|
||||
//Fetch icon from window class
|
||||
hIcon = (IntPtr)WindowMethods.GetClassLong(_handle, WindowMethods.ClassLong.IconSmall);
|
||||
|
||||
if (hIcon.ToInt64() != 0) {
|
||||
_icon = Icon.FromHandle(hIcon);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hIcon.ToInt64() != 0) {
|
||||
_icon = Icon.FromHandle(hIcon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_iconFetched = true;
|
||||
_iconFetched = true;
|
||||
|
||||
return _icon;
|
||||
}
|
||||
}
|
||||
return _icon;
|
||||
}
|
||||
}
|
||||
|
||||
string _class = null;
|
||||
|
||||
|
@ -113,32 +111,32 @@ namespace OnTopReplica {
|
|||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Equals(object obj) {
|
||||
if (ReferenceEquals(obj, this))
|
||||
return true;
|
||||
public override bool Equals(object obj) {
|
||||
if (ReferenceEquals(obj, this))
|
||||
return true;
|
||||
|
||||
System.Windows.Forms.IWin32Window win = obj as System.Windows.Forms.IWin32Window;
|
||||
if (win == null)
|
||||
return false;
|
||||
System.Windows.Forms.IWin32Window win = obj as System.Windows.Forms.IWin32Window;
|
||||
if (win == null)
|
||||
return false;
|
||||
|
||||
return (_handle.Equals(win.Handle));
|
||||
}
|
||||
return (_handle.Equals(win.Handle));
|
||||
}
|
||||
|
||||
public override int GetHashCode() {
|
||||
return _handle.GetHashCode();
|
||||
}
|
||||
public override int GetHashCode() {
|
||||
return _handle.GetHashCode();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IWin32Window Members
|
||||
|
||||
public IntPtr Handle {
|
||||
get { return _handle; }
|
||||
}
|
||||
get { return _handle; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new windowHandle instance from a given IntPtr handle.
|
||||
|
@ -148,5 +146,5 @@ namespace OnTopReplica {
|
|||
return new WindowHandle(handle, null);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue