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
*.user
*.suo
packages/

View file

@ -1,20 +1,55 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual C# Express 2010
Microsoft Visual Studio Solution File, Format Version 12.00
# 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}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{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|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.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
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3F135F78-F70E-4127-BA77-6C262C7CCCEF}
EndGlobalSection
EndGlobal

View file

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

View file

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

View file

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

View file

@ -18,9 +18,9 @@ namespace OnTopReplica {
set {
if (value && Settings.Default.FirstTimeClickForwarding) {
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;
Settings.Default.FirstTimeClickForwarding = false;

View file

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

View file

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

View file

@ -15,7 +15,7 @@ namespace OnTopReplica.Platforms {
}
public override void PostHandleFormInit(MainForm form) {
DwmManager.SetWindowFlip3dPolicy(form, Flip3DPolicy.ExcludeAbove);
DwmManager.SetWindowFlip3dPolicy(form, WindowsFormsAero.Flip3DPolicy.ExcludeAbove);
DwmManager.SetExcludeFromPeek(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
form.ShowInTaskbar = false;
DwmManager.SetWindowFlip3dPolicy(form, Flip3DPolicy.ExcludeAbove);
DwmManager.SetWindowFlip3dPolicy(form, WindowsFormsAero.Flip3DPolicy.ExcludeAbove);
_icon = new NotificationIcon(form);
}

View file

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

View file

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

View file

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

View file

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

View file

@ -146,14 +146,14 @@ namespace OnTopReplica.Update {
Instruction = string.Format(Strings.UpdateAvailableInstruction, LastInformation.LatestVersion),
Content = Strings.UpdateAvailableContent,
CustomButtons = new CustomButton[] {
new CustomButton(Result.OK, string.Format(Strings.UpdateAvailableCommandOk, LastInformation.LatestVersion)),
new CustomButton(Result.Cancel, Strings.UpdateAvailableCommandCancel)
new CustomButton(CommonButtonResult.OK, string.Format(Strings.UpdateAvailableCommandOk, LastInformation.LatestVersion)),
new CustomButton(CommonButtonResult.Cancel, Strings.UpdateAvailableCommandCancel)
},
UseCommandLinks = true,
CommonIcon = TaskDialogIcon.Information,
CommonIcon = CommonIcon.Information,
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);
}
}
@ -175,9 +175,9 @@ namespace OnTopReplica.Update {
Instruction = Strings.UpdateInfoInstruction,
Content = Strings.UpdateInfoContent,
EnableHyperlinks = true,
CommonButtons = TaskDialogButton.Close,
CommonButtons = CommonButton.Close,
AllowDialogCancellation = true,
CommonIcon = TaskDialogIcon.Information,
CommonIcon = CommonIcon.Information,
Footer = string.Format(Strings.UpdateInfoFooter, LastInformation.LatestVersionRelease.ToLongDateString())
};
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>