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
|
||||
// Title = AssemblyTitle string
|
||||
// </remarks>
|
||||
private NameValueCollection AssemblyAttribs(Assembly a)
|
||||
private static NameValueCollection AssemblyAttribs(Assembly a)
|
||||
{
|
||||
string TypeName;
|
||||
string Name;
|
||||
|
@ -379,18 +379,17 @@ namespace SystemTrayMenu.Controls
|
|||
// <summary>
|
||||
// reads an HKLM Windows Registry key value
|
||||
// </summary>
|
||||
private string RegistryHklmValue(string KeyName, string SubKeyRef)
|
||||
private static string RegistryHklmValue(string KeyName, string SubKeyRef)
|
||||
{
|
||||
RegistryKey rk;
|
||||
string strSysInfoPath = string.Empty;
|
||||
try
|
||||
{
|
||||
rk = Registry.LocalMachine.OpenSubKey(KeyName);
|
||||
return (string)rk.GetValue(SubKeyRef, "");
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return "";
|
||||
RegistryKey rk = Registry.LocalMachine.OpenSubKey(KeyName);
|
||||
strSysInfoPath = (string)rk.GetValue(SubKeyRef, string.Empty);
|
||||
}
|
||||
catch (Exception) { }
|
||||
|
||||
return strSysInfoPath;
|
||||
}
|
||||
|
||||
// <summary>
|
||||
|
@ -398,9 +397,7 @@ namespace SystemTrayMenu.Controls
|
|||
// </summary>
|
||||
private void ShowSysInfo()
|
||||
{
|
||||
string strSysInfoPath = "";
|
||||
|
||||
strSysInfoPath = RegistryHklmValue(@"SOFTWARE\Microsoft\Shared Tools Location", "MSINFO");
|
||||
string strSysInfoPath = RegistryHklmValue(@"SOFTWARE\Microsoft\Shared Tools Location", "MSINFO");
|
||||
if (string.IsNullOrEmpty(strSysInfoPath))
|
||||
{
|
||||
strSysInfoPath = RegistryHklmValue(@"SOFTWARE\Microsoft\Shared Tools\MSINFO", "PATH");
|
||||
|
@ -434,7 +431,7 @@ namespace SystemTrayMenu.Controls
|
|||
// <summary>
|
||||
// populate a listview with the specified key and value strings
|
||||
// </summary>
|
||||
private void Populate(ListView lvw, string Key, string Value)
|
||||
private static void Populate(ListView lvw, string Key, string Value)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Value))
|
||||
{
|
||||
|
|
|
@ -227,7 +227,7 @@ namespace SystemTrayMenu.Controls
|
|||
/// https://www.codeproject.com/Tips/744914/
|
||||
/// Sorted-list-of-available-cultures-in-NET
|
||||
/// </summary>
|
||||
public IEnumerable<CultureInfo> GetCultureList(
|
||||
private static IEnumerable<CultureInfo> GetCultureList(
|
||||
CultureTypes cultureType = CultureTypes.SpecificCultures)
|
||||
{
|
||||
List<CultureInfo> cultureList = CultureInfo.GetCultures(cultureType).ToList();
|
||||
|
|
|
@ -86,6 +86,7 @@ namespace SystemTrayMenu
|
|||
{
|
||||
notifyIcon.Icon = null;
|
||||
notifyIcon.Dispose();
|
||||
load.Dispose();
|
||||
}
|
||||
|
||||
public void LoadingStart()
|
||||
|
|
|
@ -6,7 +6,8 @@ namespace SystemTrayMenu.Controls
|
|||
{
|
||||
public partial class AskHotKeyForm : Form
|
||||
{
|
||||
public string NewHotKey;
|
||||
public string NewHotKey => newHotKey;
|
||||
private string newHotKey = string.Empty;
|
||||
|
||||
public AskHotKeyForm()
|
||||
{
|
||||
|
@ -102,13 +103,13 @@ namespace SystemTrayMenu.Controls
|
|||
case Keys.F22:
|
||||
case Keys.F23:
|
||||
case Keys.F24:
|
||||
NewHotKey = keys.ToString();
|
||||
newHotKey = keys.ToString();
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
break;
|
||||
case Keys.Back:
|
||||
case Keys.Delete:
|
||||
NewHotKey = string.Empty;
|
||||
newHotKey = string.Empty;
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
break;
|
||||
|
|
|
@ -174,8 +174,7 @@ namespace SystemTrayMenu
|
|||
Location = new Point(x, y);
|
||||
}
|
||||
|
||||
public void AdjustLocationAndSize(int heightMax, int widthPredecessors,
|
||||
Menu menuPredecessor)
|
||||
public void AdjustLocationAndSize(int heightMax, Menu menuPredecessor)
|
||||
{
|
||||
DataGridViewElementStates states = DataGridViewElementStates.None;
|
||||
if (!autoResizeRowsDone)
|
||||
|
|
|
@ -413,7 +413,9 @@ namespace SystemTrayMenu.Controls
|
|||
if (!isDisposed)
|
||||
{
|
||||
icon?.Dispose();
|
||||
Icon?.Dispose();
|
||||
waitMenuOpen.Dispose();
|
||||
Reading.Dispose();
|
||||
}
|
||||
isDisposed = true;
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ namespace SystemTrayMenu.Handler
|
|||
public void Dispose()
|
||||
{
|
||||
hook.Dispose();
|
||||
timerKeySearch.Dispose();
|
||||
}
|
||||
|
||||
internal void RegisterHotKey()
|
||||
|
|
|
@ -4,7 +4,7 @@ using System.Runtime.InteropServices;
|
|||
|
||||
namespace SystemTrayMenu.Helper
|
||||
{
|
||||
public class WindowToTop
|
||||
public static class WindowToTop
|
||||
{
|
||||
[DllImport("user32.dll")]
|
||||
private static extern bool IsIconic(IntPtr hWnd);
|
||||
|
|
|
@ -39,6 +39,7 @@ namespace SystemTrayMenu
|
|||
timerFadeIn.Dispose();
|
||||
timerFadeOut.Dispose();
|
||||
timerFadeHalf.Dispose();
|
||||
form.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,9 +10,11 @@ namespace SystemTrayMenu.Helper
|
|||
public FileIni(string 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))
|
||||
.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)
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace SystemTrayMenu.Helper
|
||||
{
|
||||
public class FileUrl
|
||||
public static class FileUrl
|
||||
{
|
||||
private static string browserPath = string.Empty;
|
||||
public static string GetDefaultBrowserPath()
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace SystemTrayMenu.Helper
|
|||
/// <example>
|
||||
/// <code>IconReader.GetFileIcon("c:\\general.xls");</code>
|
||||
/// </example>
|
||||
public class IconReader
|
||||
public static class IconReader
|
||||
{
|
||||
private static readonly ConcurrentDictionary<string, Icon> dictIconCache = new ConcurrentDictionary<string, Icon>();
|
||||
|
||||
|
@ -144,10 +144,10 @@ namespace SystemTrayMenu.Helper
|
|||
// Cleanup
|
||||
if (!linkOverlay)
|
||||
{
|
||||
User32.DestroyIcon(hIcon);
|
||||
NativeMethods.DestroyIco(hIcon);
|
||||
}
|
||||
|
||||
User32.DestroyIcon(shfi.hIcon);
|
||||
NativeMethods.DestroyIco(shfi.hIcon);
|
||||
}
|
||||
|
||||
return icon;
|
||||
|
@ -207,7 +207,7 @@ namespace SystemTrayMenu.Helper
|
|||
}
|
||||
|
||||
// Cleanup
|
||||
User32.DestroyIcon(shfi.hIcon);
|
||||
NativeMethods.DestroyIco(shfi.hIcon);
|
||||
}
|
||||
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
|
||||
// the icon reading code over to the IconReader type.
|
||||
public class Shell32
|
||||
public static class Shell32
|
||||
{
|
||||
|
||||
public const int MAX_PATH = 256;
|
||||
|
@ -336,7 +336,7 @@ namespace SystemTrayMenu.Helper
|
|||
/// <summary>
|
||||
/// Wraps necessary functions imported from User32.dll. Code courtesy of MSDN Cold Rooster Consulting example.
|
||||
/// </summary>
|
||||
public class User32
|
||||
public static class NativeMethods
|
||||
{
|
||||
/// <summary>
|
||||
/// 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>
|
||||
/// <returns>N/A</returns>
|
||||
[DllImport("User32.dll")]
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Interoperability",
|
||||
"CA1401:P/Invokes should not be visible", Justification = "<Pending>")]
|
||||
public static extern int DestroyIcon(IntPtr hIcon);
|
||||
private static extern int DestroyIcon(IntPtr hIcon);
|
||||
public static void DestroyIco(IntPtr hIcon)
|
||||
{
|
||||
_ = DestroyIcon(hIcon);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 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
|
||||
[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:
|
||||
//
|
||||
// Major Version
|
||||
|
|
|
@ -276,8 +276,7 @@ namespace SystemTrayMenu
|
|||
widthPredecessors -= newWith;
|
||||
}
|
||||
|
||||
menu.AdjustLocationAndSize(heightMax,
|
||||
widthPredecessors, menuPredecessor);
|
||||
menu.AdjustLocationAndSize(heightMax, menuPredecessor);
|
||||
widthPredecessors += menu.Width - menu.Padding.Left;
|
||||
menuPredecessor = menu;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue