mirror of
https://github.com/LorenzCK/OnTopReplica.git
synced 2024-06-03 11:04:32 +12:00
Fullscreen mode fixes (correct window selection and restoring).
Window selection menu improved (click on main window menuitem).
This commit is contained in:
parent
636c2b6922
commit
3a88173f52
|
@ -9,7 +9,7 @@ using System.Drawing;
|
||||||
namespace OnTopReplica {
|
namespace OnTopReplica {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Form that automatically keeps a certain aspect ratio and resizes withour flickering.
|
/// Form that automatically keeps a certain aspect ratio and resizes without flickering.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class AspectRatioForm : GlassForm {
|
public class AspectRatioForm : GlassForm {
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Drawing;
|
||||||
|
|
||||||
namespace OnTopReplica {
|
namespace OnTopReplica {
|
||||||
public class CloseRequestEventArgs : EventArgs {
|
public class CloseRequestEventArgs : EventArgs {
|
||||||
|
|
||||||
public CloseRequestEventArgs(WindowHandle lastHandle) {
|
public WindowHandle LastWindowHandle { get; set; }
|
||||||
CurrentWindowHandle = lastHandle;
|
public Rectangle? LastRegion { get; set; }
|
||||||
}
|
|
||||||
|
|
||||||
public WindowHandle CurrentWindowHandle { get; set; }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,74 +5,78 @@ using System.Data;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using VistaControls.TaskDialog;
|
||||||
|
|
||||||
namespace OnTopReplica {
|
namespace OnTopReplica {
|
||||||
|
|
||||||
public partial class FullscreenForm : Form {
|
public partial class FullscreenForm : Form {
|
||||||
|
|
||||||
public FullscreenForm() {
|
public FullscreenForm() {
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
_thumbnail.GlassMode = true;
|
_thumbnail.GlassMode = true;
|
||||||
|
|
||||||
//Set native renderer on context menu
|
//Set native renderer on context menu
|
||||||
Asztal.Szótár.NativeToolStripRenderer.SetToolStripRenderer(new Control[] {
|
Asztal.Szótár.NativeToolStripRenderer.SetToolStripRenderer(new Control[] {
|
||||||
menuContext, menuWindows
|
menuContext, menuWindows
|
||||||
});
|
});
|
||||||
|
|
||||||
_cursorTimer = new Timer();
|
/*_cursorTimer = new Timer();
|
||||||
_cursorTimer.Interval = 1000;
|
_cursorTimer.Interval = 1000;
|
||||||
_cursorTimer.Tick += new EventHandler(_cursorTimer_Tick);
|
_cursorTimer.Tick += new EventHandler(_cursorTimer_Tick);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer _cursorTimer;
|
//Timer _cursorTimer;
|
||||||
|
|
||||||
WindowHandle _lastHandle;
|
WindowHandle _lastHandle;
|
||||||
WindowManager _manager = new WindowManager(WindowManager.EnumerationMode.TaskWindows);
|
WindowManager _manager = new WindowManager(WindowManager.EnumerationMode.TaskWindows);
|
||||||
|
|
||||||
public void DisplayFullscreen(Screen screen, WindowHandle window) {
|
public void DisplayFullscreen(Screen screen, WindowHandle window) {
|
||||||
_lastHandle = window;
|
_lastHandle = window;
|
||||||
|
|
||||||
//Init thumbnail
|
//Init thumbnail
|
||||||
_thumbnail.SetThumbnailHandle(window);
|
_thumbnail.SetThumbnailHandle(window);
|
||||||
|
|
||||||
//Form setup
|
//Form setup
|
||||||
this.Location = screen.WorkingArea.Location;
|
this.Location = screen.WorkingArea.Location;
|
||||||
this.Size = screen.WorkingArea.Size;
|
this.Size = screen.WorkingArea.Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CloseFullscreen() {
|
public void CloseFullscreen() {
|
||||||
this.Visible = false;
|
this.Visible = false;
|
||||||
|
|
||||||
_thumbnail.UnsetThumbnail();
|
_thumbnail.UnsetThumbnail();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Rectangle ShownRegion {
|
public Rectangle ShownRegion {
|
||||||
get {
|
get {
|
||||||
return _thumbnail.ShownRegion;
|
return _thumbnail.ShownRegion;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
_thumbnail.ShownRegion = value;
|
_thumbnail.ShownRegion = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ShowRegion {
|
public bool ShowRegion {
|
||||||
get {
|
get {
|
||||||
return _thumbnail.ShowRegion;
|
return _thumbnail.ShowRegion;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
_thumbnail.ShowRegion = value;
|
_thumbnail.ShowRegion = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public event EventHandler<CloseRequestEventArgs> CloseRequest;
|
public event EventHandler<CloseRequestEventArgs> CloseRequest;
|
||||||
|
|
||||||
protected virtual void OnCloseRequest() {
|
protected virtual void OnCloseRequest() {
|
||||||
if (CloseRequest != null)
|
if (CloseRequest != null)
|
||||||
CloseRequest(this, new CloseRequestEventArgs(_lastHandle));
|
CloseRequest(this, new CloseRequestEventArgs {
|
||||||
}
|
LastWindowHandle = _lastHandle,
|
||||||
|
LastRegion = (_thumbnail.ShowRegion) ? (Rectangle?)_thumbnail.ShownRegion : null
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
protected override void OnActivated(EventArgs e) {
|
/*protected override void OnActivated(EventArgs e) {
|
||||||
_cursorTimer.Start();
|
_cursorTimer.Start();
|
||||||
|
|
||||||
base.OnActivated(e);
|
base.OnActivated(e);
|
||||||
|
@ -107,84 +111,94 @@ namespace OnTopReplica {
|
||||||
void _cursorTimer_Tick(object sender, EventArgs e) {
|
void _cursorTimer_Tick(object sender, EventArgs e) {
|
||||||
Cursor.Hide();
|
Cursor.Hide();
|
||||||
_cursorTimer.Stop();
|
_cursorTimer.Stop();
|
||||||
|
}*/
|
||||||
|
|
||||||
|
protected override void OnDoubleClick(EventArgs e) {
|
||||||
|
OnCloseRequest();
|
||||||
|
|
||||||
|
base.OnDoubleClick(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnDoubleClick(EventArgs e) {
|
protected override void OnKeyUp(KeyEventArgs e) {
|
||||||
OnCloseRequest();
|
if (e.KeyCode == Keys.Escape) {
|
||||||
|
e.Handled = true;
|
||||||
base.OnDoubleClick(e);
|
OnCloseRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnKeyUp(KeyEventArgs e) {
|
|
||||||
if (e.KeyCode == Keys.Escape) {
|
|
||||||
e.Handled = true;
|
|
||||||
OnCloseRequest();
|
|
||||||
}
|
|
||||||
else if (e.KeyCode == Keys.Enter && e.Modifiers == Keys.Alt) {
|
else if (e.KeyCode == Keys.Enter && e.Modifiers == Keys.Alt) {
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
OnCloseRequest();
|
OnCloseRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
base.OnKeyUp(e);
|
base.OnKeyUp(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _clickThrough = false;
|
bool _clickThrough = false;
|
||||||
|
|
||||||
public bool ClickThrough {
|
public bool ClickThrough {
|
||||||
get {
|
get {
|
||||||
return _clickThrough;
|
return _clickThrough;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
_clickThrough = value;
|
_clickThrough = value;
|
||||||
|
|
||||||
this.TransparencyKey = (value) ? Color.Black : Color.White;
|
this.TransparencyKey = (value) ? Color.Black : Color.White;
|
||||||
this.Invalidate();
|
this.Invalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const int WM_NCHITTEST = 0x0084;
|
const int WM_NCHITTEST = 0x0084;
|
||||||
const int HTTRANSPARENT = -1;
|
const int HTTRANSPARENT = -1;
|
||||||
|
|
||||||
protected override void WndProc(ref Message m) {
|
protected override void WndProc(ref Message m) {
|
||||||
if (_clickThrough && m.Msg == WM_NCHITTEST) {
|
if (_clickThrough && m.Msg == WM_NCHITTEST) {
|
||||||
m.Result = new IntPtr(HTTRANSPARENT);
|
m.Result = new IntPtr(HTTRANSPARENT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
base.WndProc(ref m);
|
base.WndProc(ref m);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Menu_Quit_click(object sender, EventArgs e) {
|
private void Menu_Quit_click(object sender, EventArgs e) {
|
||||||
OnCloseRequest();
|
OnCloseRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Menu_Windows_opening(object sender, EventArgs e) {
|
private void Menu_Windows_opening(object sender, EventArgs e) {
|
||||||
_manager.Refresh(WindowManager.EnumerationMode.TaskWindows);
|
_manager.Refresh(WindowManager.EnumerationMode.TaskWindows);
|
||||||
|
|
||||||
WindowListHelper.PopulateMenu(_manager, menuWindows, _lastHandle, new EventHandler(Menu_Window_click));
|
WindowListHelper.PopulateMenu(this, _manager, menuWindows, _lastHandle, new EventHandler(Menu_Window_click));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu_Window_click(object sender, EventArgs e) {
|
void Menu_Window_click(object sender, EventArgs e) {
|
||||||
//Get clicked item and window index from tag
|
//Ensure menu is closed
|
||||||
ToolStripItem tsi = (ToolStripItem)sender;
|
menuContext.Close();
|
||||||
|
|
||||||
//Handle -none- selection
|
//Get clicked item and window index from tag
|
||||||
if (tsi.Tag == null) {
|
ToolStripItem tsi = (ToolStripItem)sender;
|
||||||
OnCloseRequest();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int index = (int)tsi.Tag;
|
var windowData = tsi.Tag as WindowListHelper.WindowSelectionData;
|
||||||
|
|
||||||
if (index >= _manager.Windows.Count)
|
//Handle "-none-" window request
|
||||||
return;
|
if (windowData == null) {
|
||||||
|
OnCloseRequest();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var handle = _manager.Windows[index];
|
try {
|
||||||
|
_thumbnail.SetThumbnailHandle(windowData.Handle);
|
||||||
|
if (windowData.Region != null) {
|
||||||
|
_thumbnail.ShownRegion = windowData.Region.Rect;
|
||||||
|
_thumbnail.ShowRegion = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
_thumbnail.ShowRegion = false;
|
||||||
|
}
|
||||||
|
_lastHandle = windowData.Handle;
|
||||||
|
}
|
||||||
|
catch (Exception) {
|
||||||
|
OnCloseRequest();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_thumbnail.SetThumbnailHandle(handle);
|
}
|
||||||
_lastHandle = handle;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,11 +76,11 @@ namespace OnTopReplica
|
||||||
|
|
||||||
void FullscreenForm_CloseRequest(object sender, CloseRequestEventArgs e) {
|
void FullscreenForm_CloseRequest(object sender, CloseRequestEventArgs e) {
|
||||||
if (_isFullscreen) {
|
if (_isFullscreen) {
|
||||||
//Update handle to match the one selected in fullscreen mode
|
var regionContainer = (e.LastRegion != null) ?
|
||||||
if (_lastWindowHandle != e.CurrentWindowHandle) {
|
new StoredRegion { Rect = e.LastRegion.Value } : null;
|
||||||
_lastWindowHandle = e.CurrentWindowHandle;
|
|
||||||
_thumbnailPanel.SetThumbnailHandle(e.CurrentWindowHandle);
|
//Update handle to match the one selected in fullscreen mode
|
||||||
}
|
ThumbnailSet(e.LastWindowHandle, regionContainer);
|
||||||
|
|
||||||
ToggleFullscreen();
|
ToggleFullscreen();
|
||||||
}
|
}
|
||||||
|
@ -439,6 +439,9 @@ namespace OnTopReplica
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu_Windows_itemclick(object sender, EventArgs e) {
|
void Menu_Windows_itemclick(object sender, EventArgs e) {
|
||||||
|
//Insure the menu is closed
|
||||||
|
menuContext.Close();
|
||||||
|
|
||||||
//Get clicked item and window index from tag
|
//Get clicked item and window index from tag
|
||||||
ToolStripItem tsi = (ToolStripItem)sender;
|
ToolStripItem tsi = (ToolStripItem)sender;
|
||||||
|
|
||||||
|
@ -629,7 +632,7 @@ namespace OnTopReplica
|
||||||
//Refresh window list
|
//Refresh window list
|
||||||
_windowManager.Refresh(WindowManager.EnumerationMode.TaskWindows);
|
_windowManager.Refresh(WindowManager.EnumerationMode.TaskWindows);
|
||||||
|
|
||||||
WindowListHelper.PopulateMenu(_windowManager, menuWindows, _lastWindowHandle, new EventHandler(Menu_Windows_itemclick));
|
WindowListHelper.PopulateMenu(this, _windowManager, menuWindows, _lastWindowHandle, new EventHandler(Menu_Windows_itemclick));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Menu_Chrome_click(object sender, EventArgs e) {
|
private void Menu_Chrome_click(object sender, EventArgs e) {
|
||||||
|
|
|
@ -49,8 +49,8 @@
|
||||||
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
|
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
|
||||||
<WebPage>publish.htm</WebPage>
|
<WebPage>publish.htm</WebPage>
|
||||||
<OpenBrowserOnPublish>false</OpenBrowserOnPublish>
|
<OpenBrowserOnPublish>false</OpenBrowserOnPublish>
|
||||||
<ApplicationRevision>2</ApplicationRevision>
|
<ApplicationRevision>1</ApplicationRevision>
|
||||||
<ApplicationVersion>2.8.0.%2a</ApplicationVersion>
|
<ApplicationVersion>2.8.1.%2a</ApplicationVersion>
|
||||||
<UseApplicationTrust>false</UseApplicationTrust>
|
<UseApplicationTrust>false</UseApplicationTrust>
|
||||||
<PublishWizardCompleted>true</PublishWizardCompleted>
|
<PublishWizardCompleted>true</PublishWizardCompleted>
|
||||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||||
|
|
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("2.8.0.0")]
|
[assembly: AssemblyVersion("2.8.1.0")]
|
||||||
[assembly: AssemblyFileVersion("2.8.0.0")]
|
[assembly: AssemblyFileVersion("2.8.1.0")]
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace OnTopReplica {
|
||||||
|
|
||||||
const int cMaxWindowTitleLength = 55;
|
const int cMaxWindowTitleLength = 55;
|
||||||
|
|
||||||
public static void PopulateMenu(WindowManager windowManager, ToolStrip menu,
|
public static void PopulateMenu(Form ownerForm, WindowManager windowManager, ToolStrip menu,
|
||||||
WindowHandle currentHandle, EventHandler clickHandler) {
|
WindowHandle currentHandle, EventHandler clickHandler) {
|
||||||
var regions = Settings.Default.SavedRegions;
|
var regions = Settings.Default.SavedRegions;
|
||||||
|
|
||||||
|
@ -30,8 +30,13 @@ namespace OnTopReplica {
|
||||||
|
|
||||||
//Add an item for each window
|
//Add an item for each window
|
||||||
foreach (WindowHandle h in windowManager.Windows) {
|
foreach (WindowHandle h in windowManager.Windows) {
|
||||||
|
//Skip if in the same process
|
||||||
|
if (h.Handle.Equals(ownerForm.Handle))
|
||||||
|
continue;
|
||||||
|
|
||||||
var tsi = new ToolStripMenuItem();
|
var tsi = new ToolStripMenuItem();
|
||||||
|
|
||||||
|
//Window title
|
||||||
if (h.Title.Length > cMaxWindowTitleLength) {
|
if (h.Title.Length > cMaxWindowTitleLength) {
|
||||||
tsi.Text = h.Title.Substring(0, cMaxWindowTitleLength) + "...";
|
tsi.Text = h.Title.Substring(0, cMaxWindowTitleLength) + "...";
|
||||||
tsi.ToolTipText = h.Title;
|
tsi.ToolTipText = h.Title;
|
||||||
|
@ -39,12 +44,21 @@ namespace OnTopReplica {
|
||||||
else
|
else
|
||||||
tsi.Text = h.Title;
|
tsi.Text = h.Title;
|
||||||
|
|
||||||
//tsi.Click += clickHandler;
|
//Icon
|
||||||
if (h.Icon != null) {
|
if (h.Icon != null) {
|
||||||
tsi.Image = h.Icon.ToBitmap();
|
tsi.Image = h.Icon.ToBitmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Check if this is the currently displayed window
|
||||||
tsi.Checked = h.Equals(currentHandle);
|
tsi.Checked = h.Equals(currentHandle);
|
||||||
|
|
||||||
|
//Add direct click if no stored regions
|
||||||
|
tsi.Tag = new WindowSelectionData {
|
||||||
|
Handle = h,
|
||||||
|
Region = null
|
||||||
|
};
|
||||||
|
tsi.Click += clickHandler;
|
||||||
|
|
||||||
if (regions != null && regions.Count > 0) {
|
if (regions != null && regions.Count > 0) {
|
||||||
//Add subitem for no region
|
//Add subitem for no region
|
||||||
var nullRegionItem = new ToolStripMenuItem(Strings.MenuWindowsWholeRegion);
|
var nullRegionItem = new ToolStripMenuItem(Strings.MenuWindowsWholeRegion);
|
||||||
|
@ -68,14 +82,6 @@ namespace OnTopReplica {
|
||||||
tsi.DropDownItems.Add(regionItem);
|
tsi.DropDownItems.Add(regionItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
//Add direct click if no stored regions
|
|
||||||
tsi.Tag = new WindowSelectionData {
|
|
||||||
Handle = h,
|
|
||||||
Region = null
|
|
||||||
};
|
|
||||||
tsi.Click += clickHandler;
|
|
||||||
}
|
|
||||||
|
|
||||||
menu.Items.Add(tsi);
|
menu.Items.Add(tsi);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue