mirror of
https://github.com/LorenzCK/OnTopReplica.git
synced 2024-05-13 17:03:27 +12:00
131 lines
4 KiB
C#
131 lines
4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using OnTopReplica.Properties;
|
|
using WindowsFormsAero.TaskDialog;
|
|
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
|
|
namespace OnTopReplica {
|
|
//Contains some feature implementations of MainForm
|
|
partial class MainForm {
|
|
|
|
#region Click forwarding
|
|
|
|
public bool ClickForwardingEnabled {
|
|
get {
|
|
return _thumbnailPanel.ReportThumbnailClicks;
|
|
}
|
|
set {
|
|
if (value && Settings.Default.FirstTimeClickForwarding) {
|
|
TaskDialog dlg = new TaskDialog(Strings.InfoClickForwarding, Strings.InfoClickForwardingTitle, Strings.InfoClickForwardingContent) {
|
|
CommonButtons = TaskDialogButton.Yes | TaskDialogButton.No
|
|
};
|
|
if (dlg.Show(this).CommonButton == Result.No)
|
|
return;
|
|
|
|
Settings.Default.FirstTimeClickForwarding = false;
|
|
}
|
|
|
|
_thumbnailPanel.ReportThumbnailClicks = value;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Click-through
|
|
|
|
bool _clickThrough = false;
|
|
readonly Color DefaultNonClickTransparencyKey;
|
|
|
|
public bool ClickThroughEnabled {
|
|
get {
|
|
return _clickThrough;
|
|
}
|
|
set {
|
|
//Adjust opacity if fully opaque
|
|
/*if (value && Opacity == 1.0)
|
|
Opacity = 0.75;
|
|
if (!value)
|
|
Opacity = 1.0;*/
|
|
|
|
//Enable transparency and force as top-most
|
|
TransparencyKey = (value) ? Color.Black : DefaultNonClickTransparencyKey;
|
|
if (value)
|
|
TopMost = true;
|
|
|
|
_clickThrough = value;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Chrome
|
|
|
|
readonly FormBorderStyle DefaultBorderStyle; // = FormBorderStyle.Sizable; // FormBorderStyle.SizableToolWindow;
|
|
|
|
public bool IsChromeVisible {
|
|
get {
|
|
return (FormBorderStyle == DefaultBorderStyle);
|
|
}
|
|
set {
|
|
//Cancel hiding chrome if no thumbnail is shown
|
|
if (!value && !_thumbnailPanel.IsShowingThumbnail)
|
|
return;
|
|
|
|
if (!value) {
|
|
Location = new Point {
|
|
X = Location.X + SystemInformation.FrameBorderSize.Width,
|
|
Y = Location.Y + SystemInformation.FrameBorderSize.Height
|
|
};
|
|
FormBorderStyle = FormBorderStyle.None;
|
|
}
|
|
else if(value) {
|
|
Location = new Point {
|
|
X = Location.X - SystemInformation.FrameBorderSize.Width,
|
|
Y = Location.Y - SystemInformation.FrameBorderSize.Height
|
|
};
|
|
FormBorderStyle = DefaultBorderStyle;
|
|
}
|
|
|
|
Program.Platform.OnFormStateChange(this);
|
|
Invalidate();
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Position lock
|
|
|
|
ScreenPosition? _positionLock = null;
|
|
|
|
/// <summary>
|
|
/// Gets or sets the screen position where the window is currently locked in.
|
|
/// </summary>
|
|
public ScreenPosition? PositionLock {
|
|
get {
|
|
return _positionLock;
|
|
}
|
|
set {
|
|
if (value != null)
|
|
this.SetScreenPosition(value.Value);
|
|
|
|
_positionLock = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Refreshes window position if in lock mode.
|
|
/// </summary>
|
|
private void RefreshScreenLock() {
|
|
//If locked in position, move accordingly
|
|
if (PositionLock.HasValue) {
|
|
this.SetScreenPosition(PositionLock.Value);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|