mirror of
https://github.com/LorenzCK/OnTopReplica.git
synced 2024-05-21 04:43:55 +12:00
Added some experimental stuff for Windows 7 (nothing works).
Refactored the notification icon as separate class, added window selection to context menu.
This commit is contained in:
parent
bfdfc2d371
commit
2d3366a338
Binary file not shown.
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 85 KiB |
25
OnTopReplica/MainForm.Designer.cs
generated
25
OnTopReplica/MainForm.Designer.cs
generated
|
@ -44,6 +44,7 @@
|
|||
this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem4 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.fullOpacityToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.resizeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.menuResize = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.doubleToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
|
@ -68,7 +69,6 @@
|
|||
this.italianoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.menuContextClose = 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();
|
||||
|
@ -128,11 +128,11 @@
|
|||
// fullSelectWindowToolStripMenuItem
|
||||
//
|
||||
this.fullSelectWindowToolStripMenuItem.DropDown = this.menuWindows;
|
||||
this.fullSelectWindowToolStripMenuItem.Image = global::OnTopReplica.Properties.Resources.list;
|
||||
this.fullSelectWindowToolStripMenuItem.Name = "fullSelectWindowToolStripMenuItem";
|
||||
this.fullSelectWindowToolStripMenuItem.Size = new System.Drawing.Size(186, 22);
|
||||
this.fullSelectWindowToolStripMenuItem.Text = global::OnTopReplica.Strings.MenuWindows;
|
||||
this.fullSelectWindowToolStripMenuItem.ToolTipText = global::OnTopReplica.Strings.MenuWindowsTT;
|
||||
this.fullSelectWindowToolStripMenuItem.Image = global::OnTopReplica.Properties.Resources.list;
|
||||
//
|
||||
// switchToWindowToolStripMenuItem
|
||||
//
|
||||
|
@ -204,7 +204,7 @@
|
|||
this.toolStripMenuItem3,
|
||||
this.toolStripMenuItem4});
|
||||
this.menuOpacity.Name = "menuOpacity";
|
||||
this.menuOpacity.OwnerItem = this.fullOpacityToolStripMenuItem;
|
||||
this.menuOpacity.OwnerItem = this.menuContextOpacity;
|
||||
this.menuOpacity.ShowCheckMargin = true;
|
||||
this.menuOpacity.ShowImageMargin = false;
|
||||
this.menuOpacity.Size = new System.Drawing.Size(154, 92);
|
||||
|
@ -248,6 +248,14 @@
|
|||
this.toolStripMenuItem4.ToolTipText = global::OnTopReplica.Strings.MenuOp25TT;
|
||||
this.toolStripMenuItem4.Click += new System.EventHandler(this.Menu_Opacity_click);
|
||||
//
|
||||
// fullOpacityToolStripMenuItem
|
||||
//
|
||||
this.fullOpacityToolStripMenuItem.DropDown = this.menuOpacity;
|
||||
this.fullOpacityToolStripMenuItem.Image = global::OnTopReplica.Properties.Resources.window_opacity;
|
||||
this.fullOpacityToolStripMenuItem.Name = "fullOpacityToolStripMenuItem";
|
||||
this.fullOpacityToolStripMenuItem.Size = new System.Drawing.Size(186, 22);
|
||||
this.fullOpacityToolStripMenuItem.Text = global::OnTopReplica.Strings.MenuOpacity;
|
||||
//
|
||||
// resizeToolStripMenuItem
|
||||
//
|
||||
this.resizeToolStripMenuItem.DropDown = this.menuResize;
|
||||
|
@ -448,14 +456,6 @@
|
|||
this.menuContextClose.Text = global::OnTopReplica.Strings.MenuClose;
|
||||
this.menuContextClose.Click += new System.EventHandler(this.Menu_Close_click);
|
||||
//
|
||||
// fullOpacityToolStripMenuItem
|
||||
//
|
||||
this.fullOpacityToolStripMenuItem.DropDown = this.menuOpacity;
|
||||
this.fullOpacityToolStripMenuItem.Name = "fullOpacityToolStripMenuItem";
|
||||
this.fullOpacityToolStripMenuItem.Size = new System.Drawing.Size(186, 22);
|
||||
this.fullOpacityToolStripMenuItem.Text = global::OnTopReplica.Strings.MenuOpacity;
|
||||
this.fullOpacityToolStripMenuItem.Image = global::OnTopReplica.Properties.Resources.window_opacity;
|
||||
//
|
||||
// danskToolStripMenuItem
|
||||
//
|
||||
this.danskToolStripMenuItem.Image = global::OnTopReplica.Properties.Resources.flag_danish;
|
||||
|
@ -496,8 +496,9 @@
|
|||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.ClientSize = new System.Drawing.Size(264, 208);
|
||||
this.ClientSize = new System.Drawing.Size(264, 204);
|
||||
this.ControlBox = false;
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.MaximizeBox = false;
|
||||
this.MinimumSize = new System.Drawing.Size(20, 20);
|
||||
|
|
|
@ -24,10 +24,16 @@ namespace OnTopReplica {
|
|||
//Message pump extension
|
||||
MessagePumpManager _msgPumpManager = new MessagePumpManager();
|
||||
|
||||
FormBorderStyle _defaultBorderStyle;
|
||||
|
||||
public MainForm() {
|
||||
InitializeComponent();
|
||||
KeepAspectRatio = false;
|
||||
|
||||
//Store default values
|
||||
_defaultBorderStyle = FormBorderStyle;
|
||||
_nonClickThroughKey = TransparencyKey;
|
||||
|
||||
//Thumbnail panel
|
||||
_thumbnailPanel = new ThumbnailPanel {
|
||||
Location = Point.Empty,
|
||||
|
@ -257,7 +263,7 @@ namespace OnTopReplica {
|
|||
|
||||
CloseSidePanel(); //on switch, always hide side panels
|
||||
GlassEnabled = !value;
|
||||
FormBorderStyle = (value) ? FormBorderStyle.None : FormBorderStyle.Sizable;
|
||||
FormBorderStyle = (value) ? FormBorderStyle.None : _defaultBorderStyle;
|
||||
TopMost = !value;
|
||||
HandleMouseMove = !value;
|
||||
|
||||
|
@ -389,6 +395,7 @@ namespace OnTopReplica {
|
|||
#region Click-through
|
||||
|
||||
bool _clickThrough = false;
|
||||
Color _nonClickThroughKey;
|
||||
|
||||
public bool ClickThroughEnabled {
|
||||
get {
|
||||
|
@ -400,7 +407,7 @@ namespace OnTopReplica {
|
|||
Opacity = 0.75;
|
||||
|
||||
//Enable transparency and force as top-most
|
||||
TransparencyKey = (value) ? Color.Black : Color.Transparent;
|
||||
TransparencyKey = (value) ? Color.Black : _nonClickThroughKey;
|
||||
if (value)
|
||||
TopMost = true;
|
||||
|
||||
|
@ -430,6 +437,15 @@ namespace OnTopReplica {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the form's window list drop down menu.
|
||||
/// </summary>
|
||||
public ContextMenuStrip MenuWindows {
|
||||
get {
|
||||
return menuWindows;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace OnTopReplica {
|
|||
|
||||
private int ChromeBorderVertical {
|
||||
get {
|
||||
if (FormBorderStyle == FormBorderStyle.Sizable)
|
||||
if (FormBorderStyle == _defaultBorderStyle)
|
||||
return SystemInformation.FrameBorderSize.Height;
|
||||
else
|
||||
return 0;
|
||||
|
@ -49,7 +49,7 @@ namespace OnTopReplica {
|
|||
|
||||
private int ChromeBorderHorizontal {
|
||||
get {
|
||||
if (FormBorderStyle == FormBorderStyle.Sizable)
|
||||
if (FormBorderStyle == _defaultBorderStyle)
|
||||
return SystemInformation.FrameBorderSize.Width;
|
||||
else
|
||||
return 0;
|
||||
|
@ -121,7 +121,7 @@ namespace OnTopReplica {
|
|||
Point nuLoc = Screen.PrimaryScreen.WorkingArea.Location;
|
||||
nuLoc.Offset(40, 40);
|
||||
Location = nuLoc;
|
||||
Size = MinimumSize;
|
||||
Size = new Size(240, 220);
|
||||
|
||||
this.Show();
|
||||
this.Activate();
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace OnTopReplica {
|
|||
selectRegionToolStripMenuItem.Enabled = showing;
|
||||
switchToWindowToolStripMenuItem.Enabled = showing;
|
||||
resizeToolStripMenuItem.Enabled = showing;
|
||||
chromeToolStripMenuItem.Checked = (FormBorderStyle == FormBorderStyle.Sizable);
|
||||
chromeToolStripMenuItem.Checked = (FormBorderStyle == _defaultBorderStyle);
|
||||
clickForwardingToolStripMenuItem.Checked = _thumbnailPanel.ReportThumbnailClicks;
|
||||
chromeToolStripMenuItem.Enabled = showing;
|
||||
clickThroughToolStripMenuItem.Enabled = showing;
|
||||
|
@ -38,6 +38,7 @@ namespace OnTopReplica {
|
|||
//Ensure the menu is closed
|
||||
menuContext.Close();
|
||||
menuFullscreenContext.Close();
|
||||
menuWindows.Close();
|
||||
|
||||
//Get clicked item and window index from tag
|
||||
ToolStripItem tsi = (ToolStripItem)sender;
|
||||
|
@ -179,7 +180,7 @@ namespace OnTopReplica {
|
|||
}
|
||||
|
||||
private void Menu_Chrome_click(object sender, EventArgs e) {
|
||||
if (FormBorderStyle == FormBorderStyle.Sizable) {
|
||||
if (FormBorderStyle == _defaultBorderStyle) {
|
||||
FormBorderStyle = FormBorderStyle.None;
|
||||
Location = new Point {
|
||||
X = Location.X + SystemInformation.FrameBorderSize.Width,
|
||||
|
@ -187,7 +188,7 @@ namespace OnTopReplica {
|
|||
};
|
||||
}
|
||||
else {
|
||||
FormBorderStyle = FormBorderStyle.Sizable;
|
||||
FormBorderStyle = _defaultBorderStyle;
|
||||
Location = new Point {
|
||||
X = Location.X - SystemInformation.FrameBorderSize.Width,
|
||||
Y = Location.Y - SystemInformation.FrameBorderSize.Height
|
||||
|
|
45
OnTopReplica/Native/ITaskBarList.cs
Normal file
45
OnTopReplica/Native/ITaskBarList.cs
Normal file
|
@ -0,0 +1,45 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace OnTopReplica.Native {
|
||||
[ComImport,
|
||||
Guid("56fdf342-fd6d-11d0-958a-006097c9a090"),
|
||||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
public interface ITaskbarList {
|
||||
/// <summary>
|
||||
/// Initializes the taskbar list object. This method must be called before any other ITaskbarList methods can be called.
|
||||
/// </summary>
|
||||
void HrInit();
|
||||
|
||||
/// <summary>
|
||||
/// Adds an item to the taskbar.
|
||||
/// </summary>
|
||||
/// <param name="hWnd">A handle to the window to be added to the taskbar.</param>
|
||||
void AddTab([In] IntPtr hWnd);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes an item from the taskbar.
|
||||
/// </summary>
|
||||
/// <param name="hWnd">A handle to the window to be deleted from the taskbar.</param>
|
||||
void DeleteTab([In] IntPtr hWnd);
|
||||
|
||||
/// <summary>
|
||||
/// Activates an item on the taskbar. The window is not actually activated; the window's item on the taskbar is merely displayed as active.
|
||||
/// </summary>
|
||||
/// <param name="hWnd">A handle to the window on the taskbar to be displayed as active.</param>
|
||||
void ActivateTab([In] IntPtr hWnd);
|
||||
|
||||
/// <summary>
|
||||
/// Marks a taskbar item as active but does not visually activate it.
|
||||
/// </summary>
|
||||
/// <param name="hWnd">A handle to the window to be marked as active.</param>
|
||||
void SetActiveAlt([In] IntPtr hWnd);
|
||||
}
|
||||
|
||||
[ComImport]
|
||||
[Guid("56fdf344-fd6d-11d0-958a-006097c9a090")]
|
||||
public class CoTaskbarList {
|
||||
}
|
||||
}
|
|
@ -70,20 +70,43 @@ namespace OnTopReplica.Native {
|
|||
|
||||
public static IntPtr GetWindowLong(IntPtr hWnd, WindowLong i) {
|
||||
if (IntPtr.Size == 8) {
|
||||
return GetWindowLongPtr64(hWnd, (int)i);
|
||||
return GetWindowLongPtr64(hWnd, i);
|
||||
}
|
||||
else {
|
||||
return new IntPtr(GetWindowLong32(hWnd, (int)i));
|
||||
return new IntPtr(GetWindowLong32(hWnd, i));
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("user32.dll", EntryPoint = "GetWindowLong")]
|
||||
static extern int GetWindowLong32(IntPtr hWnd, int nIndex);
|
||||
static extern int GetWindowLong32(IntPtr hWnd, WindowLong nIndex);
|
||||
|
||||
[DllImport("user32.dll", EntryPoint = "GetWindowLongPtr")]
|
||||
static extern IntPtr GetWindowLongPtr64(IntPtr hWnd, int nIndex);
|
||||
static extern IntPtr GetWindowLongPtr64(IntPtr hWnd, WindowLong nIndex);
|
||||
|
||||
public static IntPtr GetClassLongPtr(IntPtr hWnd, ClassLong i) {
|
||||
public static IntPtr SetWindowLong(IntPtr hWnd, WindowLong i, IntPtr dwNewLong) {
|
||||
if (IntPtr.Size == 8) {
|
||||
return SetWindowLongPtr64(hWnd, i, dwNewLong);
|
||||
}
|
||||
else {
|
||||
return new IntPtr(SetWindowLong32(hWnd, i, dwNewLong.ToInt32()));
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("user32.dll", EntryPoint = "SetWindowLong")]
|
||||
static extern int SetWindowLong32(IntPtr hWnd, WindowLong nIndex, int dwNewLong);
|
||||
|
||||
[DllImport("user32.dll", EntryPoint = "SetWindowLongPtr")]
|
||||
static extern IntPtr SetWindowLongPtr64(IntPtr hWnd, WindowLong nIndex, IntPtr dwNewLong);
|
||||
|
||||
#region Class styles
|
||||
|
||||
[DllImport("user32.dll", EntryPoint = "GetClassLongPtrW")]
|
||||
static extern IntPtr GetClassLong64(IntPtr hWnd, int nIndex);
|
||||
|
||||
[DllImport("user32.dll", EntryPoint = "GetClassLongW")]
|
||||
static extern int GetClassLong32(IntPtr hWnd, int nIndex);
|
||||
|
||||
public static IntPtr GetClassLong(IntPtr hWnd, ClassLong i) {
|
||||
if (IntPtr.Size == 8) {
|
||||
return GetClassLong64(hWnd, (int)i);
|
||||
}
|
||||
|
@ -92,12 +115,7 @@ namespace OnTopReplica.Native {
|
|||
}
|
||||
}
|
||||
|
||||
[DllImport("user32.dll", EntryPoint = "GetClassLongPtrW")]
|
||||
static extern IntPtr GetClassLong64(IntPtr hWnd, int nIndex);
|
||||
|
||||
[DllImport("user32.dll", EntryPoint = "GetClassLongW")]
|
||||
static extern int GetClassLong32(IntPtr hWnd, int nIndex);
|
||||
|
||||
#endregion
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern IntPtr GetMenu(IntPtr hwnd);
|
||||
|
|
84
OnTopReplica/NotificationIcon.cs
Normal file
84
OnTopReplica/NotificationIcon.cs
Normal file
|
@ -0,0 +1,84 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using OnTopReplica.Properties;
|
||||
|
||||
namespace OnTopReplica {
|
||||
/// <summary>
|
||||
/// Notification icon that installs itself in the "tray" and manipulates the OnTopReplica main form.
|
||||
/// </summary>
|
||||
class NotificationIcon : IDisposable {
|
||||
|
||||
public NotificationIcon(MainForm form) {
|
||||
Form = form;
|
||||
Install();
|
||||
}
|
||||
|
||||
public MainForm Form { get; private set; }
|
||||
|
||||
NotifyIcon _taskIcon;
|
||||
ContextMenuStrip _contextMenu;
|
||||
|
||||
private void Install() {
|
||||
_contextMenu = new ContextMenuStrip();
|
||||
_contextMenu.Items.AddRange(new ToolStripItem[] {
|
||||
new ToolStripMenuItem(Strings.MenuOpen, Resources.icon, TaskIconOpen_click) {
|
||||
ToolTipText = Strings.MenuOpenTT,
|
||||
},
|
||||
new ToolStripMenuItem(Strings.MenuWindows, Resources.window16){
|
||||
DropDown = Form.MenuWindows,
|
||||
ToolTipText = Strings.MenuWindowsTT
|
||||
},
|
||||
new ToolStripMenuItem(Strings.MenuReset, null, TaskIconReset_click){
|
||||
ToolTipText = Strings.MenuResetTT
|
||||
},
|
||||
new ToolStripMenuItem(Strings.MenuClose, Resources.close_new, TaskIconExit_click){
|
||||
ToolTipText = Strings.MenuCloseTT
|
||||
}
|
||||
});
|
||||
Asztal.Szótár.NativeToolStripRenderer.SetToolStripRenderer(_contextMenu);
|
||||
|
||||
_taskIcon = new NotifyIcon {
|
||||
Text = Strings.ApplicationName,
|
||||
Icon = Resources.icon_new,
|
||||
Visible = true,
|
||||
ContextMenuStrip = _contextMenu
|
||||
};
|
||||
_taskIcon.DoubleClick += new EventHandler(TaskIcon_doubleclick);
|
||||
}
|
||||
|
||||
#region IDisposable Members
|
||||
|
||||
public void Dispose() {
|
||||
//Destroy NotifyIcon
|
||||
if (_taskIcon != null) {
|
||||
_taskIcon.Visible = false;
|
||||
_taskIcon.Dispose();
|
||||
_taskIcon = null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Task Icon events
|
||||
|
||||
void TaskIcon_doubleclick(object sender, EventArgs e) {
|
||||
Form.EnsureMainFormVisible();
|
||||
}
|
||||
|
||||
private void TaskIconOpen_click(object sender, EventArgs e) {
|
||||
Form.EnsureMainFormVisible();
|
||||
}
|
||||
|
||||
private void TaskIconReset_click(object sender, EventArgs e) {
|
||||
Form.ResetMainFormWithConfirmation();
|
||||
}
|
||||
|
||||
private void TaskIconExit_click(object sender, EventArgs e) {
|
||||
Form.Close();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -12,7 +12,7 @@
|
|||
<AssemblyName>OnTopReplica</AssemblyName>
|
||||
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ApplicationIcon>Assets\icon.ico</ApplicationIcon>
|
||||
<ApplicationIcon>Assets\icon-new.ico</ApplicationIcon>
|
||||
<IsWebBootstrapper>true</IsWebBootstrapper>
|
||||
<GenerateManifests>true</GenerateManifests>
|
||||
<TargetZone>Internet</TargetZone>
|
||||
|
@ -149,6 +149,7 @@
|
|||
<Compile Include="Native\HookMethods.cs" />
|
||||
<Compile Include="Native\HotKeyMethods.cs" />
|
||||
<Compile Include="Native\HT.cs" />
|
||||
<None Include="Native\ITaskBarList.cs" />
|
||||
<Compile Include="Native\MessagingMethods.cs" />
|
||||
<Compile Include="Native\MK.cs" />
|
||||
<Compile Include="Native\Point.cs" />
|
||||
|
@ -157,6 +158,7 @@
|
|||
<Compile Include="Native\WindowMethods.cs" />
|
||||
<Compile Include="Native\WM.cs" />
|
||||
<Compile Include="Native\WMSZ.cs" />
|
||||
<Compile Include="NotificationIcon.cs" />
|
||||
<Compile Include="SidePanel.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
|
@ -292,9 +294,6 @@
|
|||
<ItemGroup>
|
||||
<None Include="Assets\window_multiple16.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Assets\close16.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Assets\reduce.png" />
|
||||
</ItemGroup>
|
||||
|
@ -312,6 +311,7 @@
|
|||
<None Include="Assets\regions_new.png" />
|
||||
<None Include="Assets\desktop.png" />
|
||||
<None Include="Assets\list.png" />
|
||||
<Content Include="Assets\icon-new.ico" />
|
||||
<Content Include="Assets\screenshot-icon.ico" />
|
||||
<Content Include="Assets\window_multiple16.ico" />
|
||||
</ItemGroup>
|
||||
|
@ -358,7 +358,6 @@
|
|||
<None Include="Assets\xiao_up.png" />
|
||||
<None Include="Assets\xiao_down.png" />
|
||||
<None Include="Assets\thumbs_up.png" />
|
||||
<None Include="Assets\ok.png" />
|
||||
<None Include="Assets\pos_null.png" />
|
||||
<None Include="Assets\pos_topright.png" />
|
||||
<None Include="Assets\pos_topleft.png" />
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Windows.Forms;
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using OnTopReplica.Native;
|
||||
using VistaControls.Dwm;
|
||||
|
||||
|
@ -6,10 +7,19 @@ namespace OnTopReplica.Platforms {
|
|||
class WindowsSeven : WindowsVista {
|
||||
|
||||
public override void InitForm(MainForm form) {
|
||||
DwmManager.SetWindowFlip3dPolicy(form, Flip3DPolicy.ExcludeAbove);
|
||||
DwmManager.SetExludeFromPeek(form, true);
|
||||
DwmManager.SetDisallowPeek(form, true);
|
||||
|
||||
base.InitForm(form);
|
||||
|
||||
//This hides the app from ALT+TAB, but when minimized the window is shrunk on the bottom, right above the task bar (ugly)
|
||||
/*Native.WindowMethods.SetWindowLong(form.Handle, WindowMethods.WindowLong.ExStyle,
|
||||
(IntPtr)WindowMethods.WindowExStyles.ToolWindow);*/
|
||||
|
||||
//This adds the task bar item, but hiding/showing again adds it back to alt+tab
|
||||
/*var list = (ITaskbarList)new CoTaskbarList();
|
||||
list.HrInit();
|
||||
list.AddTab(form.Handle);
|
||||
list.ActivateTab(form.Handle); */
|
||||
}
|
||||
|
||||
public override void InitApp() {
|
||||
|
@ -17,10 +27,6 @@ namespace OnTopReplica.Platforms {
|
|||
WindowsSevenMethods.SetCurrentProcessExplicitAppUserModelID("OnTopReplica");
|
||||
}
|
||||
|
||||
protected override void InitFormCore(MainForm form) {
|
||||
//do nothing
|
||||
}
|
||||
|
||||
public override void HideForm(MainForm form) {
|
||||
form.WindowState = FormWindowState.Minimized;
|
||||
}
|
||||
|
|
|
@ -18,74 +18,27 @@ namespace OnTopReplica.Platforms {
|
|||
return true;
|
||||
}
|
||||
|
||||
NotificationIcon _icon;
|
||||
|
||||
public override void InitForm(MainForm form) {
|
||||
base.InitForm(form);
|
||||
|
||||
DwmManager.SetWindowFlip3dPolicy(form, Flip3DPolicy.ExcludeAbove);
|
||||
|
||||
this.InitFormCore(form);
|
||||
}
|
||||
|
||||
protected virtual void InitFormCore(MainForm form){
|
||||
//Do not show in task bar, but display icon
|
||||
|
||||
//Do not show in task bar, but display notify icon
|
||||
//NOTE: this effectively makes Windows ignore the Flip 3D policy set above (on Windows 7)
|
||||
// weird...
|
||||
form.ShowInTaskbar = false;
|
||||
|
||||
//Install tray icon
|
||||
_contextMenu = new ContextMenuStrip();
|
||||
_contextMenu.Items.AddRange(new ToolStripItem[] {
|
||||
new ToolStripMenuItem(Strings.MenuOpen, Resources.icon, TaskIconOpen_click) {
|
||||
ToolTipText = Strings.MenuOpenTT,
|
||||
},
|
||||
new ToolStripMenuItem(Strings.MenuReset, null, TaskIconReset_click){
|
||||
ToolTipText = Strings.MenuResetTT
|
||||
},
|
||||
new ToolStripMenuItem(Strings.MenuClose, Resources.close_new, TaskIconExit_click){
|
||||
ToolTipText = Strings.MenuCloseTT
|
||||
}
|
||||
});
|
||||
Asztal.Szótár.NativeToolStripRenderer.SetToolStripRenderer(_contextMenu);
|
||||
|
||||
_taskIcon = new NotifyIcon {
|
||||
Text = Strings.ApplicationName,
|
||||
Icon = Resources.main_icon,
|
||||
Visible = true,
|
||||
ContextMenuStrip = _contextMenu
|
||||
};
|
||||
_taskIcon.DoubleClick += new EventHandler(TaskIcon_doubleclick);
|
||||
_icon = new NotificationIcon(form);
|
||||
}
|
||||
|
||||
NotifyIcon _taskIcon;
|
||||
ContextMenuStrip _contextMenu;
|
||||
|
||||
public override void ShutdownApp() {
|
||||
//Destroy NotifyIcon
|
||||
if (_taskIcon != null) {
|
||||
_taskIcon.Visible = false;
|
||||
_taskIcon.Dispose();
|
||||
_taskIcon = null;
|
||||
if (_icon != null) {
|
||||
_icon.Dispose();
|
||||
_icon = null;
|
||||
}
|
||||
}
|
||||
|
||||
#region Task Icon events
|
||||
|
||||
void TaskIcon_doubleclick(object sender, EventArgs e) {
|
||||
Form.EnsureMainFormVisible();
|
||||
}
|
||||
|
||||
private void TaskIconOpen_click(object sender, EventArgs e) {
|
||||
Form.EnsureMainFormVisible();
|
||||
}
|
||||
|
||||
private void TaskIconReset_click(object sender, EventArgs e) {
|
||||
Form.ResetMainFormWithConfirmation();
|
||||
}
|
||||
|
||||
private void TaskIconExit_click(object sender, EventArgs e) {
|
||||
Form.Close();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
28
OnTopReplica/Properties/Resources.Designer.cs
generated
28
OnTopReplica/Properties/Resources.Designer.cs
generated
|
@ -116,6 +116,13 @@ namespace OnTopReplica.Properties {
|
|||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Icon icon_new {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("icon_new", resourceCulture);
|
||||
return ((System.Drawing.Icon)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap list {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("list", resourceCulture);
|
||||
|
@ -123,13 +130,6 @@ namespace OnTopReplica.Properties {
|
|||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Icon main_icon {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("main_icon", resourceCulture);
|
||||
return ((System.Drawing.Icon)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap pos_bottomleft {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("pos_bottomleft", resourceCulture);
|
||||
|
@ -186,13 +186,6 @@ namespace OnTopReplica.Properties {
|
|||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Icon screenshot_icon {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("screenshot_icon", resourceCulture);
|
||||
return ((System.Drawing.Icon)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap thumbs_up {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("thumbs_up", resourceCulture);
|
||||
|
@ -214,13 +207,6 @@ namespace OnTopReplica.Properties {
|
|||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Icon window_multiple161 {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("window_multiple161", resourceCulture);
|
||||
return ((System.Drawing.Icon)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap window_opacity {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("window_opacity", resourceCulture);
|
||||
|
|
|
@ -163,9 +163,6 @@
|
|||
<data name="window_switch" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Assets\window_switch.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="main_icon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Assets\icon.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="flag_danish" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Assets\flag_danish.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
|
@ -175,9 +172,6 @@
|
|||
<data name="xiao_ok" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Assets\xiao_ok.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="window_multiple161" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Assets\window_multiple16.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="xiao_component" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Assets\component.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
|
@ -199,9 +193,6 @@
|
|||
<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>
|
||||
<data name="screenshot_icon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Assets\screenshot-icon.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="icon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Assets\newicon.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
|
@ -214,8 +205,11 @@
|
|||
<data name="regions" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Assets\regions_new.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="list" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Assets\list.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="icon_new" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Assets\icon-new.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
|
@ -39,7 +39,7 @@ namespace OnTopReplica {
|
|||
}
|
||||
else {
|
||||
//Fetch icon from window class
|
||||
hIcon = (IntPtr)WindowMethods.GetClassLongPtr(_handle, WindowMethods.ClassLong.IconSmall);
|
||||
hIcon = (IntPtr)WindowMethods.GetClassLong(_handle, WindowMethods.ClassLong.IconSmall);
|
||||
|
||||
if (hIcon.ToInt64() != 0) {
|
||||
_icon = Icon.FromHandle(hIcon);
|
||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue