mirror of
https://github.com/Hofknecht/SystemTrayMenu.git
synced 2024-06-28 19:10:26 +12:00
parent
a2b1e7537e
commit
0a9921fb8b
|
@ -251,7 +251,7 @@ namespace SystemTrayMenu.Controls
|
||||||
// Description = AssemblyDescription string
|
// Description = AssemblyDescription string
|
||||||
// Title = AssemblyTitle string
|
// Title = AssemblyTitle string
|
||||||
// </remarks>
|
// </remarks>
|
||||||
private NameValueCollection AssemblyAttribs(Assembly a)
|
private static NameValueCollection AssemblyAttribs(Assembly a)
|
||||||
{
|
{
|
||||||
string TypeName;
|
string TypeName;
|
||||||
string Name;
|
string Name;
|
||||||
|
@ -379,18 +379,17 @@ namespace SystemTrayMenu.Controls
|
||||||
// <summary>
|
// <summary>
|
||||||
// reads an HKLM Windows Registry key value
|
// reads an HKLM Windows Registry key value
|
||||||
// </summary>
|
// </summary>
|
||||||
private string RegistryHklmValue(string KeyName, string SubKeyRef)
|
private static string RegistryHklmValue(string KeyName, string SubKeyRef)
|
||||||
{
|
{
|
||||||
RegistryKey rk;
|
string strSysInfoPath = string.Empty;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
rk = Registry.LocalMachine.OpenSubKey(KeyName);
|
RegistryKey rk = Registry.LocalMachine.OpenSubKey(KeyName);
|
||||||
return (string)rk.GetValue(SubKeyRef, "");
|
strSysInfoPath = (string)rk.GetValue(SubKeyRef, string.Empty);
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
catch (Exception) { }
|
||||||
|
|
||||||
|
return strSysInfoPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
// <summary>
|
// <summary>
|
||||||
|
@ -398,9 +397,7 @@ namespace SystemTrayMenu.Controls
|
||||||
// </summary>
|
// </summary>
|
||||||
private void ShowSysInfo()
|
private void ShowSysInfo()
|
||||||
{
|
{
|
||||||
string strSysInfoPath = "";
|
string strSysInfoPath = RegistryHklmValue(@"SOFTWARE\Microsoft\Shared Tools Location", "MSINFO");
|
||||||
|
|
||||||
strSysInfoPath = RegistryHklmValue(@"SOFTWARE\Microsoft\Shared Tools Location", "MSINFO");
|
|
||||||
if (string.IsNullOrEmpty(strSysInfoPath))
|
if (string.IsNullOrEmpty(strSysInfoPath))
|
||||||
{
|
{
|
||||||
strSysInfoPath = RegistryHklmValue(@"SOFTWARE\Microsoft\Shared Tools\MSINFO", "PATH");
|
strSysInfoPath = RegistryHklmValue(@"SOFTWARE\Microsoft\Shared Tools\MSINFO", "PATH");
|
||||||
|
@ -434,7 +431,7 @@ namespace SystemTrayMenu.Controls
|
||||||
// <summary>
|
// <summary>
|
||||||
// populate a listview with the specified key and value strings
|
// populate a listview with the specified key and value strings
|
||||||
// </summary>
|
// </summary>
|
||||||
private void Populate(ListView lvw, string Key, string Value)
|
private static void Populate(ListView lvw, string Key, string Value)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(Value))
|
if (!string.IsNullOrEmpty(Value))
|
||||||
{
|
{
|
||||||
|
|
|
@ -227,7 +227,7 @@ namespace SystemTrayMenu.Controls
|
||||||
/// https://www.codeproject.com/Tips/744914/
|
/// https://www.codeproject.com/Tips/744914/
|
||||||
/// Sorted-list-of-available-cultures-in-NET
|
/// Sorted-list-of-available-cultures-in-NET
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IEnumerable<CultureInfo> GetCultureList(
|
private static IEnumerable<CultureInfo> GetCultureList(
|
||||||
CultureTypes cultureType = CultureTypes.SpecificCultures)
|
CultureTypes cultureType = CultureTypes.SpecificCultures)
|
||||||
{
|
{
|
||||||
List<CultureInfo> cultureList = CultureInfo.GetCultures(cultureType).ToList();
|
List<CultureInfo> cultureList = CultureInfo.GetCultures(cultureType).ToList();
|
||||||
|
|
|
@ -86,6 +86,7 @@ namespace SystemTrayMenu
|
||||||
{
|
{
|
||||||
notifyIcon.Icon = null;
|
notifyIcon.Icon = null;
|
||||||
notifyIcon.Dispose();
|
notifyIcon.Dispose();
|
||||||
|
load.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadingStart()
|
public void LoadingStart()
|
||||||
|
|
|
@ -6,7 +6,8 @@ namespace SystemTrayMenu.Controls
|
||||||
{
|
{
|
||||||
public partial class AskHotKeyForm : Form
|
public partial class AskHotKeyForm : Form
|
||||||
{
|
{
|
||||||
public string NewHotKey;
|
public string NewHotKey => newHotKey;
|
||||||
|
private string newHotKey = string.Empty;
|
||||||
|
|
||||||
public AskHotKeyForm()
|
public AskHotKeyForm()
|
||||||
{
|
{
|
||||||
|
@ -102,13 +103,13 @@ namespace SystemTrayMenu.Controls
|
||||||
case Keys.F22:
|
case Keys.F22:
|
||||||
case Keys.F23:
|
case Keys.F23:
|
||||||
case Keys.F24:
|
case Keys.F24:
|
||||||
NewHotKey = keys.ToString();
|
newHotKey = keys.ToString();
|
||||||
DialogResult = DialogResult.OK;
|
DialogResult = DialogResult.OK;
|
||||||
Close();
|
Close();
|
||||||
break;
|
break;
|
||||||
case Keys.Back:
|
case Keys.Back:
|
||||||
case Keys.Delete:
|
case Keys.Delete:
|
||||||
NewHotKey = string.Empty;
|
newHotKey = string.Empty;
|
||||||
DialogResult = DialogResult.OK;
|
DialogResult = DialogResult.OK;
|
||||||
Close();
|
Close();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -174,8 +174,7 @@ namespace SystemTrayMenu
|
||||||
Location = new Point(x, y);
|
Location = new Point(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AdjustLocationAndSize(int heightMax, int widthPredecessors,
|
public void AdjustLocationAndSize(int heightMax, Menu menuPredecessor)
|
||||||
Menu menuPredecessor)
|
|
||||||
{
|
{
|
||||||
DataGridViewElementStates states = DataGridViewElementStates.None;
|
DataGridViewElementStates states = DataGridViewElementStates.None;
|
||||||
if (!autoResizeRowsDone)
|
if (!autoResizeRowsDone)
|
||||||
|
|
|
@ -413,7 +413,9 @@ namespace SystemTrayMenu.Controls
|
||||||
if (!isDisposed)
|
if (!isDisposed)
|
||||||
{
|
{
|
||||||
icon?.Dispose();
|
icon?.Dispose();
|
||||||
|
Icon?.Dispose();
|
||||||
waitMenuOpen.Dispose();
|
waitMenuOpen.Dispose();
|
||||||
|
Reading.Dispose();
|
||||||
}
|
}
|
||||||
isDisposed = true;
|
isDisposed = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ namespace SystemTrayMenu.Handler
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
hook.Dispose();
|
hook.Dispose();
|
||||||
|
timerKeySearch.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void RegisterHotKey()
|
internal void RegisterHotKey()
|
||||||
|
|
|
@ -4,7 +4,7 @@ using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace SystemTrayMenu.Helper
|
namespace SystemTrayMenu.Helper
|
||||||
{
|
{
|
||||||
public class WindowToTop
|
public static class WindowToTop
|
||||||
{
|
{
|
||||||
[DllImport("user32.dll")]
|
[DllImport("user32.dll")]
|
||||||
private static extern bool IsIconic(IntPtr hWnd);
|
private static extern bool IsIconic(IntPtr hWnd);
|
||||||
|
|
|
@ -39,6 +39,7 @@ namespace SystemTrayMenu
|
||||||
timerFadeIn.Dispose();
|
timerFadeIn.Dispose();
|
||||||
timerFadeOut.Dispose();
|
timerFadeOut.Dispose();
|
||||||
timerFadeHalf.Dispose();
|
timerFadeHalf.Dispose();
|
||||||
|
form.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,11 @@ namespace SystemTrayMenu.Helper
|
||||||
public FileIni(string path)
|
public FileIni(string path)
|
||||||
{
|
{
|
||||||
values = File.ReadLines(path)
|
values = File.ReadLines(path)
|
||||||
.Where(line => (!string.IsNullOrWhiteSpace(line) && !line.StartsWith("#")))
|
.Where(line => !string.IsNullOrWhiteSpace(line) &&
|
||||||
|
!line.StartsWith("#", System.StringComparison.InvariantCulture))
|
||||||
.Select(line => line.Split(new char[] { '=' }, 2, 0))
|
.Select(line => line.Split(new char[] { '=' }, 2, 0))
|
||||||
.ToDictionary(parts => parts[0].Trim(), parts => parts.Length > 1 ? parts[1].Trim() : null);
|
.ToDictionary(parts => parts[0].Trim(), parts =>
|
||||||
|
parts.Length > 1 ? parts[1].Trim() : null);
|
||||||
}
|
}
|
||||||
public string Value(string name, string value = null)
|
public string Value(string name, string value = null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace SystemTrayMenu.Helper
|
namespace SystemTrayMenu.Helper
|
||||||
{
|
{
|
||||||
public class FileUrl
|
public static class FileUrl
|
||||||
{
|
{
|
||||||
private static string browserPath = string.Empty;
|
private static string browserPath = string.Empty;
|
||||||
public static string GetDefaultBrowserPath()
|
public static string GetDefaultBrowserPath()
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace SystemTrayMenu.Helper
|
||||||
/// <example>
|
/// <example>
|
||||||
/// <code>IconReader.GetFileIcon("c:\\general.xls");</code>
|
/// <code>IconReader.GetFileIcon("c:\\general.xls");</code>
|
||||||
/// </example>
|
/// </example>
|
||||||
public class IconReader
|
public static class IconReader
|
||||||
{
|
{
|
||||||
private static readonly ConcurrentDictionary<string, Icon> dictIconCache = new ConcurrentDictionary<string, Icon>();
|
private static readonly ConcurrentDictionary<string, Icon> dictIconCache = new ConcurrentDictionary<string, Icon>();
|
||||||
|
|
||||||
|
@ -144,10 +144,10 @@ namespace SystemTrayMenu.Helper
|
||||||
// Cleanup
|
// Cleanup
|
||||||
if (!linkOverlay)
|
if (!linkOverlay)
|
||||||
{
|
{
|
||||||
User32.DestroyIcon(hIcon);
|
NativeMethods.DestroyIco(hIcon);
|
||||||
}
|
}
|
||||||
|
|
||||||
User32.DestroyIcon(shfi.hIcon);
|
NativeMethods.DestroyIco(shfi.hIcon);
|
||||||
}
|
}
|
||||||
|
|
||||||
return icon;
|
return icon;
|
||||||
|
@ -207,7 +207,7 @@ namespace SystemTrayMenu.Helper
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
User32.DestroyIcon(shfi.hIcon);
|
NativeMethods.DestroyIco(shfi.hIcon);
|
||||||
}
|
}
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
@ -231,7 +231,7 @@ namespace SystemTrayMenu.Helper
|
||||||
|
|
||||||
// This code has been left largely untouched from that in the CRC example. The main changes have been moving
|
// This code has been left largely untouched from that in the CRC example. The main changes have been moving
|
||||||
// the icon reading code over to the IconReader type.
|
// the icon reading code over to the IconReader type.
|
||||||
public class Shell32
|
public static class Shell32
|
||||||
{
|
{
|
||||||
|
|
||||||
public const int MAX_PATH = 256;
|
public const int MAX_PATH = 256;
|
||||||
|
@ -336,7 +336,7 @@ namespace SystemTrayMenu.Helper
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Wraps necessary functions imported from User32.dll. Code courtesy of MSDN Cold Rooster Consulting example.
|
/// Wraps necessary functions imported from User32.dll. Code courtesy of MSDN Cold Rooster Consulting example.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class User32
|
public static class NativeMethods
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Provides access to function required to delete handle. This method is used internally
|
/// Provides access to function required to delete handle. This method is used internally
|
||||||
|
@ -345,8 +345,10 @@ namespace SystemTrayMenu.Helper
|
||||||
/// <param name="hIcon">Pointer to icon handle.</param>
|
/// <param name="hIcon">Pointer to icon handle.</param>
|
||||||
/// <returns>N/A</returns>
|
/// <returns>N/A</returns>
|
||||||
[DllImport("User32.dll")]
|
[DllImport("User32.dll")]
|
||||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Interoperability",
|
private static extern int DestroyIcon(IntPtr hIcon);
|
||||||
"CA1401:P/Invokes should not be visible", Justification = "<Pending>")]
|
public static void DestroyIco(IntPtr hIcon)
|
||||||
public static extern int DestroyIcon(IntPtr hIcon);
|
{
|
||||||
|
_ = DestroyIcon(hIcon);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Resources;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
// General Information about an assembly is controlled through the following
|
||||||
|
@ -21,6 +22,9 @@ using System.Runtime.InteropServices;
|
||||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
[assembly: Guid("116c8741-a9b0-4560-8e82-7cf412894340")]
|
[assembly: Guid("116c8741-a9b0-4560-8e82-7cf412894340")]
|
||||||
|
|
||||||
|
//https://stackoverflow.com/questions/4068360/c-sharp-warning-mark-assemblies-with-neutralresourceslanguageattribute
|
||||||
|
[assembly: NeutralResourcesLanguage("en")]
|
||||||
|
|
||||||
// Version information for an assembly consists of the following four values:
|
// Version information for an assembly consists of the following four values:
|
||||||
//
|
//
|
||||||
// Major Version
|
// Major Version
|
||||||
|
|
|
@ -276,8 +276,7 @@ namespace SystemTrayMenu
|
||||||
widthPredecessors -= newWith;
|
widthPredecessors -= newWith;
|
||||||
}
|
}
|
||||||
|
|
||||||
menu.AdjustLocationAndSize(heightMax,
|
menu.AdjustLocationAndSize(heightMax, menuPredecessor);
|
||||||
widthPredecessors, menuPredecessor);
|
|
||||||
widthPredecessors += menu.Width - menu.Padding.Left;
|
widthPredecessors += menu.Width - menu.Padding.Left;
|
||||||
menuPredecessor = menu;
|
menuPredecessor = menu;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue