mirror of
https://github.com/Hofknecht/SystemTrayMenu.git
synced 2024-05-19 11:53:02 +12:00
parent
c90563a0b8
commit
c08336df9e
|
@ -3,6 +3,9 @@ using System.Linq;
|
|||
using System.Windows.Forms;
|
||||
using SystemTrayMenu.DataClasses;
|
||||
using SystemTrayMenu.Helper;
|
||||
using SystemTrayMenu.Utilities;
|
||||
using EventHandler = SystemTrayMenu.Helper.EventHandler;
|
||||
using Menu = SystemTrayMenu.UserInterface.Menu;
|
||||
|
||||
namespace SystemTrayMenu.Handler
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using SystemTrayMenu.Helper;
|
||||
using SystemTrayMenu.Utilities;
|
||||
|
||||
namespace SystemTrayMenu
|
||||
{
|
||||
|
|
|
@ -10,6 +10,10 @@ using System.Windows.Forms;
|
|||
using SystemTrayMenu.DataClasses;
|
||||
using SystemTrayMenu.Handler;
|
||||
using SystemTrayMenu.Helper;
|
||||
using SystemTrayMenu.Helper.Taskbar;
|
||||
using SystemTrayMenu.UserInterface;
|
||||
using SystemTrayMenu.Utilities;
|
||||
using Menu = SystemTrayMenu.UserInterface.Menu;
|
||||
|
||||
namespace SystemTrayMenu
|
||||
{
|
||||
|
@ -133,7 +137,7 @@ namespace SystemTrayMenu
|
|||
Menus().ToList().ForEach(m => { m.FadeIn(); m.FadeHalf(); });
|
||||
menus[0].SetTitleColorActive();
|
||||
menus[0].Activate();
|
||||
NativeMethods.NativeMethods.ForceForegroundWindow(menus[0].Handle);
|
||||
NativeDllImport.NativeMethods.ForceForegroundWindow(menus[0].Handle);
|
||||
}
|
||||
|
||||
menuNotifyIcon.OpenLog += Log.OpenLogFile;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using EventHandler = SystemTrayMenu.Helper.EventHandler;
|
||||
using Timer = System.Windows.Forms.Timer;
|
||||
|
||||
namespace SystemTrayMenu.Handler
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using EventHandler = SystemTrayMenu.Helper.EventHandler;
|
||||
using Timer = System.Windows.Forms.Timer;
|
||||
|
||||
namespace SystemTrayMenu.Handler
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using SystemTrayMenu.Helper;
|
||||
using SystemTrayMenu.Utilities;
|
||||
|
||||
namespace SystemTrayMenu
|
||||
{
|
||||
|
|
|
@ -9,8 +9,9 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using SystemTrayMenu.Handler;
|
||||
using SystemTrayMenu.Helper;
|
||||
using SystemTrayMenu.Utilities;
|
||||
using TAFactory.IconPack;
|
||||
using Menu = SystemTrayMenu.UserInterface.Menu;
|
||||
|
||||
namespace SystemTrayMenu.DataClasses
|
||||
{
|
||||
|
@ -155,7 +156,7 @@ namespace SystemTrayMenu.DataClasses
|
|||
StringBuilder executable = new StringBuilder(1024);
|
||||
try
|
||||
{
|
||||
NativeMethods.NativeMethods.Shell32FindExecutable(TargetFilePath, string.Empty, executable);
|
||||
NativeDllImport.NativeMethods.Shell32FindExecutable(TargetFilePath, string.Empty, executable);
|
||||
// icon = IconReader.GetFileIcon(executable, false);
|
||||
// e.g. VS 2019 icon, need another icom in imagelist
|
||||
List<Icon> extractedIcons = IconHelper.ExtractAllIcons(
|
||||
|
|
|
@ -79,7 +79,7 @@ namespace SystemTrayMenu.Helper
|
|||
_currentId = _currentId + 1;
|
||||
|
||||
// register the hot key.
|
||||
if (!NativeMethods.NativeMethods.User32RegisterHotKey(_window.Handle, _currentId, (uint)modifier, (uint)key))
|
||||
if (!NativeDllImport.NativeMethods.User32RegisterHotKey(_window.Handle, _currentId, (uint)modifier, (uint)key))
|
||||
{
|
||||
throw new InvalidOperationException("Couldn’t register the hot key.");
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ namespace SystemTrayMenu.Helper
|
|||
// unregister all the registered hot keys.
|
||||
for (int i = _currentId; i > 0; i--)
|
||||
{
|
||||
NativeMethods.NativeMethods.User32UnregisterHotKey(_window.Handle, i);
|
||||
NativeDllImport.NativeMethods.User32UnregisterHotKey(_window.Handle, i);
|
||||
}
|
||||
|
||||
// dispose the inner native window.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace SystemTrayMenu
|
||||
namespace SystemTrayMenu.Helper
|
||||
{
|
||||
public delegate void EventHandler();
|
||||
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
using System;
|
||||
using System.Drawing;
|
||||
using System.Runtime.InteropServices;
|
||||
using static SystemTrayMenu.NativeDllImport.NativeMethods;
|
||||
|
||||
namespace SystemTrayMenu
|
||||
namespace SystemTrayMenu.Helper.Taskbar
|
||||
{
|
||||
public enum TaskbarPosition
|
||||
{
|
||||
|
@ -43,14 +44,14 @@ namespace SystemTrayMenu
|
|||
|
||||
public Taskbar()
|
||||
{
|
||||
IntPtr taskbarHandle = NativeMethods.NativeMethods.User32FindWindow(Taskbar.ClassName, null);
|
||||
IntPtr taskbarHandle = NativeDllImport.NativeMethods.User32FindWindow(Taskbar.ClassName, null);
|
||||
|
||||
APPBARDATA data = new APPBARDATA
|
||||
{
|
||||
cbSize = (uint)Marshal.SizeOf(typeof(APPBARDATA)),
|
||||
hWnd = taskbarHandle
|
||||
};
|
||||
IntPtr result = NativeMethods.NativeMethods.Shell32SHAppBarMessage(ABM.GetTaskbarPos, ref data);
|
||||
IntPtr result = NativeDllImport.NativeMethods.Shell32SHAppBarMessage(ABM.GetTaskbarPos, ref data);
|
||||
if (result == IntPtr.Zero)
|
||||
{
|
||||
//throw new InvalidOperationException();
|
||||
|
@ -62,60 +63,11 @@ namespace SystemTrayMenu
|
|||
Bounds = Rectangle.FromLTRB(data.rc.left, data.rc.top, data.rc.right, data.rc.bottom);
|
||||
|
||||
data.cbSize = (uint)Marshal.SizeOf(typeof(APPBARDATA));
|
||||
result = NativeMethods.NativeMethods.Shell32SHAppBarMessage(ABM.GetState, ref data);
|
||||
result = NativeDllImport.NativeMethods.Shell32SHAppBarMessage(ABM.GetState, ref data);
|
||||
int state = result.ToInt32();
|
||||
AlwaysOnTop = (state & ABS.AlwaysOnTop) == ABS.AlwaysOnTop;
|
||||
AutoHide = (state & ABS.Autohide) == ABS.Autohide;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum ABM : uint
|
||||
{
|
||||
New = 0x00000000,
|
||||
Remove = 0x00000001,
|
||||
QueryPos = 0x00000002,
|
||||
SetPos = 0x00000003,
|
||||
GetState = 0x00000004,
|
||||
GetTaskbarPos = 0x00000005,
|
||||
Activate = 0x00000006,
|
||||
GetAutoHideBar = 0x00000007,
|
||||
SetAutoHideBar = 0x00000008,
|
||||
WindowPosChanged = 0x00000009,
|
||||
SetState = 0x0000000A,
|
||||
}
|
||||
|
||||
public enum ABE : uint
|
||||
{
|
||||
Left = 0,
|
||||
Top = 1,
|
||||
Right = 2,
|
||||
Bottom = 3
|
||||
}
|
||||
|
||||
public static class ABS
|
||||
{
|
||||
public const int Autohide = 0x0000001;
|
||||
public const int AlwaysOnTop = 0x0000002;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct APPBARDATA
|
||||
{
|
||||
public uint cbSize;
|
||||
public IntPtr hWnd;
|
||||
public uint uCallbackMessage;
|
||||
public ABE uEdge;
|
||||
public RECT rc;
|
||||
public int lParam;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct RECT
|
||||
{
|
||||
public int left;
|
||||
public int top;
|
||||
public int right;
|
||||
public int bottom;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace SystemTrayMenu.Helper
|
|||
{
|
||||
public int Compare(string x, string y)
|
||||
{
|
||||
return NativeMethods.NativeMethods.ShlwapiStrCmpLogicalW(x, y);
|
||||
return NativeDllImport.NativeMethods.ShlwapiStrCmpLogicalW(x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SystemTrayMenu.NativeMethods
|
||||
namespace SystemTrayMenu.NativeDllImport
|
||||
{
|
||||
public static partial class NativeMethods
|
||||
{
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SystemTrayMenu.NativeMethods
|
||||
namespace SystemTrayMenu.NativeDllImport
|
||||
{
|
||||
public static partial class NativeMethods
|
||||
{
|
|
@ -1,12 +1,13 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SystemTrayMenu.NativeMethods
|
||||
namespace SystemTrayMenu.NativeDllImport
|
||||
{
|
||||
public static partial class NativeMethods
|
||||
{
|
||||
[DllImport("User32.dll")]
|
||||
private static extern int DestroyIcon(IntPtr hIcon);
|
||||
|
||||
public static void User32DestroyIcon(IntPtr hIcon)
|
||||
{
|
||||
_ = DestroyIcon(hIcon);
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SystemTrayMenu.NativeMethods
|
||||
namespace SystemTrayMenu.NativeDllImport
|
||||
{
|
||||
public static partial class NativeMethods
|
||||
{
|
|
@ -1,7 +1,7 @@
|
|||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace SystemTrayMenu.NativeMethods
|
||||
namespace SystemTrayMenu.NativeDllImport
|
||||
{
|
||||
public static partial class NativeMethods
|
||||
{
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SystemTrayMenu.NativeMethods
|
||||
namespace SystemTrayMenu.NativeDllImport
|
||||
{
|
||||
public static partial class NativeMethods
|
||||
{
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SystemTrayMenu.NativeMethods
|
||||
namespace SystemTrayMenu.NativeDllImport
|
||||
{
|
||||
public static partial class NativeMethods
|
||||
{
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SystemTrayMenu.NativeMethods
|
||||
namespace SystemTrayMenu.NativeDllImport
|
||||
{
|
||||
public static partial class NativeMethods
|
||||
{
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SystemTrayMenu.NativeMethods
|
||||
namespace SystemTrayMenu.NativeDllImport
|
||||
{
|
||||
public static partial class NativeMethods
|
||||
{
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SystemTrayMenu.NativeMethods
|
||||
namespace SystemTrayMenu.NativeDllImport
|
||||
{
|
||||
public static partial class NativeMethods
|
||||
{
|
65
NativeDllImport/SHAppBarMessage.cs
Normal file
65
NativeDllImport/SHAppBarMessage.cs
Normal file
|
@ -0,0 +1,65 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SystemTrayMenu.NativeDllImport
|
||||
{
|
||||
public static partial class NativeMethods
|
||||
{
|
||||
[DllImport("shell32.dll", SetLastError = true)]
|
||||
private static extern IntPtr SHAppBarMessage(ABM dwMessage, [In] ref APPBARDATA pData);
|
||||
|
||||
public static IntPtr Shell32SHAppBarMessage(ABM dwMessage, [In] ref APPBARDATA pData)
|
||||
{
|
||||
return SHAppBarMessage(dwMessage, ref pData);
|
||||
}
|
||||
|
||||
public enum ABM : uint
|
||||
{
|
||||
New = 0x00000000,
|
||||
Remove = 0x00000001,
|
||||
QueryPos = 0x00000002,
|
||||
SetPos = 0x00000003,
|
||||
GetState = 0x00000004,
|
||||
GetTaskbarPos = 0x00000005,
|
||||
Activate = 0x00000006,
|
||||
GetAutoHideBar = 0x00000007,
|
||||
SetAutoHideBar = 0x00000008,
|
||||
WindowPosChanged = 0x00000009,
|
||||
SetState = 0x0000000A,
|
||||
}
|
||||
|
||||
public enum ABE : uint
|
||||
{
|
||||
Left = 0,
|
||||
Top = 1,
|
||||
Right = 2,
|
||||
Bottom = 3
|
||||
}
|
||||
|
||||
public static class ABS
|
||||
{
|
||||
public const int Autohide = 0x0000001;
|
||||
public const int AlwaysOnTop = 0x0000002;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct APPBARDATA
|
||||
{
|
||||
public uint cbSize;
|
||||
public IntPtr hWnd;
|
||||
public uint uCallbackMessage;
|
||||
public ABE uEdge;
|
||||
public RECT rc;
|
||||
public int lParam;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct RECT
|
||||
{
|
||||
public int left;
|
||||
public int top;
|
||||
public int right;
|
||||
public int bottom;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SystemTrayMenu.NativeMethods
|
||||
namespace SystemTrayMenu.NativeDllImport
|
||||
{
|
||||
public static partial class NativeMethods
|
||||
{
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SystemTrayMenu.NativeMethods
|
||||
namespace SystemTrayMenu.NativeDllImport
|
||||
{
|
||||
public static partial class NativeMethods
|
||||
{
|
|
@ -2,7 +2,7 @@
|
|||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace SystemTrayMenu.NativeMethods
|
||||
namespace SystemTrayMenu.NativeDllImport
|
||||
{
|
||||
public static partial class NativeMethods
|
||||
{
|
|
@ -1,6 +1,6 @@
|
|||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SystemTrayMenu.NativeMethods
|
||||
namespace SystemTrayMenu.NativeDllImport
|
||||
{
|
||||
public static partial class NativeMethods
|
||||
{
|
|
@ -1,7 +1,7 @@
|
|||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace SystemTrayMenu.NativeMethods
|
||||
namespace SystemTrayMenu.NativeDllImport
|
||||
{
|
||||
public static partial class NativeMethods
|
||||
{
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SystemTrayMenu.NativeMethods
|
||||
namespace SystemTrayMenu.NativeDllImport
|
||||
{
|
||||
public static partial class NativeMethods
|
||||
{
|
|
@ -1,6 +1,6 @@
|
|||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SystemTrayMenu.NativeMethods
|
||||
namespace SystemTrayMenu.NativeDllImport
|
||||
{
|
||||
public static partial class NativeMethods
|
||||
{
|
|
@ -2,7 +2,7 @@
|
|||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace SystemTrayMenu.NativeMethods
|
||||
namespace SystemTrayMenu.NativeDllImport
|
||||
{
|
||||
public static partial class NativeMethods
|
||||
{
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SystemTrayMenu.NativeMethods
|
||||
namespace SystemTrayMenu.NativeDllImport
|
||||
{
|
||||
public static partial class NativeMethods
|
||||
{
|
|
@ -1,16 +0,0 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SystemTrayMenu.NativeMethods
|
||||
{
|
||||
public static partial class NativeMethods
|
||||
{
|
||||
[DllImport("shell32.dll", SetLastError = true)]
|
||||
private static extern IntPtr SHAppBarMessage(ABM dwMessage, [In] ref APPBARDATA pData);
|
||||
|
||||
public static IntPtr Shell32SHAppBarMessage(ABM dwMessage, [In] ref APPBARDATA pData)
|
||||
{
|
||||
return SHAppBarMessage(dwMessage, ref pData);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -139,12 +139,12 @@
|
|||
<ItemGroup>
|
||||
<Compile Include="Config\Config.cs" />
|
||||
<Compile Include="GlobalSuppressions.cs" />
|
||||
<Compile Include="NativeMethods\DestroyMenu.cs" />
|
||||
<Compile Include="NativeMethods\CreatePopupMenu.cs" />
|
||||
<Compile Include="NativeMethods\GetMenuDefaultItem.cs" />
|
||||
<Compile Include="NativeMethods\TrackPopupMenuEx.cs" />
|
||||
<Compile Include="NativeMethods\StrRetToBuf.cs" />
|
||||
<Compile Include="NativeMethods\SHGetDesktopFolder.cs" />
|
||||
<Compile Include="NativeDllImport\DestroyMenu.cs" />
|
||||
<Compile Include="NativeDllImport\CreatePopupMenu.cs" />
|
||||
<Compile Include="NativeDllImport\GetMenuDefaultItem.cs" />
|
||||
<Compile Include="NativeDllImport\TrackPopupMenuEx.cs" />
|
||||
<Compile Include="NativeDllImport\StrRetToBuf.cs" />
|
||||
<Compile Include="NativeDllImport\SHGetDesktopFolder.cs" />
|
||||
<Compile Include="UserInterface\AboutBox.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
@ -166,6 +166,9 @@
|
|||
<Compile Include="DataClasses\MenuData.cs" />
|
||||
<Compile Include="DataClasses\RowData.cs" />
|
||||
<Compile Include="UserInterface\AppContextMenu.cs" />
|
||||
<Compile Include="UserInterface\LabelNoCopy.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Utilities\AppRestart.cs" />
|
||||
<Compile Include="Utilities\DataGridViewExtensions.cs" />
|
||||
<Compile Include="Utilities\File\IconReader.cs" />
|
||||
|
@ -188,20 +191,20 @@
|
|||
<Compile Include="Business\WaitFastLeave.cs" />
|
||||
<Compile Include="Business\WaitMenuOpen.cs" />
|
||||
<Compile Include="Helpers\WindowsExplorerSort.cs" />
|
||||
<Compile Include="NativeMethods\GetIcon.cs" />
|
||||
<Compile Include="NativeMethods\SHGetFolderPath.cs" />
|
||||
<Compile Include="NativeMethods\SHGetFileInfo.cs" />
|
||||
<Compile Include="NativeMethods\SetProcessDPIAware.cs" />
|
||||
<Compile Include="NativeMethods\GetDeviceCaps.cs" />
|
||||
<Compile Include="NativeMethods\RegisterHotKey.cs" />
|
||||
<Compile Include="NativeMethods\ShowWindow.cs" />
|
||||
<Compile Include="NativeMethods\ShowInactiveTopmost.cs" />
|
||||
<Compile Include="NativeMethods\SHAppBarMessage.cs" />
|
||||
<Compile Include="NativeMethods\FindWindow.cs" />
|
||||
<Compile Include="NativeMethods\StrCmpLogicalW.cs" />
|
||||
<Compile Include="NativeMethods\FindExecuteable.cs" />
|
||||
<Compile Include="NativeMethods\BringWindowToTop.cs" />
|
||||
<Compile Include="NativeMethods\DestroyIcon.cs" />
|
||||
<Compile Include="NativeDllImport\GetIcon.cs" />
|
||||
<Compile Include="NativeDllImport\SHGetFolderPath.cs" />
|
||||
<Compile Include="NativeDllImport\SHGetFileInfo.cs" />
|
||||
<Compile Include="NativeDllImport\SetProcessDPIAware.cs" />
|
||||
<Compile Include="NativeDllImport\GetDeviceCaps.cs" />
|
||||
<Compile Include="NativeDllImport\RegisterHotKey.cs" />
|
||||
<Compile Include="NativeDllImport\ShowWindow.cs" />
|
||||
<Compile Include="NativeDllImport\ShowInactiveTopmost.cs" />
|
||||
<Compile Include="NativeDllImport\SHAppBarMessage.cs" />
|
||||
<Compile Include="NativeDllImport\FindWindow.cs" />
|
||||
<Compile Include="NativeDllImport\StrCmpLogicalW.cs" />
|
||||
<Compile Include="NativeDllImport\FindExecuteable.cs" />
|
||||
<Compile Include="NativeDllImport\BringWindowToTop.cs" />
|
||||
<Compile Include="NativeDllImport\DestroyIcon.cs" />
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
|
|
2
UserInterface/AboutBox.Designer.cs
generated
2
UserInterface/AboutBox.Designer.cs
generated
|
@ -1,4 +1,4 @@
|
|||
namespace SystemTrayMenu.Controls
|
||||
namespace SystemTrayMenu.UserInterface
|
||||
{
|
||||
partial class AboutBox
|
||||
{
|
||||
|
|
|
@ -6,9 +6,9 @@ using System.IO;
|
|||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
using SystemTrayMenu.Helper;
|
||||
using SystemTrayMenu.Utilities;
|
||||
|
||||
namespace SystemTrayMenu.Controls
|
||||
namespace SystemTrayMenu.UserInterface
|
||||
{
|
||||
/// <summary>
|
||||
/// Generic, self-contained About Box dialog
|
||||
|
|
|
@ -8,9 +8,10 @@ using System.Globalization;
|
|||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
using SystemTrayMenu.Helper;
|
||||
using SystemTrayMenu.UserInterface;
|
||||
using SystemTrayMenu.Utilities;
|
||||
|
||||
namespace SystemTrayMenu.Controls
|
||||
namespace SystemTrayMenu.Helper
|
||||
{
|
||||
internal class AppContextMenu
|
||||
{
|
||||
|
|
|
@ -3,11 +3,12 @@ using System.Collections.Generic;
|
|||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using SystemTrayMenu.Controls;
|
||||
using SystemTrayMenu.Helper;
|
||||
using EventHandler = SystemTrayMenu.Helper.EventHandler;
|
||||
using R = SystemTrayMenu.Properties.Resources;
|
||||
using Timer = System.Windows.Forms.Timer;
|
||||
|
||||
namespace SystemTrayMenu
|
||||
namespace SystemTrayMenu.UserInterface
|
||||
{
|
||||
internal class MenuNotifyIcon : IDisposable
|
||||
{
|
||||
|
|
2
UserInterface/AskHotKeyForm.Designer.cs
generated
2
UserInterface/AskHotKeyForm.Designer.cs
generated
|
@ -1,4 +1,4 @@
|
|||
namespace SystemTrayMenu.Controls
|
||||
namespace SystemTrayMenu.UserInterface
|
||||
{
|
||||
partial class AskHotKeyForm
|
||||
{
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
using System;
|
||||
using System.Windows.Forms;
|
||||
using SystemTrayMenu.Helper;
|
||||
using SystemTrayMenu.Utilities;
|
||||
|
||||
namespace SystemTrayMenu.Controls
|
||||
namespace SystemTrayMenu.UserInterface
|
||||
{
|
||||
public partial class AskHotKeyForm : Form
|
||||
{
|
||||
|
|
268
UserInterface/DragDropHintForm.Designer.cs
generated
268
UserInterface/DragDropHintForm.Designer.cs
generated
|
@ -1,140 +1,140 @@
|
|||
namespace SystemTrayMenu.Controls
|
||||
{
|
||||
partial class DragDropHintForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
//namespace SystemTrayMenu.UserInterface
|
||||
//{
|
||||
// partial class DragDropHintForm
|
||||
// {
|
||||
// /// <summary>
|
||||
// /// Required designer variable.
|
||||
// /// </summary>
|
||||
// private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
// /// <summary>
|
||||
// /// Clean up any resources being used.
|
||||
// /// </summary>
|
||||
// /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
// protected override void Dispose(bool disposing)
|
||||
// {
|
||||
// if (disposing && (components != null))
|
||||
// {
|
||||
// components.Dispose();
|
||||
// }
|
||||
// base.Dispose(disposing);
|
||||
// }
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
// #region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DragDropHintForm));
|
||||
this.tableLayoutPanelMain = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.tableLayoutPanelBottom = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.buttonOk = new System.Windows.Forms.Button();
|
||||
this.labelHint = new System.Windows.Forms.Label();
|
||||
this.pictureBoxHint = new System.Windows.Forms.PictureBox();
|
||||
this.tableLayoutPanelMain.SuspendLayout();
|
||||
this.tableLayoutPanelBottom.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxHint)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// tableLayoutPanelMain
|
||||
//
|
||||
this.tableLayoutPanelMain.AutoSize = true;
|
||||
this.tableLayoutPanelMain.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.tableLayoutPanelMain.ColumnCount = 1;
|
||||
this.tableLayoutPanelMain.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.tableLayoutPanelMain.Controls.Add(this.tableLayoutPanelBottom, 0, 2);
|
||||
this.tableLayoutPanelMain.Controls.Add(this.labelHint, 0, 0);
|
||||
this.tableLayoutPanelMain.Controls.Add(this.pictureBoxHint, 0, 1);
|
||||
this.tableLayoutPanelMain.Location = new System.Drawing.Point(12, 12);
|
||||
this.tableLayoutPanelMain.Name = "tableLayoutPanelMain";
|
||||
this.tableLayoutPanelMain.RowCount = 3;
|
||||
this.tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tableLayoutPanelMain.Size = new System.Drawing.Size(223, 149);
|
||||
this.tableLayoutPanelMain.TabIndex = 0;
|
||||
//
|
||||
// tableLayoutPanelBottom
|
||||
//
|
||||
this.tableLayoutPanelBottom.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.tableLayoutPanelBottom.AutoSize = true;
|
||||
this.tableLayoutPanelBottom.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.tableLayoutPanelBottom.ColumnCount = 3;
|
||||
this.tableLayoutPanelBottom.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||
this.tableLayoutPanelBottom.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
|
||||
this.tableLayoutPanelBottom.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||
this.tableLayoutPanelBottom.Controls.Add(this.buttonOk, 1, 0);
|
||||
this.tableLayoutPanelBottom.Location = new System.Drawing.Point(3, 117);
|
||||
this.tableLayoutPanelBottom.Name = "tableLayoutPanelBottom";
|
||||
this.tableLayoutPanelBottom.RowCount = 1;
|
||||
this.tableLayoutPanelBottom.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tableLayoutPanelBottom.Size = new System.Drawing.Size(217, 29);
|
||||
this.tableLayoutPanelBottom.TabIndex = 1;
|
||||
//
|
||||
// buttonOk
|
||||
//
|
||||
this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.buttonOk.Location = new System.Drawing.Point(71, 3);
|
||||
this.buttonOk.Name = "buttonOk";
|
||||
this.buttonOk.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonOk.TabIndex = 2;
|
||||
this.buttonOk.Text = "OK";
|
||||
this.buttonOk.UseVisualStyleBackColor = true;
|
||||
this.buttonOk.Click += new System.EventHandler(this.ButtonOk_Click);
|
||||
//
|
||||
// labelHint
|
||||
//
|
||||
this.labelHint.AutoSize = true;
|
||||
this.labelHint.Location = new System.Drawing.Point(3, 0);
|
||||
this.labelHint.MaximumSize = new System.Drawing.Size(217, 0);
|
||||
this.labelHint.Name = "labelHint";
|
||||
this.labelHint.Size = new System.Drawing.Size(41, 13);
|
||||
this.labelHint.TabIndex = 0;
|
||||
this.labelHint.Text = "Hint: ...";
|
||||
//
|
||||
// pictureBoxHint
|
||||
//
|
||||
this.pictureBoxHint.Image = global::SystemTrayMenu.Properties.Resources.hintDragDrop;
|
||||
this.pictureBoxHint.Location = new System.Drawing.Point(3, 16);
|
||||
this.pictureBoxHint.Name = "pictureBoxHint";
|
||||
this.pictureBoxHint.Size = new System.Drawing.Size(217, 95);
|
||||
this.pictureBoxHint.TabIndex = 1;
|
||||
this.pictureBoxHint.TabStop = false;
|
||||
//
|
||||
// DragDropHintForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||
this.AutoSize = true;
|
||||
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.ClientSize = new System.Drawing.Size(302, 221);
|
||||
this.Controls.Add(this.tableLayoutPanelMain);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "DragDropHintForm";
|
||||
this.Padding = new System.Windows.Forms.Padding(0, 0, 10, 0);
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "DragDropHintForm";
|
||||
this.tableLayoutPanelMain.ResumeLayout(false);
|
||||
this.tableLayoutPanelMain.PerformLayout();
|
||||
this.tableLayoutPanelBottom.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxHint)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
// /// <summary>
|
||||
// /// Required method for Designer support - do not modify
|
||||
// /// the contents of this method with the code editor.
|
||||
// /// </summary>
|
||||
// private void InitializeComponent()
|
||||
// {
|
||||
// System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DragDropHintForm));
|
||||
// this.tableLayoutPanelMain = new System.Windows.Forms.TableLayoutPanel();
|
||||
// this.tableLayoutPanelBottom = new System.Windows.Forms.TableLayoutPanel();
|
||||
// this.buttonOk = new System.Windows.Forms.Button();
|
||||
// this.labelHint = new System.Windows.Forms.Label();
|
||||
// this.pictureBoxHint = new System.Windows.Forms.PictureBox();
|
||||
// this.tableLayoutPanelMain.SuspendLayout();
|
||||
// this.tableLayoutPanelBottom.SuspendLayout();
|
||||
// ((System.ComponentModel.ISupportInitialize)(this.pictureBoxHint)).BeginInit();
|
||||
// this.SuspendLayout();
|
||||
// //
|
||||
// // tableLayoutPanelMain
|
||||
// //
|
||||
// this.tableLayoutPanelMain.AutoSize = true;
|
||||
// this.tableLayoutPanelMain.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
// this.tableLayoutPanelMain.ColumnCount = 1;
|
||||
// this.tableLayoutPanelMain.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
// this.tableLayoutPanelMain.Controls.Add(this.tableLayoutPanelBottom, 0, 2);
|
||||
// this.tableLayoutPanelMain.Controls.Add(this.labelHint, 0, 0);
|
||||
// this.tableLayoutPanelMain.Controls.Add(this.pictureBoxHint, 0, 1);
|
||||
// this.tableLayoutPanelMain.Location = new System.Drawing.Point(12, 12);
|
||||
// this.tableLayoutPanelMain.Name = "tableLayoutPanelMain";
|
||||
// this.tableLayoutPanelMain.RowCount = 3;
|
||||
// this.tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
// this.tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
// this.tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
// this.tableLayoutPanelMain.Size = new System.Drawing.Size(223, 149);
|
||||
// this.tableLayoutPanelMain.TabIndex = 0;
|
||||
// //
|
||||
// // tableLayoutPanelBottom
|
||||
// //
|
||||
// this.tableLayoutPanelBottom.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
|
||||
// this.tableLayoutPanelBottom.AutoSize = true;
|
||||
// this.tableLayoutPanelBottom.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
// this.tableLayoutPanelBottom.ColumnCount = 3;
|
||||
// this.tableLayoutPanelBottom.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||
// this.tableLayoutPanelBottom.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
|
||||
// this.tableLayoutPanelBottom.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||
// this.tableLayoutPanelBottom.Controls.Add(this.buttonOk, 1, 0);
|
||||
// this.tableLayoutPanelBottom.Location = new System.Drawing.Point(3, 117);
|
||||
// this.tableLayoutPanelBottom.Name = "tableLayoutPanelBottom";
|
||||
// this.tableLayoutPanelBottom.RowCount = 1;
|
||||
// this.tableLayoutPanelBottom.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
// this.tableLayoutPanelBottom.Size = new System.Drawing.Size(217, 29);
|
||||
// this.tableLayoutPanelBottom.TabIndex = 1;
|
||||
// //
|
||||
// // buttonOk
|
||||
// //
|
||||
// this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
// this.buttonOk.Location = new System.Drawing.Point(71, 3);
|
||||
// this.buttonOk.Name = "buttonOk";
|
||||
// this.buttonOk.Size = new System.Drawing.Size(75, 23);
|
||||
// this.buttonOk.TabIndex = 2;
|
||||
// this.buttonOk.Text = "OK";
|
||||
// this.buttonOk.UseVisualStyleBackColor = true;
|
||||
// this.buttonOk.Click += new System.EventHandler(this.ButtonOk_Click);
|
||||
// //
|
||||
// // labelHint
|
||||
// //
|
||||
// this.labelHint.AutoSize = true;
|
||||
// this.labelHint.Location = new System.Drawing.Point(3, 0);
|
||||
// this.labelHint.MaximumSize = new System.Drawing.Size(217, 0);
|
||||
// this.labelHint.Name = "labelHint";
|
||||
// this.labelHint.Size = new System.Drawing.Size(41, 13);
|
||||
// this.labelHint.TabIndex = 0;
|
||||
// this.labelHint.Text = "Hint: ...";
|
||||
// //
|
||||
// // pictureBoxHint
|
||||
// //
|
||||
// this.pictureBoxHint.Image = global::SystemTrayMenu.Properties.Resources.hintDragDrop;
|
||||
// this.pictureBoxHint.Location = new System.Drawing.Point(3, 16);
|
||||
// this.pictureBoxHint.Name = "pictureBoxHint";
|
||||
// this.pictureBoxHint.Size = new System.Drawing.Size(217, 95);
|
||||
// this.pictureBoxHint.TabIndex = 1;
|
||||
// this.pictureBoxHint.TabStop = false;
|
||||
// //
|
||||
// // DragDropHintForm
|
||||
// //
|
||||
// this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
|
||||
// this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||
// this.AutoSize = true;
|
||||
// this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
// this.ClientSize = new System.Drawing.Size(302, 221);
|
||||
// this.Controls.Add(this.tableLayoutPanelMain);
|
||||
// this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
// this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
// this.MaximizeBox = false;
|
||||
// this.MinimizeBox = false;
|
||||
// this.Name = "DragDropHintForm";
|
||||
// this.Padding = new System.Windows.Forms.Padding(0, 0, 10, 0);
|
||||
// this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
// this.Text = "DragDropHintForm";
|
||||
// this.tableLayoutPanelMain.ResumeLayout(false);
|
||||
// this.tableLayoutPanelMain.PerformLayout();
|
||||
// this.tableLayoutPanelBottom.ResumeLayout(false);
|
||||
// ((System.ComponentModel.ISupportInitialize)(this.pictureBoxHint)).EndInit();
|
||||
// this.ResumeLayout(false);
|
||||
// this.PerformLayout();
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
#endregion
|
||||
// #endregion
|
||||
|
||||
private System.Windows.Forms.TableLayoutPanel tableLayoutPanelMain;
|
||||
private System.Windows.Forms.Button buttonOk;
|
||||
private System.Windows.Forms.Label labelHint;
|
||||
private System.Windows.Forms.PictureBox pictureBoxHint;
|
||||
private System.Windows.Forms.TableLayoutPanel tableLayoutPanelBottom;
|
||||
}
|
||||
}
|
||||
// private System.Windows.Forms.TableLayoutPanel tableLayoutPanelMain;
|
||||
// private System.Windows.Forms.Button buttonOk;
|
||||
// private System.Windows.Forms.Label labelHint;
|
||||
// private System.Windows.Forms.PictureBox pictureBoxHint;
|
||||
// private System.Windows.Forms.TableLayoutPanel tableLayoutPanelBottom;
|
||||
// }
|
||||
//}
|
|
@ -1,22 +1,22 @@
|
|||
using System;
|
||||
using System.Windows.Forms;
|
||||
//using System;
|
||||
//using System.Windows.Forms;
|
||||
|
||||
namespace SystemTrayMenu.Controls
|
||||
{
|
||||
public partial class DragDropHintForm : Form
|
||||
{
|
||||
public DragDropHintForm(string hintTitle, string hintText,
|
||||
string buttonOk)
|
||||
{
|
||||
InitializeComponent();
|
||||
Text = hintTitle;
|
||||
labelHint.Text = hintText;
|
||||
this.buttonOk.Text = buttonOk;
|
||||
}
|
||||
//namespace SystemTrayMenu.UserInterface
|
||||
//{
|
||||
// public partial class DragDropHintForm : Form
|
||||
// {
|
||||
// public DragDropHintForm(string hintTitle, string hintText,
|
||||
// string buttonOk)
|
||||
// {
|
||||
// InitializeComponent();
|
||||
// Text = hintTitle;
|
||||
// labelHint.Text = hintText;
|
||||
// this.buttonOk.Text = buttonOk;
|
||||
// }
|
||||
|
||||
private void ButtonOk_Click(object sender, EventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
// private void ButtonOk_Click(object sender, EventArgs e)
|
||||
// {
|
||||
// Close();
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace SystemTrayMenu
|
||||
namespace SystemTrayMenu.UserInterface
|
||||
{
|
||||
public class FadeForm : IDisposable
|
||||
{
|
||||
|
@ -29,6 +29,7 @@ namespace SystemTrayMenu
|
|||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
|
@ -78,7 +79,7 @@ namespace SystemTrayMenu
|
|||
}
|
||||
else
|
||||
{
|
||||
NativeMethods.NativeMethods.User32ShowInactiveTopmost(form);
|
||||
NativeDllImport.NativeMethods.User32ShowInactiveTopmost(form);
|
||||
timerFadeOut.Stop();
|
||||
timerFadeIn.Start();
|
||||
}
|
||||
|
|
38
UserInterface/LabelNoCopy.cs
Normal file
38
UserInterface/LabelNoCopy.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace SystemTrayMenu.UserInterface
|
||||
{
|
||||
/// <summary>
|
||||
/// Workaround class for "Clipboard" issue on .Net Windows Forms Label (https://github.com/Hofknecht/SystemTrayMenu/issues/5)
|
||||
/// On Label MouseDoubleClick the framework will copy the title text into the clipboard.
|
||||
/// We avoid this by overriding the Text atrribute and use own _text attribute.
|
||||
/// Text will remain unset and clipboard copy will not take place but it is still possible to get/set Text attribute as usual from outside.
|
||||
/// (see: https://stackoverflow.com/questions/2519587/is-there-any-way-to-disable-the-double-click-to-copy-functionality-of-a-net-l)
|
||||
///
|
||||
/// Note: When you have trouble with the Visual Studio Designer not showing the GUI properly, simply build once and reopen the Designer.
|
||||
/// This will place the required files into the Designer's cache and becomes able to show the GUI as usual.
|
||||
/// </summary>
|
||||
public class LabelNoCopy : Label
|
||||
{
|
||||
private string _text;
|
||||
public override string Text
|
||||
{
|
||||
get => _text;
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
value = "";
|
||||
}
|
||||
|
||||
if (_text != value)
|
||||
{
|
||||
_text = value;
|
||||
Refresh();
|
||||
OnTextChanged(EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
8
UserInterface/Menu.Designer.cs
generated
8
UserInterface/Menu.Designer.cs
generated
|
@ -1,6 +1,4 @@
|
|||
using SystemTrayMenu.Controls;
|
||||
|
||||
namespace SystemTrayMenu
|
||||
namespace SystemTrayMenu.UserInterface
|
||||
{
|
||||
partial class Menu
|
||||
{
|
||||
|
@ -34,7 +32,7 @@ namespace SystemTrayMenu
|
|||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
this.labelTitle = new global::SystemTrayMenu.LabelNoCopy();
|
||||
this.labelTitle = new global::SystemTrayMenu.UserInterface.LabelNoCopy();
|
||||
this.dgv = new System.Windows.Forms.DataGridView();
|
||||
this.ColumnIcon = new System.Windows.Forms.DataGridViewImageColumn();
|
||||
this.ColumnText = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
|
@ -174,7 +172,7 @@ namespace SystemTrayMenu
|
|||
}
|
||||
|
||||
#endregion
|
||||
private global::SystemTrayMenu.LabelNoCopy labelTitle;
|
||||
private global::SystemTrayMenu.UserInterface.LabelNoCopy labelTitle;
|
||||
private System.Windows.Forms.DataGridView dgv;
|
||||
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel;
|
||||
private System.Windows.Forms.DataGridViewImageColumn ColumnIcon;
|
||||
|
|
|
@ -4,11 +4,13 @@ using System.Linq;
|
|||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
using SystemTrayMenu.DataClasses;
|
||||
using SystemTrayMenu.Helper;
|
||||
using SystemTrayMenu.Helper.Taskbar;
|
||||
using SystemTrayMenu.Utilities;
|
||||
using EventHandler = SystemTrayMenu.Helper.EventHandler;
|
||||
|
||||
namespace SystemTrayMenu
|
||||
namespace SystemTrayMenu.UserInterface
|
||||
{
|
||||
public partial class Menu : Form, IDisposable
|
||||
public partial class Menu : Form
|
||||
{
|
||||
public new event EventHandler MouseWheel;
|
||||
public event EventHandler Deactivated;
|
||||
|
@ -133,11 +135,14 @@ namespace SystemTrayMenu
|
|||
|
||||
public void SetTitle(string title)
|
||||
{
|
||||
if (title.Length > MenuDefines.LengthMax)
|
||||
if (!string.IsNullOrEmpty(title))
|
||||
{
|
||||
title = $"{title.Substring(0, MenuDefines.LengthMax)}...";
|
||||
if (title.Length > MenuDefines.LengthMax)
|
||||
{
|
||||
title = $"{title.Substring(0, MenuDefines.LengthMax)}...";
|
||||
}
|
||||
labelTitle.Text = title;
|
||||
}
|
||||
labelTitle.Text = title;
|
||||
}
|
||||
|
||||
public void FadeIn()
|
||||
|
@ -157,22 +162,25 @@ namespace SystemTrayMenu
|
|||
|
||||
public void AdjustLocationAndSize(Screen screen)
|
||||
{
|
||||
DataGridViewElementStates states = DataGridViewElementStates.None;
|
||||
dgv.AutoResizeRows();
|
||||
int height = dgv.Rows.GetRowsHeight(states);
|
||||
int heightMax = screen.Bounds.Height -
|
||||
new Taskbar().Size.Height -
|
||||
labelTitle.Height;
|
||||
if (height > heightMax)
|
||||
if (screen != null)
|
||||
{
|
||||
height = heightMax;
|
||||
}
|
||||
dgv.Height = height;
|
||||
AdjustDataGridViewSize();
|
||||
int x = screen.Bounds.Right - Width;
|
||||
int y = heightMax - Height + labelTitle.Height;
|
||||
DataGridViewElementStates states = DataGridViewElementStates.None;
|
||||
dgv.AutoResizeRows();
|
||||
int height = dgv.Rows.GetRowsHeight(states);
|
||||
int heightMax = screen.Bounds.Height -
|
||||
new Taskbar().Size.Height -
|
||||
labelTitle.Height;
|
||||
if (height > heightMax)
|
||||
{
|
||||
height = heightMax;
|
||||
}
|
||||
dgv.Height = height;
|
||||
AdjustDataGridViewSize();
|
||||
int x = screen.Bounds.Right - Width;
|
||||
int y = heightMax - Height + labelTitle.Height;
|
||||
|
||||
Location = new Point(x, y);
|
||||
Location = new Point(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
public void AdjustLocationAndSize(int heightMax, Menu menuPredecessor)
|
||||
|
@ -326,37 +334,4 @@ namespace SystemTrayMenu
|
|||
return base.ProcessCmdKey(ref msg, keys);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Workaround class for "Clipboard" issue on .Net Windows Forms Label (https://github.com/Hofknecht/SystemTrayMenu/issues/5)
|
||||
/// On Label MouseDoubleClick the framework will copy the title text into the clipboard.
|
||||
/// We avoid this by overriding the Text atrribute and use own _text attribute.
|
||||
/// Text will remain unset and clipboard copy will not take place but it is still possible to get/set Text attribute as usual from outside.
|
||||
/// (see: https://stackoverflow.com/questions/2519587/is-there-any-way-to-disable-the-double-click-to-copy-functionality-of-a-net-l)
|
||||
///
|
||||
/// Note: When you have trouble with the Visual Studio Designer not showing the GUI properly, simply build once and reopen the Designer.
|
||||
/// This will place the required files into the Designer's cache and becomes able to show the GUI as usual.
|
||||
/// </summary>
|
||||
public class LabelNoCopy : Label
|
||||
{
|
||||
private string _text;
|
||||
public override string Text
|
||||
{
|
||||
get => _text;
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
value = "";
|
||||
}
|
||||
|
||||
if (_text != value)
|
||||
{
|
||||
_text = value;
|
||||
Refresh();
|
||||
OnTextChanged(EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,8 +4,9 @@ using System.IO;
|
|||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using SystemTrayMenu.Helper;
|
||||
|
||||
namespace SystemTrayMenu.Helper
|
||||
namespace SystemTrayMenu.Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// "Stand-alone" shell context menu
|
||||
|
@ -234,7 +235,7 @@ namespace SystemTrayMenu.Helper
|
|||
if (null == _oDesktopFolder)
|
||||
{
|
||||
// Get desktop IShellFolder
|
||||
int nResult = NativeMethods.NativeMethods.Shell32SHGetDesktopFolder(out pUnkownDesktopFolder);
|
||||
int nResult = NativeDllImport.NativeMethods.Shell32SHGetDesktopFolder(out pUnkownDesktopFolder);
|
||||
if (S_OK != nResult)
|
||||
{
|
||||
throw new ShellContextMenuException("Failed to get the desktop shell folder");
|
||||
|
@ -276,7 +277,7 @@ namespace SystemTrayMenu.Helper
|
|||
Marshal.WriteInt32(pStrRet, 0, 0);
|
||||
nResult = _oDesktopFolder.GetDisplayNameOf(pPIDL, SHGNO.FORPARSING, pStrRet);
|
||||
StringBuilder strFolder = new StringBuilder(MAX_PATH);
|
||||
_ = NativeMethods.NativeMethods.ShlwapiStrRetToBuf(pStrRet, pPIDL, strFolder, MAX_PATH);
|
||||
_ = NativeDllImport.NativeMethods.ShlwapiStrRetToBuf(pStrRet, pPIDL, strFolder, MAX_PATH);
|
||||
Marshal.FreeCoTaskMem(pStrRet);
|
||||
pStrRet = IntPtr.Zero;
|
||||
_strParentFolder = strFolder.ToString();
|
||||
|
@ -422,7 +423,7 @@ namespace SystemTrayMenu.Helper
|
|||
return;
|
||||
}
|
||||
|
||||
pMenu = NativeMethods.NativeMethods.User32CreatePopupMenu();
|
||||
pMenu = NativeDllImport.NativeMethods.User32CreatePopupMenu();
|
||||
|
||||
int nResult = _oContextMenu.QueryContextMenu(
|
||||
pMenu,
|
||||
|
@ -432,13 +433,13 @@ namespace SystemTrayMenu.Helper
|
|||
CMF.DEFAULTONLY |
|
||||
((Control.ModifierKeys & Keys.Shift) != 0 ? CMF.EXTENDEDVERBS : 0));
|
||||
|
||||
uint nDefaultCmd = (uint)NativeMethods.NativeMethods.User32GetMenuDefaultItem(pMenu, false, 0);
|
||||
uint nDefaultCmd = (uint)NativeDllImport.NativeMethods.User32GetMenuDefaultItem(pMenu, false, 0);
|
||||
if (nDefaultCmd >= CMD_FIRST)
|
||||
{
|
||||
InvokeCommand(_oContextMenu, nDefaultCmd, arrFI[0].DirectoryName, Control.MousePosition);
|
||||
}
|
||||
|
||||
NativeMethods.NativeMethods.User32DestroyMenu(pMenu);
|
||||
NativeDllImport.NativeMethods.User32DestroyMenu(pMenu);
|
||||
pMenu = IntPtr.Zero;
|
||||
}
|
||||
catch
|
||||
|
@ -449,7 +450,7 @@ namespace SystemTrayMenu.Helper
|
|||
{
|
||||
if (pMenu != IntPtr.Zero)
|
||||
{
|
||||
NativeMethods.NativeMethods.User32DestroyMenu(pMenu);
|
||||
NativeDllImport.NativeMethods.User32DestroyMenu(pMenu);
|
||||
}
|
||||
ReleaseAll();
|
||||
}
|
||||
|
@ -515,7 +516,7 @@ namespace SystemTrayMenu.Helper
|
|||
return;
|
||||
}
|
||||
|
||||
pMenu = NativeMethods.NativeMethods.User32CreatePopupMenu();
|
||||
pMenu = NativeDllImport.NativeMethods.User32CreatePopupMenu();
|
||||
|
||||
int nResult = _oContextMenu.QueryContextMenu(
|
||||
pMenu,
|
||||
|
@ -534,15 +535,15 @@ namespace SystemTrayMenu.Helper
|
|||
|
||||
//hook.Install();
|
||||
|
||||
uint nSelected = NativeMethods.NativeMethods.User32TrackPopupMenuEx(
|
||||
uint nSelected = NativeDllImport.NativeMethods.User32TrackPopupMenuEx(
|
||||
pMenu,
|
||||
NativeMethods.NativeMethods.TPM.RETURNCMD,
|
||||
NativeDllImport.NativeMethods.TPM.RETURNCMD,
|
||||
pointScreen.X,
|
||||
pointScreen.Y,
|
||||
Handle,
|
||||
IntPtr.Zero);
|
||||
|
||||
NativeMethods.NativeMethods.User32DestroyMenu(pMenu);
|
||||
NativeDllImport.NativeMethods.User32DestroyMenu(pMenu);
|
||||
pMenu = IntPtr.Zero;
|
||||
|
||||
if (nSelected != 0)
|
||||
|
@ -559,7 +560,7 @@ namespace SystemTrayMenu.Helper
|
|||
//hook.Uninstall();
|
||||
if (pMenu != IntPtr.Zero)
|
||||
{
|
||||
NativeMethods.NativeMethods.User32DestroyMenu(pMenu);
|
||||
NativeDllImport.NativeMethods.User32DestroyMenu(pMenu);
|
||||
}
|
||||
|
||||
if (iContextMenuPtr != IntPtr.Zero)
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using EventHandler = SystemTrayMenu.Helper.EventHandler;
|
||||
|
||||
namespace SystemTrayMenu.Helper
|
||||
namespace SystemTrayMenu.Utilities
|
||||
{
|
||||
internal class AppRestart
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace SystemTrayMenu.Helper
|
||||
namespace SystemTrayMenu.Utilities
|
||||
{
|
||||
public static class DataGridViewExtensions
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace SystemTrayMenu.Helper
|
||||
namespace SystemTrayMenu.Utilities
|
||||
{
|
||||
public class FileIni
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@ using System.IO;
|
|||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace SystemTrayMenu
|
||||
namespace SystemTrayMenu.Utilities
|
||||
{
|
||||
internal class LnkHelper
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using Microsoft.Win32;
|
||||
|
||||
namespace SystemTrayMenu.Helper
|
||||
namespace SystemTrayMenu.Utilities
|
||||
{
|
||||
public static class FileUrl
|
||||
{
|
||||
|
|
|
@ -6,7 +6,7 @@ using System.Drawing.Imaging;
|
|||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SystemTrayMenu.Helper
|
||||
namespace SystemTrayMenu.Utilities
|
||||
{
|
||||
// from https://www.codeproject.com/Articles/2532/Obtaining-and-managing-file-and-folder-icons-using
|
||||
// added ImageList_GetIcon, IconCache, AddIconOverlay
|
||||
|
@ -70,29 +70,29 @@ namespace SystemTrayMenu.Helper
|
|||
IconSize size = IconSize.Small)
|
||||
{
|
||||
Icon icon = null;
|
||||
NativeMethods.NativeMethods.SHFILEINFO shfi = new NativeMethods.NativeMethods.SHFILEINFO();
|
||||
uint flags = NativeMethods.NativeMethods.ShgfiIcon | NativeMethods.NativeMethods.ShgfiSYSICONINDEX;
|
||||
NativeDllImport.NativeMethods.SHFILEINFO shfi = new NativeDllImport.NativeMethods.SHFILEINFO();
|
||||
uint flags = NativeDllImport.NativeMethods.ShgfiIcon | NativeDllImport.NativeMethods.ShgfiSYSICONINDEX;
|
||||
|
||||
//MH: Removed, otherwise wrong icon
|
||||
// | Shell32.SHGFI_USEFILEATTRIBUTES ;
|
||||
|
||||
if (true == linkOverlay)
|
||||
{
|
||||
flags += NativeMethods.NativeMethods.ShgfiLINKOVERLAY;
|
||||
flags += NativeDllImport.NativeMethods.ShgfiLINKOVERLAY;
|
||||
}
|
||||
|
||||
/* Check the size specified for return. */
|
||||
if (IconSize.Small == size)
|
||||
{
|
||||
flags += NativeMethods.NativeMethods.ShgfiSMALLICON;
|
||||
flags += NativeDllImport.NativeMethods.ShgfiSMALLICON;
|
||||
}
|
||||
else
|
||||
{
|
||||
flags += NativeMethods.NativeMethods.ShgfiLARGEICON;
|
||||
flags += NativeDllImport.NativeMethods.ShgfiLARGEICON;
|
||||
}
|
||||
|
||||
IntPtr hImageList = NativeMethods.NativeMethods.Shell32SHGetFileInfo(filePath,
|
||||
NativeMethods.NativeMethods.FileAttributeNormal,
|
||||
IntPtr hImageList = NativeDllImport.NativeMethods.Shell32SHGetFileInfo(filePath,
|
||||
NativeDllImport.NativeMethods.FileAttributeNormal,
|
||||
ref shfi,
|
||||
(uint)System.Runtime.InteropServices.Marshal.SizeOf(shfi),
|
||||
flags);
|
||||
|
@ -106,7 +106,7 @@ namespace SystemTrayMenu.Helper
|
|||
else
|
||||
{
|
||||
// Get icon from .ink without overlay
|
||||
hIcon = NativeMethods.NativeMethods.ImageList_GetIcon(hImageList, shfi.iIcon, NativeMethods.NativeMethods.IldTransparent);
|
||||
hIcon = NativeDllImport.NativeMethods.ImageList_GetIcon(hImageList, shfi.iIcon, NativeDllImport.NativeMethods.IldTransparent);
|
||||
}
|
||||
|
||||
try
|
||||
|
@ -122,10 +122,10 @@ namespace SystemTrayMenu.Helper
|
|||
// Cleanup
|
||||
if (!linkOverlay)
|
||||
{
|
||||
NativeMethods.NativeMethods.User32DestroyIcon(hIcon);
|
||||
NativeDllImport.NativeMethods.User32DestroyIcon(hIcon);
|
||||
}
|
||||
|
||||
NativeMethods.NativeMethods.User32DestroyIcon(shfi.hIcon);
|
||||
NativeDllImport.NativeMethods.User32DestroyIcon(shfi.hIcon);
|
||||
}
|
||||
|
||||
return icon;
|
||||
|
@ -141,31 +141,31 @@ namespace SystemTrayMenu.Helper
|
|||
//uint flags = Shell32.SHGFI_ICON | Shell32.SHGFI_USEFILEATTRIBUTES;
|
||||
|
||||
//MH: Removed SHGFI_USEFILEATTRIBUTES, otherwise was wrong folder icon
|
||||
uint flags = NativeMethods.NativeMethods.ShgfiIcon; // | Shell32.SHGFI_USEFILEATTRIBUTES;
|
||||
uint flags = NativeDllImport.NativeMethods.ShgfiIcon; // | Shell32.SHGFI_USEFILEATTRIBUTES;
|
||||
|
||||
if (true == linkOverlay)
|
||||
{
|
||||
flags += NativeMethods.NativeMethods.ShgfiLINKOVERLAY;
|
||||
flags += NativeDllImport.NativeMethods.ShgfiLINKOVERLAY;
|
||||
}
|
||||
|
||||
if (FolderType.Open == folderType)
|
||||
{
|
||||
flags += NativeMethods.NativeMethods.ShgfiOPENICON;
|
||||
flags += NativeDllImport.NativeMethods.ShgfiOPENICON;
|
||||
}
|
||||
|
||||
if (IconSize.Small == size)
|
||||
{
|
||||
flags += NativeMethods.NativeMethods.ShgfiSMALLICON;
|
||||
flags += NativeDllImport.NativeMethods.ShgfiSMALLICON;
|
||||
}
|
||||
else
|
||||
{
|
||||
flags += NativeMethods.NativeMethods.ShgfiLARGEICON;
|
||||
flags += NativeDllImport.NativeMethods.ShgfiLARGEICON;
|
||||
}
|
||||
|
||||
// Get the folder icon
|
||||
NativeMethods.NativeMethods.SHFILEINFO shfi = new NativeMethods.NativeMethods.SHFILEINFO();
|
||||
IntPtr Success = NativeMethods.NativeMethods.Shell32SHGetFileInfo(directoryPath,
|
||||
NativeMethods.NativeMethods.FileAttributeDirectory,
|
||||
NativeDllImport.NativeMethods.SHFILEINFO shfi = new NativeDllImport.NativeMethods.SHFILEINFO();
|
||||
IntPtr Success = NativeDllImport.NativeMethods.Shell32SHGetFileInfo(directoryPath,
|
||||
NativeDllImport.NativeMethods.FileAttributeDirectory,
|
||||
ref shfi,
|
||||
(uint)Marshal.SizeOf(shfi),
|
||||
flags);
|
||||
|
@ -184,7 +184,7 @@ namespace SystemTrayMenu.Helper
|
|||
}
|
||||
|
||||
// Cleanup
|
||||
NativeMethods.NativeMethods.User32DestroyIcon(shfi.hIcon);
|
||||
NativeDllImport.NativeMethods.User32DestroyIcon(shfi.hIcon);
|
||||
}
|
||||
|
||||
return icon;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace SystemTrayMenu.Helper
|
||||
namespace SystemTrayMenu.Utilities
|
||||
{
|
||||
internal static class FolderOptions
|
||||
{
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
using System.Resources;
|
||||
using System.Threading;
|
||||
using SystemTrayMenu.Properties;
|
||||
using SystemTrayMenu.UserInterface;
|
||||
|
||||
namespace SystemTrayMenu.Helper
|
||||
namespace SystemTrayMenu.Utilities
|
||||
{
|
||||
internal static class Language
|
||||
{
|
||||
|
|
|
@ -4,7 +4,7 @@ using System.Diagnostics;
|
|||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
namespace SystemTrayMenu.Helper
|
||||
namespace SystemTrayMenu.Utilities
|
||||
{
|
||||
internal static class Log
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
namespace SystemTrayMenu.Helper
|
||||
namespace SystemTrayMenu.Utilities
|
||||
{
|
||||
internal static class Scaling
|
||||
{
|
||||
|
@ -21,7 +21,7 @@ namespace SystemTrayMenu.Helper
|
|||
{
|
||||
if (Environment.OSVersion.Version.Major >= 6)
|
||||
{
|
||||
NativeMethods.NativeMethods.User32SetProcessDPIAware();
|
||||
NativeDllImport.NativeMethods.User32SetProcessDPIAware();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,9 +30,9 @@ namespace SystemTrayMenu.Helper
|
|||
{
|
||||
Graphics g = Graphics.FromHwnd(IntPtr.Zero);
|
||||
IntPtr desktop = g.GetHdc();
|
||||
int LogicalScreenHeight = NativeMethods.NativeMethods.Gdi32GetDeviceCaps(
|
||||
int LogicalScreenHeight = NativeDllImport.NativeMethods.Gdi32GetDeviceCaps(
|
||||
desktop, (int)DeviceCap.VERTRES);
|
||||
int PhysicalScreenHeight = NativeMethods.NativeMethods.Gdi32GetDeviceCaps(
|
||||
int PhysicalScreenHeight = NativeDllImport.NativeMethods.Gdi32GetDeviceCaps(
|
||||
desktop, (int)DeviceCap.DESKTOPVERTRES);
|
||||
Factor = PhysicalScreenHeight / (float)LogicalScreenHeight;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
|
||||
namespace SystemTrayMenu.Helper
|
||||
namespace SystemTrayMenu.Utilities
|
||||
{
|
||||
internal static class SingleAppInstance
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue