[Feature] CodeBuity&Refactor #49, [Feature] Code review tool #10, Version 0.9.2.12

This commit is contained in:
Markus Hofknecht 2020-03-29 13:20:18 +02:00
parent c08336df9e
commit 3b0903e39e
24 changed files with 166 additions and 314 deletions

View file

@ -1,4 +1,5 @@
using System;
using System.Globalization;
using System.Linq;
using System.Windows.Forms;
using SystemTrayMenu.DataClasses;
@ -98,7 +99,7 @@ namespace SystemTrayMenu.Handler
char.IsWhiteSpace(e.KeyChar) ||
char.IsSeparator(e.KeyChar))
{
string letter = e.KeyChar.ToString();
string letter = e.KeyChar.ToString(CultureInfo.InvariantCulture);
timerKeySearch.Stop();
@ -108,7 +109,7 @@ namespace SystemTrayMenu.Handler
KeySearchString += letter;
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
SelectByKey(Keys.None, letter);
@ -169,8 +170,8 @@ namespace SystemTrayMenu.Handler
{
if (KeepSelection)
{
// Is current selection is still valid for this search then skip selecting different item
if (textselected.ToLower().StartsWith(keyInput.ToLower()))
// If current selection is still valid for this search then skip selecting different item
if (textselected.StartsWith(keyInput, true, CultureInfo.InvariantCulture))
{
return;
}
@ -380,7 +381,7 @@ namespace SystemTrayMenu.Handler
DataGridViewRow row = dgv.Rows[i];
RowData rowData = (RowData)row.Tag;
string text = row.Cells[1].Value.ToString();
if (text.ToLower().StartsWith(keyInput.ToLower()))
if (text.StartsWith(keyInput, true, CultureInfo.InvariantCulture))
{
iRowKey = rowData.RowIndex;
rowData.IsSelectedByKeyboard = true;

View file

@ -214,6 +214,7 @@ namespace SystemTrayMenu
public void Dispose()
{
worker.Dispose();
keyboardInput.Dispose();
menuNotifyIcon.Dispose();
fastLeave.Dispose();
@ -402,6 +403,18 @@ namespace SystemTrayMenu
Log.Info($"UnauthorizedAccessException:'{path}'");
menuData.Validity = MenuDataValidity.NoAccess;
}
//catch (PathTooLongException ex)
//{
//}
//catch (DirectoryNotFoundException ex)
//{
//}
//catch (IOException ex)
//{
//}
catch (Exception ex)
{
Log.Error($"path:'{path}'", ex);

View file

@ -7,14 +7,14 @@ namespace SystemTrayMenu
{
public static readonly List<string> Languages =
new List<string>() { "en", "de" };
public static Color File = Color.White;
public static Color Folder = Color.White;
public static Color ColorSelectedItem = AppColors.Blue;
public static Color ColorOpenFolder = AppColors.Green;
public static Color ColorTitleWarning = AppColors.Red;
public static Color ColorTitleSelected = AppColors.Yellow;
public static Color ColorTitleBackground = AppColors.YellowSlightly;
public static int KeySearchInterval = 1000;
public static readonly Color File = Color.White;
public static readonly Color Folder = Color.White;
public static readonly Color ColorSelectedItem = AppColors.Blue;
public static readonly Color ColorOpenFolder = AppColors.Green;
public static readonly Color ColorTitleWarning = AppColors.Red;
public static readonly Color ColorTitleSelected = AppColors.Yellow;
public static readonly Color ColorTitleBackground = AppColors.YellowSlightly;
public const int KeySearchInterval = 1000;
public const int MenuRowsHeight = 18;
public const int LengthMax = 37;
public const int Scrollspeed = 4;
@ -28,17 +28,17 @@ namespace SystemTrayMenu
public const double OpacityOutStep = 0.05;
public const double OpacityHalfStep = 0.01;
public const int MenusMax = 50;
public static int MaxClicksInQueue = 1;
public const int MaxClicksInQueue = 1;
}
public static class AppColors
{
public static Color Blue = Color.FromArgb(204, 232, 255);
public static Color BlueSelectedInactive = Color.FromArgb(217, 217, 217);
public static Color Green = Color.FromArgb(194, 245, 222);
public static Color GreenBackgroundInactive = Color.FromArgb(217, 217, 217);
public static Color Red = Color.FromArgb(255, 204, 232);
public static Color Yellow = Color.LightYellow;
public static Color YellowSlightly = Color.Azure;
public static readonly Color Blue = Color.FromArgb(204, 232, 255);
public static readonly Color BlueSelectedInactive = Color.FromArgb(217, 217, 217);
public static readonly Color Green = Color.FromArgb(194, 245, 222);
public static readonly Color GreenBackgroundInactive = Color.FromArgb(217, 217, 217);
public static readonly Color Red = Color.FromArgb(255, 204, 232);
public static readonly Color Yellow = Color.LightYellow;
public static readonly Color YellowSlightly = Color.Azure;
}
}

View file

@ -2,14 +2,14 @@
namespace SystemTrayMenu.DataClasses
{
public enum MenuDataValidity
internal enum MenuDataValidity
{
Valid,
Invalid,
NoAccess
}
public struct MenuData
internal struct MenuData
{
public List<RowData> RowDatas;
public MenuDataValidity Validity;

View file

@ -18,25 +18,25 @@ namespace SystemTrayMenu.DataClasses
public class RowData : IDisposable
{
public event Action<object, EventArgs> OpenMenu;
public BackgroundWorker Reading = new BackgroundWorker();
public FileInfo FileInfo;
public Menu SubMenu;
public Icon Icon;
public bool IsSelected;
public bool IsSelectedByKeyboard;
public bool ContainsMenu;
public bool IsContextMenuOpen;
public bool ResolvedFileNotFound;
public bool IsResolvedLnk;
public bool IsLoading = false;
public bool RestartLoading = false;
public bool HiddenEntry;
public string WorkingDirectory;
public string Arguments;
public string TargetFilePath;
public string TargetFilePathOrig;
public string Text;
public int RowIndex;
internal BackgroundWorker Reading = new BackgroundWorker();
internal FileInfo FileInfo;
internal Menu SubMenu;
internal Icon Icon;
internal bool IsSelected;
internal bool IsSelectedByKeyboard;
internal bool ContainsMenu;
internal bool IsContextMenuOpen;
internal bool ResolvedFileNotFound;
internal bool IsResolvedLnk;
internal bool IsLoading = false;
internal bool RestartLoading = false;
internal bool HiddenEntry;
internal string WorkingDirectory;
internal string Arguments;
internal string TargetFilePath;
internal string TargetFilePathOrig;
internal string Text;
internal int RowIndex;
private readonly WaitMenuOpen waitMenuOpen = new WaitMenuOpen();
private bool isDisposed = false;
@ -279,16 +279,16 @@ namespace SystemTrayMenu.DataClasses
try
{
//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,
WorkingDirectory = WorkingDirectory,
CreateNoWindow = true
}
};
p.Start();
};
p.Start();
}
catch (Exception ex)
{

View file

@ -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")]

View file

@ -10,7 +10,7 @@ namespace SystemTrayMenu.Helper
/// </summary>
private class Window : NativeWindow, IDisposable
{
private static readonly int WM_HOTKEY = 0x0312;
private const int WM_HOTKEY = 0x0312;
public Window()
{
@ -73,7 +73,7 @@ namespace SystemTrayMenu.Helper
/// </summary>
/// <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>
public void RegisterHotKey(KeyboardHookModifierKeys modifier, Keys key)
internal void RegisterHotKey(KeyboardHookModifierKeys modifier, Keys key)
{
// increment the counter.
_currentId = _currentId + 1;
@ -88,7 +88,7 @@ namespace SystemTrayMenu.Helper
/// <summary>
/// A hot key has been pressed.
/// </summary>
public event EventHandler<KeyPressedEventArgs> KeyPressed;
internal event EventHandler<KeyPressedEventArgs> KeyPressed;
#region IDisposable Members
@ -110,7 +110,7 @@ namespace SystemTrayMenu.Helper
/// <summary>
/// Event Args for the event that is fired after the hot key has been pressed.
/// </summary>
public class KeyPressedEventArgs : EventArgs
internal class KeyPressedEventArgs : EventArgs
{
private readonly KeyboardHookModifierKeys _modifier;
private readonly Keys _key;
@ -121,16 +121,16 @@ namespace SystemTrayMenu.Helper
_key = key;
}
public KeyboardHookModifierKeys Modifier => _modifier;
internal KeyboardHookModifierKeys Modifier => _modifier;
public Keys Key => _key;
internal Keys Key => _key;
}
/// <summary>
/// The enumeration of possible modifiers.
/// </summary>
[Flags]
public enum KeyboardHookModifierKeys : uint
internal enum KeyboardHookModifierKeys : uint
{
Alt = 1,
Control = 2,

View file

@ -14,6 +14,7 @@ namespace SystemTrayMenu.Helper.Taskbar
Bottom,
}
//Microsoft.WindowsAPICodePack.Taskbar.TaskbarManager do not have the bounds implemented?
public sealed class Taskbar
{
private const string ClassName = "Shell_TrayWnd";

View file

@ -5,33 +5,36 @@ namespace SystemTrayMenu.NativeDllImport
{
public static partial class NativeMethods
{
[StructLayout(LayoutKind.Sequential)]
public struct SHITEMID
{
public ushort cb;
[MarshalAs(UnmanagedType.LPArray)]
public byte[] abID;
}
//[StructLayout(LayoutKind.Sequential)]
//[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 byte[] abID;
//}
[StructLayout(LayoutKind.Sequential)]
public struct ITEMIDLIST
{
public SHITEMID mkid;
}
//[StructLayout(LayoutKind.Sequential)]
//[System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1815:Override equals and operator equals on value types", Justification = "<Pending>")]
//internal struct ITEMIDLIST
//{
// public SHITEMID mkid;
//}
[StructLayout(LayoutKind.Sequential)]
public struct BROWSEINFO
{
public IntPtr hwndOwner;
public IntPtr pidlRoot;
public IntPtr pszDisplayName;
[MarshalAs(UnmanagedType.LPTStr)]
public string lpszTitle;
public uint ulFlags;
public IntPtr lpfn;
public int lParam;
public IntPtr iImage;
}
//[StructLayout(LayoutKind.Sequential)]
//[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 pszDisplayName;
// [MarshalAs(UnmanagedType.LPTStr)]
// public string lpszTitle;
// public uint ulFlags;
// public IntPtr lpfn;
// public int lParam;
// public IntPtr iImage;
//}
// Browsing for directory.
//public const uint BIF_RETURNONLYFSDIRS = 0x0001;
@ -78,7 +81,7 @@ namespace SystemTrayMenu.NativeDllImport
int i,
int flags);
public static void Comctl32ImageList_GetIcon(IntPtr hIcon)
public static void Comctl32ImageListGetIcon(IntPtr hIcon)
{
_ = DestroyIcon(hIcon);
}

View file

@ -8,12 +8,12 @@ namespace SystemTrayMenu.NativeDllImport
[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)
internal static IntPtr Shell32SHAppBarMessage(ABM dwMessage, [In] ref APPBARDATA pData)
{
return SHAppBarMessage(dwMessage, ref pData);
}
public enum ABM : uint
internal enum ABM : uint
{
New = 0x00000000,
Remove = 0x00000001,
@ -28,7 +28,7 @@ namespace SystemTrayMenu.NativeDllImport
SetState = 0x0000000A,
}
public enum ABE : uint
internal enum ABE : uint
{
Left = 0,
Top = 1,
@ -36,14 +36,14 @@ namespace SystemTrayMenu.NativeDllImport
Bottom = 3
}
public static class ABS
internal static class ABS
{
public const int Autohide = 0x0000001;
public const int AlwaysOnTop = 0x0000002;
}
[StructLayout(LayoutKind.Sequential)]
public struct APPBARDATA
internal struct APPBARDATA
{
public uint cbSize;
public IntPtr hWnd;
@ -54,7 +54,7 @@ namespace SystemTrayMenu.NativeDllImport
}
[StructLayout(LayoutKind.Sequential)]
public struct RECT
internal struct RECT
{
public int left;
public int top;

View file

@ -16,7 +16,7 @@ namespace SystemTrayMenu.NativeDllImport
uint uFlags
);
public static IntPtr Shell32SHGetFileInfo(
internal static IntPtr Shell32SHGetFileInfo(
string pszPath,
uint dwFileAttributes,
ref SHFILEINFO psfi,
@ -32,7 +32,7 @@ namespace SystemTrayMenu.NativeDllImport
}
[StructLayout(LayoutKind.Sequential)]
public struct SHFILEINFO
internal struct SHFILEINFO
{
public const int NAMESIZE = 80;
public IntPtr hIcon;

View file

@ -9,14 +9,14 @@ namespace SystemTrayMenu.NativeDllImport
[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);
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);
}
// Specifies how TrackPopupMenuEx positions the shortcut menu horizontally
[Flags]
public enum TPM : uint
internal enum TPM : uint
{
LEFTBUTTON = 0x0000,
RIGHTBUTTON = 0x0002,

View file

@ -35,5 +35,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.9.2.11")]
[assembly: AssemblyFileVersion("0.9.2.11")]
[assembly: AssemblyVersion("0.9.2.12")]
[assembly: AssemblyFileVersion("0.9.2.12")]

View file

@ -138,7 +138,6 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Config\Config.cs" />
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="NativeDllImport\DestroyMenu.cs" />
<Compile Include="NativeDllImport\CreatePopupMenu.cs" />
<Compile Include="NativeDllImport\GetMenuDefaultItem.cs" />
@ -157,9 +156,7 @@
<Compile Include="UserInterface\AskHotKeyForm.Designer.cs">
<DependentUpon>AskHotKeyForm.cs</DependentUpon>
</Compile>
<Compile Include="UserInterface\DragDropHintForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="UserInterface\DragDropHintForm.cs" />
<Compile Include="UserInterface\DragDropHintForm.Designer.cs">
<DependentUpon>DragDropHintForm.cs</DependentUpon>
</Compile>
@ -181,11 +178,8 @@
<Compile Include="Helpers\MessageFilter.cs" />
<Compile Include="Utilities\Language.cs" />
<Compile Include="Utilities\Scaling.cs" />
<Compile Include="UserInterface\ShellContextMenu\HookEventArgs.cs" />
<Compile Include="UserInterface\ShellContextMenu\ShellContextMenuException.cs" />
<Compile Include="UserInterface\ShellContextMenu\HookType.cs" />
<Compile Include="UserInterface\ShellContextMenu\ShellHelper.cs" />
<Compile Include="UserInterface\ShellContextMenu\LocalWindowsHook.cs" />
<Compile Include="UserInterface\ShellContextMenu\ShellContextMenu.cs" />
<Compile Include="Utilities\File\FileUrl.cs" />
<Compile Include="Business\WaitFastLeave.cs" />
@ -329,9 +323,6 @@
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Connected Services\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers">
<Version>2.9.8</Version>

View file

@ -2,6 +2,7 @@
using System;
using System.Collections.Specialized;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Text.RegularExpressions;
@ -220,7 +221,7 @@ namespace SystemTrayMenu.UserInterface
}
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)))
{
dt = dt.AddHours(1);
@ -267,35 +268,35 @@ namespace SystemTrayMenu.UserInterface
switch (TypeName)
{
case "System.CLSCompliantAttribute":
Value = ((CLSCompliantAttribute)attrib).IsCompliant.ToString(); break;
Value = ((CLSCompliantAttribute)attrib).IsCompliant.ToString(CultureInfo.InvariantCulture); break;
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":
Value = ((AssemblyCompanyAttribute)attrib).Company.ToString(); break;
Value = ((AssemblyCompanyAttribute)attrib).Company.ToString(CultureInfo.InvariantCulture); break;
case "System.Reflection.AssemblyConfigurationAttribute":
Value = ((AssemblyConfigurationAttribute)attrib).Configuration.ToString(); break;
Value = ((AssemblyConfigurationAttribute)attrib).Configuration.ToString(CultureInfo.InvariantCulture); break;
case "System.Reflection.AssemblyCopyrightAttribute":
Value = ((AssemblyCopyrightAttribute)attrib).Copyright.ToString(); break;
Value = ((AssemblyCopyrightAttribute)attrib).Copyright.ToString(CultureInfo.InvariantCulture); break;
case "System.Reflection.AssemblyDefaultAliasAttribute":
Value = ((AssemblyDefaultAliasAttribute)attrib).DefaultAlias.ToString(); break;
Value = ((AssemblyDefaultAliasAttribute)attrib).DefaultAlias.ToString(CultureInfo.InvariantCulture); break;
case "System.Reflection.AssemblyDelaySignAttribute":
Value = ((AssemblyDelaySignAttribute)attrib).DelaySign.ToString(); break;
Value = ((AssemblyDelaySignAttribute)attrib).DelaySign.ToString(CultureInfo.InvariantCulture); break;
case "System.Reflection.AssemblyDescriptionAttribute":
Value = ((AssemblyDescriptionAttribute)attrib).Description.ToString(); break;
Value = ((AssemblyDescriptionAttribute)attrib).Description.ToString(CultureInfo.InvariantCulture); break;
case "System.Reflection.AssemblyInformationalVersionAttribute":
Value = ((AssemblyInformationalVersionAttribute)attrib).InformationalVersion.ToString(); break;
Value = ((AssemblyInformationalVersionAttribute)attrib).InformationalVersion.ToString(CultureInfo.InvariantCulture); break;
case "System.Reflection.AssemblyKeyFileAttribute":
Value = ((AssemblyKeyFileAttribute)attrib).KeyFile.ToString(); break;
Value = ((AssemblyKeyFileAttribute)attrib).KeyFile.ToString(CultureInfo.InvariantCulture); break;
case "System.Reflection.AssemblyProductAttribute":
Value = ((AssemblyProductAttribute)attrib).Product.ToString(); break;
Value = ((AssemblyProductAttribute)attrib).Product.ToString(CultureInfo.InvariantCulture); break;
case "System.Reflection.AssemblyTrademarkAttribute":
Value = ((AssemblyTrademarkAttribute)attrib).Trademark.ToString(); break;
Value = ((AssemblyTrademarkAttribute)attrib).Trademark.ToString(CultureInfo.InvariantCulture); break;
case "System.Reflection.AssemblyTitleAttribute":
Value = ((AssemblyTitleAttribute)attrib).Title.ToString(); break;
Value = ((AssemblyTitleAttribute)attrib).Title.ToString(CultureInfo.InvariantCulture); break;
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":
Value = ((System.Resources.SatelliteContractVersionAttribute)attrib).Version.ToString(); break;
Value = ((System.Resources.SatelliteContractVersionAttribute)attrib).Version.ToString(CultureInfo.InvariantCulture); break;
case "System.Runtime.InteropServices.ComCompatibleVersionAttribute":
{
System.Runtime.InteropServices.ComCompatibleVersionAttribute x;
@ -303,9 +304,9 @@ namespace SystemTrayMenu.UserInterface
Value = x.MajorVersion + "." + x.MinorVersion + "." + x.RevisionNumber + "." + x.BuildNumber; break;
}
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":
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":
{
System.Runtime.InteropServices.TypeLibVersionAttribute x;
@ -343,7 +344,7 @@ namespace SystemTrayMenu.UserInterface
}
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
try
@ -524,7 +525,7 @@ namespace SystemTrayMenu.UserInterface
}
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("%product%", EntryAssemblyAttrib("product"));
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("%builddate%", EntryAssemblyAttrib("builddate"));
return s;
@ -599,7 +600,7 @@ namespace SystemTrayMenu.UserInterface
// this assembly property is only available in framework versions 1.1+
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);
foreach (string strKey in nvc)
@ -714,7 +715,7 @@ namespace SystemTrayMenu.UserInterface
string strAssemblyName;
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);
TabPanelDetails.SelectedTab = TabPageAssemblyDetails;
}
@ -725,7 +726,7 @@ namespace SystemTrayMenu.UserInterface
// </summary>
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);
}
@ -738,9 +739,9 @@ namespace SystemTrayMenu.UserInterface
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;
@ -790,9 +791,10 @@ namespace SystemTrayMenu.UserInterface
public int Compare(object x, object y)
{
int intResult =
string.Compare(((ListViewItem)x).SubItems[_intCol].Text, ((ListViewItem)y).SubItems[_intCol].Text);
int intResult = string.Compare(
((ListViewItem)x).SubItems[_intCol].Text,
((ListViewItem)y).SubItems[_intCol].Text,
CultureInfo.InvariantCulture, CompareOptions.None);
if (_IsAscending)
{
return intResult;

View file

@ -233,7 +233,7 @@ namespace SystemTrayMenu.Helper
{
List<CultureInfo> cultureList = CultureInfo.GetCultures(cultureType).ToList();
cultureList.Sort((p1, p2) => string.Compare(
p1.NativeName, p2.NativeName, true));
p1.NativeName, p2.NativeName, true, CultureInfo.InvariantCulture));
return cultureList;
}

View file

@ -31,7 +31,8 @@ namespace SystemTrayMenu.UserInterface
public bool IsFadingOut => FadeForm.IsFadingOut;
public int Level = 0;
internal int Level = 0;
private readonly FadeForm FadeForm = null;
private bool autoResizeRowsDone = false;

View file

@ -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
}
}

View file

@ -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
}
}

View file

@ -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);
// }
//}

View file

@ -583,37 +583,6 @@ namespace SystemTrayMenu.Utilities
}
#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
private IContextMenu _oContextMenu;
private IContextMenu2 _oContextMenu2;

View file

@ -1,19 +1,31 @@
using System;
using System.Runtime.Serialization;
namespace SystemTrayMenu.Helper
{
[Serializable]
public class ShellContextMenuException : Exception
{
/// <summary>Default contructor</summary>
public ShellContextMenuException()
{
// Add any type-specific logic, and supply the default message.
}
/// <summary>Constructor with message</summary>
/// <param name="message">Message</param>
public ShellContextMenuException(string message)
: base(message)
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.
}
}

View file

@ -126,12 +126,13 @@ namespace SystemTrayMenu.Utilities
public interface IPersistFile : IPersist
{
new void GetClassID(out Guid pClassID);
[PreserveSig]
int IsDirty();
[PreserveSig]
void Load([In, MarshalAs(UnmanagedType.LPWStr)]
string pszFileName, uint dwMode);
string pszFileName, uint dwMode);
[PreserveSig]
void Save([In, MarshalAs(UnmanagedType.LPWStr)] string pszFileName,
@ -160,8 +161,6 @@ namespace SystemTrayMenu.Utilities
{
ShellLink link = new ShellLink();
((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);
WIN32_FIND_DATAW data = new WIN32_FIND_DATAW();
((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)
{
int pos = text.IndexOf(search);
int pos = text.IndexOf(search, StringComparison.InvariantCulture);
if (pos < 0)
{
return text;

View file

@ -42,8 +42,8 @@ namespace SystemTrayMenu.Utilities
{
bool isExtensionWitSameIcon = true;
List<string> extensionsWithDiffIcons = new List<string>
{ ".exe", ".lnk", ".ico", ".url" };
if (extensionsWithDiffIcons.Contains(fileExtension.ToLower()))
{ ".EXE", ".LNK", ".ICO", ".URL" };
if (extensionsWithDiffIcons.Contains(fileExtension.ToUpperInvariant()))
{
isExtensionWitSameIcon = false;
}