mirror of
https://github.com/Hofknecht/SystemTrayMenu.git
synced 2024-06-10 14:35:06 +12:00
[Feature] Fix warnings / clean code (#215), version 1.0.21.0
This commit is contained in:
parent
30312cc025
commit
4919aa9afd
|
@ -206,12 +206,12 @@ namespace SystemTrayMenu.Business
|
||||||
waitToOpenMenu.CloseMenu += CloseMenu;
|
waitToOpenMenu.CloseMenu += CloseMenu;
|
||||||
void CloseMenu(int level)
|
void CloseMenu(int level)
|
||||||
{
|
{
|
||||||
if (level < menus.Count() && menus[level] != null)
|
if (level < menus.Length && menus[level] != null)
|
||||||
{
|
{
|
||||||
HideOldMenu(menus[level]);
|
HideOldMenu(menus[level]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (level - 1 < menus.Count() && menus[level - 1] != null)
|
if (level - 1 < menus.Length && menus[level - 1] != null)
|
||||||
{
|
{
|
||||||
menus[level - 1].FocusTextBox();
|
menus[level - 1].FocusTextBox();
|
||||||
}
|
}
|
||||||
|
@ -571,7 +571,7 @@ namespace SystemTrayMenu.Business
|
||||||
|
|
||||||
if (FileUrl.GetDefaultBrowserPath(out string browserPath))
|
if (FileUrl.GetDefaultBrowserPath(out string browserPath))
|
||||||
{
|
{
|
||||||
IconReader.GetFileIconWithCache(browserPath, true, true, out bool loading);
|
IconReader.GetFileIconWithCache(browserPath, true, true, out _);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -612,7 +612,7 @@ namespace SystemTrayMenu.Business
|
||||||
{
|
{
|
||||||
string path = rowData.FileInfo.FullName;
|
string path = rowData.FileInfo.FullName;
|
||||||
int directoryNameBegin = path.LastIndexOf(@"\", StringComparison.InvariantCulture) + 1;
|
int directoryNameBegin = path.LastIndexOf(@"\", StringComparison.InvariantCulture) + 1;
|
||||||
rowData.SetText(path.Substring(directoryNameBegin));
|
rowData.SetText(path[directoryNameBegin..]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1054,7 +1054,7 @@ namespace SystemTrayMenu.Business
|
||||||
searchTextChanging = false;
|
searchTextChanging = false;
|
||||||
|
|
||||||
// if any open menu close
|
// if any open menu close
|
||||||
if (menu.Level + 1 < menus.Count())
|
if (menu.Level + 1 < menus.Length)
|
||||||
{
|
{
|
||||||
Menu menuToClose = menus[menu.Level + 1];
|
Menu menuToClose = menus[menu.Level + 1];
|
||||||
if (menuToClose != null)
|
if (menuToClose != null)
|
||||||
|
|
|
@ -73,17 +73,15 @@ namespace SystemTrayMenu
|
||||||
|
|
||||||
public static void SetFolderByUser(bool save = true)
|
public static void SetFolderByUser(bool save = true)
|
||||||
{
|
{
|
||||||
using (FolderDialog dialog = new FolderDialog())
|
using FolderDialog dialog = new FolderDialog();
|
||||||
{
|
dialog.InitialFolder = Path;
|
||||||
dialog.InitialFolder = Path;
|
|
||||||
|
|
||||||
if (dialog.ShowDialog() == DialogResult.OK)
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
Settings.Default.PathDirectory = dialog.Folder;
|
||||||
|
if (save)
|
||||||
{
|
{
|
||||||
Settings.Default.PathDirectory = dialog.Folder;
|
Settings.Default.Save();
|
||||||
if (save)
|
|
||||||
{
|
|
||||||
Settings.Default.Save();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -424,12 +422,10 @@ namespace SystemTrayMenu
|
||||||
str = str.Replace("#585858", htmlColorCode);
|
str = str.Replace("#585858", htmlColorCode);
|
||||||
byteArray = Encoding.UTF8.GetBytes(str);
|
byteArray = Encoding.UTF8.GetBytes(str);
|
||||||
|
|
||||||
using (MemoryStream stream = new MemoryStream(byteArray))
|
using MemoryStream stream = new MemoryStream(byteArray);
|
||||||
{
|
SvgDocument svgDocument = SvgDocument.Open<SvgDocument>(stream);
|
||||||
SvgDocument svgDocument = SvgDocument.Open<SvgDocument>(stream);
|
svgDocument.Color = new SvgColourServer(Color.Black);
|
||||||
svgDocument.Color = new SvgColourServer(Color.Black);
|
return svgDocument.Draw();
|
||||||
return svgDocument.Draw();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool IsRegistryValueThisValue(string keyName, string valueName, string value)
|
private static bool IsRegistryValueThisValue(string keyName, string valueName, string value)
|
||||||
|
|
|
@ -144,7 +144,7 @@ namespace SystemTrayMenu.DataClasses
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
icon = IconReader.GetFileIconWithCache(
|
icon = IconReader.GetFileIconWithCache(
|
||||||
TargetFilePath,
|
TargetFilePathOrig,
|
||||||
showOverlay,
|
showOverlay,
|
||||||
true,
|
true,
|
||||||
out bool loading);
|
out bool loading);
|
||||||
|
@ -153,7 +153,7 @@ namespace SystemTrayMenu.DataClasses
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Log.Warn($"path:'{TargetFilePath}'", ex);
|
Log.Warn($"path:'{TargetFilePathOrig}'", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -235,14 +235,8 @@ namespace SystemTrayMenu.DataClasses
|
||||||
showOverlay = true;
|
showOverlay = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
string path = TargetFilePath;
|
|
||||||
if (ContainsMenu)
|
|
||||||
{
|
|
||||||
path = TargetFilePathOrig;
|
|
||||||
}
|
|
||||||
|
|
||||||
icon = IconReader.GetFileIconWithCache(
|
icon = IconReader.GetFileIconWithCache(
|
||||||
path,
|
TargetFilePathOrig,
|
||||||
showOverlay,
|
showOverlay,
|
||||||
false,
|
false,
|
||||||
out bool loading);
|
out bool loading);
|
||||||
|
|
|
@ -96,16 +96,14 @@ namespace SystemTrayMenu.Helpers
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
using (StreamWriter writer = new StreamWriter(pathToStoreFile + "\\" + title.Trim() + ".url"))
|
using StreamWriter writer = new StreamWriter(pathToStoreFile + "\\" + title.Trim() + ".url");
|
||||||
{
|
writer.WriteLine("[InternetShortcut]");
|
||||||
writer.WriteLine("[InternetShortcut]");
|
writer.WriteLine($"URL={url.TrimEnd('\0')}");
|
||||||
writer.WriteLine($"URL={url.TrimEnd('\0')}");
|
writer.WriteLine("IconIndex=0");
|
||||||
writer.WriteLine("IconIndex=0");
|
writer.WriteLine($"HotKey=0");
|
||||||
writer.WriteLine($"HotKey=0");
|
writer.WriteLine($"IDList=");
|
||||||
writer.WriteLine($"IDList=");
|
writer.WriteLine($"IconFile={pathIcon}");
|
||||||
writer.WriteLine($"IconFile={pathIcon}");
|
writer.Flush();
|
||||||
writer.Flush();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,56 +42,54 @@ namespace SystemTrayMenu.Helpers
|
||||||
if (newBitmap != null)
|
if (newBitmap != null)
|
||||||
{
|
{
|
||||||
// save the resized png into a memory stream for future use
|
// save the resized png into a memory stream for future use
|
||||||
using (MemoryStream memoryStream = new MemoryStream())
|
using MemoryStream memoryStream = new MemoryStream();
|
||||||
|
newBitmap.Save(memoryStream, ImageFormat.Png);
|
||||||
|
|
||||||
|
BinaryWriter iconWriter = new BinaryWriter(output);
|
||||||
|
if (output != null && iconWriter != null)
|
||||||
{
|
{
|
||||||
newBitmap.Save(memoryStream, ImageFormat.Png);
|
// 0-1 reserved, 0
|
||||||
|
iconWriter.Write((byte)0);
|
||||||
|
iconWriter.Write((byte)0);
|
||||||
|
|
||||||
BinaryWriter iconWriter = new BinaryWriter(output);
|
// 2-3 image type, 1 = icon, 2 = cursor
|
||||||
if (output != null && iconWriter != null)
|
iconWriter.Write((short)1);
|
||||||
{
|
|
||||||
// 0-1 reserved, 0
|
|
||||||
iconWriter.Write((byte)0);
|
|
||||||
iconWriter.Write((byte)0);
|
|
||||||
|
|
||||||
// 2-3 image type, 1 = icon, 2 = cursor
|
// 4-5 number of images
|
||||||
iconWriter.Write((short)1);
|
iconWriter.Write((short)1);
|
||||||
|
|
||||||
// 4-5 number of images
|
// image entry 1
|
||||||
iconWriter.Write((short)1);
|
// 0 image width
|
||||||
|
iconWriter.Write((byte)width);
|
||||||
|
|
||||||
// image entry 1
|
// 1 image height
|
||||||
// 0 image width
|
iconWriter.Write((byte)height);
|
||||||
iconWriter.Write((byte)width);
|
|
||||||
|
|
||||||
// 1 image height
|
// 2 number of colors
|
||||||
iconWriter.Write((byte)height);
|
iconWriter.Write((byte)0);
|
||||||
|
|
||||||
// 2 number of colors
|
// 3 reserved
|
||||||
iconWriter.Write((byte)0);
|
iconWriter.Write((byte)0);
|
||||||
|
|
||||||
// 3 reserved
|
// 4-5 color planes
|
||||||
iconWriter.Write((byte)0);
|
iconWriter.Write((short)0);
|
||||||
|
|
||||||
// 4-5 color planes
|
// 6-7 bits per pixel
|
||||||
iconWriter.Write((short)0);
|
iconWriter.Write((short)32);
|
||||||
|
|
||||||
// 6-7 bits per pixel
|
// 8-11 size of image data
|
||||||
iconWriter.Write((short)32);
|
iconWriter.Write((int)memoryStream.Length);
|
||||||
|
|
||||||
// 8-11 size of image data
|
// 12-15 offset of image data
|
||||||
iconWriter.Write((int)memoryStream.Length);
|
iconWriter.Write(6 + 16);
|
||||||
|
|
||||||
// 12-15 offset of image data
|
// write image data
|
||||||
iconWriter.Write(6 + 16);
|
// png data must contain the whole png data file
|
||||||
|
iconWriter.Write(memoryStream.ToArray());
|
||||||
|
|
||||||
// write image data
|
iconWriter.Flush();
|
||||||
// png data must contain the whole png data file
|
|
||||||
iconWriter.Write(memoryStream.ToArray());
|
|
||||||
|
|
||||||
iconWriter.Flush();
|
return true;
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,11 +109,9 @@ namespace SystemTrayMenu.Helpers
|
||||||
/// <returns>Wether or not the icon was succesfully generated.</returns>
|
/// <returns>Wether or not the icon was succesfully generated.</returns>
|
||||||
public static bool ConvertToIcon(string inputPath, string outputPath, int size = 16, bool preserveAspectRatio = false)
|
public static bool ConvertToIcon(string inputPath, string outputPath, int size = 16, bool preserveAspectRatio = false)
|
||||||
{
|
{
|
||||||
using (FileStream inputStream = new FileStream(inputPath, FileMode.Open))
|
using FileStream inputStream = new FileStream(inputPath, FileMode.Open);
|
||||||
using (FileStream outputStream = new FileStream(outputPath, FileMode.OpenOrCreate))
|
using FileStream outputStream = new FileStream(outputPath, FileMode.OpenOrCreate);
|
||||||
{
|
return ConvertToIcon(inputStream, outputStream, size, preserveAspectRatio);
|
||||||
return ConvertToIcon(inputStream, outputStream, size, preserveAspectRatio);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Image RotateImage(Image img, float rotationAngle)
|
public static Image RotateImage(Image img, float rotationAngle)
|
||||||
|
|
|
@ -39,5 +39,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("1.0.20.5")]
|
[assembly: AssemblyVersion("1.0.21.0")]
|
||||||
[assembly: AssemblyFileVersion("1.0.20.5")]
|
[assembly: AssemblyFileVersion("1.0.21.0")]
|
||||||
|
|
10
Properties/Resources.Designer.cs
generated
10
Properties/Resources.Designer.cs
generated
|
@ -140,16 +140,6 @@ namespace SystemTrayMenu.Properties {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
|
||||||
/// </summary>
|
|
||||||
public static System.Drawing.Icon search {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("search", resourceCulture);
|
|
||||||
return ((System.Drawing.Icon)(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -124,9 +124,6 @@
|
||||||
<data name="SystemTrayMenu" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="SystemTrayMenu" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\SystemTrayMenu.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\SystemTrayMenu.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="search" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\search.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
<data name="ic_fluent_pin_48_filled" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="ic_fluent_pin_48_filled" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\ic_fluent_pin_48_filled.svg;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>..\Resources\ic_fluent_pin_48_filled.svg;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</data>
|
</data>
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 114 KiB |
|
@ -111,12 +111,10 @@ namespace SystemTrayMenu.UserInterface
|
||||||
{
|
{
|
||||||
if (threadsLoading)
|
if (threadsLoading)
|
||||||
{
|
{
|
||||||
rotationAngle = rotationAngle + 5;
|
rotationAngle += 5;
|
||||||
using (Bitmap bitmapLoading = new Bitmap(ImagingHelper.RotateImage(LoadingIcon.ToBitmap(), rotationAngle)))
|
using Bitmap bitmapLoading = new Bitmap(ImagingHelper.RotateImage(LoadingIcon.ToBitmap(), rotationAngle));
|
||||||
{
|
DisposeIconIfNotDefaultIcon();
|
||||||
DisposeIconIfNotDefaultIcon();
|
notifyIcon.Icon = Icon.FromHandle(bitmapLoading.GetHicon());
|
||||||
notifyIcon.Icon = Icon.FromHandle(bitmapLoading.GetHicon());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -393,7 +393,7 @@ namespace SystemTrayMenu.UserInterface.HotkeyTextboxControl
|
||||||
return "* " + keyString;
|
return "* " + keyString;
|
||||||
}
|
}
|
||||||
|
|
||||||
keyString = keyString.Substring(0, 1).ToUpperInvariant() + keyString.Substring(1).ToLowerInvariant();
|
keyString = keyString.Substring(0, 1).ToUpperInvariant() + keyString[1..].ToLowerInvariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
return keyString + " *";
|
return keyString + " *";
|
||||||
|
@ -406,7 +406,7 @@ namespace SystemTrayMenu.UserInterface.HotkeyTextboxControl
|
||||||
return "/ " + keyString;
|
return "/ " + keyString;
|
||||||
}
|
}
|
||||||
|
|
||||||
keyString = keyString.Substring(0, 1).ToUpperInvariant() + keyString.Substring(1).ToLowerInvariant();
|
keyString = keyString.Substring(0, 1).ToUpperInvariant() + keyString[1..].ToLowerInvariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
return keyString + " /";
|
return keyString + " /";
|
||||||
|
@ -444,7 +444,7 @@ namespace SystemTrayMenu.UserInterface.HotkeyTextboxControl
|
||||||
string visibleName = keyName.ToString();
|
string visibleName = keyName.ToString();
|
||||||
if (visibleName.Length > 1)
|
if (visibleName.Length > 1)
|
||||||
{
|
{
|
||||||
visibleName = visibleName.Substring(0, 1) + visibleName.Substring(1).ToLowerInvariant();
|
visibleName = visibleName.Substring(0, 1) + visibleName[1..].ToLowerInvariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
return visibleName;
|
return visibleName;
|
||||||
|
|
|
@ -18,7 +18,6 @@ namespace SystemTrayMenu.UserInterface
|
||||||
internal partial class Menu : Form
|
internal partial class Menu : Form
|
||||||
{
|
{
|
||||||
private static readonly Icon LoadingIcon = Properties.Resources.Loading;
|
private static readonly Icon LoadingIcon = Properties.Resources.Loading;
|
||||||
private static readonly Icon Search = Properties.Resources.search;
|
|
||||||
private readonly Fading fading = new Fading();
|
private readonly Fading fading = new Fading();
|
||||||
private bool isShowing;
|
private bool isShowing;
|
||||||
private bool directionToRight;
|
private bool directionToRight;
|
||||||
|
@ -789,7 +788,7 @@ namespace SystemTrayMenu.UserInterface
|
||||||
private void LoadingMenu_Paint(object sender, PaintEventArgs e)
|
private void LoadingMenu_Paint(object sender, PaintEventArgs e)
|
||||||
{
|
{
|
||||||
PictureBox pictureBox = (PictureBox)sender;
|
PictureBox pictureBox = (PictureBox)sender;
|
||||||
rotationAngle = rotationAngle + 5;
|
rotationAngle += 5;
|
||||||
e.Graphics.DrawImage(
|
e.Graphics.DrawImage(
|
||||||
ImagingHelper.RotateImage(LoadingIcon.ToBitmap(), rotationAngle),
|
ImagingHelper.RotateImage(LoadingIcon.ToBitmap(), rotationAngle),
|
||||||
new Rectangle(Point.Empty, new Size(pictureBox.ClientSize.Width - 2, pictureBox.ClientSize.Height - 2)));
|
new Rectangle(Point.Empty, new Size(pictureBox.ClientSize.Width - 2, pictureBox.ClientSize.Height - 2)));
|
||||||
|
|
|
@ -256,7 +256,7 @@ namespace SystemTrayMenu.UserInterface
|
||||||
decimal newValue = numericUpDownSizeInPercentage.Value;
|
decimal newValue = numericUpDownSizeInPercentage.Value;
|
||||||
if (e.Delta > 0)
|
if (e.Delta > 0)
|
||||||
{
|
{
|
||||||
newValue = newValue + numericUpDownSizeInPercentage.Increment;
|
newValue += numericUpDownSizeInPercentage.Increment;
|
||||||
if (newValue > numericUpDownSizeInPercentage.Maximum)
|
if (newValue > numericUpDownSizeInPercentage.Maximum)
|
||||||
{
|
{
|
||||||
newValue = (int)numericUpDownSizeInPercentage.Maximum;
|
newValue = (int)numericUpDownSizeInPercentage.Maximum;
|
||||||
|
@ -264,7 +264,7 @@ namespace SystemTrayMenu.UserInterface
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
newValue = newValue - numericUpDownSizeInPercentage.Increment;
|
newValue -= numericUpDownSizeInPercentage.Increment;
|
||||||
if (newValue < numericUpDownSizeInPercentage.Minimum)
|
if (newValue < numericUpDownSizeInPercentage.Minimum)
|
||||||
{
|
{
|
||||||
newValue = (int)numericUpDownSizeInPercentage.Minimum;
|
newValue = (int)numericUpDownSizeInPercentage.Minimum;
|
||||||
|
@ -473,6 +473,83 @@ namespace SystemTrayMenu.UserInterface
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void AdjustControlMultilineIfNecessary(Control control)
|
||||||
|
{
|
||||||
|
if (control.Width > control.Parent.Width)
|
||||||
|
{
|
||||||
|
control.MaximumSize = new Size(control.Parent.Width, 0);
|
||||||
|
control.MinimumSize = new Size(0, control.Height * 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void AddPossibilityToSelectFolderByWindowsContextMenu()
|
||||||
|
{
|
||||||
|
RegistryKey registryKeyContextMenu = null;
|
||||||
|
RegistryKey registryKeyContextMenuCommand = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
registryKeyContextMenu = Registry.CurrentUser.CreateSubKey(MenuName);
|
||||||
|
string binLocation = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
|
||||||
|
if (registryKeyContextMenu != null)
|
||||||
|
{
|
||||||
|
registryKeyContextMenu.SetValue(string.Empty, Translator.GetText("Set as SystemTrayMenu folder"));
|
||||||
|
registryKeyContextMenu.SetValue("Icon", binLocation);
|
||||||
|
}
|
||||||
|
|
||||||
|
registryKeyContextMenuCommand = Registry.CurrentUser.CreateSubKey(Command);
|
||||||
|
|
||||||
|
if (registryKeyContextMenuCommand != null)
|
||||||
|
{
|
||||||
|
registryKeyContextMenuCommand.SetValue(string.Empty, binLocation + " \"%1\"");
|
||||||
|
}
|
||||||
|
|
||||||
|
Settings.Default.PossibilityToSelectFolderByWindowsContextMenu = true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Warn("SavePossibilityToSelectFolderByWindowsContextMenu failed", ex);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (registryKeyContextMenu != null)
|
||||||
|
{
|
||||||
|
registryKeyContextMenu.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (registryKeyContextMenuCommand != null)
|
||||||
|
{
|
||||||
|
registryKeyContextMenuCommand.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void RemovePossibilityToSelectFolderByWindowsContextMenu()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(Command);
|
||||||
|
if (registryKey != null)
|
||||||
|
{
|
||||||
|
registryKey.Close();
|
||||||
|
Registry.CurrentUser.DeleteSubKey(Command);
|
||||||
|
}
|
||||||
|
|
||||||
|
registryKey = Registry.CurrentUser.OpenSubKey(MenuName);
|
||||||
|
if (registryKey != null)
|
||||||
|
{
|
||||||
|
registryKey.Close();
|
||||||
|
Registry.CurrentUser.DeleteSubKey(MenuName);
|
||||||
|
}
|
||||||
|
|
||||||
|
Settings.Default.PossibilityToSelectFolderByWindowsContextMenu = false;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Warn("DeletePossibilityToSelectFolderByWindowsContextMenu failed", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void SettingsForm_Load(object sender, EventArgs e)
|
private void SettingsForm_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
AdjustControlMultilineIfNecessary(checkBoxStayOpenWhenFocusLost);
|
AdjustControlMultilineIfNecessary(checkBoxStayOpenWhenFocusLost);
|
||||||
|
@ -482,15 +559,6 @@ namespace SystemTrayMenu.UserInterface
|
||||||
tableLayoutPanelGeneral.Size.Height + 50);
|
tableLayoutPanelGeneral.Size.Height + 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AdjustControlMultilineIfNecessary(Control control)
|
|
||||||
{
|
|
||||||
if (control.Width > control.Parent.Width)
|
|
||||||
{
|
|
||||||
control.MaximumSize = new Size(control.Parent.Width, 0);
|
|
||||||
control.MinimumSize = new Size(0, control.Height * 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonOk_Click(object sender, EventArgs e)
|
private void ButtonOk_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Settings.Default.UseIconFromRootFolder =
|
Settings.Default.UseIconFromRootFolder =
|
||||||
|
@ -573,74 +641,6 @@ namespace SystemTrayMenu.UserInterface
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddPossibilityToSelectFolderByWindowsContextMenu()
|
|
||||||
{
|
|
||||||
RegistryKey registryKeyContextMenu = null;
|
|
||||||
RegistryKey registryKeyContextMenuCommand = null;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
registryKeyContextMenu = Registry.CurrentUser.CreateSubKey(MenuName);
|
|
||||||
string binLocation = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
|
|
||||||
if (registryKeyContextMenu != null)
|
|
||||||
{
|
|
||||||
registryKeyContextMenu.SetValue(string.Empty, Translator.GetText("Set as SystemTrayMenu folder"));
|
|
||||||
registryKeyContextMenu.SetValue("Icon", binLocation);
|
|
||||||
}
|
|
||||||
|
|
||||||
registryKeyContextMenuCommand = Registry.CurrentUser.CreateSubKey(Command);
|
|
||||||
|
|
||||||
if (registryKeyContextMenuCommand != null)
|
|
||||||
{
|
|
||||||
registryKeyContextMenuCommand.SetValue(string.Empty, binLocation + " \"%1\"");
|
|
||||||
}
|
|
||||||
|
|
||||||
Settings.Default.PossibilityToSelectFolderByWindowsContextMenu = true;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Log.Warn("SavePossibilityToSelectFolderByWindowsContextMenu failed", ex);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
if (registryKeyContextMenu != null)
|
|
||||||
{
|
|
||||||
registryKeyContextMenu.Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (registryKeyContextMenuCommand != null)
|
|
||||||
{
|
|
||||||
registryKeyContextMenuCommand.Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void RemovePossibilityToSelectFolderByWindowsContextMenu()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(Command);
|
|
||||||
if (registryKey != null)
|
|
||||||
{
|
|
||||||
registryKey.Close();
|
|
||||||
Registry.CurrentUser.DeleteSubKey(Command);
|
|
||||||
}
|
|
||||||
|
|
||||||
registryKey = Registry.CurrentUser.OpenSubKey(MenuName);
|
|
||||||
if (registryKey != null)
|
|
||||||
{
|
|
||||||
registryKey.Close();
|
|
||||||
Registry.CurrentUser.DeleteSubKey(MenuName);
|
|
||||||
}
|
|
||||||
|
|
||||||
Settings.Default.PossibilityToSelectFolderByWindowsContextMenu = false;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Log.Warn("DeletePossibilityToSelectFolderByWindowsContextMenu failed", ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonHotkeyDefault_Click(object sender, EventArgs e)
|
private void ButtonHotkeyDefault_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
textBoxHotkey.SetHotkey("Ctrl+LWin");
|
textBoxHotkey.SetHotkey("Ctrl+LWin");
|
||||||
|
|
|
@ -38,7 +38,7 @@ namespace SystemTrayMenu.Utilities
|
||||||
public static bool IsNetworkRoot(string path)
|
public static bool IsNetworkRoot(string path)
|
||||||
{
|
{
|
||||||
return path.StartsWith(@"\\", StringComparison.InvariantCulture) &&
|
return path.StartsWith(@"\\", StringComparison.InvariantCulture) &&
|
||||||
!path.Substring(2).Contains(@"\", StringComparison.InvariantCulture);
|
!path[2..].Contains(@"\", StringComparison.InvariantCulture);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool PingHost(string nameOrAddress)
|
public static bool PingHost(string nameOrAddress)
|
||||||
|
|
|
@ -101,7 +101,6 @@ namespace SystemTrayMenu.Utilities
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Reliability", "CA2008:Do not create tasks without passing a TaskScheduler", Justification = "todo")]
|
|
||||||
public static Icon GetFolderIconSTA(
|
public static Icon GetFolderIconSTA(
|
||||||
string directoryPath,
|
string directoryPath,
|
||||||
FolderType folderType,
|
FolderType folderType,
|
||||||
|
@ -210,7 +209,6 @@ namespace SystemTrayMenu.Utilities
|
||||||
return isExtensionWithSameIcon;
|
return isExtensionWithSameIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Reliability", "CA2008:Do not create tasks without passing a TaskScheduler", Justification = "todo")]
|
|
||||||
private static Icon GetFileIconSTA(string filePath, bool linkOverlay, IconSize size = IconSize.Small)
|
private static Icon GetFileIconSTA(string filePath, bool linkOverlay, IconSize size = IconSize.Small)
|
||||||
{
|
{
|
||||||
Icon icon = null;
|
Icon icon = null;
|
||||||
|
|
|
@ -110,7 +110,7 @@ namespace SystemTrayMenu.Utilities
|
||||||
if (ex.Message == "The system cannot find the file specified.")
|
if (ex.Message == "The system cannot find the file specified.")
|
||||||
{
|
{
|
||||||
new Thread(ShowProblemWithShortcut).Start();
|
new Thread(ShowProblemWithShortcut).Start();
|
||||||
void ShowProblemWithShortcut()
|
static void ShowProblemWithShortcut()
|
||||||
{
|
{
|
||||||
_ = MessageBox.Show(
|
_ = MessageBox.Show(
|
||||||
Translator.GetText("The item that this shortcut refers to has been changed or moved, so this shortcut will no longer work properly."),
|
Translator.GetText("The item that this shortcut refers to has been changed or moved, so this shortcut will no longer work properly."),
|
||||||
|
|
Loading…
Reference in a new issue