mirror of
https://github.com/Hofknecht/SystemTrayMenu.git
synced 2024-06-02 10:34:42 +12:00
This commit is contained in:
parent
c08336df9e
commit
3b0903e39e
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using SystemTrayMenu.DataClasses;
|
using SystemTrayMenu.DataClasses;
|
||||||
|
@ -98,7 +99,7 @@ namespace SystemTrayMenu.Handler
|
||||||
char.IsWhiteSpace(e.KeyChar) ||
|
char.IsWhiteSpace(e.KeyChar) ||
|
||||||
char.IsSeparator(e.KeyChar))
|
char.IsSeparator(e.KeyChar))
|
||||||
{
|
{
|
||||||
string letter = e.KeyChar.ToString();
|
string letter = e.KeyChar.ToString(CultureInfo.InvariantCulture);
|
||||||
|
|
||||||
timerKeySearch.Stop();
|
timerKeySearch.Stop();
|
||||||
|
|
||||||
|
@ -108,7 +109,7 @@ namespace SystemTrayMenu.Handler
|
||||||
KeySearchString += letter;
|
KeySearchString += letter;
|
||||||
SelectByKey(Keys.None, KeySearchString);
|
SelectByKey(Keys.None, KeySearchString);
|
||||||
}
|
}
|
||||||
else if (KeySearchString.Length == 1 && KeySearchString.LastOrDefault().ToString() == letter)
|
else if (KeySearchString.Length == 1 && KeySearchString.LastOrDefault().ToString(CultureInfo.InvariantCulture) == letter)
|
||||||
{
|
{
|
||||||
// initial letter pressed again, jump to next element
|
// initial letter pressed again, jump to next element
|
||||||
SelectByKey(Keys.None, letter);
|
SelectByKey(Keys.None, letter);
|
||||||
|
@ -169,8 +170,8 @@ namespace SystemTrayMenu.Handler
|
||||||
{
|
{
|
||||||
if (KeepSelection)
|
if (KeepSelection)
|
||||||
{
|
{
|
||||||
// Is current selection is still valid for this search then skip selecting different item
|
// If current selection is still valid for this search then skip selecting different item
|
||||||
if (textselected.ToLower().StartsWith(keyInput.ToLower()))
|
if (textselected.StartsWith(keyInput, true, CultureInfo.InvariantCulture))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -380,7 +381,7 @@ namespace SystemTrayMenu.Handler
|
||||||
DataGridViewRow row = dgv.Rows[i];
|
DataGridViewRow row = dgv.Rows[i];
|
||||||
RowData rowData = (RowData)row.Tag;
|
RowData rowData = (RowData)row.Tag;
|
||||||
string text = row.Cells[1].Value.ToString();
|
string text = row.Cells[1].Value.ToString();
|
||||||
if (text.ToLower().StartsWith(keyInput.ToLower()))
|
if (text.StartsWith(keyInput, true, CultureInfo.InvariantCulture))
|
||||||
{
|
{
|
||||||
iRowKey = rowData.RowIndex;
|
iRowKey = rowData.RowIndex;
|
||||||
rowData.IsSelectedByKeyboard = true;
|
rowData.IsSelectedByKeyboard = true;
|
||||||
|
|
|
@ -214,6 +214,7 @@ namespace SystemTrayMenu
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
worker.Dispose();
|
||||||
keyboardInput.Dispose();
|
keyboardInput.Dispose();
|
||||||
menuNotifyIcon.Dispose();
|
menuNotifyIcon.Dispose();
|
||||||
fastLeave.Dispose();
|
fastLeave.Dispose();
|
||||||
|
@ -402,6 +403,18 @@ namespace SystemTrayMenu
|
||||||
Log.Info($"UnauthorizedAccessException:'{path}'");
|
Log.Info($"UnauthorizedAccessException:'{path}'");
|
||||||
menuData.Validity = MenuDataValidity.NoAccess;
|
menuData.Validity = MenuDataValidity.NoAccess;
|
||||||
}
|
}
|
||||||
|
//catch (PathTooLongException ex)
|
||||||
|
//{
|
||||||
|
|
||||||
|
//}
|
||||||
|
//catch (DirectoryNotFoundException ex)
|
||||||
|
//{
|
||||||
|
|
||||||
|
//}
|
||||||
|
//catch (IOException ex)
|
||||||
|
//{
|
||||||
|
|
||||||
|
//}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Log.Error($"path:'{path}'", ex);
|
Log.Error($"path:'{path}'", ex);
|
||||||
|
|
|
@ -7,14 +7,14 @@ namespace SystemTrayMenu
|
||||||
{
|
{
|
||||||
public static readonly List<string> Languages =
|
public static readonly List<string> Languages =
|
||||||
new List<string>() { "en", "de" };
|
new List<string>() { "en", "de" };
|
||||||
public static Color File = Color.White;
|
public static readonly Color File = Color.White;
|
||||||
public static Color Folder = Color.White;
|
public static readonly Color Folder = Color.White;
|
||||||
public static Color ColorSelectedItem = AppColors.Blue;
|
public static readonly Color ColorSelectedItem = AppColors.Blue;
|
||||||
public static Color ColorOpenFolder = AppColors.Green;
|
public static readonly Color ColorOpenFolder = AppColors.Green;
|
||||||
public static Color ColorTitleWarning = AppColors.Red;
|
public static readonly Color ColorTitleWarning = AppColors.Red;
|
||||||
public static Color ColorTitleSelected = AppColors.Yellow;
|
public static readonly Color ColorTitleSelected = AppColors.Yellow;
|
||||||
public static Color ColorTitleBackground = AppColors.YellowSlightly;
|
public static readonly Color ColorTitleBackground = AppColors.YellowSlightly;
|
||||||
public static int KeySearchInterval = 1000;
|
public const int KeySearchInterval = 1000;
|
||||||
public const int MenuRowsHeight = 18;
|
public const int MenuRowsHeight = 18;
|
||||||
public const int LengthMax = 37;
|
public const int LengthMax = 37;
|
||||||
public const int Scrollspeed = 4;
|
public const int Scrollspeed = 4;
|
||||||
|
@ -28,17 +28,17 @@ namespace SystemTrayMenu
|
||||||
public const double OpacityOutStep = 0.05;
|
public const double OpacityOutStep = 0.05;
|
||||||
public const double OpacityHalfStep = 0.01;
|
public const double OpacityHalfStep = 0.01;
|
||||||
public const int MenusMax = 50;
|
public const int MenusMax = 50;
|
||||||
public static int MaxClicksInQueue = 1;
|
public const int MaxClicksInQueue = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class AppColors
|
public static class AppColors
|
||||||
{
|
{
|
||||||
public static Color Blue = Color.FromArgb(204, 232, 255);
|
public static readonly Color Blue = Color.FromArgb(204, 232, 255);
|
||||||
public static Color BlueSelectedInactive = Color.FromArgb(217, 217, 217);
|
public static readonly Color BlueSelectedInactive = Color.FromArgb(217, 217, 217);
|
||||||
public static Color Green = Color.FromArgb(194, 245, 222);
|
public static readonly Color Green = Color.FromArgb(194, 245, 222);
|
||||||
public static Color GreenBackgroundInactive = Color.FromArgb(217, 217, 217);
|
public static readonly Color GreenBackgroundInactive = Color.FromArgb(217, 217, 217);
|
||||||
public static Color Red = Color.FromArgb(255, 204, 232);
|
public static readonly Color Red = Color.FromArgb(255, 204, 232);
|
||||||
public static Color Yellow = Color.LightYellow;
|
public static readonly Color Yellow = Color.LightYellow;
|
||||||
public static Color YellowSlightly = Color.Azure;
|
public static readonly Color YellowSlightly = Color.Azure;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,14 +2,14 @@
|
||||||
|
|
||||||
namespace SystemTrayMenu.DataClasses
|
namespace SystemTrayMenu.DataClasses
|
||||||
{
|
{
|
||||||
public enum MenuDataValidity
|
internal enum MenuDataValidity
|
||||||
{
|
{
|
||||||
Valid,
|
Valid,
|
||||||
Invalid,
|
Invalid,
|
||||||
NoAccess
|
NoAccess
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct MenuData
|
internal struct MenuData
|
||||||
{
|
{
|
||||||
public List<RowData> RowDatas;
|
public List<RowData> RowDatas;
|
||||||
public MenuDataValidity Validity;
|
public MenuDataValidity Validity;
|
||||||
|
|
|
@ -18,25 +18,25 @@ namespace SystemTrayMenu.DataClasses
|
||||||
public class RowData : IDisposable
|
public class RowData : IDisposable
|
||||||
{
|
{
|
||||||
public event Action<object, EventArgs> OpenMenu;
|
public event Action<object, EventArgs> OpenMenu;
|
||||||
public BackgroundWorker Reading = new BackgroundWorker();
|
internal BackgroundWorker Reading = new BackgroundWorker();
|
||||||
public FileInfo FileInfo;
|
internal FileInfo FileInfo;
|
||||||
public Menu SubMenu;
|
internal Menu SubMenu;
|
||||||
public Icon Icon;
|
internal Icon Icon;
|
||||||
public bool IsSelected;
|
internal bool IsSelected;
|
||||||
public bool IsSelectedByKeyboard;
|
internal bool IsSelectedByKeyboard;
|
||||||
public bool ContainsMenu;
|
internal bool ContainsMenu;
|
||||||
public bool IsContextMenuOpen;
|
internal bool IsContextMenuOpen;
|
||||||
public bool ResolvedFileNotFound;
|
internal bool ResolvedFileNotFound;
|
||||||
public bool IsResolvedLnk;
|
internal bool IsResolvedLnk;
|
||||||
public bool IsLoading = false;
|
internal bool IsLoading = false;
|
||||||
public bool RestartLoading = false;
|
internal bool RestartLoading = false;
|
||||||
public bool HiddenEntry;
|
internal bool HiddenEntry;
|
||||||
public string WorkingDirectory;
|
internal string WorkingDirectory;
|
||||||
public string Arguments;
|
internal string Arguments;
|
||||||
public string TargetFilePath;
|
internal string TargetFilePath;
|
||||||
public string TargetFilePathOrig;
|
internal string TargetFilePathOrig;
|
||||||
public string Text;
|
internal string Text;
|
||||||
public int RowIndex;
|
internal int RowIndex;
|
||||||
private readonly WaitMenuOpen waitMenuOpen = new WaitMenuOpen();
|
private readonly WaitMenuOpen waitMenuOpen = new WaitMenuOpen();
|
||||||
private bool isDisposed = false;
|
private bool isDisposed = false;
|
||||||
|
|
||||||
|
@ -279,16 +279,16 @@ namespace SystemTrayMenu.DataClasses
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//https://stackoverflow.com/questions/31627801/
|
//https://stackoverflow.com/questions/31627801/
|
||||||
Process p = new Process
|
using (Process p = new Process())
|
||||||
{
|
{
|
||||||
StartInfo = new ProcessStartInfo(TargetFilePath)
|
p.StartInfo = new ProcessStartInfo(TargetFilePath)
|
||||||
{
|
{
|
||||||
Arguments = Arguments,
|
Arguments = Arguments,
|
||||||
WorkingDirectory = WorkingDirectory,
|
WorkingDirectory = WorkingDirectory,
|
||||||
CreateNoWindow = true
|
CreateNoWindow = true
|
||||||
}
|
};
|
||||||
|
p.Start();
|
||||||
};
|
};
|
||||||
p.Start();
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
// This file is used by Code Analysis to maintain SuppressMessage
|
|
||||||
// attributes that are applied to this project.
|
|
||||||
// Project-level suppressions either have no target or are given
|
|
||||||
// a specific target and scoped to a namespace, type, member, etc.
|
|
||||||
|
|
||||||
using System.Diagnostics.CodeAnalysis;
|
|
||||||
|
|
||||||
[assembly: SuppressMessage("Naming", "CA1707:Identifiers should not contain underscores", Justification = "<Pending>", Scope = "type", Target = "~T:SystemTrayMenu.Helper.HookType")]
|
|
|
@ -10,7 +10,7 @@ namespace SystemTrayMenu.Helper
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private class Window : NativeWindow, IDisposable
|
private class Window : NativeWindow, IDisposable
|
||||||
{
|
{
|
||||||
private static readonly int WM_HOTKEY = 0x0312;
|
private const int WM_HOTKEY = 0x0312;
|
||||||
|
|
||||||
public Window()
|
public Window()
|
||||||
{
|
{
|
||||||
|
@ -73,7 +73,7 @@ namespace SystemTrayMenu.Helper
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="modifier">The modifiers that are associated with the hot key.</param>
|
/// <param name="modifier">The modifiers that are associated with the hot key.</param>
|
||||||
/// <param name="key">The key itself that is associated with the hot key.</param>
|
/// <param name="key">The key itself that is associated with the hot key.</param>
|
||||||
public void RegisterHotKey(KeyboardHookModifierKeys modifier, Keys key)
|
internal void RegisterHotKey(KeyboardHookModifierKeys modifier, Keys key)
|
||||||
{
|
{
|
||||||
// increment the counter.
|
// increment the counter.
|
||||||
_currentId = _currentId + 1;
|
_currentId = _currentId + 1;
|
||||||
|
@ -88,7 +88,7 @@ namespace SystemTrayMenu.Helper
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A hot key has been pressed.
|
/// A hot key has been pressed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event EventHandler<KeyPressedEventArgs> KeyPressed;
|
internal event EventHandler<KeyPressedEventArgs> KeyPressed;
|
||||||
|
|
||||||
#region IDisposable Members
|
#region IDisposable Members
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ namespace SystemTrayMenu.Helper
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Event Args for the event that is fired after the hot key has been pressed.
|
/// Event Args for the event that is fired after the hot key has been pressed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class KeyPressedEventArgs : EventArgs
|
internal class KeyPressedEventArgs : EventArgs
|
||||||
{
|
{
|
||||||
private readonly KeyboardHookModifierKeys _modifier;
|
private readonly KeyboardHookModifierKeys _modifier;
|
||||||
private readonly Keys _key;
|
private readonly Keys _key;
|
||||||
|
@ -121,16 +121,16 @@ namespace SystemTrayMenu.Helper
|
||||||
_key = key;
|
_key = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
public KeyboardHookModifierKeys Modifier => _modifier;
|
internal KeyboardHookModifierKeys Modifier => _modifier;
|
||||||
|
|
||||||
public Keys Key => _key;
|
internal Keys Key => _key;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The enumeration of possible modifiers.
|
/// The enumeration of possible modifiers.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Flags]
|
[Flags]
|
||||||
public enum KeyboardHookModifierKeys : uint
|
internal enum KeyboardHookModifierKeys : uint
|
||||||
{
|
{
|
||||||
Alt = 1,
|
Alt = 1,
|
||||||
Control = 2,
|
Control = 2,
|
||||||
|
|
|
@ -14,6 +14,7 @@ namespace SystemTrayMenu.Helper.Taskbar
|
||||||
Bottom,
|
Bottom,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Microsoft.WindowsAPICodePack.Taskbar.TaskbarManager do not have the bounds implemented?
|
||||||
public sealed class Taskbar
|
public sealed class Taskbar
|
||||||
{
|
{
|
||||||
private const string ClassName = "Shell_TrayWnd";
|
private const string ClassName = "Shell_TrayWnd";
|
||||||
|
|
|
@ -5,33 +5,36 @@ namespace SystemTrayMenu.NativeDllImport
|
||||||
{
|
{
|
||||||
public static partial class NativeMethods
|
public static partial class NativeMethods
|
||||||
{
|
{
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
//[StructLayout(LayoutKind.Sequential)]
|
||||||
public struct SHITEMID
|
//[System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1815:Override equals and operator equals on value types", Justification = "<Pending>")]
|
||||||
{
|
//internal struct SHITEMID
|
||||||
public ushort cb;
|
//{
|
||||||
[MarshalAs(UnmanagedType.LPArray)]
|
// public ushort cb;
|
||||||
public byte[] abID;
|
// [MarshalAs(UnmanagedType.LPArray)]
|
||||||
}
|
// public byte[] abID;
|
||||||
|
//}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
//[StructLayout(LayoutKind.Sequential)]
|
||||||
public struct ITEMIDLIST
|
//[System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1815:Override equals and operator equals on value types", Justification = "<Pending>")]
|
||||||
{
|
//internal struct ITEMIDLIST
|
||||||
public SHITEMID mkid;
|
//{
|
||||||
}
|
// public SHITEMID mkid;
|
||||||
|
//}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
//[StructLayout(LayoutKind.Sequential)]
|
||||||
public struct BROWSEINFO
|
//[System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1815:Override equals and operator equals on value types", Justification = "<Pending>")]
|
||||||
{
|
//internal struct BROWSEINFO
|
||||||
public IntPtr hwndOwner;
|
//{
|
||||||
public IntPtr pidlRoot;
|
// public IntPtr hwndOwner;
|
||||||
public IntPtr pszDisplayName;
|
// public IntPtr pidlRoot;
|
||||||
[MarshalAs(UnmanagedType.LPTStr)]
|
// public IntPtr pszDisplayName;
|
||||||
public string lpszTitle;
|
// [MarshalAs(UnmanagedType.LPTStr)]
|
||||||
public uint ulFlags;
|
// public string lpszTitle;
|
||||||
public IntPtr lpfn;
|
// public uint ulFlags;
|
||||||
public int lParam;
|
// public IntPtr lpfn;
|
||||||
public IntPtr iImage;
|
// public int lParam;
|
||||||
}
|
// public IntPtr iImage;
|
||||||
|
//}
|
||||||
|
|
||||||
// Browsing for directory.
|
// Browsing for directory.
|
||||||
//public const uint BIF_RETURNONLYFSDIRS = 0x0001;
|
//public const uint BIF_RETURNONLYFSDIRS = 0x0001;
|
||||||
|
@ -78,7 +81,7 @@ namespace SystemTrayMenu.NativeDllImport
|
||||||
int i,
|
int i,
|
||||||
int flags);
|
int flags);
|
||||||
|
|
||||||
public static void Comctl32ImageList_GetIcon(IntPtr hIcon)
|
public static void Comctl32ImageListGetIcon(IntPtr hIcon)
|
||||||
{
|
{
|
||||||
_ = DestroyIcon(hIcon);
|
_ = DestroyIcon(hIcon);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,12 +8,12 @@ namespace SystemTrayMenu.NativeDllImport
|
||||||
[DllImport("shell32.dll", SetLastError = true)]
|
[DllImport("shell32.dll", SetLastError = true)]
|
||||||
private static extern IntPtr SHAppBarMessage(ABM dwMessage, [In] ref APPBARDATA pData);
|
private static extern IntPtr SHAppBarMessage(ABM dwMessage, [In] ref APPBARDATA pData);
|
||||||
|
|
||||||
public static IntPtr Shell32SHAppBarMessage(ABM dwMessage, [In] ref APPBARDATA pData)
|
internal static IntPtr Shell32SHAppBarMessage(ABM dwMessage, [In] ref APPBARDATA pData)
|
||||||
{
|
{
|
||||||
return SHAppBarMessage(dwMessage, ref pData);
|
return SHAppBarMessage(dwMessage, ref pData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ABM : uint
|
internal enum ABM : uint
|
||||||
{
|
{
|
||||||
New = 0x00000000,
|
New = 0x00000000,
|
||||||
Remove = 0x00000001,
|
Remove = 0x00000001,
|
||||||
|
@ -28,7 +28,7 @@ namespace SystemTrayMenu.NativeDllImport
|
||||||
SetState = 0x0000000A,
|
SetState = 0x0000000A,
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ABE : uint
|
internal enum ABE : uint
|
||||||
{
|
{
|
||||||
Left = 0,
|
Left = 0,
|
||||||
Top = 1,
|
Top = 1,
|
||||||
|
@ -36,14 +36,14 @@ namespace SystemTrayMenu.NativeDllImport
|
||||||
Bottom = 3
|
Bottom = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ABS
|
internal static class ABS
|
||||||
{
|
{
|
||||||
public const int Autohide = 0x0000001;
|
public const int Autohide = 0x0000001;
|
||||||
public const int AlwaysOnTop = 0x0000002;
|
public const int AlwaysOnTop = 0x0000002;
|
||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public struct APPBARDATA
|
internal struct APPBARDATA
|
||||||
{
|
{
|
||||||
public uint cbSize;
|
public uint cbSize;
|
||||||
public IntPtr hWnd;
|
public IntPtr hWnd;
|
||||||
|
@ -54,7 +54,7 @@ namespace SystemTrayMenu.NativeDllImport
|
||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public struct RECT
|
internal struct RECT
|
||||||
{
|
{
|
||||||
public int left;
|
public int left;
|
||||||
public int top;
|
public int top;
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace SystemTrayMenu.NativeDllImport
|
||||||
uint uFlags
|
uint uFlags
|
||||||
);
|
);
|
||||||
|
|
||||||
public static IntPtr Shell32SHGetFileInfo(
|
internal static IntPtr Shell32SHGetFileInfo(
|
||||||
string pszPath,
|
string pszPath,
|
||||||
uint dwFileAttributes,
|
uint dwFileAttributes,
|
||||||
ref SHFILEINFO psfi,
|
ref SHFILEINFO psfi,
|
||||||
|
@ -32,7 +32,7 @@ namespace SystemTrayMenu.NativeDllImport
|
||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public struct SHFILEINFO
|
internal struct SHFILEINFO
|
||||||
{
|
{
|
||||||
public const int NAMESIZE = 80;
|
public const int NAMESIZE = 80;
|
||||||
public IntPtr hIcon;
|
public IntPtr hIcon;
|
||||||
|
|
|
@ -9,14 +9,14 @@ namespace SystemTrayMenu.NativeDllImport
|
||||||
[DllImport("user32.dll", ExactSpelling = true, CharSet = CharSet.Auto)]
|
[DllImport("user32.dll", ExactSpelling = true, CharSet = CharSet.Auto)]
|
||||||
private static extern uint TrackPopupMenuEx(IntPtr hmenu, TPM flags, int x, int y, IntPtr hwnd, IntPtr lptpm);
|
private static extern uint TrackPopupMenuEx(IntPtr hmenu, TPM flags, int x, int y, IntPtr hwnd, IntPtr lptpm);
|
||||||
|
|
||||||
public static uint User32TrackPopupMenuEx(IntPtr hmenu, TPM flags, int x, int y, IntPtr hwnd, IntPtr lptpm)
|
internal static uint User32TrackPopupMenuEx(IntPtr hmenu, TPM flags, int x, int y, IntPtr hwnd, IntPtr lptpm)
|
||||||
{
|
{
|
||||||
return TrackPopupMenuEx(hmenu, flags, x, y, hwnd, lptpm);
|
return TrackPopupMenuEx(hmenu, flags, x, y, hwnd, lptpm);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Specifies how TrackPopupMenuEx positions the shortcut menu horizontally
|
// Specifies how TrackPopupMenuEx positions the shortcut menu horizontally
|
||||||
[Flags]
|
[Flags]
|
||||||
public enum TPM : uint
|
internal enum TPM : uint
|
||||||
{
|
{
|
||||||
LEFTBUTTON = 0x0000,
|
LEFTBUTTON = 0x0000,
|
||||||
RIGHTBUTTON = 0x0002,
|
RIGHTBUTTON = 0x0002,
|
||||||
|
|
|
@ -35,5 +35,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("0.9.2.11")]
|
[assembly: AssemblyVersion("0.9.2.12")]
|
||||||
[assembly: AssemblyFileVersion("0.9.2.11")]
|
[assembly: AssemblyFileVersion("0.9.2.12")]
|
||||||
|
|
|
@ -138,7 +138,6 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Config\Config.cs" />
|
<Compile Include="Config\Config.cs" />
|
||||||
<Compile Include="GlobalSuppressions.cs" />
|
|
||||||
<Compile Include="NativeDllImport\DestroyMenu.cs" />
|
<Compile Include="NativeDllImport\DestroyMenu.cs" />
|
||||||
<Compile Include="NativeDllImport\CreatePopupMenu.cs" />
|
<Compile Include="NativeDllImport\CreatePopupMenu.cs" />
|
||||||
<Compile Include="NativeDllImport\GetMenuDefaultItem.cs" />
|
<Compile Include="NativeDllImport\GetMenuDefaultItem.cs" />
|
||||||
|
@ -157,9 +156,7 @@
|
||||||
<Compile Include="UserInterface\AskHotKeyForm.Designer.cs">
|
<Compile Include="UserInterface\AskHotKeyForm.Designer.cs">
|
||||||
<DependentUpon>AskHotKeyForm.cs</DependentUpon>
|
<DependentUpon>AskHotKeyForm.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="UserInterface\DragDropHintForm.cs">
|
<Compile Include="UserInterface\DragDropHintForm.cs" />
|
||||||
<SubType>Form</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="UserInterface\DragDropHintForm.Designer.cs">
|
<Compile Include="UserInterface\DragDropHintForm.Designer.cs">
|
||||||
<DependentUpon>DragDropHintForm.cs</DependentUpon>
|
<DependentUpon>DragDropHintForm.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
@ -181,11 +178,8 @@
|
||||||
<Compile Include="Helpers\MessageFilter.cs" />
|
<Compile Include="Helpers\MessageFilter.cs" />
|
||||||
<Compile Include="Utilities\Language.cs" />
|
<Compile Include="Utilities\Language.cs" />
|
||||||
<Compile Include="Utilities\Scaling.cs" />
|
<Compile Include="Utilities\Scaling.cs" />
|
||||||
<Compile Include="UserInterface\ShellContextMenu\HookEventArgs.cs" />
|
|
||||||
<Compile Include="UserInterface\ShellContextMenu\ShellContextMenuException.cs" />
|
<Compile Include="UserInterface\ShellContextMenu\ShellContextMenuException.cs" />
|
||||||
<Compile Include="UserInterface\ShellContextMenu\HookType.cs" />
|
|
||||||
<Compile Include="UserInterface\ShellContextMenu\ShellHelper.cs" />
|
<Compile Include="UserInterface\ShellContextMenu\ShellHelper.cs" />
|
||||||
<Compile Include="UserInterface\ShellContextMenu\LocalWindowsHook.cs" />
|
|
||||||
<Compile Include="UserInterface\ShellContextMenu\ShellContextMenu.cs" />
|
<Compile Include="UserInterface\ShellContextMenu\ShellContextMenu.cs" />
|
||||||
<Compile Include="Utilities\File\FileUrl.cs" />
|
<Compile Include="Utilities\File\FileUrl.cs" />
|
||||||
<Compile Include="Business\WaitFastLeave.cs" />
|
<Compile Include="Business\WaitFastLeave.cs" />
|
||||||
|
@ -329,9 +323,6 @@
|
||||||
<Install>false</Install>
|
<Install>false</Install>
|
||||||
</BootstrapperPackage>
|
</BootstrapperPackage>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<WCFMetadata Include="Connected Services\" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers">
|
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers">
|
||||||
<Version>2.9.8</Version>
|
<Version>2.9.8</Version>
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
@ -220,7 +221,7 @@ namespace SystemTrayMenu.UserInterface
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dt = DateTime.Parse("01/01/2000").AddDays(AssemblyVersion.Build).AddSeconds(AssemblyVersion.Revision * 2);
|
dt = DateTime.Parse("01/01/2000", CultureInfo.InvariantCulture).AddDays(AssemblyVersion.Build).AddSeconds(AssemblyVersion.Revision * 2);
|
||||||
if (TimeZone.IsDaylightSavingTime(dt, TimeZone.CurrentTimeZone.GetDaylightChanges(dt.Year)))
|
if (TimeZone.IsDaylightSavingTime(dt, TimeZone.CurrentTimeZone.GetDaylightChanges(dt.Year)))
|
||||||
{
|
{
|
||||||
dt = dt.AddHours(1);
|
dt = dt.AddHours(1);
|
||||||
|
@ -267,35 +268,35 @@ namespace SystemTrayMenu.UserInterface
|
||||||
switch (TypeName)
|
switch (TypeName)
|
||||||
{
|
{
|
||||||
case "System.CLSCompliantAttribute":
|
case "System.CLSCompliantAttribute":
|
||||||
Value = ((CLSCompliantAttribute)attrib).IsCompliant.ToString(); break;
|
Value = ((CLSCompliantAttribute)attrib).IsCompliant.ToString(CultureInfo.InvariantCulture); break;
|
||||||
case "System.Diagnostics.DebuggableAttribute":
|
case "System.Diagnostics.DebuggableAttribute":
|
||||||
Value = ((System.Diagnostics.DebuggableAttribute)attrib).IsJITTrackingEnabled.ToString(); break;
|
Value = ((System.Diagnostics.DebuggableAttribute)attrib).IsJITTrackingEnabled.ToString(CultureInfo.InvariantCulture); break;
|
||||||
case "System.Reflection.AssemblyCompanyAttribute":
|
case "System.Reflection.AssemblyCompanyAttribute":
|
||||||
Value = ((AssemblyCompanyAttribute)attrib).Company.ToString(); break;
|
Value = ((AssemblyCompanyAttribute)attrib).Company.ToString(CultureInfo.InvariantCulture); break;
|
||||||
case "System.Reflection.AssemblyConfigurationAttribute":
|
case "System.Reflection.AssemblyConfigurationAttribute":
|
||||||
Value = ((AssemblyConfigurationAttribute)attrib).Configuration.ToString(); break;
|
Value = ((AssemblyConfigurationAttribute)attrib).Configuration.ToString(CultureInfo.InvariantCulture); break;
|
||||||
case "System.Reflection.AssemblyCopyrightAttribute":
|
case "System.Reflection.AssemblyCopyrightAttribute":
|
||||||
Value = ((AssemblyCopyrightAttribute)attrib).Copyright.ToString(); break;
|
Value = ((AssemblyCopyrightAttribute)attrib).Copyright.ToString(CultureInfo.InvariantCulture); break;
|
||||||
case "System.Reflection.AssemblyDefaultAliasAttribute":
|
case "System.Reflection.AssemblyDefaultAliasAttribute":
|
||||||
Value = ((AssemblyDefaultAliasAttribute)attrib).DefaultAlias.ToString(); break;
|
Value = ((AssemblyDefaultAliasAttribute)attrib).DefaultAlias.ToString(CultureInfo.InvariantCulture); break;
|
||||||
case "System.Reflection.AssemblyDelaySignAttribute":
|
case "System.Reflection.AssemblyDelaySignAttribute":
|
||||||
Value = ((AssemblyDelaySignAttribute)attrib).DelaySign.ToString(); break;
|
Value = ((AssemblyDelaySignAttribute)attrib).DelaySign.ToString(CultureInfo.InvariantCulture); break;
|
||||||
case "System.Reflection.AssemblyDescriptionAttribute":
|
case "System.Reflection.AssemblyDescriptionAttribute":
|
||||||
Value = ((AssemblyDescriptionAttribute)attrib).Description.ToString(); break;
|
Value = ((AssemblyDescriptionAttribute)attrib).Description.ToString(CultureInfo.InvariantCulture); break;
|
||||||
case "System.Reflection.AssemblyInformationalVersionAttribute":
|
case "System.Reflection.AssemblyInformationalVersionAttribute":
|
||||||
Value = ((AssemblyInformationalVersionAttribute)attrib).InformationalVersion.ToString(); break;
|
Value = ((AssemblyInformationalVersionAttribute)attrib).InformationalVersion.ToString(CultureInfo.InvariantCulture); break;
|
||||||
case "System.Reflection.AssemblyKeyFileAttribute":
|
case "System.Reflection.AssemblyKeyFileAttribute":
|
||||||
Value = ((AssemblyKeyFileAttribute)attrib).KeyFile.ToString(); break;
|
Value = ((AssemblyKeyFileAttribute)attrib).KeyFile.ToString(CultureInfo.InvariantCulture); break;
|
||||||
case "System.Reflection.AssemblyProductAttribute":
|
case "System.Reflection.AssemblyProductAttribute":
|
||||||
Value = ((AssemblyProductAttribute)attrib).Product.ToString(); break;
|
Value = ((AssemblyProductAttribute)attrib).Product.ToString(CultureInfo.InvariantCulture); break;
|
||||||
case "System.Reflection.AssemblyTrademarkAttribute":
|
case "System.Reflection.AssemblyTrademarkAttribute":
|
||||||
Value = ((AssemblyTrademarkAttribute)attrib).Trademark.ToString(); break;
|
Value = ((AssemblyTrademarkAttribute)attrib).Trademark.ToString(CultureInfo.InvariantCulture); break;
|
||||||
case "System.Reflection.AssemblyTitleAttribute":
|
case "System.Reflection.AssemblyTitleAttribute":
|
||||||
Value = ((AssemblyTitleAttribute)attrib).Title.ToString(); break;
|
Value = ((AssemblyTitleAttribute)attrib).Title.ToString(CultureInfo.InvariantCulture); break;
|
||||||
case "System.Resources.NeutralResourcesLanguageAttribute":
|
case "System.Resources.NeutralResourcesLanguageAttribute":
|
||||||
Value = ((System.Resources.NeutralResourcesLanguageAttribute)attrib).CultureName.ToString(); break;
|
Value = ((System.Resources.NeutralResourcesLanguageAttribute)attrib).CultureName.ToString(CultureInfo.InvariantCulture); break;
|
||||||
case "System.Resources.SatelliteContractVersionAttribute":
|
case "System.Resources.SatelliteContractVersionAttribute":
|
||||||
Value = ((System.Resources.SatelliteContractVersionAttribute)attrib).Version.ToString(); break;
|
Value = ((System.Resources.SatelliteContractVersionAttribute)attrib).Version.ToString(CultureInfo.InvariantCulture); break;
|
||||||
case "System.Runtime.InteropServices.ComCompatibleVersionAttribute":
|
case "System.Runtime.InteropServices.ComCompatibleVersionAttribute":
|
||||||
{
|
{
|
||||||
System.Runtime.InteropServices.ComCompatibleVersionAttribute x;
|
System.Runtime.InteropServices.ComCompatibleVersionAttribute x;
|
||||||
|
@ -303,9 +304,9 @@ namespace SystemTrayMenu.UserInterface
|
||||||
Value = x.MajorVersion + "." + x.MinorVersion + "." + x.RevisionNumber + "." + x.BuildNumber; break;
|
Value = x.MajorVersion + "." + x.MinorVersion + "." + x.RevisionNumber + "." + x.BuildNumber; break;
|
||||||
}
|
}
|
||||||
case "System.Runtime.InteropServices.ComVisibleAttribute":
|
case "System.Runtime.InteropServices.ComVisibleAttribute":
|
||||||
Value = ((System.Runtime.InteropServices.ComVisibleAttribute)attrib).Value.ToString(); break;
|
Value = ((System.Runtime.InteropServices.ComVisibleAttribute)attrib).Value.ToString(CultureInfo.InvariantCulture); break;
|
||||||
case "System.Runtime.InteropServices.GuidAttribute":
|
case "System.Runtime.InteropServices.GuidAttribute":
|
||||||
Value = ((System.Runtime.InteropServices.GuidAttribute)attrib).Value.ToString(); break;
|
Value = ((System.Runtime.InteropServices.GuidAttribute)attrib).Value.ToString(CultureInfo.InvariantCulture); break;
|
||||||
case "System.Runtime.InteropServices.TypeLibVersionAttribute":
|
case "System.Runtime.InteropServices.TypeLibVersionAttribute":
|
||||||
{
|
{
|
||||||
System.Runtime.InteropServices.TypeLibVersionAttribute x;
|
System.Runtime.InteropServices.TypeLibVersionAttribute x;
|
||||||
|
@ -343,7 +344,7 @@ namespace SystemTrayMenu.UserInterface
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nvc.Add("BuildDate", dt.ToString("yyyy-MM-dd hh:mm tt"));
|
nvc.Add("BuildDate", dt.ToString("yyyy-MM-dd hh:mm tt", CultureInfo.InvariantCulture));
|
||||||
}
|
}
|
||||||
// location
|
// location
|
||||||
try
|
try
|
||||||
|
@ -524,7 +525,7 @@ namespace SystemTrayMenu.UserInterface
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return _EntryAssemblyAttribCollection[strName].ToString();
|
return _EntryAssemblyAttribCollection[strName].ToString(CultureInfo.InvariantCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -584,7 +585,7 @@ namespace SystemTrayMenu.UserInterface
|
||||||
s = s.Replace("%company%", EntryAssemblyAttrib("company"));
|
s = s.Replace("%company%", EntryAssemblyAttrib("company"));
|
||||||
s = s.Replace("%product%", EntryAssemblyAttrib("product"));
|
s = s.Replace("%product%", EntryAssemblyAttrib("product"));
|
||||||
s = s.Replace("%trademark%", EntryAssemblyAttrib("trademark"));
|
s = s.Replace("%trademark%", EntryAssemblyAttrib("trademark"));
|
||||||
s = s.Replace("%year%", DateTime.Now.Year.ToString());
|
s = s.Replace("%year%", DateTime.Now.Year.ToString(CultureInfo.InvariantCulture));
|
||||||
s = s.Replace("%version%", EntryAssemblyAttrib("version"));
|
s = s.Replace("%version%", EntryAssemblyAttrib("version"));
|
||||||
s = s.Replace("%builddate%", EntryAssemblyAttrib("builddate"));
|
s = s.Replace("%builddate%", EntryAssemblyAttrib("builddate"));
|
||||||
return s;
|
return s;
|
||||||
|
@ -599,7 +600,7 @@ namespace SystemTrayMenu.UserInterface
|
||||||
|
|
||||||
// this assembly property is only available in framework versions 1.1+
|
// this assembly property is only available in framework versions 1.1+
|
||||||
Populate(lvw, "Image Runtime Version", a.ImageRuntimeVersion);
|
Populate(lvw, "Image Runtime Version", a.ImageRuntimeVersion);
|
||||||
Populate(lvw, "Loaded from GAC", a.GlobalAssemblyCache.ToString());
|
Populate(lvw, "Loaded from GAC", a.GlobalAssemblyCache.ToString(CultureInfo.InvariantCulture));
|
||||||
|
|
||||||
NameValueCollection nvc = AssemblyAttribs(a);
|
NameValueCollection nvc = AssemblyAttribs(a);
|
||||||
foreach (string strKey in nvc)
|
foreach (string strKey in nvc)
|
||||||
|
@ -714,7 +715,7 @@ namespace SystemTrayMenu.UserInterface
|
||||||
string strAssemblyName;
|
string strAssemblyName;
|
||||||
if (AssemblyInfoListView.SelectedItems.Count > 0)
|
if (AssemblyInfoListView.SelectedItems.Count > 0)
|
||||||
{
|
{
|
||||||
strAssemblyName = Convert.ToString(AssemblyInfoListView.SelectedItems[0].Tag);
|
strAssemblyName = Convert.ToString(AssemblyInfoListView.SelectedItems[0].Tag, CultureInfo.InvariantCulture);
|
||||||
AssemblyNamesComboBox.SelectedIndex = AssemblyNamesComboBox.FindStringExact(strAssemblyName);
|
AssemblyNamesComboBox.SelectedIndex = AssemblyNamesComboBox.FindStringExact(strAssemblyName);
|
||||||
TabPanelDetails.SelectedTab = TabPageAssemblyDetails;
|
TabPanelDetails.SelectedTab = TabPageAssemblyDetails;
|
||||||
}
|
}
|
||||||
|
@ -725,7 +726,7 @@ namespace SystemTrayMenu.UserInterface
|
||||||
// </summary>
|
// </summary>
|
||||||
private void AssemblyNamesComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
private void AssemblyNamesComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
string strAssemblyName = Convert.ToString(AssemblyNamesComboBox.SelectedItem);
|
string strAssemblyName = Convert.ToString(AssemblyNamesComboBox.SelectedItem, CultureInfo.InvariantCulture);
|
||||||
PopulateAssemblyDetails(MatchAssemblyByName(strAssemblyName), AssemblyDetailsListView);
|
PopulateAssemblyDetails(MatchAssemblyByName(strAssemblyName), AssemblyDetailsListView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -738,9 +739,9 @@ namespace SystemTrayMenu.UserInterface
|
||||||
|
|
||||||
if (AssemblyInfoListView.Tag != null)
|
if (AssemblyInfoListView.Tag != null)
|
||||||
{
|
{
|
||||||
if (Math.Abs(Convert.ToInt32(AssemblyInfoListView.Tag)) == intTargetCol)
|
if (Math.Abs(Convert.ToInt32(AssemblyInfoListView.Tag, CultureInfo.InvariantCulture)) == intTargetCol)
|
||||||
{
|
{
|
||||||
intTargetCol = -Convert.ToInt32(AssemblyInfoListView.Tag);
|
intTargetCol = -Convert.ToInt32(AssemblyInfoListView.Tag, CultureInfo.InvariantCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AssemblyInfoListView.Tag = intTargetCol;
|
AssemblyInfoListView.Tag = intTargetCol;
|
||||||
|
@ -790,9 +791,10 @@ namespace SystemTrayMenu.UserInterface
|
||||||
|
|
||||||
public int Compare(object x, object y)
|
public int Compare(object x, object y)
|
||||||
{
|
{
|
||||||
int intResult =
|
int intResult = string.Compare(
|
||||||
string.Compare(((ListViewItem)x).SubItems[_intCol].Text, ((ListViewItem)y).SubItems[_intCol].Text);
|
((ListViewItem)x).SubItems[_intCol].Text,
|
||||||
|
((ListViewItem)y).SubItems[_intCol].Text,
|
||||||
|
CultureInfo.InvariantCulture, CompareOptions.None);
|
||||||
if (_IsAscending)
|
if (_IsAscending)
|
||||||
{
|
{
|
||||||
return intResult;
|
return intResult;
|
||||||
|
|
|
@ -233,7 +233,7 @@ namespace SystemTrayMenu.Helper
|
||||||
{
|
{
|
||||||
List<CultureInfo> cultureList = CultureInfo.GetCultures(cultureType).ToList();
|
List<CultureInfo> cultureList = CultureInfo.GetCultures(cultureType).ToList();
|
||||||
cultureList.Sort((p1, p2) => string.Compare(
|
cultureList.Sort((p1, p2) => string.Compare(
|
||||||
p1.NativeName, p2.NativeName, true));
|
p1.NativeName, p2.NativeName, true, CultureInfo.InvariantCulture));
|
||||||
return cultureList;
|
return cultureList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,8 @@ namespace SystemTrayMenu.UserInterface
|
||||||
|
|
||||||
public bool IsFadingOut => FadeForm.IsFadingOut;
|
public bool IsFadingOut => FadeForm.IsFadingOut;
|
||||||
|
|
||||||
public int Level = 0;
|
internal int Level = 0;
|
||||||
|
|
||||||
private readonly FadeForm FadeForm = null;
|
private readonly FadeForm FadeForm = null;
|
||||||
private bool autoResizeRowsDone = false;
|
private bool autoResizeRowsDone = false;
|
||||||
|
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace SystemTrayMenu.Helper
|
|
||||||
{
|
|
||||||
public class HookEventArgs : EventArgs
|
|
||||||
{
|
|
||||||
public int HookCode; // Hook code
|
|
||||||
public IntPtr wParam; // WPARAM argument
|
|
||||||
public IntPtr lParam; // LPARAM argument
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
namespace SystemTrayMenu.Helper
|
|
||||||
{
|
|
||||||
public enum HookType : int
|
|
||||||
{
|
|
||||||
WH_JOURNALRECORD = 0,
|
|
||||||
WH_JOURNALPLAYBACK = 1,
|
|
||||||
WH_KEYBOARD = 2,
|
|
||||||
WH_GETMESSAGE = 3,
|
|
||||||
WH_CALLWNDPROC = 4,
|
|
||||||
WH_CBT = 5,
|
|
||||||
WH_SYSMSGFILTER = 6,
|
|
||||||
WH_MOUSE = 7,
|
|
||||||
WH_HARDWARE = 8,
|
|
||||||
WH_DEBUG = 9,
|
|
||||||
WH_SHELL = 10,
|
|
||||||
WH_FOREGROUNDIDLE = 11,
|
|
||||||
WH_CALLWNDPROCRET = 12,
|
|
||||||
WH_KEYBOARD_LL = 13,
|
|
||||||
WH_MOUSE_LL = 14
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,100 +0,0 @@
|
||||||
//using System;
|
|
||||||
//using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
//namespace SystemTrayMenu.Helper
|
|
||||||
//{
|
|
||||||
// public class LocalWindowsHook
|
|
||||||
// {
|
|
||||||
// // ************************************************************************
|
|
||||||
// // Filter function delegate
|
|
||||||
// public delegate int HookProc(int code, IntPtr wParam, IntPtr lParam);
|
|
||||||
// // ************************************************************************
|
|
||||||
|
|
||||||
// // ************************************************************************
|
|
||||||
// // Internal properties
|
|
||||||
// protected IntPtr m_hhook = IntPtr.Zero;
|
|
||||||
// protected HookProc m_filterFunc = null;
|
|
||||||
// protected HookType m_hookType;
|
|
||||||
// // ************************************************************************
|
|
||||||
|
|
||||||
// // ************************************************************************
|
|
||||||
// // Event delegate
|
|
||||||
// public delegate void HookEventHandler(object sender, HookEventArgs e);
|
|
||||||
// // ************************************************************************
|
|
||||||
|
|
||||||
// // ************************************************************************
|
|
||||||
// // Event: HookInvoked
|
|
||||||
// public event HookEventHandler HookInvoked;
|
|
||||||
// protected void OnHookInvoked(HookEventArgs e)
|
|
||||||
// {
|
|
||||||
// if (HookInvoked != null)
|
|
||||||
// {
|
|
||||||
// HookInvoked(this, e);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// // ************************************************************************
|
|
||||||
|
|
||||||
// // ************************************************************************
|
|
||||||
// // Class constructor(s)
|
|
||||||
// public LocalWindowsHook(HookType hook)
|
|
||||||
// {
|
|
||||||
// m_hookType = hook;
|
|
||||||
// m_filterFunc = new HookProc(CoreHookProc);
|
|
||||||
// }
|
|
||||||
// public LocalWindowsHook(HookType hook, HookProc func)
|
|
||||||
// {
|
|
||||||
// m_hookType = hook;
|
|
||||||
// m_filterFunc = func;
|
|
||||||
// }
|
|
||||||
// // ************************************************************************
|
|
||||||
|
|
||||||
// // ************************************************************************
|
|
||||||
// // Default filter function
|
|
||||||
// protected int CoreHookProc(int code, IntPtr wParam, IntPtr lParam)
|
|
||||||
// {
|
|
||||||
// if (code < 0)
|
|
||||||
// {
|
|
||||||
// return CallNextHookEx(m_hhook, code, wParam, lParam);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // Let clients determine what to do
|
|
||||||
// HookEventArgs e = new HookEventArgs
|
|
||||||
// {
|
|
||||||
// HookCode = code,
|
|
||||||
// wParam = wParam,
|
|
||||||
// lParam = lParam
|
|
||||||
// };
|
|
||||||
// OnHookInvoked(e);
|
|
||||||
|
|
||||||
// // Yield to the next hook in the chain
|
|
||||||
// return CallNextHookEx(m_hhook, code, wParam, lParam);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public void Install()
|
|
||||||
// {
|
|
||||||
// m_hhook = SetWindowsHookEx(
|
|
||||||
// m_hookType,
|
|
||||||
// m_filterFunc,
|
|
||||||
// IntPtr.Zero,
|
|
||||||
// AppDomain.GetCurrentThreadId());
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public void Uninstall()
|
|
||||||
// {
|
|
||||||
// UnhookWindowsHookEx(m_hhook);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [DllImport("user32.dll")]
|
|
||||||
// protected static extern IntPtr SetWindowsHookEx(HookType code,
|
|
||||||
// HookProc func,
|
|
||||||
// IntPtr hInstance,
|
|
||||||
// int threadID);
|
|
||||||
|
|
||||||
// [DllImport("user32.dll")]
|
|
||||||
// protected static extern int UnhookWindowsHookEx(IntPtr hhook);
|
|
||||||
|
|
||||||
// [DllImport("user32.dll")]
|
|
||||||
// protected static extern int CallNextHookEx(IntPtr hhook,
|
|
||||||
// int code, IntPtr wParam, IntPtr lParam);
|
|
||||||
// }
|
|
||||||
//}
|
|
|
@ -583,37 +583,6 @@ namespace SystemTrayMenu.Utilities
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region WindowsHookInvoked()
|
|
||||||
/// <summary>
|
|
||||||
/// Handle messages for context menu
|
|
||||||
/// </summary>
|
|
||||||
private void WindowsHookInvoked(object sender, HookEventArgs e)
|
|
||||||
{
|
|
||||||
CWPSTRUCT cwp = (CWPSTRUCT)Marshal.PtrToStructure(e.lParam, typeof(CWPSTRUCT));
|
|
||||||
|
|
||||||
if (_oContextMenu2 != null &&
|
|
||||||
(cwp.message == (int)WM.INITMENUPOPUP ||
|
|
||||||
cwp.message == (int)WM.MEASUREITEM ||
|
|
||||||
cwp.message == (int)WM.DRAWITEM))
|
|
||||||
{
|
|
||||||
if (_oContextMenu2.HandleMenuMsg((uint)cwp.message, cwp.wparam, cwp.lparam) == S_OK)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_oContextMenu3 != null && cwp.message == (int)WM.MENUCHAR)
|
|
||||||
{
|
|
||||||
if (_oContextMenu3.HandleMenuMsg2((uint)cwp.message, cwp.wparam, cwp.lparam, IntPtr.Zero) == S_OK)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Local variabled
|
#region Local variabled
|
||||||
private IContextMenu _oContextMenu;
|
private IContextMenu _oContextMenu;
|
||||||
private IContextMenu2 _oContextMenu2;
|
private IContextMenu2 _oContextMenu2;
|
||||||
|
|
|
@ -1,19 +1,31 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace SystemTrayMenu.Helper
|
namespace SystemTrayMenu.Helper
|
||||||
{
|
{
|
||||||
|
[Serializable]
|
||||||
public class ShellContextMenuException : Exception
|
public class ShellContextMenuException : Exception
|
||||||
{
|
{
|
||||||
/// <summary>Default contructor</summary>
|
|
||||||
public ShellContextMenuException()
|
public ShellContextMenuException()
|
||||||
{
|
{
|
||||||
|
// Add any type-specific logic, and supply the default message.
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Constructor with message</summary>
|
public ShellContextMenuException(string message) : base(message)
|
||||||
/// <param name="message">Message</param>
|
|
||||||
public ShellContextMenuException(string message)
|
|
||||||
: base(message)
|
|
||||||
{
|
{
|
||||||
|
// Add any type-specific logic.
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShellContextMenuException(string message, Exception innerException) :
|
||||||
|
base(message, innerException)
|
||||||
|
{
|
||||||
|
// Add any type-specific logic for inner exceptions.
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ShellContextMenuException(SerializationInfo info,
|
||||||
|
StreamingContext context) : base(info, context)
|
||||||
|
{
|
||||||
|
// Implement type-specific serialization constructor logic.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -126,12 +126,13 @@ namespace SystemTrayMenu.Utilities
|
||||||
public interface IPersistFile : IPersist
|
public interface IPersistFile : IPersist
|
||||||
{
|
{
|
||||||
new void GetClassID(out Guid pClassID);
|
new void GetClassID(out Guid pClassID);
|
||||||
|
|
||||||
[PreserveSig]
|
[PreserveSig]
|
||||||
int IsDirty();
|
int IsDirty();
|
||||||
|
|
||||||
[PreserveSig]
|
[PreserveSig]
|
||||||
void Load([In, MarshalAs(UnmanagedType.LPWStr)]
|
void Load([In, MarshalAs(UnmanagedType.LPWStr)]
|
||||||
string pszFileName, uint dwMode);
|
string pszFileName, uint dwMode);
|
||||||
|
|
||||||
[PreserveSig]
|
[PreserveSig]
|
||||||
void Save([In, MarshalAs(UnmanagedType.LPWStr)] string pszFileName,
|
void Save([In, MarshalAs(UnmanagedType.LPWStr)] string pszFileName,
|
||||||
|
@ -160,8 +161,6 @@ namespace SystemTrayMenu.Utilities
|
||||||
{
|
{
|
||||||
ShellLink link = new ShellLink();
|
ShellLink link = new ShellLink();
|
||||||
((IPersistFile)link).Load(filename, STGM_READ);
|
((IPersistFile)link).Load(filename, STGM_READ);
|
||||||
// TODO: if I can get hold of the hwnd call resolve first. This handles moved and renamed files.
|
|
||||||
// ((IShellLinkW)link).Resolve(hwnd, 0)
|
|
||||||
StringBuilder sb = new StringBuilder(MAX_PATH);
|
StringBuilder sb = new StringBuilder(MAX_PATH);
|
||||||
WIN32_FIND_DATAW data = new WIN32_FIND_DATAW();
|
WIN32_FIND_DATAW data = new WIN32_FIND_DATAW();
|
||||||
((IShellLinkW)link).GetPath(sb, sb.Capacity, out data, 0);
|
((IShellLinkW)link).GetPath(sb, sb.Capacity, out data, 0);
|
||||||
|
@ -199,7 +198,7 @@ namespace SystemTrayMenu.Utilities
|
||||||
|
|
||||||
public static string ReplaceFirst(string text, string search, string replace)
|
public static string ReplaceFirst(string text, string search, string replace)
|
||||||
{
|
{
|
||||||
int pos = text.IndexOf(search);
|
int pos = text.IndexOf(search, StringComparison.InvariantCulture);
|
||||||
if (pos < 0)
|
if (pos < 0)
|
||||||
{
|
{
|
||||||
return text;
|
return text;
|
||||||
|
|
|
@ -42,8 +42,8 @@ namespace SystemTrayMenu.Utilities
|
||||||
{
|
{
|
||||||
bool isExtensionWitSameIcon = true;
|
bool isExtensionWitSameIcon = true;
|
||||||
List<string> extensionsWithDiffIcons = new List<string>
|
List<string> extensionsWithDiffIcons = new List<string>
|
||||||
{ ".exe", ".lnk", ".ico", ".url" };
|
{ ".EXE", ".LNK", ".ICO", ".URL" };
|
||||||
if (extensionsWithDiffIcons.Contains(fileExtension.ToLower()))
|
if (extensionsWithDiffIcons.Contains(fileExtension.ToUpperInvariant()))
|
||||||
{
|
{
|
||||||
isExtensionWitSameIcon = false;
|
isExtensionWitSameIcon = false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue