Refresh solution and add WindowsFormsAero as NuGet package

This commit is contained in:
Lorenz Cuno Klopfenstein 2017-11-29 23:16:52 +01:00
parent 9ab38b5963
commit 57d8fed017
17 changed files with 202 additions and 174 deletions

1
.gitignore vendored
View file

@ -5,3 +5,4 @@
Installer/OnTopReplica-Setup.exe Installer/OnTopReplica-Setup.exe
*.user *.user
*.suo *.suo
packages/

View file

@ -1,20 +1,55 @@
 
Microsoft Visual Studio Solution File, Format Version 11.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual C# Express 2010 # Visual Studio 15
VisualStudioVersion = 15.0.27004.2008
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OnTopReplica", "OnTopReplica\OnTopReplica.csproj", "{E626BD6E-BF38-4EB7-A128-5CA6F40EF557}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OnTopReplica", "OnTopReplica\OnTopReplica.csproj", "{E626BD6E-BF38-4EB7-A128-5CA6F40EF557}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E626BD6E-BF38-4EB7-A128-5CA6F40EF557}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E626BD6E-BF38-4EB7-A128-5CA6F40EF557}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E626BD6E-BF38-4EB7-A128-5CA6F40EF557}.Debug|Any CPU.Build.0 = Debug|Any CPU {E626BD6E-BF38-4EB7-A128-5CA6F40EF557}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E626BD6E-BF38-4EB7-A128-5CA6F40EF557}.Debug|x64.ActiveCfg = Debug|Any CPU
{E626BD6E-BF38-4EB7-A128-5CA6F40EF557}.Debug|x64.Build.0 = Debug|Any CPU
{E626BD6E-BF38-4EB7-A128-5CA6F40EF557}.Debug|x86.ActiveCfg = Debug|Any CPU
{E626BD6E-BF38-4EB7-A128-5CA6F40EF557}.Debug|x86.Build.0 = Debug|Any CPU
{E626BD6E-BF38-4EB7-A128-5CA6F40EF557}.Release|Any CPU.ActiveCfg = Release|Any CPU {E626BD6E-BF38-4EB7-A128-5CA6F40EF557}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E626BD6E-BF38-4EB7-A128-5CA6F40EF557}.Release|Any CPU.Build.0 = Release|Any CPU {E626BD6E-BF38-4EB7-A128-5CA6F40EF557}.Release|Any CPU.Build.0 = Release|Any CPU
{E626BD6E-BF38-4EB7-A128-5CA6F40EF557}.Release|x64.ActiveCfg = Release|Any CPU
{E626BD6E-BF38-4EB7-A128-5CA6F40EF557}.Release|x64.Build.0 = Release|Any CPU
{E626BD6E-BF38-4EB7-A128-5CA6F40EF557}.Release|x86.ActiveCfg = Release|Any CPU
{E626BD6E-BF38-4EB7-A128-5CA6F40EF557}.Release|x86.Build.0 = Release|Any CPU
{01391A7F-A9A1-4C90-89EB-29E0C98BF9BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{01391A7F-A9A1-4C90-89EB-29E0C98BF9BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{01391A7F-A9A1-4C90-89EB-29E0C98BF9BE}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{01391A7F-A9A1-4C90-89EB-29E0C98BF9BE}.Debug|x64.ActiveCfg = Debug|x64
{01391A7F-A9A1-4C90-89EB-29E0C98BF9BE}.Debug|x64.Build.0 = Debug|x64
{01391A7F-A9A1-4C90-89EB-29E0C98BF9BE}.Debug|x64.Deploy.0 = Debug|x64
{01391A7F-A9A1-4C90-89EB-29E0C98BF9BE}.Debug|x86.ActiveCfg = Debug|x86
{01391A7F-A9A1-4C90-89EB-29E0C98BF9BE}.Debug|x86.Build.0 = Debug|x86
{01391A7F-A9A1-4C90-89EB-29E0C98BF9BE}.Debug|x86.Deploy.0 = Debug|x86
{01391A7F-A9A1-4C90-89EB-29E0C98BF9BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{01391A7F-A9A1-4C90-89EB-29E0C98BF9BE}.Release|Any CPU.Build.0 = Release|Any CPU
{01391A7F-A9A1-4C90-89EB-29E0C98BF9BE}.Release|Any CPU.Deploy.0 = Release|Any CPU
{01391A7F-A9A1-4C90-89EB-29E0C98BF9BE}.Release|x64.ActiveCfg = Release|x64
{01391A7F-A9A1-4C90-89EB-29E0C98BF9BE}.Release|x64.Build.0 = Release|x64
{01391A7F-A9A1-4C90-89EB-29E0C98BF9BE}.Release|x64.Deploy.0 = Release|x64
{01391A7F-A9A1-4C90-89EB-29E0C98BF9BE}.Release|x86.ActiveCfg = Release|x86
{01391A7F-A9A1-4C90-89EB-29E0C98BF9BE}.Release|x86.Build.0 = Release|x86
{01391A7F-A9A1-4C90-89EB-29E0C98BF9BE}.Release|x86.Deploy.0 = Release|x86
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3F135F78-F70E-4127-BA77-6C262C7CCCEF}
EndGlobalSection
EndGlobal EndGlobal

View file

@ -4,14 +4,13 @@ using System.Drawing;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Windows.Forms; using System.Windows.Forms;
using OnTopReplica.Native; using OnTopReplica.Native;
using WindowsFormsAero.Dwm.Helpers;
namespace OnTopReplica { namespace OnTopReplica {
/// <summary> /// <summary>
/// Form that automatically keeps a certain aspect ratio and resizes without flickering. /// Form that automatically keeps a certain aspect ratio and resizes without flickering.
/// </summary> /// </summary>
public class AspectRatioForm : GlassForm { public class AspectRatioForm : WindowsFormsAero.AeroForm {
bool _keepAspectRatio = true; bool _keepAspectRatio = true;

View file

@ -97,9 +97,8 @@ namespace OnTopReplica {
private void CommonCompleteSwitch(bool enabled) { private void CommonCompleteSwitch(bool enabled) {
//UI stuff switching //UI stuff switching
_mainForm.GlassEnabled = !enabled; _mainForm.GlassMargins = (!enabled) ? new Padding(-1) : Padding.Empty;
_mainForm.TopMost = !enabled; _mainForm.TopMost = !enabled;
_mainForm.HandleMouseMove = !enabled;
IsFullscreen = enabled; IsFullscreen = enabled;

View file

@ -64,8 +64,7 @@ namespace OnTopReplica {
//Window init //Window init
KeepAspectRatio = false; KeepAspectRatio = false;
GlassEnabled = true; GlassMargins = new Padding(-1);
GlassMargins = new Margins(-1);
//Managers //Managers
_msgPumpManager.Initialize(this); _msgPumpManager.Initialize(this);

View file

@ -18,9 +18,9 @@ namespace OnTopReplica {
set { set {
if (value && Settings.Default.FirstTimeClickForwarding) { if (value && Settings.Default.FirstTimeClickForwarding) {
TaskDialog dlg = new TaskDialog(Strings.InfoClickForwarding, Strings.InfoClickForwardingTitle, Strings.InfoClickForwardingContent) { TaskDialog dlg = new TaskDialog(Strings.InfoClickForwarding, Strings.InfoClickForwardingTitle, Strings.InfoClickForwardingContent) {
CommonButtons = TaskDialogButton.Yes | TaskDialogButton.No CommonButtons = CommonButton.Yes | CommonButton.No
}; };
if (dlg.Show(this).CommonButton == Result.No) if (dlg.Show(this).CommonButton == CommonButtonResult.No)
return; return;
Settings.Default.FirstTimeClickForwarding = false; Settings.Default.FirstTimeClickForwarding = false;

View file

@ -54,7 +54,7 @@ namespace OnTopReplica {
/// <param name="errorMessage">Expanded error codes/messages.</param> /// <param name="errorMessage">Expanded error codes/messages.</param>
private void ShowErrorDialog(string mainInstruction, string explanation, string errorMessage) { private void ShowErrorDialog(string mainInstruction, string explanation, string errorMessage) {
TaskDialog dlg = new TaskDialog(mainInstruction, Strings.ErrorGenericTitle, explanation) { TaskDialog dlg = new TaskDialog(mainInstruction, Strings.ErrorGenericTitle, explanation) {
CommonIcon = TaskDialogIcon.Stop, CommonIcon = CommonIcon.Stop,
IsExpanded = false IsExpanded = false
}; };
@ -85,12 +85,12 @@ namespace OnTopReplica {
var dlg = new TaskDialog(Strings.AskReset, Strings.AskResetTitle, Strings.AskResetContent); var dlg = new TaskDialog(Strings.AskReset, Strings.AskResetTitle, Strings.AskResetContent);
dlg.UseCommandLinks = true; dlg.UseCommandLinks = true;
dlg.CustomButtons = new CustomButton[] { dlg.CustomButtons = new CustomButton[] {
new CustomButton(Result.OK, Strings.AskResetButtonOk), new CustomButton(CommonButtonResult.OK, Strings.AskResetButtonOk),
new CustomButton(Result.Cancel, Strings.ButtonCancel) new CustomButton(CommonButtonResult.Cancel, Strings.ButtonCancel)
}; };
dlg.CommonIcon = TaskDialogIcon.Information; dlg.CommonIcon = CommonIcon.Information;
if (dlg.Show(this).CommonButton == Result.OK) { if (dlg.Show(this).CommonButton == CommonButtonResult.OK) {
ResetMainForm(); ResetMainForm();
} }
} }

View file

@ -98,8 +98,8 @@
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="WindowsFormsAero"> <Reference Include="WindowsFormsAero, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\Lib\WindowsFormsAero.dll</HintPath> <HintPath>..\packages\Windows-Forms-Aero.3.0.1\lib\net461\WindowsFormsAero.dll</HintPath>
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -408,6 +408,7 @@
<LastGenOutput>Strings.pt.Designer.cs</LastGenOutput> <LastGenOutput>Strings.pt.Designer.cs</LastGenOutput>
</EmbeddedResource> </EmbeddedResource>
<None Include="OnTopReplica.exe.manifest" /> <None Include="OnTopReplica.exe.manifest" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings"> <None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput> <LastGenOutput>Settings.Designer.cs</LastGenOutput>
@ -535,72 +536,72 @@
<ItemGroup> <ItemGroup>
<PublishFile Include="Assets\icon.ico"> <PublishFile Include="Assets\icon.ico">
<Visible>False</Visible> <Visible>False</Visible>
<PublishState>Exclude</PublishState>
<IncludeHash>True</IncludeHash>
<Group> <Group>
</Group> </Group>
<TargetPath> <TargetPath>
</TargetPath> </TargetPath>
<PublishState>Exclude</PublishState>
<IncludeHash>True</IncludeHash>
<FileType>File</FileType> <FileType>File</FileType>
</PublishFile> </PublishFile>
<PublishFile Include="Assets\screenshot-icon.ico"> <PublishFile Include="Assets\screenshot-icon.ico">
<Visible>False</Visible> <Visible>False</Visible>
<PublishState>Exclude</PublishState>
<IncludeHash>True</IncludeHash>
<Group> <Group>
</Group> </Group>
<TargetPath> <TargetPath>
</TargetPath> </TargetPath>
<PublishState>Exclude</PublishState>
<IncludeHash>True</IncludeHash>
<FileType>File</FileType> <FileType>File</FileType>
</PublishFile> </PublishFile>
<PublishFile Include="Assets\window_multiple16.ico"> <PublishFile Include="Assets\window_multiple16.ico">
<Visible>False</Visible> <Visible>False</Visible>
<PublishState>Exclude</PublishState>
<IncludeHash>True</IncludeHash>
<Group> <Group>
</Group> </Group>
<TargetPath> <TargetPath>
</TargetPath> </TargetPath>
<PublishState>Exclude</PublishState>
<IncludeHash>True</IncludeHash>
<FileType>File</FileType> <FileType>File</FileType>
</PublishFile> </PublishFile>
<PublishFile Include="Assets\xiao_arrow.png"> <PublishFile Include="Assets\xiao_arrow.png">
<Visible>False</Visible> <Visible>False</Visible>
<PublishState>Exclude</PublishState>
<IncludeHash>True</IncludeHash>
<Group> <Group>
</Group> </Group>
<TargetPath> <TargetPath>
</TargetPath> </TargetPath>
<PublishState>Exclude</PublishState>
<IncludeHash>True</IncludeHash>
<FileType>File</FileType> <FileType>File</FileType>
</PublishFile> </PublishFile>
<PublishFile Include="cs\OnTopReplica.resources"> <PublishFile Include="cs\OnTopReplica.resources">
<Visible>False</Visible> <Visible>False</Visible>
<PublishState>Include</PublishState>
<IncludeHash>True</IncludeHash>
<Group> <Group>
</Group> </Group>
<TargetPath> <TargetPath>
</TargetPath> </TargetPath>
<PublishState>Include</PublishState>
<IncludeHash>True</IncludeHash>
<FileType>Satellite</FileType> <FileType>Satellite</FileType>
</PublishFile> </PublishFile>
<PublishFile Include="da\OnTopReplica.resources"> <PublishFile Include="da\OnTopReplica.resources">
<Visible>False</Visible> <Visible>False</Visible>
<PublishState>Include</PublishState>
<IncludeHash>True</IncludeHash>
<Group> <Group>
</Group> </Group>
<TargetPath> <TargetPath>
</TargetPath> </TargetPath>
<PublishState>Include</PublishState>
<IncludeHash>True</IncludeHash>
<FileType>Satellite</FileType> <FileType>Satellite</FileType>
</PublishFile> </PublishFile>
<PublishFile Include="it\OnTopReplica.resources"> <PublishFile Include="it\OnTopReplica.resources">
<Visible>False</Visible> <Visible>False</Visible>
<PublishState>Include</PublishState>
<IncludeHash>True</IncludeHash>
<Group> <Group>
</Group> </Group>
<TargetPath> <TargetPath>
</TargetPath> </TargetPath>
<PublishState>Include</PublishState>
<IncludeHash>True</IncludeHash>
<FileType>Satellite</FileType> <FileType>Satellite</FileType>
</PublishFile> </PublishFile>
</ItemGroup> </ItemGroup>

View file

@ -15,7 +15,7 @@ namespace OnTopReplica.Platforms {
} }
public override void PostHandleFormInit(MainForm form) { public override void PostHandleFormInit(MainForm form) {
DwmManager.SetWindowFlip3dPolicy(form, Flip3DPolicy.ExcludeAbove); DwmManager.SetWindowFlip3dPolicy(form, WindowsFormsAero.Flip3DPolicy.ExcludeAbove);
DwmManager.SetExcludeFromPeek(form, true); DwmManager.SetExcludeFromPeek(form, true);
DwmManager.SetDisallowPeek(form, true); DwmManager.SetDisallowPeek(form, true);
} }

View file

@ -23,7 +23,7 @@ namespace OnTopReplica.Platforms {
//NOTE: this also makes HotKey registration critically fail on Windows 7 //NOTE: this also makes HotKey registration critically fail on Windows 7
form.ShowInTaskbar = false; form.ShowInTaskbar = false;
DwmManager.SetWindowFlip3dPolicy(form, Flip3DPolicy.ExcludeAbove); DwmManager.SetWindowFlip3dPolicy(form, WindowsFormsAero.Flip3DPolicy.ExcludeAbove);
_icon = new NotificationIcon(form); _icon = new NotificationIcon(form);
} }

View file

@ -65,11 +65,11 @@ namespace OnTopReplica {
} }
/// <summary> /// <summary>
/// Gets the panel's desired glass margins or null if no glass surface is required. /// Gets the panel's desired glass margins.
/// </summary> /// </summary>
public virtual Margins? GlassMargins { public virtual Padding GlassMargins {
get { get {
return null; return Padding.Empty;
} }
} }

View file

@ -4,13 +4,12 @@ using System.ComponentModel;
using System.Drawing; using System.Drawing;
using System.Text; using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using WindowsFormsAero.Dwm.Helpers;
namespace OnTopReplica { namespace OnTopReplica {
/// <summary> /// <summary>
/// Acts as a form that can contain a SidePanel instance. /// Acts as a form that can contain a SidePanel instance.
/// </summary> /// </summary>
partial class SidePanelContainer : GlassForm { partial class SidePanelContainer : WindowsFormsAero.AeroForm {
EventHandler RequestClosingHandler; EventHandler RequestClosingHandler;
@ -56,15 +55,7 @@ namespace OnTopReplica {
var minSize = panel.MinimumSize.Expand(this.Padding); var minSize = panel.MinimumSize.Expand(this.Padding);
this.ClientSize = minSize; this.ClientSize = minSize;
this.EnsureMinimumClientSize(minSize); this.EnsureMinimumClientSize(minSize);
this.GlassMargins = panel.GlassMargins;
//Enable glass if needed
var margins = panel.GlassMargins;
if (margins.HasValue) {
this.GlassMargins = margins.Value;
this.GlassEnabled = true;
}
else
this.GlassEnabled = false;
this.ResumeLayout(); this.ResumeLayout();
} }

View file

@ -23,7 +23,7 @@
/// the contents of this method with the code editor. /// the contents of this method with the code editor.
/// </summary> /// </summary>
private void InitializeComponent() { private void InitializeComponent() {
this.labelVersion = new WindowsFormsAero.ThemeText.ThemedLabel(); this.labelVersion = new WindowsFormsAero.ThemeLabel();
this.panelContents = new OnTopReplica.SidePanels.AboutPanelContents(); this.panelContents = new OnTopReplica.SidePanels.AboutPanelContents();
this.SuspendLayout(); this.SuspendLayout();
// //
@ -66,7 +66,7 @@
#endregion #endregion
private WindowsFormsAero.ThemeText.ThemedLabel labelVersion; private WindowsFormsAero.ThemeLabel labelVersion;
private AboutPanelContents panelContents; private AboutPanelContents panelContents;
} }

View file

@ -23,9 +23,9 @@ namespace OnTopReplica.SidePanels {
} }
} }
public override Margins? GlassMargins { public override Padding GlassMargins {
get { get {
return new Margins(0, 0, 0, labelVersion.Height); return new Padding(0, 0, 0, labelVersion.Height);
} }
} }

View file

@ -3,30 +3,29 @@ using System.Collections.Generic;
using System.Text; using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using WindowsFormsAero.Dwm; using WindowsFormsAero.Dwm;
using WindowsFormsAero.ThemeText;
using System.Drawing; using System.Drawing;
using System.Windows.Forms.VisualStyles; using System.Windows.Forms.VisualStyles;
using OnTopReplica.Native; using OnTopReplica.Native;
namespace OnTopReplica { namespace OnTopReplica {
class ThumbnailPanel : Panel { class ThumbnailPanel : Panel {
//DWM Thumbnail stuff //DWM Thumbnail stuff
Thumbnail _thumbnail = null; Thumbnail _thumbnail = null;
//Labels //Labels
ThemedLabel _labelGlass; WindowsFormsAero.ThemeLabel _labelGlass;
public ThumbnailPanel() { public ThumbnailPanel() {
InitFormComponents(); InitFormComponents();
} }
private void InitFormComponents() { private void InitFormComponents() {
BackColor = Color.Black; BackColor = Color.Black;
//Themed Label //Themed Label
_labelGlass = new ThemedLabel { _labelGlass = new WindowsFormsAero.ThemeLabel {
Dock = DockStyle.Fill, Dock = DockStyle.Fill,
ForeColor = SystemColors.ControlText, ForeColor = SystemColors.ControlText,
Location = Point.Empty, Location = Point.Empty,
@ -36,43 +35,43 @@ namespace OnTopReplica {
TextAlign = HorizontalAlignment.Center, TextAlign = HorizontalAlignment.Center,
TextAlignVertical = VerticalAlignment.Center TextAlignVertical = VerticalAlignment.Center
}; };
this.Controls.Add(_labelGlass); this.Controls.Add(_labelGlass);
} }
#region Properties and settings #region Properties and settings
ThumbnailRegion _currentRegion; ThumbnailRegion _currentRegion;
/// <summary> /// <summary>
/// Gets or sets the region that is currently shown on the thumbnail. When set, also enables region constrain. /// Gets or sets the region that is currently shown on the thumbnail. When set, also enables region constrain.
/// </summary> /// </summary>
public ThumbnailRegion SelectedRegion { public ThumbnailRegion SelectedRegion {
get { get {
return _currentRegion; return _currentRegion;
} }
set { set {
_currentRegion = value; _currentRegion = value;
_regionEnabled = (value != null); _regionEnabled = (value != null);
UpdateThubmnail(); UpdateThubmnail();
} }
} }
bool _regionEnabled = false; bool _regionEnabled = false;
/// <summary> /// <summary>
/// Gets or sets whether the thumbnail is constrained to a region or not. /// Gets or sets whether the thumbnail is constrained to a region or not.
/// </summary> /// </summary>
public bool ConstrainToRegion { public bool ConstrainToRegion {
get { get {
return _regionEnabled; return _regionEnabled;
} }
set { set {
if (_regionEnabled != value) { if (_regionEnabled != value) {
_regionEnabled = value; _regionEnabled = value;
UpdateThubmnail(); UpdateThubmnail();
} }
} }
} }
/// <summary> /// <summary>
/// Enables mouse regions drawing, simulating one first click on the panel at the current cursor's position. /// Enables mouse regions drawing, simulating one first click on the panel at the current cursor's position.
@ -87,38 +86,38 @@ namespace OnTopReplica {
OnMouseDown(new MouseEventArgs(System.Windows.Forms.MouseButtons.Left, 1, localCursor.X, localCursor.Y, 0)); OnMouseDown(new MouseEventArgs(System.Windows.Forms.MouseButtons.Left, 1, localCursor.X, localCursor.Y, 0));
} }
bool _drawMouseRegions = false; bool _drawMouseRegions = false;
/// <summary> /// <summary>
/// Gets or sets whether the control is is "region drawing" mode and reports them via events. /// Gets or sets whether the control is is "region drawing" mode and reports them via events.
/// </summary> /// </summary>
public bool DrawMouseRegions { public bool DrawMouseRegions {
get { get {
return _drawMouseRegions; return _drawMouseRegions;
} }
set { set {
//Set mode and reset region //Set mode and reset region
_drawMouseRegions = value; _drawMouseRegions = value;
_drawingRegion = false; _drawingRegion = false;
//Cursor change //Cursor change
Cursor = (value) ? Cursors.Cross : Cursors.Default; Cursor = (value) ? Cursors.Cross : Cursors.Default;
//Refresh gui //Refresh gui
UpdateThubmnail(); UpdateThubmnail();
_labelGlass.Visible = !value; _labelGlass.Visible = !value;
this.Invalidate(); this.Invalidate();
} }
} }
/// <summary> /// <summary>
/// Gets the target opacity of the thumbnail, depending on the control's state. /// Gets the target opacity of the thumbnail, depending on the control's state.
/// </summary> /// </summary>
protected byte ThumbnailOpacity { protected byte ThumbnailOpacity {
get { get {
return (_drawMouseRegions) ? (byte)130 : (byte)255; return (_drawMouseRegions) ? (byte)130 : (byte)255;
} }
} }
/// <summary> /// <summary>
/// Gets or sets whether the control should report clicks made on the cloned thumbnail. /// Gets or sets whether the control should report clicks made on the cloned thumbnail.
@ -138,11 +137,11 @@ namespace OnTopReplica {
get { get {
if (_thumbnail != null && !_thumbnail.IsInvalid) { if (_thumbnail != null && !_thumbnail.IsInvalid) {
if (_regionEnabled) { if (_regionEnabled) {
return _currentRegion.ComputeRegionSize(_thumbnail.SourceSize); return _currentRegion.ComputeRegionSize(_thumbnail.GetSourceSize());
} }
else { else {
//Thumbnail is not cropped, return full thumbnail source size //Thumbnail is not cropped, return full thumbnail source size
return _thumbnail.SourceSize; return _thumbnail.GetSourceSize();
} }
} }
else { else {
@ -164,7 +163,7 @@ namespace OnTopReplica {
public Size ThumbnailOriginalSize { public Size ThumbnailOriginalSize {
get { get {
if (_thumbnail != null && !_thumbnail.IsInvalid) { if (_thumbnail != null && !_thumbnail.IsInvalid) {
return _thumbnail.SourceSize; return _thumbnail.GetSourceSize();
} }
else { else {
#if DEBUG #if DEBUG
@ -176,7 +175,7 @@ namespace OnTopReplica {
} }
} }
#endregion #endregion
#region GUI event handling #region GUI event handling
@ -206,7 +205,7 @@ namespace OnTopReplica {
/// </summary> /// </summary>
/// <param name="handle">Handle of the window to clone.</param> /// <param name="handle">Handle of the window to clone.</param>
/// <param name="region">Optional region.</param> /// <param name="region">Optional region.</param>
public void SetThumbnailHandle(WindowHandle handle, ThumbnailRegion region) { public void SetThumbnailHandle(WindowHandle handle, ThumbnailRegion region) {
Log.WriteDetails("Setting new thumbnail", Log.WriteDetails("Setting new thumbnail",
"HWND {0}, region {1}", handle, region "HWND {0}, region {1}", handle, region
); );
@ -216,52 +215,52 @@ namespace OnTopReplica {
_thumbnail = null; _thumbnail = null;
} }
//Attempt to get top level Form from Control //Attempt to get top level Form from Control
Form owner = this.TopLevelControl as Form; Form owner = this.TopLevelControl as Form;
if (owner == null) if (owner == null)
throw new Exception("Internal error: ThumbnailPanel.TopLevelControl is not a Form."); throw new Exception("Internal error: ThumbnailPanel.TopLevelControl is not a Form.");
_labelGlass.Visible = false; _labelGlass.Visible = false;
//Register new thumbnail, update regioning directly and refresh thumbnail //Register new thumbnail, update regioning directly and refresh thumbnail
_thumbnail = DwmManager.Register(owner, handle.Handle); _thumbnail = DwmManager.Register(owner, handle.Handle);
_currentRegion = region; _currentRegion = region;
_regionEnabled = (region != null); _regionEnabled = (region != null);
UpdateThubmnail(); UpdateThubmnail();
} }
/// <summary> /// <summary>
/// Disposes current thumbnail and enters stand-by mode. /// Disposes current thumbnail and enters stand-by mode.
/// </summary> /// </summary>
public void UnsetThumbnail() { public void UnsetThumbnail() {
Log.Write("Unsetting thumbnail"); Log.Write("Unsetting thumbnail");
if (_thumbnail != null && !_thumbnail.IsInvalid) { if (_thumbnail != null && !_thumbnail.IsInvalid) {
_thumbnail.Close(); _thumbnail.Close();
} }
_thumbnail = null; _thumbnail = null;
_labelGlass.Visible = true; _labelGlass.Visible = true;
} }
/// <summary> /// <summary>
/// Gets whether the control is currently displaying a thumbnail. /// Gets whether the control is currently displaying a thumbnail.
/// </summary> /// </summary>
public bool IsShowingThumbnail { public bool IsShowingThumbnail {
get { get {
return (_thumbnail != null && !_thumbnail.IsInvalid); return (_thumbnail != null && !_thumbnail.IsInvalid);
} }
} }
int _padWidth = 0; int _padWidth = 0;
int _padHeight = 0; int _padHeight = 0;
Size _thumbnailSize; Size _thumbnailSize;
/// <summary> /// <summary>
/// Updates the thumbnail options and the right-click label. /// Updates the thumbnail options and the right-click label.
/// </summary> /// </summary>
private void UpdateThubmnail() { private void UpdateThubmnail() {
if (_thumbnail != null && !_thumbnail.IsInvalid){ if (_thumbnail != null && !_thumbnail.IsInvalid){
try { try {
//Get thumbnail size and attempt to fit to control, with padding //Get thumbnail size and attempt to fit to control, with padding
Size sourceSize = ThumbnailPixelSize; Size sourceSize = ThumbnailPixelSize;
@ -272,7 +271,7 @@ namespace OnTopReplica {
System.Diagnostics.Debug.WriteLine("Fitting {0} inside {1} as {2}. Padding {3},{4}.", sourceSize, Size, _thumbnailSize, _padWidth, _padHeight); System.Diagnostics.Debug.WriteLine("Fitting {0} inside {1} as {2}. Padding {3},{4}.", sourceSize, Size, _thumbnailSize, _padWidth, _padHeight);
var target = new Rectangle(_padWidth, _padHeight, _thumbnailSize.Width, _thumbnailSize.Height); var target = new Rectangle(_padWidth, _padHeight, _thumbnailSize.Width, _thumbnailSize.Height);
Rectangle source = (_regionEnabled) ? _currentRegion.ComputeRegionRectangle(_thumbnail.SourceSize) : new Rectangle(Point.Empty, _thumbnail.SourceSize); Rectangle source = (_regionEnabled) ? _currentRegion.ComputeRegionRectangle(_thumbnail.GetSourceSize()) : new Rectangle(Point.Empty, _thumbnail.GetSourceSize());
_thumbnail.Update(target, source, ThumbnailOpacity, true, true); _thumbnail.Update(target, source, ThumbnailOpacity, true, true);
} }
@ -281,12 +280,12 @@ namespace OnTopReplica {
UnsetThumbnail(); UnsetThumbnail();
return; return;
} }
} }
} }
#endregion #endregion
#region Region drawing #region Region drawing
const int MinimumRegionSize = 1; const int MinimumRegionSize = 1;
@ -348,39 +347,39 @@ namespace OnTopReplica {
OnRegionDrawn(final); OnRegionDrawn(final);
} }
protected override void OnMouseDown(MouseEventArgs e) { protected override void OnMouseDown(MouseEventArgs e) {
if (DrawMouseRegions && e.Button == MouseButtons.Left) { if (DrawMouseRegions && e.Button == MouseButtons.Left) {
//Start new region drawing //Start new region drawing
_drawingRegion = true; _drawingRegion = true;
_drawingSuspended = false; _drawingSuspended = false;
_regionStartPoint = _regionLastPoint = e.Location; _regionStartPoint = _regionLastPoint = e.Location;
this.Invalidate(); this.Invalidate();
} }
base.OnMouseDown(e); base.OnMouseDown(e);
} }
protected override void OnMouseUp(MouseEventArgs e) { protected override void OnMouseUp(MouseEventArgs e) {
if (DrawMouseRegions && e.Button == MouseButtons.Left) { if (DrawMouseRegions && e.Button == MouseButtons.Left) {
//Region completed //Region completed
_drawingRegion = false; _drawingRegion = false;
_drawingSuspended = false; _drawingSuspended = false;
RaiseRegionDrawn(_regionStartPoint, _regionLastPoint); RaiseRegionDrawn(_regionStartPoint, _regionLastPoint);
this.Invalidate(); this.Invalidate();
} }
base.OnMouseUp(e); base.OnMouseUp(e);
} }
protected override void OnMouseLeave(EventArgs e) { protected override void OnMouseLeave(EventArgs e) {
_drawingSuspended = true; _drawingSuspended = true;
this.Invalidate(); this.Invalidate();
base.OnMouseLeave(e); base.OnMouseLeave(e);
} }
protected override void OnMouseEnter(EventArgs e) { protected override void OnMouseEnter(EventArgs e) {
_drawingSuspended = false; _drawingSuspended = false;
@ -390,13 +389,13 @@ namespace OnTopReplica {
base.OnMouseEnter(e); base.OnMouseEnter(e);
} }
protected override void OnMouseMove(MouseEventArgs e) { protected override void OnMouseMove(MouseEventArgs e) {
if (_drawingRegion && e.Button == MouseButtons.Left) { if (_drawingRegion && e.Button == MouseButtons.Left) {
//Continue drawing //Continue drawing
_regionLastPoint = e.Location; _regionLastPoint = e.Location;
this.Invalidate(); this.Invalidate();
} }
else if(DrawMouseRegions && !_drawingRegion){ else if(DrawMouseRegions && !_drawingRegion){
//Keep track of region start point //Keep track of region start point
_regionLastPoint = e.Location; _regionLastPoint = e.Location;
@ -404,31 +403,31 @@ namespace OnTopReplica {
this.Invalidate(); this.Invalidate();
} }
base.OnMouseMove(e); base.OnMouseMove(e);
} }
readonly static Pen RedPen = new Pen(Color.FromArgb(255, Color.Red), 1.5f); //TODO: check width readonly static Pen RedPen = new Pen(Color.FromArgb(255, Color.Red), 1.5f); //TODO: check width
protected override void OnPaint(PaintEventArgs e) { protected override void OnPaint(PaintEventArgs e) {
if (_drawingRegion) { if (_drawingRegion) {
//Is currently drawing, show rectangle //Is currently drawing, show rectangle
int left = Math.Min(_regionStartPoint.X, _regionLastPoint.X); int left = Math.Min(_regionStartPoint.X, _regionLastPoint.X);
int right = Math.Max(_regionStartPoint.X, _regionLastPoint.X); int right = Math.Max(_regionStartPoint.X, _regionLastPoint.X);
int top = Math.Min(_regionStartPoint.Y, _regionLastPoint.Y); int top = Math.Min(_regionStartPoint.Y, _regionLastPoint.Y);
int bottom = Math.Max(_regionStartPoint.Y, _regionLastPoint.Y); int bottom = Math.Max(_regionStartPoint.Y, _regionLastPoint.Y);
e.Graphics.DrawRectangle(RedPen, left, top, right - left, bottom - top); e.Graphics.DrawRectangle(RedPen, left, top, right - left, bottom - top);
} }
else if (DrawMouseRegions && ! _drawingSuspended) { else if (DrawMouseRegions && ! _drawingSuspended) {
//Show cursor coordinates //Show cursor coordinates
e.Graphics.DrawLine(RedPen, new Point(0, _regionLastPoint.Y), new Point(ClientSize.Width, _regionLastPoint.Y)); e.Graphics.DrawLine(RedPen, new Point(0, _regionLastPoint.Y), new Point(ClientSize.Width, _regionLastPoint.Y));
e.Graphics.DrawLine(RedPen, new Point(_regionLastPoint.X, 0), new Point(_regionLastPoint.X, ClientSize.Height)); e.Graphics.DrawLine(RedPen, new Point(_regionLastPoint.X, 0), new Point(_regionLastPoint.X, ClientSize.Height));
} }
base.OnPaint(e); base.OnPaint(e);
} }
#endregion #endregion
#region Thumbnail clone click #region Thumbnail clone click
@ -459,12 +458,12 @@ namespace OnTopReplica {
/// <summary> /// <summary>
/// Is raised when the thumbnail clone is clicked. /// Is raised when the thumbnail clone is clicked.
/// </summary> /// </summary>
public event EventHandler<CloneClickEventArgs> CloneClick; public event EventHandler<CloneClickEventArgs> CloneClick;
protected virtual void OnCloneClick(Point location, MouseButtons buttons, bool doubleClick){ protected virtual void OnCloneClick(Point location, MouseButtons buttons, bool doubleClick){
var evt = CloneClick; var evt = CloneClick;
if(evt != null) if(evt != null)
evt(this, new CloneClickEventArgs(location, buttons, doubleClick)); evt(this, new CloneClickEventArgs(location, buttons, doubleClick));
} }
#endregion #endregion

View file

@ -146,14 +146,14 @@ namespace OnTopReplica.Update {
Instruction = string.Format(Strings.UpdateAvailableInstruction, LastInformation.LatestVersion), Instruction = string.Format(Strings.UpdateAvailableInstruction, LastInformation.LatestVersion),
Content = Strings.UpdateAvailableContent, Content = Strings.UpdateAvailableContent,
CustomButtons = new CustomButton[] { CustomButtons = new CustomButton[] {
new CustomButton(Result.OK, string.Format(Strings.UpdateAvailableCommandOk, LastInformation.LatestVersion)), new CustomButton(CommonButtonResult.OK, string.Format(Strings.UpdateAvailableCommandOk, LastInformation.LatestVersion)),
new CustomButton(Result.Cancel, Strings.UpdateAvailableCommandCancel) new CustomButton(CommonButtonResult.Cancel, Strings.UpdateAvailableCommandCancel)
}, },
UseCommandLinks = true, UseCommandLinks = true,
CommonIcon = TaskDialogIcon.Information, CommonIcon = CommonIcon.Information,
ExpandedInformation = string.Format(Strings.UpdateAvailableExpanded, LastInformation.CurrentVersion, LastInformation.LatestVersion), ExpandedInformation = string.Format(Strings.UpdateAvailableExpanded, LastInformation.CurrentVersion, LastInformation.LatestVersion),
}; };
if (updateDialog.Show(AttachedForm).CommonButton == Result.OK) { if (updateDialog.Show(AttachedForm).CommonButton == CommonButtonResult.OK) {
Shell.Execute(LastInformation.DownloadPage); Shell.Execute(LastInformation.DownloadPage);
} }
} }
@ -175,9 +175,9 @@ namespace OnTopReplica.Update {
Instruction = Strings.UpdateInfoInstruction, Instruction = Strings.UpdateInfoInstruction,
Content = Strings.UpdateInfoContent, Content = Strings.UpdateInfoContent,
EnableHyperlinks = true, EnableHyperlinks = true,
CommonButtons = TaskDialogButton.Close, CommonButtons = CommonButton.Close,
AllowDialogCancellation = true, AllowDialogCancellation = true,
CommonIcon = TaskDialogIcon.Information, CommonIcon = CommonIcon.Information,
Footer = string.Format(Strings.UpdateInfoFooter, LastInformation.LatestVersionRelease.ToLongDateString()) Footer = string.Format(Strings.UpdateInfoFooter, LastInformation.LatestVersionRelease.ToLongDateString())
}; };
dlg.HyperlinkClick += delegate(object sender, HyperlinkEventArgs args) { dlg.HyperlinkClick += delegate(object sender, HyperlinkEventArgs args) {

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Windows-Forms-Aero" version="3.0.1" targetFramework="net47" />
</packages>