Added click-through to standard and fullscreen mode.

Changed context menu (new advanced dropdown).
Refactored MainForm class to reduce file sizes and facilitate navigation.
This commit is contained in:
Lorenz Cuno Klopfenstein 2010-07-01 03:11:36 +02:00
parent b1696f4dd8
commit a097979ce3
16 changed files with 757 additions and 497 deletions

View file

@ -107,12 +107,16 @@ namespace OnTopReplica {
}
/// <summary>
/// Updates the aspect ratio of the form and forces a refresh.
/// Updates the aspect ratio of the form and optionally forces a refresh.
/// </summary>
public void SetAspectRatio(Size aspectRatioSource) {
_keepAspectRatio = true; //set without updating
/// <param name="aspectRatioSource">Size from which aspect ratio should be computed.</param>
/// <param name="forceRefresh">True if the size of the form should be refreshed to match the new aspect ratio.</param>
public void SetAspectRatio(Size aspectRatioSource, bool forceRefresh) {
AspectRatio = ((double)aspectRatioSource.Width / (double)aspectRatioSource.Height);
RefreshAspectRatio();
if (forceRefresh) {
KeepAspectRatio = true;
}
}
#region Event overriding

Binary file not shown.

After

Width:  |  Height:  |  Size: 459 B

View file

@ -3,9 +3,23 @@ using System.Collections.Generic;
using System.Text;
namespace OnTopReplica {
enum FullscreenMode {
/// <summary>
/// Describes a fullscreen mode used by OnTopReplica.
/// </summary>
public enum FullscreenMode {
/// <summary>
/// Normal non-topmost fullscreen mode.
/// </summary>
Normal,
/// <summary>
/// Topmost fullscreen mode.
/// </summary>
AlwaysOnTop,
/// <summary>
/// Clickthrough overlay mode.
/// </summary>
ClickThrough
}
}

View file

@ -33,7 +33,9 @@
this.noneToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.switchToWindowToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.selectRegionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.advancedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.forwardClicksToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.clickthroughToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.dualWindowModeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuContextOpacity = new System.Windows.Forms.ToolStripMenuItem();
this.menuOpacity = new System.Windows.Forms.ContextMenuStrip(this.components);
@ -65,12 +67,18 @@
this.italianoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuContextClose = new System.Windows.Forms.ToolStripMenuItem();
this.fullSelectWindowToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.fullOpacityToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.danskToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuFullscreenContext = new System.Windows.Forms.ContextMenuStrip(this.components);
this.enableClickthroughToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.fullExitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuContext.SuspendLayout();
this.menuWindows.SuspendLayout();
this.menuOpacity.SuspendLayout();
this.menuResize.SuspendLayout();
this.menuLanguages.SuspendLayout();
this.menuFullscreenContext.SuspendLayout();
this.SuspendLayout();
//
// menuContext
@ -79,8 +87,7 @@
this.menuContextWindows,
this.switchToWindowToolStripMenuItem,
this.selectRegionToolStripMenuItem,
this.forwardClicksToolStripMenuItem,
this.dualWindowModeToolStripMenuItem,
this.advancedToolStripMenuItem,
this.menuContextOpacity,
this.resizeToolStripMenuItem,
this.dockToolStripMenuItem,
@ -91,7 +98,7 @@
this.aboutToolStripMenuItem,
this.menuContextClose});
this.menuContext.Name = "menuContext";
this.menuContext.Size = new System.Drawing.Size(178, 318);
this.menuContext.Size = new System.Drawing.Size(169, 274);
this.menuContext.Opening += new System.ComponentModel.CancelEventHandler(this.Menu_opening);
//
// menuContextWindows
@ -99,30 +106,29 @@
this.menuContextWindows.DropDown = this.menuWindows;
this.menuContextWindows.Image = global::OnTopReplica.Properties.Resources.window_multiple16;
this.menuContextWindows.Name = "menuContextWindows";
this.menuContextWindows.Size = new System.Drawing.Size(177, 22);
this.menuContextWindows.Size = new System.Drawing.Size(168, 22);
this.menuContextWindows.Text = global::OnTopReplica.Strings.MenuWindows;
this.menuContextWindows.ToolTipText = global::OnTopReplica.Strings.MenuWindowsTT;
this.menuContextWindows.DropDownOpening += new System.EventHandler(this.Menu_Windows_opening);
//
// menuWindows
//
this.menuWindows.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.noneToolStripMenuItem});
this.menuWindows.Name = "menuWindows";
this.menuWindows.OwnerItem = this.menuContextWindows;
this.menuWindows.Size = new System.Drawing.Size(118, 26);
this.menuWindows.Size = new System.Drawing.Size(153, 48);
this.menuWindows.Opening += new System.ComponentModel.CancelEventHandler(this.Menu_Windows_opening);
//
// noneToolStripMenuItem
//
this.noneToolStripMenuItem.Name = "noneToolStripMenuItem";
this.noneToolStripMenuItem.Size = new System.Drawing.Size(117, 22);
this.noneToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.noneToolStripMenuItem.Text = global::OnTopReplica.Strings.MenuWindowsNone;
//
// switchToWindowToolStripMenuItem
//
this.switchToWindowToolStripMenuItem.Image = global::OnTopReplica.Properties.Resources.window_switch;
this.switchToWindowToolStripMenuItem.Name = "switchToWindowToolStripMenuItem";
this.switchToWindowToolStripMenuItem.Size = new System.Drawing.Size(177, 22);
this.switchToWindowToolStripMenuItem.Size = new System.Drawing.Size(168, 22);
this.switchToWindowToolStripMenuItem.Text = global::OnTopReplica.Strings.MenuSwitch;
this.switchToWindowToolStripMenuItem.ToolTipText = global::OnTopReplica.Strings.MenuSwitchTT;
this.switchToWindowToolStripMenuItem.Click += new System.EventHandler(this.Menu_Switch_click);
@ -132,33 +138,50 @@
this.selectRegionToolStripMenuItem.Enabled = false;
this.selectRegionToolStripMenuItem.Image = global::OnTopReplica.Properties.Resources.regions;
this.selectRegionToolStripMenuItem.Name = "selectRegionToolStripMenuItem";
this.selectRegionToolStripMenuItem.Size = new System.Drawing.Size(177, 22);
this.selectRegionToolStripMenuItem.Size = new System.Drawing.Size(168, 22);
this.selectRegionToolStripMenuItem.Text = global::OnTopReplica.Strings.MenuRegion;
this.selectRegionToolStripMenuItem.ToolTipText = global::OnTopReplica.Strings.MenuRegionTT;
this.selectRegionToolStripMenuItem.Click += new System.EventHandler(this.Menu_Region_click);
//
// advancedToolStripMenuItem
//
this.advancedToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.forwardClicksToolStripMenuItem,
this.clickthroughToolStripMenuItem,
this.dualWindowModeToolStripMenuItem});
this.advancedToolStripMenuItem.Image = global::OnTopReplica.Properties.Resources.xiao_wrench;
this.advancedToolStripMenuItem.Name = "advancedToolStripMenuItem";
this.advancedToolStripMenuItem.Size = new System.Drawing.Size(168, 22);
this.advancedToolStripMenuItem.Text = "Advanced";
//
// forwardClicksToolStripMenuItem
//
this.forwardClicksToolStripMenuItem.Name = "forwardClicksToolStripMenuItem";
this.forwardClicksToolStripMenuItem.Size = new System.Drawing.Size(177, 22);
this.forwardClicksToolStripMenuItem.Text = global::OnTopReplica.Strings.MenuClickForwarding;
this.forwardClicksToolStripMenuItem.Size = new System.Drawing.Size(199, 22);
this.forwardClicksToolStripMenuItem.Text = "Enable Click forwarding";
this.forwardClicksToolStripMenuItem.ToolTipText = global::OnTopReplica.Strings.MenuClickForwardingTT;
this.forwardClicksToolStripMenuItem.Click += new System.EventHandler(this.Menu_Forward_click);
this.forwardClicksToolStripMenuItem.Click += new System.EventHandler(this.Menu_ClickForwarding_click);
//
// clickthroughToolStripMenuItem
//
this.clickthroughToolStripMenuItem.Name = "clickthroughToolStripMenuItem";
this.clickthroughToolStripMenuItem.Size = new System.Drawing.Size(199, 22);
this.clickthroughToolStripMenuItem.Text = "Enable Click-through";
this.clickthroughToolStripMenuItem.Click += new System.EventHandler(this.Menu_ClickThrough_click);
//
// dualWindowModeToolStripMenuItem
//
this.dualWindowModeToolStripMenuItem.Image = global::OnTopReplica.Properties.Resources.window_multiple16;
this.dualWindowModeToolStripMenuItem.Name = "dualWindowModeToolStripMenuItem";
this.dualWindowModeToolStripMenuItem.Size = new System.Drawing.Size(177, 22);
this.dualWindowModeToolStripMenuItem.Text = "Dual window mode";
this.dualWindowModeToolStripMenuItem.Click += new System.EventHandler(this.Menu_Group_click);
this.dualWindowModeToolStripMenuItem.Size = new System.Drawing.Size(199, 22);
this.dualWindowModeToolStripMenuItem.Text = "Group switch mode";
this.dualWindowModeToolStripMenuItem.Click += new System.EventHandler(this.Menu_GroupSwitchMode_click);
//
// menuContextOpacity
//
this.menuContextOpacity.DropDown = this.menuOpacity;
this.menuContextOpacity.Image = global::OnTopReplica.Properties.Resources.window_opacity16;
this.menuContextOpacity.Name = "menuContextOpacity";
this.menuContextOpacity.Size = new System.Drawing.Size(177, 22);
this.menuContextOpacity.Size = new System.Drawing.Size(168, 22);
this.menuContextOpacity.Text = global::OnTopReplica.Strings.MenuOpacity;
//
// menuOpacity
@ -169,7 +192,7 @@
this.toolStripMenuItem3,
this.toolStripMenuItem4});
this.menuOpacity.Name = "menuOpacity";
this.menuOpacity.OwnerItem = this.menuContextOpacity;
this.menuOpacity.OwnerItem = this.fullOpacityToolStripMenuItem;
this.menuOpacity.ShowCheckMargin = true;
this.menuOpacity.ShowImageMargin = false;
this.menuOpacity.Size = new System.Drawing.Size(154, 92);
@ -218,7 +241,7 @@
this.resizeToolStripMenuItem.DropDown = this.menuResize;
this.resizeToolStripMenuItem.Enabled = false;
this.resizeToolStripMenuItem.Name = "resizeToolStripMenuItem";
this.resizeToolStripMenuItem.Size = new System.Drawing.Size(177, 22);
this.resizeToolStripMenuItem.Size = new System.Drawing.Size(168, 22);
this.resizeToolStripMenuItem.Text = global::OnTopReplica.Strings.MenuResize;
//
// menuResize
@ -284,7 +307,7 @@
this.bottomRightToolStripMenuItem});
this.dockToolStripMenuItem.Image = global::OnTopReplica.Properties.Resources.pos_null;
this.dockToolStripMenuItem.Name = "dockToolStripMenuItem";
this.dockToolStripMenuItem.Size = new System.Drawing.Size(177, 22);
this.dockToolStripMenuItem.Size = new System.Drawing.Size(168, 22);
this.dockToolStripMenuItem.Text = global::OnTopReplica.Strings.MenuPosition;
this.dockToolStripMenuItem.ToolTipText = global::OnTopReplica.Strings.MenuPositionTT;
//
@ -323,7 +346,7 @@
// chromeToolStripMenuItem
//
this.chromeToolStripMenuItem.Name = "chromeToolStripMenuItem";
this.chromeToolStripMenuItem.Size = new System.Drawing.Size(177, 22);
this.chromeToolStripMenuItem.Size = new System.Drawing.Size(168, 22);
this.chromeToolStripMenuItem.Text = global::OnTopReplica.Strings.MenuChrome;
this.chromeToolStripMenuItem.ToolTipText = global::OnTopReplica.Strings.MenuChromeTT;
this.chromeToolStripMenuItem.Click += new System.EventHandler(this.Menu_Chrome_click);
@ -332,7 +355,7 @@
//
this.reduceToIconToolStripMenuItem.Image = global::OnTopReplica.Properties.Resources.reduce;
this.reduceToIconToolStripMenuItem.Name = "reduceToIconToolStripMenuItem";
this.reduceToIconToolStripMenuItem.Size = new System.Drawing.Size(177, 22);
this.reduceToIconToolStripMenuItem.Size = new System.Drawing.Size(168, 22);
this.reduceToIconToolStripMenuItem.Text = global::OnTopReplica.Strings.MenuReduce;
this.reduceToIconToolStripMenuItem.ToolTipText = global::OnTopReplica.Strings.MenuReduceTT;
this.reduceToIconToolStripMenuItem.Click += new System.EventHandler(this.Menu_Reduce_click);
@ -340,13 +363,13 @@
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(174, 6);
this.toolStripSeparator1.Size = new System.Drawing.Size(165, 6);
//
// languageToolStripMenuItem
//
this.languageToolStripMenuItem.DropDown = this.menuLanguages;
this.languageToolStripMenuItem.Name = "languageToolStripMenuItem";
this.languageToolStripMenuItem.Size = new System.Drawing.Size(177, 22);
this.languageToolStripMenuItem.Size = new System.Drawing.Size(168, 22);
this.languageToolStripMenuItem.Text = global::OnTopReplica.Strings.Language;
//
// menuLanguages
@ -400,7 +423,7 @@
// aboutToolStripMenuItem
//
this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem";
this.aboutToolStripMenuItem.Size = new System.Drawing.Size(177, 22);
this.aboutToolStripMenuItem.Size = new System.Drawing.Size(168, 22);
this.aboutToolStripMenuItem.Text = global::OnTopReplica.Strings.MenuAbout;
this.aboutToolStripMenuItem.ToolTipText = global::OnTopReplica.Strings.MenuAboutTT;
this.aboutToolStripMenuItem.Click += new System.EventHandler(this.Menu_About_click);
@ -409,10 +432,24 @@
//
this.menuContextClose.Image = global::OnTopReplica.Properties.Resources.close_new;
this.menuContextClose.Name = "menuContextClose";
this.menuContextClose.Size = new System.Drawing.Size(177, 22);
this.menuContextClose.Size = new System.Drawing.Size(168, 22);
this.menuContextClose.Text = global::OnTopReplica.Strings.MenuClose;
this.menuContextClose.Click += new System.EventHandler(this.Menu_Close_click);
//
// fullSelectWindowToolStripMenuItem
//
this.fullSelectWindowToolStripMenuItem.DropDown = this.menuWindows;
this.fullSelectWindowToolStripMenuItem.Name = "fullSelectWindowToolStripMenuItem";
this.fullSelectWindowToolStripMenuItem.Size = new System.Drawing.Size(186, 22);
this.fullSelectWindowToolStripMenuItem.Text = "Select window...";
//
// fullOpacityToolStripMenuItem
//
this.fullOpacityToolStripMenuItem.DropDown = this.menuOpacity;
this.fullOpacityToolStripMenuItem.Name = "fullOpacityToolStripMenuItem";
this.fullOpacityToolStripMenuItem.Size = new System.Drawing.Size(186, 22);
this.fullOpacityToolStripMenuItem.Text = "Opacity";
//
// danskToolStripMenuItem
//
this.danskToolStripMenuItem.Image = global::OnTopReplica.Properties.Resources.flag_danish;
@ -422,6 +459,31 @@
this.danskToolStripMenuItem.Text = "Dansk";
this.danskToolStripMenuItem.Click += new System.EventHandler(this.Menu_Language_click);
//
// menuFullscreenContext
//
this.menuFullscreenContext.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.fullSelectWindowToolStripMenuItem,
this.fullOpacityToolStripMenuItem,
this.enableClickthroughToolStripMenuItem,
this.fullExitToolStripMenuItem});
this.menuFullscreenContext.Name = "menuFullscreenContext";
this.menuFullscreenContext.Size = new System.Drawing.Size(187, 114);
//
// enableClickthroughToolStripMenuItem
//
this.enableClickthroughToolStripMenuItem.Name = "enableClickthroughToolStripMenuItem";
this.enableClickthroughToolStripMenuItem.Size = new System.Drawing.Size(186, 22);
this.enableClickthroughToolStripMenuItem.Text = "Enable Click-through";
this.enableClickthroughToolStripMenuItem.Click += new System.EventHandler(this.Menu_ClickThrough_click);
//
// fullExitToolStripMenuItem
//
this.fullExitToolStripMenuItem.Image = global::OnTopReplica.Properties.Resources.close_new;
this.fullExitToolStripMenuItem.Name = "fullExitToolStripMenuItem";
this.fullExitToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.fullExitToolStripMenuItem.Text = "Exit fullscreen mode";
this.fullExitToolStripMenuItem.Click += new System.EventHandler(this.Menu_Fullscreen_ExitFullscreen_click);
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -439,6 +501,7 @@
this.menuOpacity.ResumeLayout(false);
this.menuResize.ResumeLayout(false);
this.menuLanguages.ResumeLayout(false);
this.menuFullscreenContext.ResumeLayout(false);
this.ResumeLayout(false);
}
@ -474,7 +537,6 @@
private System.Windows.Forms.ToolStripMenuItem quarterToolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem fullscreenToolStripMenuItem1;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
private System.Windows.Forms.ToolStripMenuItem forwardClicksToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem languageToolStripMenuItem;
private System.Windows.Forms.ContextMenuStrip menuLanguages;
private System.Windows.Forms.ToolStripMenuItem englishToolStripMenuItem;
@ -483,7 +545,15 @@
private System.Windows.Forms.ToolStripMenuItem danskToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem chromeToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem danskToolStripMenuItem1;
private System.Windows.Forms.ContextMenuStrip menuFullscreenContext;
private System.Windows.Forms.ToolStripMenuItem fullSelectWindowToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem fullOpacityToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem fullExitToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem advancedToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem forwardClicksToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem clickthroughToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem dualWindowModeToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem enableClickthroughToolStripMenuItem;
}
}

View file

@ -50,7 +50,7 @@ namespace OnTopReplica {
//Set native renderer on context menus
Asztal.Szótár.NativeToolStripRenderer.SetToolStripRenderer(
menuContext, menuWindows, menuOpacity, menuResize, menuLanguages
menuContext, menuWindows, menuOpacity, menuResize, menuLanguages, menuFullscreenContext
);
//Hook keyboard handler
@ -66,125 +66,6 @@ namespace OnTopReplica {
Keys.O, new Native.HotKeyMethods.HotKeyHandler(HotKeyOpenHandler));
}
#region Child forms & controls events
EventHandler RequestClosingHandler;
const int SidePanelMargin = 1;
const int ScreenBorderMargin = 10;
bool _sidePanelDidMoveForm = false;
Point _sidePanelPreviousFormLocation;
/// <summary>
/// Opens a new side panel.
/// </summary>
/// <param name="panel">The side panel to embed.</param>
public void SetSidePanel(SidePanel panel) {
if (_currentSidePanel != null) {
CloseSidePanel();
}
_currentSidePanel = panel;
_currentSidePanel.OnFirstShown(this);
//Add and show
_sidePanelContainer.Controls.Add(panel);
_sidePanelContainer.Visible = _sidePanelContainer.Enabled = true;
panel.Show();
int intHorzMargin = panel.Margin.Horizontal + _sidePanelContainer.Padding.Horizontal; //internal margins for sidepanel
int intVertMargin = panel.Margin.Vertical + _sidePanelContainer.Padding.Vertical;
//Resize container
_sidePanelContainer.ClientSize = new Size(
panel.MinimumSize.Width + intHorzMargin,
ClientSize.Height
);
int rightHorzMargin = _sidePanelContainer.Width + SidePanelMargin; //horz margin between the two controls
//Resize rest
MinimumSize = new Size(
20 + panel.MinimumSize.Width + SidePanelMargin + intHorzMargin,
panel.MinimumSize.Height + intVertMargin
);
ClientSize = new Size(
ClientSize.Width + rightHorzMargin,
ClientSize.Height
);
ExtraPadding = new Padding(0, 0, rightHorzMargin, 0);
_thumbnailPanel.Size = new Size(
ClientSize.Width - rightHorzMargin,
ClientSize.Height
);
_sidePanelContainer.Location = new Point(
ClientSize.Width - rightHorzMargin,
0
);
//Move window if needed
var screenCurr = Screen.FromControl(this);
int pRight = Location.X + Width + ScreenBorderMargin;
if (pRight >= screenCurr.Bounds.Width) {
_sidePanelPreviousFormLocation = Location;
_sidePanelDidMoveForm = true;
Location = new Point(screenCurr.WorkingArea.Width - Width - ScreenBorderMargin, Location.Y);
}
else {
_sidePanelDidMoveForm = false;
}
//Hook event listener
if (RequestClosingHandler == null)
RequestClosingHandler = new EventHandler(SidePanel_RequestClosing);
panel.RequestClosing += RequestClosingHandler;
}
/// <summary>
/// Closes the current side panel.
/// </summary>
public void CloseSidePanel() {
if (_currentSidePanel == null)
return;
//Unhook listener
_currentSidePanel.RequestClosing -= RequestClosingHandler;
//Remove side panel
_currentSidePanel.OnClosing(this);
_sidePanelContainer.Controls.Clear();
_sidePanelContainer.Visible = _sidePanelContainer.Enabled = false;
_currentSidePanel = null;
//Resize
MinimumSize = new Size(20, 20);
ClientSize = new Size(
ClientSize.Width - _sidePanelContainer.Width - SidePanelMargin,
ClientSize.Height
);
ExtraPadding = new Padding(0);
_thumbnailPanel.Size = ClientSize;
//Move window back if needed
if (_sidePanelDidMoveForm) {
Location = _sidePanelPreviousFormLocation;
_sidePanelDidMoveForm = false;
}
}
void SidePanel_RequestClosing(object sender, EventArgs e) {
CloseSidePanel();
}
void Thumbnail_CloneClick(object sender, CloneClickEventArgs e) {
//TODO: handle other mouse buttons
Win32Helper.InjectFakeMouseClick(_lastWindowHandle.Handle, e.ClientClickLocation, e.IsDoubleClick);
}
#endregion
#region Event override
protected override void OnShown(EventArgs e) {
@ -211,6 +92,15 @@ namespace OnTopReplica {
new Margins(-1);
}
protected override void OnActivated(EventArgs e) {
base.OnActivated(e);
//Deactivate click-through if reactivated
if (ClickThroughEnabled) {
ClickThroughEnabled = false;
}
}
protected override void OnDeactivate(EventArgs e) {
base.OnDeactivate(e);
@ -228,6 +118,24 @@ namespace OnTopReplica {
AdjustSize(change);
}
protected override void OnMouseDoubleClick(MouseEventArgs e) {
base.OnMouseDoubleClick(e);
//This is handled by the WM_NCLBUTTONDBLCLK msg handler usually (because the GlassForm translates
//clicks on client to clicks on caption). But if fullscreen mode disables GlassForm dragging, we need
//this auxiliary handler to switch mode.
IsFullscreen = !IsFullscreen;
}
protected override void OnMouseClick(MouseEventArgs e) {
base.OnMouseClick(e);
//Same story as above...
if (e.Button == System.Windows.Forms.MouseButtons.Right) {
OpenContextMenu();
}
}
protected override void WndProc(ref Message m) {
_msgPumpManager.PumpMessage(m);
@ -235,7 +143,7 @@ namespace OnTopReplica {
case MessagingMethods.WM_NCRBUTTONUP:
//Open context menu if right button clicked on caption (i.e. all of the window area because of glass)
if (m.WParam.ToInt32() == MessagingMethods.HTCAPTION) {
menuContext.Show(MousePosition);
OpenContextMenu();
m.Result = IntPtr.Zero;
return;
@ -251,6 +159,14 @@ namespace OnTopReplica {
return;
}
break;
case MessagingMethods.WM_NCHITTEST:
//Make transparent to hit-testing if in click through mode
if (ClickThroughEnabled) {
m.Result = (IntPtr)MessagingMethods.HTTRANSPARENT;
return;
}
break;
}
base.WndProc(ref m);
@ -258,221 +174,7 @@ namespace OnTopReplica {
#endregion
#region Menu Event Handling
private void Close_click(object sender, EventArgs e) {
this.Close();
}
private void Menu_opening(object sender, CancelEventArgs e) {
//Cancel if currently in "fullscreen" mode or a side panel is open
if (IsFullscreen || _currentSidePanel != null) {
e.Cancel = true;
return;
}
selectRegionToolStripMenuItem.Enabled = _thumbnailPanel.IsShowingThumbnail;
switchToWindowToolStripMenuItem.Enabled = _thumbnailPanel.IsShowingThumbnail;
resizeToolStripMenuItem.Enabled = _thumbnailPanel.IsShowingThumbnail;
chromeToolStripMenuItem.Checked = (FormBorderStyle == FormBorderStyle.Sizable);
forwardClicksToolStripMenuItem.Checked = _thumbnailPanel.ReportThumbnailClicks;
}
private void Menu_Close_click(object sender, EventArgs e) {
this.Close();
}
private void Menu_About_click(object sender, EventArgs e) {
this.Hide();
using (var box = new AboutForm()) {
box.Location = RecenterLocation(this, box);
box.ShowDialog();
Location = RecenterLocation(box, this);
}
this.Show();
}
private void Menu_Language_click(object sender, EventArgs e) {
ToolStripItem tsi = (ToolStripItem)sender;
string langCode = tsi.Tag as string;
if (Program.ForceGlobalLanguageChange(langCode))
this.Close();
else
MessageBox.Show("Error");
}
void Menu_Windows_itemclick(object sender, EventArgs e) {
//Ensure the menu is closed
menuContext.Close();
//Get clicked item and window index from tag
ToolStripItem tsi = (ToolStripItem)sender;
//Handle special "none" window
if (tsi.Tag == null) {
UnsetThumbnail();
return;
}
var selectionData = (WindowListHelper.WindowSelectionData)tsi.Tag;
SetThumbnail(selectionData.Handle, selectionData.Region);
}
private void Menu_Switch_click(object sender, EventArgs e) {
if (_lastWindowHandle == null)
return;
Program.Platform.HideForm(this);
Native.WindowManagerMethods.SetForegroundWindow(_lastWindowHandle.Handle);
}
private void Menu_Group_click(object sender, EventArgs e) {
SetSidePanel(new SidePanels.GroupSwitchPanel());
}
private void Menu_Forward_click(object sender, EventArgs e) {
if (Settings.Default.FirstTimeClickForwarding && !_thumbnailPanel.ReportThumbnailClicks) {
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 = !_thumbnailPanel.ReportThumbnailClicks;
}
private void Menu_Opacity_opening(object sender, CancelEventArgs e) {
ToolStripMenuItem[] items = {
toolStripMenuItem1,
toolStripMenuItem2,
toolStripMenuItem3,
toolStripMenuItem4
};
foreach (ToolStripMenuItem i in items) {
if ((double)i.Tag == this.Opacity)
i.Checked = true;
else
i.Checked = false;
}
}
private void Menu_Opacity_click(object sender, EventArgs e) {
//Get clicked menu item
ToolStripMenuItem tsi = sender as ToolStripMenuItem;
if (tsi != null) {
//Get opacity from the tag
this.Opacity = (double)tsi.Tag;
}
}
private void Menu_Region_click(object sender, EventArgs e) {
SetSidePanel(new OnTopReplica.SidePanels.RegionPanel());
}
private void Menu_Resize_opening(object sender, CancelEventArgs e) {
if (!_thumbnailPanel.IsShowingThumbnail)
e.Cancel = true;
}
private void Menu_Resize_Double(object sender, EventArgs e) {
FitToThumbnail(2.0);
}
private void Menu_Resize_FitToWindow(object sender, EventArgs e) {
FitToThumbnail(1.0);
}
private void Menu_Resize_Half(object sender, EventArgs e) {
FitToThumbnail(0.5);
}
private void Menu_Resize_Quarter(object sender, EventArgs e) {
FitToThumbnail(0.25);
}
private void Menu_Resize_Fullscreen(object sender, EventArgs e) {
IsFullscreen = true;
}
private void Menu_Position_TopLeft(object sender, EventArgs e) {
var screen = Screen.FromControl(this);
Location = new Point(
screen.WorkingArea.Left - ChromeBorderHorizontal,
screen.WorkingArea.Top - ChromeBorderVertical
);
}
private void Menu_Position_TopRight(object sender, EventArgs e) {
var screen = Screen.FromControl(this);
Location = new Point(
screen.WorkingArea.Width - Size.Width + ChromeBorderHorizontal,
screen.WorkingArea.Top - ChromeBorderVertical
);
}
private void Menu_Position_BottomLeft(object sender, EventArgs e) {
var screen = Screen.FromControl(this);
Location = new Point(
screen.WorkingArea.Left - ChromeBorderHorizontal,
screen.WorkingArea.Height - Size.Height + ChromeBorderVertical
);
}
private void Menu_Position_BottomRight(object sender, EventArgs e) {
var screen = Screen.FromControl(this);
Location = new Point(
screen.WorkingArea.Width - Size.Width + ChromeBorderHorizontal,
screen.WorkingArea.Height - Size.Height + ChromeBorderVertical
);
}
private void Menu_Reduce_click(object sender, EventArgs e) {
//Hide form in a platform specific way
Program.Platform.HideForm(this);
}
private void Menu_Windows_opening(object sender, EventArgs e) {
//Refresh window list
_windowManager.Refresh(WindowManager.EnumerationMode.TaskWindows);
WindowListHelper.PopulateMenu(this, _windowManager, menuWindows, _lastWindowHandle, new EventHandler(Menu_Windows_itemclick));
}
private void Menu_Chrome_click(object sender, EventArgs e) {
if (FormBorderStyle == FormBorderStyle.Sizable) {
FormBorderStyle = FormBorderStyle.None;
Location = new Point {
X = Location.X + SystemInformation.FrameBorderSize.Width,
Y = Location.Y + SystemInformation.FrameBorderSize.Height
};
}
else {
FormBorderStyle = FormBorderStyle.Sizable;
Location = new Point {
X = Location.X - SystemInformation.FrameBorderSize.Width,
Y = Location.Y - SystemInformation.FrameBorderSize.Height
};
}
Invalidate();
}
#endregion
#region Event handling
#region Keyboard event handling
void Form_KeyUp(object sender, KeyEventArgs e) {
//ALT
@ -501,8 +203,14 @@ namespace OnTopReplica {
//ESCAPE
else if (e.KeyCode == Keys.Escape) {
Console.WriteLine("Received ESC");
//Disable click-through
if (ClickThroughEnabled) {
ClickThroughEnabled = false;
}
//Toggle fullscreen
if (IsFullscreen) {
else if (IsFullscreen) {
IsFullscreen = false;
}
//Disable click forwarding
@ -544,6 +252,7 @@ namespace OnTopReplica {
GlassEnabled = !value;
FormBorderStyle = (value) ? FormBorderStyle.None : FormBorderStyle.Sizable;
TopMost = !value;
HandleMouseMove = !value;
//Location and size
if (value) {
@ -557,6 +266,7 @@ namespace OnTopReplica {
else {
Location = _preFullscreenLocation;
Size = _preFullscreenSize;
RefreshAspectRatio();
}
_isFullscreen = value;
@ -586,8 +296,8 @@ namespace OnTopReplica {
ThumbnailError(ex, false, Strings.ErrorUnableToCreateThumbnail);
}
//Set aspect ratio (this will resize the form)
SetAspectRatio(_thumbnailPanel.ThumbnailOriginalSize);
//Set aspect ratio (this will resize the form), do not refresh if in fullscreen
SetAspectRatio(_thumbnailPanel.ThumbnailOriginalSize, !IsFullscreen);
}
/// <summary>
@ -637,33 +347,15 @@ namespace OnTopReplica {
if (value.HasValue) {
_thumbnailPanel.SelectedRegion = value.Value;
SetAspectRatio(value.Value.Size);
SetAspectRatio(value.Value.Size, true);
}
else {
_thumbnailPanel.ConstrainToRegion = false;
SetAspectRatio(_thumbnailPanel.ThumbnailOriginalSize);
SetAspectRatio(_thumbnailPanel.ThumbnailOriginalSize, true);
}
}
}
/// <summary>
/// Gets the form's thumbnail panel.
/// </summary>
public ThumbnailPanel ThumbnailPanel {
get {
return _thumbnailPanel;
}
}
/// <summary>
/// Gets the form's message pump manager.
/// </summary>
public MessagePumpManager MessagePumpManager {
get {
return _msgPumpManager;
}
}
private void ThumbnailError(Exception ex, bool suppress, string title) {
if (!suppress) {
ShowErrorDialog(title, Strings.ErrorGenericThumbnailHandleError, ex.Message);
@ -687,117 +379,51 @@ namespace OnTopReplica {
#endregion
#region GUI stuff
#region Click-through
private Point RecenterLocation(Control original, Control final) {
int origX = original.Location.X + original.Size.Width / 2;
int origY = original.Location.Y + original.Size.Height / 2;
bool _clickThrough = false;
int finX = origX - final.Size.Width / 2;
int finY = origY - final.Size.Height / 2;
//Check boundaries
var screen = Screen.FromControl(final);
if (finX < screen.WorkingArea.X)
finX = screen.WorkingArea.X;
if (finX + final.Size.Width > screen.WorkingArea.Width)
finX = screen.WorkingArea.Width - final.Size.Width;
if (finY < screen.WorkingArea.Y)
finY = screen.WorkingArea.Y;
if (finY + final.Size.Height > screen.WorkingArea.Height)
finY = screen.WorkingArea.Height - final.Size.Height;
return new Point(finX, finY);
}
private int ChromeBorderVertical {
public bool ClickThroughEnabled {
get {
if (FormBorderStyle == FormBorderStyle.Sizable)
return SystemInformation.FrameBorderSize.Height;
else
return 0;
return _clickThrough;
}
}
set {
//Adjust opacity if fully opaque
if (value && Opacity == 1.0)
Opacity = 0.75;
private int ChromeBorderHorizontal {
get {
if (FormBorderStyle == FormBorderStyle.Sizable)
return SystemInformation.FrameBorderSize.Width;
else
return 0;
//Enable transparency and force as top-most
TransparencyKey = (value) ? Color.Black : Color.Transparent;
if (value)
TopMost = true;
_clickThrough = value;
}
}
/// <summary>
/// Displays an error task dialog.
/// </summary>
/// <param name="mainInstruction">Main instruction of the error dialog.</param>
/// <param name="explanation">Detailed informations about the error.</param>
/// <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,
IsExpanded = false
};
if (!string.IsNullOrEmpty(errorMessage)) {
dlg.ExpandedInformation = Strings.ErrorGenericInfoText + errorMessage;
dlg.ExpandedControlText = Strings.ErrorGenericInfoButton;
}
dlg.Show(this);
}
/// <summary>
/// Ensures that the main form is visible (either closing the fullscreen mode or reactivating from task icon).
/// </summary>
public void EnsureMainFormVisible() {
if (IsFullscreen)
IsFullscreen = false;
//Ensure main form is shown
WindowState = FormWindowState.Normal;
Show();
Activate();
TopMost = true;
}
/// <summary>
/// Opens a confirmation dialog to confirm whether to reset the main form or not.
/// </summary>
public void ResetMainFormWithConfirmation() {
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;
if (dlg.Show(this).CommonButton == Result.OK) {
ResetMainForm();
}
}
/// <summary>
/// Resets the main form to its initial state.
/// </summary>
public void ResetMainForm() {
//Reset form settings
UnsetThumbnail();
CloseSidePanel();
//Reset location and size (edge of the screen, min size)
Point nuLoc = Screen.PrimaryScreen.WorkingArea.Location;
nuLoc.Offset(40, 40);
Location = nuLoc;
Size = MinimumSize;
this.Show();
this.Activate();
}
#endregion
#region Accessors
/// <summary>
/// Gets the form's thumbnail panel.
/// </summary>
public ThumbnailPanel ThumbnailPanel {
get {
return _thumbnailPanel;
}
}
/// <summary>
/// Gets the form's message pump manager.
/// </summary>
public MessagePumpManager MessagePumpManager {
get {
return _msgPumpManager;
}
}
#endregion
}
}

View file

@ -127,10 +127,13 @@
<value>275, 17</value>
</metadata>
<metadata name="menuResize.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>547, 17</value>
<value>578, 17</value>
</metadata>
<metadata name="menuLanguages.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>664, 17</value>
<value>695, 17</value>
</metadata>
<metadata name="menuFullscreenContext.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>399, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">

View file

@ -0,0 +1,126 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
namespace OnTopReplica {
partial class MainForm {
EventHandler RequestClosingHandler;
const int SidePanelMargin = 1;
const int ScreenBorderMargin = 10;
bool _sidePanelDidMoveForm = false;
Point _sidePanelPreviousFormLocation;
/// <summary>
/// Opens a new side panel.
/// </summary>
/// <param name="panel">The side panel to embed.</param>
public void SetSidePanel(SidePanel panel) {
if (_currentSidePanel != null) {
CloseSidePanel();
}
_currentSidePanel = panel;
_currentSidePanel.OnFirstShown(this);
//Add and show
_sidePanelContainer.Controls.Add(panel);
_sidePanelContainer.Visible = _sidePanelContainer.Enabled = true;
panel.Show();
int intHorzMargin = panel.Margin.Horizontal + _sidePanelContainer.Padding.Horizontal; //internal margins for sidepanel
int intVertMargin = panel.Margin.Vertical + _sidePanelContainer.Padding.Vertical;
//Resize container
_sidePanelContainer.ClientSize = new Size(
panel.MinimumSize.Width + intHorzMargin,
ClientSize.Height
);
int rightHorzMargin = _sidePanelContainer.Width + SidePanelMargin; //horz margin between the two controls
//Resize rest
MinimumSize = new Size(
20 + panel.MinimumSize.Width + SidePanelMargin + intHorzMargin,
panel.MinimumSize.Height + intVertMargin
);
ClientSize = new Size(
ClientSize.Width + rightHorzMargin,
ClientSize.Height
);
ExtraPadding = new Padding(0, 0, rightHorzMargin, 0);
_thumbnailPanel.Size = new Size(
ClientSize.Width - rightHorzMargin,
ClientSize.Height
);
_sidePanelContainer.Location = new Point(
ClientSize.Width - rightHorzMargin,
0
);
//Move window if needed
var screenCurr = Screen.FromControl(this);
int pRight = Location.X + Width + ScreenBorderMargin;
if (pRight >= screenCurr.Bounds.Width) {
_sidePanelPreviousFormLocation = Location;
_sidePanelDidMoveForm = true;
Location = new Point(screenCurr.WorkingArea.Width - Width - ScreenBorderMargin, Location.Y);
}
else {
_sidePanelDidMoveForm = false;
}
//Hook event listener
if (RequestClosingHandler == null)
RequestClosingHandler = new EventHandler(SidePanel_RequestClosing);
panel.RequestClosing += RequestClosingHandler;
}
/// <summary>
/// Closes the current side panel.
/// </summary>
public void CloseSidePanel() {
if (_currentSidePanel == null)
return;
//Unhook listener
_currentSidePanel.RequestClosing -= RequestClosingHandler;
//Remove side panel
_currentSidePanel.OnClosing(this);
_sidePanelContainer.Controls.Clear();
_sidePanelContainer.Visible = _sidePanelContainer.Enabled = false;
_currentSidePanel = null;
//Resize
MinimumSize = new Size(20, 20);
ClientSize = new Size(
ClientSize.Width - _sidePanelContainer.Width - SidePanelMargin,
ClientSize.Height
);
ExtraPadding = new Padding(0);
_thumbnailPanel.Size = ClientSize;
//Move window back if needed
if (_sidePanelDidMoveForm) {
Location = _sidePanelPreviousFormLocation;
_sidePanelDidMoveForm = false;
}
}
void SidePanel_RequestClosing(object sender, EventArgs e) {
CloseSidePanel();
}
void Thumbnail_CloneClick(object sender, CloneClickEventArgs e) {
//TODO: handle other mouse buttons
Win32Helper.InjectFakeMouseClick(_lastWindowHandle.Handle, e.ClientClickLocation, e.IsDoubleClick);
}
}
}

View file

@ -0,0 +1,131 @@
using System.Drawing;
using System.Windows.Forms;
using VistaControls.TaskDialog;
namespace OnTopReplica {
partial class MainForm {
/// <summary>
/// Opens the context menu.
/// </summary>
public void OpenContextMenu() {
if (IsFullscreen) {
menuFullscreenContext.Show(MousePosition);
}
else {
menuContext.Show(MousePosition);
}
}
private Point RecenterLocation(Control original, Control final) {
int origX = original.Location.X + original.Size.Width / 2;
int origY = original.Location.Y + original.Size.Height / 2;
int finX = origX - final.Size.Width / 2;
int finY = origY - final.Size.Height / 2;
//Check boundaries
var screen = Screen.FromControl(final);
if (finX < screen.WorkingArea.X)
finX = screen.WorkingArea.X;
if (finX + final.Size.Width > screen.WorkingArea.Width)
finX = screen.WorkingArea.Width - final.Size.Width;
if (finY < screen.WorkingArea.Y)
finY = screen.WorkingArea.Y;
if (finY + final.Size.Height > screen.WorkingArea.Height)
finY = screen.WorkingArea.Height - final.Size.Height;
return new Point(finX, finY);
}
private int ChromeBorderVertical {
get {
if (FormBorderStyle == FormBorderStyle.Sizable)
return SystemInformation.FrameBorderSize.Height;
else
return 0;
}
}
private int ChromeBorderHorizontal {
get {
if (FormBorderStyle == FormBorderStyle.Sizable)
return SystemInformation.FrameBorderSize.Width;
else
return 0;
}
}
/// <summary>
/// Displays an error task dialog.
/// </summary>
/// <param name="mainInstruction">Main instruction of the error dialog.</param>
/// <param name="explanation">Detailed informations about the error.</param>
/// <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,
IsExpanded = false
};
if (!string.IsNullOrEmpty(errorMessage)) {
dlg.ExpandedInformation = Strings.ErrorGenericInfoText + errorMessage;
dlg.ExpandedControlText = Strings.ErrorGenericInfoButton;
}
dlg.Show(this);
}
/// <summary>
/// Ensures that the main form is visible (either closing the fullscreen mode or reactivating from task icon).
/// </summary>
public void EnsureMainFormVisible() {
//Reset special modes
IsFullscreen = false;
ClickThroughEnabled = false;
Opacity = 1.0;
//Ensure main form is shown
WindowState = FormWindowState.Normal;
Show();
Activate();
TopMost = true;
}
/// <summary>
/// Opens a confirmation dialog to confirm whether to reset the main form or not.
/// </summary>
public void ResetMainFormWithConfirmation() {
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;
if (dlg.Show(this).CommonButton == Result.OK) {
ResetMainForm();
}
}
/// <summary>
/// Resets the main form to its initial state.
/// </summary>
public void ResetMainForm() {
//Reset form settings
UnsetThumbnail();
CloseSidePanel();
//Reset location and size (edge of the screen, min size)
Point nuLoc = Screen.PrimaryScreen.WorkingArea.Location;
nuLoc.Offset(40, 40);
Location = nuLoc;
Size = MinimumSize;
this.Show();
this.Activate();
}
}
}

View file

@ -0,0 +1,226 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using OnTopReplica.Properties;
using VistaControls.TaskDialog;
namespace OnTopReplica {
partial class MainForm {
private void Menu_opening(object sender, CancelEventArgs e) {
//Cancel if currently in "fullscreen" mode or a side panel is open
if (IsFullscreen || _currentSidePanel != null) {
e.Cancel = true;
return;
}
selectRegionToolStripMenuItem.Enabled = _thumbnailPanel.IsShowingThumbnail;
switchToWindowToolStripMenuItem.Enabled = _thumbnailPanel.IsShowingThumbnail;
resizeToolStripMenuItem.Enabled = _thumbnailPanel.IsShowingThumbnail;
chromeToolStripMenuItem.Checked = (FormBorderStyle == FormBorderStyle.Sizable);
forwardClicksToolStripMenuItem.Checked = _thumbnailPanel.ReportThumbnailClicks;
}
private void Menu_Windows_opening(object sender, CancelEventArgs e) {
_windowManager.Refresh(WindowManager.EnumerationMode.TaskWindows);
WindowListHelper.PopulateMenu(this, _windowManager, (ToolStrip)sender,
_lastWindowHandle, new EventHandler(Menu_Windows_itemclick));
}
void Menu_Windows_itemclick(object sender, EventArgs e) {
//Ensure the menu is closed
menuContext.Close();
menuFullscreenContext.Close();
//Get clicked item and window index from tag
ToolStripItem tsi = (ToolStripItem)sender;
//Handle special "none" window
if (tsi.Tag == null) {
UnsetThumbnail();
return;
}
var selectionData = (WindowListHelper.WindowSelectionData)tsi.Tag;
SetThumbnail(selectionData.Handle, selectionData.Region);
}
private void Menu_Switch_click(object sender, EventArgs e) {
if (_lastWindowHandle == null)
return;
Program.Platform.HideForm(this);
Native.WindowManagerMethods.SetForegroundWindow(_lastWindowHandle.Handle);
}
private void Menu_GroupSwitchMode_click(object sender, EventArgs e) {
SetSidePanel(new SidePanels.GroupSwitchPanel());
}
private void Menu_ClickForwarding_click(object sender, EventArgs e) {
if (Settings.Default.FirstTimeClickForwarding && !_thumbnailPanel.ReportThumbnailClicks) {
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 = !_thumbnailPanel.ReportThumbnailClicks;
}
private void Menu_ClickThrough_click(object sender, EventArgs e) {
ClickThroughEnabled = true;
}
private void Menu_Opacity_opening(object sender, CancelEventArgs e) {
ToolStripMenuItem[] items = {
toolStripMenuItem1,
toolStripMenuItem2,
toolStripMenuItem3,
toolStripMenuItem4
};
foreach (ToolStripMenuItem i in items) {
if ((double)i.Tag == this.Opacity)
i.Checked = true;
else
i.Checked = false;
}
}
private void Menu_Opacity_click(object sender, EventArgs e) {
//Get clicked menu item
ToolStripMenuItem tsi = sender as ToolStripMenuItem;
if (tsi != null) {
//Get opacity from the tag
this.Opacity = (double)tsi.Tag;
}
}
private void Menu_Region_click(object sender, EventArgs e) {
SetSidePanel(new OnTopReplica.SidePanels.RegionPanel());
}
private void Menu_Resize_opening(object sender, CancelEventArgs e) {
if (!_thumbnailPanel.IsShowingThumbnail)
e.Cancel = true;
}
private void Menu_Resize_Double(object sender, EventArgs e) {
FitToThumbnail(2.0);
}
private void Menu_Resize_FitToWindow(object sender, EventArgs e) {
FitToThumbnail(1.0);
}
private void Menu_Resize_Half(object sender, EventArgs e) {
FitToThumbnail(0.5);
}
private void Menu_Resize_Quarter(object sender, EventArgs e) {
FitToThumbnail(0.25);
}
private void Menu_Resize_Fullscreen(object sender, EventArgs e) {
IsFullscreen = true;
}
private void Menu_Position_TopLeft(object sender, EventArgs e) {
var screen = Screen.FromControl(this);
Location = new Point(
screen.WorkingArea.Left - ChromeBorderHorizontal,
screen.WorkingArea.Top - ChromeBorderVertical
);
}
private void Menu_Position_TopRight(object sender, EventArgs e) {
var screen = Screen.FromControl(this);
Location = new Point(
screen.WorkingArea.Width - Size.Width + ChromeBorderHorizontal,
screen.WorkingArea.Top - ChromeBorderVertical
);
}
private void Menu_Position_BottomLeft(object sender, EventArgs e) {
var screen = Screen.FromControl(this);
Location = new Point(
screen.WorkingArea.Left - ChromeBorderHorizontal,
screen.WorkingArea.Height - Size.Height + ChromeBorderVertical
);
}
private void Menu_Position_BottomRight(object sender, EventArgs e) {
var screen = Screen.FromControl(this);
Location = new Point(
screen.WorkingArea.Width - Size.Width + ChromeBorderHorizontal,
screen.WorkingArea.Height - Size.Height + ChromeBorderVertical
);
}
private void Menu_Reduce_click(object sender, EventArgs e) {
//Hide form in a platform specific way
Program.Platform.HideForm(this);
}
private void Menu_Chrome_click(object sender, EventArgs e) {
if (FormBorderStyle == FormBorderStyle.Sizable) {
FormBorderStyle = FormBorderStyle.None;
Location = new Point {
X = Location.X + SystemInformation.FrameBorderSize.Width,
Y = Location.Y + SystemInformation.FrameBorderSize.Height
};
}
else {
FormBorderStyle = FormBorderStyle.Sizable;
Location = new Point {
X = Location.X - SystemInformation.FrameBorderSize.Width,
Y = Location.Y - SystemInformation.FrameBorderSize.Height
};
}
Invalidate();
}
private void Menu_Language_click(object sender, EventArgs e) {
ToolStripItem tsi = (ToolStripItem)sender;
string langCode = tsi.Tag as string;
if (Program.ForceGlobalLanguageChange(langCode))
this.Close();
else
MessageBox.Show("Error");
}
private void Menu_About_click(object sender, EventArgs e) {
this.Hide();
using (var box = new AboutForm()) {
box.Location = RecenterLocation(this, box);
box.ShowDialog();
Location = RecenterLocation(box, this);
}
this.Show();
}
private void Menu_Close_click(object sender, EventArgs e) {
this.Close();
}
private void Menu_Fullscreen_ExitFullscreen_click(object sender, EventArgs e) {
IsFullscreen = false;
}
}
}

View file

@ -132,6 +132,15 @@
</Compile>
<Compile Include="CloneClickEventArgs.cs" />
<Compile Include="CloseRequestEventArgs.cs" />
<Compile Include="MainForm_Gui.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="MainForm_MenuEvents.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="MainForm_ChildForms.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="MessagePumpManager.cs" />
<Compile Include="MessagePumpProcessors\GroupSwitchManager.cs" />
<Compile Include="IMessagePumpProcessor.cs" />
@ -287,6 +296,7 @@
<None Include="Assets\reduce.png" />
</ItemGroup>
<ItemGroup>
<None Include="Assets\xiao_wrench.png" />
<None Include="Assets\xiao_delete.png" />
<None Include="Assets\xiao_add.png" />
<None Include="Assets\xiao_ok.png" />
@ -294,6 +304,7 @@
<SubType>Designer</SubType>
</None>
<None Include="Assets\flag_danish.png" />
<None Include="Assets\71.png" />
<Content Include="Assets\window_multiple16.ico" />
</ItemGroup>
<ItemGroup>

View file

@ -269,5 +269,12 @@ namespace OnTopReplica.Properties {
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap xiao_wrench {
get {
object obj = ResourceManager.GetObject("xiao_wrench", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View file

@ -202,11 +202,14 @@
<data name="flag_usa" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Assets\flag_usa.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="xiao_add" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Assets\xiao_add.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="xiao_delete" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Assets\xiao_delete.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="xiao_wrench" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Assets\xiao_wrench.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View file

@ -129,5 +129,29 @@ namespace OnTopReplica.Properties {
this["FullscreenAlwaysOnTop"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string Setting {
get {
return ((string)(this["Setting"]));
}
set {
this["Setting"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string Setting1 {
get {
return ((string)(this["Setting1"]));
}
set {
this["Setting1"] = value;
}
}
}
}

View file

@ -29,5 +29,11 @@
<Setting Name="FullscreenAlwaysOnTop" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="Setting" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="Setting1" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings>
</SettingsFile>

View file

@ -160,6 +160,8 @@ namespace OnTopReplica {
if(owner == null)
throw new Exception("Internal error: ThumbnailPanel.TopLevelControl is not a Form.");
_labelGlass.Visible = false;
_thumbnail = DwmManager.Register(owner, handle.Handle);
ConstrainToRegion = false; //this also invokes a thumbnail update
}
@ -172,6 +174,7 @@ namespace OnTopReplica {
_thumbnail.Close();
_thumbnail = null;
_labelGlass.Visible = true;
}
/// <summary>

View file

@ -31,6 +31,12 @@
<setting name="FullscreenAlwaysOnTop" serializeAs="String">
<value>False</value>
</setting>
<setting name="Setting" serializeAs="String">
<value />
</setting>
<setting name="Setting1" serializeAs="String">
<value />
</setting>
</OnTopReplica.Properties.Settings>
</userSettings>
<startup><supportedRuntime version="v2.0.50727"/></startup></configuration>