mirror of
https://github.com/Hofknecht/SystemTrayMenu.git
synced 2024-05-17 19:02:27 +12:00
Code Cleanup, version 1.0.23.0
This commit is contained in:
parent
7c234efad6
commit
d3e4c655ae
|
@ -18,6 +18,9 @@ namespace SystemTrayMenu
|
|||
private readonly AppNotifyIcon menuNotifyIcon = new AppNotifyIcon();
|
||||
private readonly Menus menus = new Menus();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="App"/> class.
|
||||
/// </summary>
|
||||
public App()
|
||||
{
|
||||
AppRestart.BeforeRestarting += Dispose;
|
||||
|
@ -36,6 +39,7 @@ namespace SystemTrayMenu
|
|||
menus.MainPreload();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Dispose()
|
||||
{
|
||||
SystemEvents.DisplaySettingsChanged -= AppRestart.ByDisplaySettings;
|
||||
|
|
|
@ -41,6 +41,7 @@ namespace SystemTrayMenu.Handler
|
|||
|
||||
internal bool InUse { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Dispose()
|
||||
{
|
||||
hook.Dispose();
|
||||
|
|
|
@ -281,6 +281,7 @@ namespace SystemTrayMenu.Business
|
|||
|
||||
private List<Menu> AsList => AsEnumerable.ToList();
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Dispose()
|
||||
{
|
||||
workerMainMenu.Dispose();
|
||||
|
|
|
@ -20,6 +20,7 @@ namespace SystemTrayMenu.Handler
|
|||
|
||||
public event EventHandlerEmpty LeaveTriggered;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Dispose()
|
||||
{
|
||||
timerLeaveCheck.Dispose();
|
||||
|
|
|
@ -39,6 +39,7 @@ namespace SystemTrayMenu.Handler
|
|||
|
||||
internal bool MouseActive { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Dispose()
|
||||
{
|
||||
timerStartLoad.Stop();
|
||||
|
|
|
@ -13,6 +13,9 @@ namespace SystemTrayMenu.DataClasses
|
|||
using SystemTrayMenu.Utilities;
|
||||
using Menu = SystemTrayMenu.UserInterface.Menu;
|
||||
|
||||
/// <summary>
|
||||
/// Contains data of row.
|
||||
/// </summary>
|
||||
internal class RowData
|
||||
{
|
||||
private static readonly Icon White50PercentageIcon = Properties.Resources.White50Percentage;
|
||||
|
@ -23,43 +26,97 @@ namespace SystemTrayMenu.DataClasses
|
|||
private string text;
|
||||
private Icon icon;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RowData"/> class.
|
||||
/// </summary>
|
||||
internal RowData()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets fileInfo.
|
||||
/// </summary>
|
||||
internal FileInfo FileInfo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets SubMenu.
|
||||
/// </summary>
|
||||
internal Menu SubMenu { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether IsMenuOpen.
|
||||
/// </summary>
|
||||
internal bool IsMenuOpen { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether IsSelected.
|
||||
/// </summary>
|
||||
internal bool IsSelected { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether ContainsMenu.
|
||||
/// </summary>
|
||||
internal bool ContainsMenu { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether IsContextMenuOpen.
|
||||
/// </summary>
|
||||
internal bool IsContextMenuOpen { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether IsResolvedLnk.
|
||||
/// </summary>
|
||||
internal bool IsResolvedLnk { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether is a HiddenEntry.
|
||||
/// </summary>
|
||||
internal bool HiddenEntry { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets TargetFilePath.
|
||||
/// </summary>
|
||||
internal string TargetFilePath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets TargetFilePathOrig.
|
||||
/// </summary>
|
||||
internal string TargetFilePathOrig { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets RowIndex.
|
||||
/// </summary>
|
||||
internal int RowIndex { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets MenuLevel.
|
||||
/// </summary>
|
||||
internal int MenuLevel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether IconLoading.
|
||||
/// </summary>
|
||||
internal bool IconLoading { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets FilePathIcon.
|
||||
/// </summary>
|
||||
internal string FilePathIcon { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Set text of row.
|
||||
/// </summary>
|
||||
/// <param name="text">text of row.</param>
|
||||
internal void SetText(string text)
|
||||
{
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// SetData.
|
||||
/// </summary>
|
||||
/// <param name="data">data.</param>
|
||||
/// <param name="dataTable">dataTable.</param>
|
||||
internal void SetData(RowData data, DataTable dataTable)
|
||||
{
|
||||
DataRow row = dataTable.Rows.Add();
|
||||
|
@ -87,6 +144,12 @@ namespace SystemTrayMenu.DataClasses
|
|||
row[2] = data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ReadIcon.
|
||||
/// </summary>
|
||||
/// <param name="isDirectory">isDirectory.</param>
|
||||
/// <param name="resolvedLnkPath">resolvedLnkPath.</param>
|
||||
/// <returns>isLnkDirectory.</returns>
|
||||
internal bool ReadIcon(bool isDirectory, ref string resolvedLnkPath)
|
||||
{
|
||||
bool isLnkDirectory = false;
|
||||
|
@ -150,6 +213,12 @@ namespace SystemTrayMenu.DataClasses
|
|||
return isLnkDirectory;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// MouseDown.
|
||||
/// </summary>
|
||||
/// <param name="dgv">dgv.</param>
|
||||
/// <param name="e">e.</param>
|
||||
/// <param name="toCloseByDoubleClick">toCloseByDoubleClick.</param>
|
||||
internal void MouseDown(DataGridView dgv, MouseEventArgs e, out bool toCloseByDoubleClick)
|
||||
{
|
||||
toCloseByDoubleClick = false;
|
||||
|
@ -191,6 +260,11 @@ namespace SystemTrayMenu.DataClasses
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DoubleClick.
|
||||
/// </summary>
|
||||
/// <param name="e">e.</param>
|
||||
/// <param name="toCloseByDoubleClick">toCloseByDoubleClick.</param>
|
||||
internal void DoubleClick(MouseEventArgs e, out bool toCloseByDoubleClick)
|
||||
{
|
||||
toCloseByDoubleClick = false;
|
||||
|
@ -209,6 +283,10 @@ namespace SystemTrayMenu.DataClasses
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ReadLoadedIcon.
|
||||
/// </summary>
|
||||
/// <returns>Icon.</returns>
|
||||
internal Icon ReadLoadedIcon()
|
||||
{
|
||||
if (ContainsMenu)
|
||||
|
|
|
@ -5,9 +5,4 @@
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA0001:XML comment analysis is disabled due to project configuration", Justification = "no idea what this is")]
|
||||
|
||||
[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "we need to document")]
|
||||
[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1601:Partial elements should be documented", Justification = "we need to document")]
|
||||
[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1602:Enumeration items should be documented", Justification = "we need to document")]
|
||||
|
||||
[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1101:Prefix local calls with this", Justification = "Standard codecleanup removes the this")]
|
||||
|
|
|
@ -28,6 +28,7 @@ namespace SystemTrayMenu.Helper
|
|||
|
||||
internal event Action<object, DataGridViewCellEventArgs> RowMouseLeave;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
|
|
|
@ -51,6 +51,7 @@ namespace SystemTrayMenu.UserInterface
|
|||
|
||||
internal bool IsHiding => state == FadingState.Hide;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
|
|
|
@ -12,16 +12,15 @@ namespace SystemTrayMenu.Helper
|
|||
/// </summary>
|
||||
internal class KeyPressedEventArgs : EventArgs
|
||||
{
|
||||
private readonly KeyboardHookModifierKeys modifier;
|
||||
private readonly Keys key;
|
||||
|
||||
internal KeyPressedEventArgs(KeyboardHookModifierKeys modifier, Keys key)
|
||||
{
|
||||
this.modifier = modifier;
|
||||
this.Modifier = modifier;
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
internal KeyboardHookModifierKeys Modifier => modifier;
|
||||
internal KeyboardHookModifierKeys Modifier { get; }
|
||||
|
||||
internal Keys Key => key;
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ namespace SystemTrayMenu.Helper
|
|||
/// </summary>
|
||||
internal event EventHandler<KeyPressedEventArgs> KeyPressed;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Dispose()
|
||||
{
|
||||
// unregister all the registered hot keys.
|
||||
|
|
|
@ -8,6 +8,7 @@ namespace SystemTrayMenu.Helper
|
|||
|
||||
internal class WindowsExplorerSort : IComparer<string>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public int Compare(string x, string y)
|
||||
{
|
||||
return DllImports.NativeMethods.ShlwapiStrCmpLogicalW(x, y);
|
||||
|
|
|
@ -31,7 +31,6 @@ namespace SystemTrayMenu.UserInterface
|
|||
private string entryAssemblyName;
|
||||
private string callingAssemblyName;
|
||||
private string executingAssemblyName;
|
||||
private Assembly entryAssembly;
|
||||
private NameValueCollection entryAssemblyAttribCollection;
|
||||
|
||||
public AboutBox()
|
||||
|
@ -49,11 +48,7 @@ namespace SystemTrayMenu.UserInterface
|
|||
// This is usually read-only, but in some weird cases (Smart Client apps)
|
||||
// you won't have an entry assembly, so you may want to set this manually.
|
||||
// </remarks>
|
||||
public Assembly AppEntryAssembly
|
||||
{
|
||||
get => entryAssembly;
|
||||
set => entryAssembly = value;
|
||||
}
|
||||
public Assembly AppEntryAssembly { get; set; }
|
||||
|
||||
// <summary>
|
||||
// single line of text to show in the application title section of the about box dialog
|
||||
|
@ -585,7 +580,7 @@ namespace SystemTrayMenu.UserInterface
|
|||
private void PopulateLabels()
|
||||
{
|
||||
// get entry assembly attribs
|
||||
entryAssemblyAttribCollection = AssemblyAttribs(entryAssembly);
|
||||
entryAssemblyAttribCollection = AssemblyAttribs(AppEntryAssembly);
|
||||
|
||||
// set icon from parent, if present
|
||||
if (Owner != null)
|
||||
|
@ -646,14 +641,14 @@ namespace SystemTrayMenu.UserInterface
|
|||
private void AboutBox_Load(object sender, EventArgs e)
|
||||
{
|
||||
// if the user didn't provide an assembly, try to guess which one is the entry assembly
|
||||
if (entryAssembly == null)
|
||||
if (AppEntryAssembly == null)
|
||||
{
|
||||
entryAssembly = Assembly.GetEntryAssembly();
|
||||
AppEntryAssembly = Assembly.GetEntryAssembly();
|
||||
}
|
||||
|
||||
if (entryAssembly == null)
|
||||
if (AppEntryAssembly == null)
|
||||
{
|
||||
entryAssembly = Assembly.GetExecutingAssembly();
|
||||
AppEntryAssembly = Assembly.GetExecutingAssembly();
|
||||
}
|
||||
|
||||
executingAssemblyName = Assembly.GetExecutingAssembly().GetName().Name;
|
||||
|
|
|
@ -80,6 +80,7 @@ namespace SystemTrayMenu.UserInterface
|
|||
|
||||
public event EventHandlerEmpty Exit;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Dispose()
|
||||
{
|
||||
notifyIcon.Icon = null;
|
||||
|
|
|
@ -141,6 +141,7 @@ namespace SystemTrayMenu.UserInterface
|
|||
|
||||
public int Delta => Value - lastValue;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool AutoSize
|
||||
{
|
||||
get => base.AutoSize;
|
||||
|
@ -207,12 +208,14 @@ namespace SystemTrayMenu.UserInterface
|
|||
Invalidate();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
timerMouseStillClicked.Dispose();
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
|
||||
|
|
|
@ -9,6 +9,7 @@ namespace SystemTrayMenu.UserInterface
|
|||
|
||||
internal class ScrollbarControlDesigner : ControlDesigner
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override SelectionRules SelectionRules
|
||||
{
|
||||
get
|
||||
|
|
|
@ -30,11 +30,13 @@ namespace SystemTrayMenu.UserInterface.FolderBrowseDialog
|
|||
/// </summary>
|
||||
public string Folder { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public DialogResult ShowDialog()
|
||||
{
|
||||
return ShowDialog(owner: new WindowWrapper(IntPtr.Zero));
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public DialogResult ShowDialog(IWin32Window owner)
|
||||
{
|
||||
if (Environment.OSVersion.Version.Major >= 6)
|
||||
|
@ -47,6 +49,7 @@ namespace SystemTrayMenu.UserInterface.FolderBrowseDialog
|
|||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public DialogResult ShowVistaDialog(IWin32Window owner)
|
||||
{
|
||||
NativeMethods.IFileDialog frm = (NativeMethods.IFileDialog)new NativeMethods.FileOpenDialogRCW();
|
||||
|
@ -110,6 +113,7 @@ namespace SystemTrayMenu.UserInterface.FolderBrowseDialog
|
|||
return DialogResult.Cancel;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public DialogResult ShowLegacyDialog(IWin32Window owner)
|
||||
{
|
||||
using SaveFileDialog frm = new SaveFileDialog
|
||||
|
@ -139,6 +143,7 @@ namespace SystemTrayMenu.UserInterface.FolderBrowseDialog
|
|||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
|
|
|
@ -6,22 +6,23 @@ namespace SystemTrayMenu.UserInterface.FolderBrowseDialog
|
|||
{
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// WindowWrapper.
|
||||
/// </summary>
|
||||
public class WindowWrapper : System.Windows.Forms.IWin32Window
|
||||
{
|
||||
private readonly IntPtr hwnd;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="WindowWrapper"/> class.
|
||||
/// </summary>
|
||||
/// <param name="handle">Handle to wrap.</param>
|
||||
public WindowWrapper(IntPtr handle)
|
||||
{
|
||||
hwnd = handle;
|
||||
Handle = handle;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets original ptr.
|
||||
/// </summary>
|
||||
public IntPtr Handle => hwnd;
|
||||
public IntPtr Handle { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -485,6 +485,7 @@ namespace SystemTrayMenu.UserInterface.HotkeyTextboxControl
|
|||
Redraw(true);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string ToString()
|
||||
{
|
||||
return HotkeyToString(HotkeyModifiers, Hotkey);
|
||||
|
|
|
@ -21,6 +21,7 @@ namespace SystemTrayMenu.UserInterface
|
|||
{
|
||||
private string text;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string Text
|
||||
{
|
||||
get => text;
|
||||
|
|
|
@ -193,6 +193,7 @@ namespace SystemTrayMenu.UserInterface
|
|||
internal bool IsUsable => Visible && !fading.IsHiding &&
|
||||
!IsDisposed && !Disposing;
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override CreateParams CreateParams
|
||||
{
|
||||
get
|
||||
|
@ -482,6 +483,7 @@ namespace SystemTrayMenu.UserInterface
|
|||
labelFilesCount.Text = filesCount.ToString();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override bool ProcessCmdKey(ref Message msg, Keys keys)
|
||||
{
|
||||
switch (keys)
|
||||
|
|
|
@ -18,16 +18,21 @@ namespace SystemTrayMenu.UserInterface
|
|||
using Windows.ApplicationModel;
|
||||
using static SystemTrayMenu.UserInterface.HotkeyTextboxControl.HotkeyControl;
|
||||
|
||||
/// <summary>
|
||||
/// SettingsForm.
|
||||
/// </summary>
|
||||
public partial class SettingsForm : Form
|
||||
{
|
||||
private const string MenuName = @"Software\Classes\directory\shell\SystemTrayMenu_SetAsRootFolder";
|
||||
private const string Command = @"Software\Classes\directory\shell\SystemTrayMenu_SetAsRootFolder\command";
|
||||
|
||||
private static readonly Icon SystemTrayMenu = Resources.SystemTrayMenu;
|
||||
private readonly string newHotKey = string.Empty;
|
||||
private readonly ColorConverter colorConverter = new ColorConverter();
|
||||
private bool inHotkey;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SettingsForm"/> class.
|
||||
/// </summary>
|
||||
public SettingsForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
@ -362,7 +367,10 @@ namespace SystemTrayMenu.UserInterface
|
|||
textBoxColorArrowHoverBackgroundDarkMode.Text = Settings.Default.ColorArrowHoverBackgroundDarkMode;
|
||||
}
|
||||
|
||||
public string NewHotKey => newHotKey;
|
||||
/// <summary>
|
||||
/// Gets NewHotKey.
|
||||
/// </summary>
|
||||
public string NewHotKey { get; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Registers all hotkeys as configured, displaying a dialog in case of hotkey conflicts with other tools.
|
||||
|
@ -373,6 +381,7 @@ namespace SystemTrayMenu.UserInterface
|
|||
return RegisterHotkeys(false);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
|
||||
{
|
||||
switch (keyData)
|
||||
|
@ -566,6 +575,15 @@ namespace SystemTrayMenu.UserInterface
|
|||
}
|
||||
}
|
||||
|
||||
private static bool IsStartupTask()
|
||||
{
|
||||
bool useStartupTask = false;
|
||||
#if RELEASEPACKAGE
|
||||
useStartupTask = true;
|
||||
#endif
|
||||
return useStartupTask;
|
||||
}
|
||||
|
||||
private void SettingsForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
AdjustControlMultilineIfNecessary(checkBoxStayOpenWhenFocusLost);
|
||||
|
@ -931,14 +949,5 @@ namespace SystemTrayMenu.UserInterface
|
|||
e.Handled = e.SuppressKeyPress = true;
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsStartupTask()
|
||||
{
|
||||
bool useStartupTask = false;
|
||||
#if RELEASEPACKAGE
|
||||
useStartupTask = true;
|
||||
#endif
|
||||
return useStartupTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,10 +8,17 @@ namespace SystemTrayMenu.Utilities
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
/// <summary>
|
||||
/// Read *.ini files.
|
||||
/// </summary>
|
||||
public class FileIni
|
||||
{
|
||||
private readonly Dictionary<string, string> values;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FileIni"/> class.
|
||||
/// </summary>
|
||||
/// <param name="path">path of *.ini file.</param>
|
||||
public FileIni(string path)
|
||||
{
|
||||
values = File.ReadLines(path)
|
||||
|
@ -22,6 +29,12 @@ namespace SystemTrayMenu.Utilities
|
|||
parts.Length > 1 ? parts[1].Trim() : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get value of line in *.ini file.
|
||||
/// </summary>
|
||||
/// <param name="name">attribute name of line.</param>
|
||||
/// <param name="value">default value.</param>
|
||||
/// <returns>value of attribute name of line.</returns>
|
||||
public string Value(string name, string value = null)
|
||||
{
|
||||
if (values != null && values.ContainsKey(name))
|
||||
|
|
Loading…
Reference in a new issue