mirror of
https://github.com/Hofknecht/SystemTrayMenu.git
synced 2024-07-09 00:06:11 +12:00
Fix some nullables
This commit is contained in:
parent
22679392f4
commit
11bac5dd1e
|
@ -455,7 +455,7 @@ namespace SystemTrayMenu.Business
|
||||||
timerShowProcessStartedAsLoadingIcon.Tick += Tick;
|
timerShowProcessStartedAsLoadingIcon.Tick += Tick;
|
||||||
timerShowProcessStartedAsLoadingIcon.Interval = TimeSpan.FromMilliseconds(5);
|
timerShowProcessStartedAsLoadingIcon.Interval = TimeSpan.FromMilliseconds(5);
|
||||||
timerShowProcessStartedAsLoadingIcon.Start();
|
timerShowProcessStartedAsLoadingIcon.Start();
|
||||||
void Tick(object sender, EventArgs e)
|
void Tick(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
timerShowProcessStartedAsLoadingIcon.Tick -= Tick;
|
timerShowProcessStartedAsLoadingIcon.Tick -= Tick;
|
||||||
timerShowProcessStartedAsLoadingIcon.Interval = TimeSpan.FromMilliseconds(Properties.Settings.Default.TimeUntilClosesAfterEnterPressed);
|
timerShowProcessStartedAsLoadingIcon.Interval = TimeSpan.FromMilliseconds(Properties.Settings.Default.TimeUntilClosesAfterEnterPressed);
|
||||||
|
@ -488,12 +488,17 @@ namespace SystemTrayMenu.Business
|
||||||
|
|
||||||
private static void LoadMenu(object senderDoWork, DoWorkEventArgs eDoWork)
|
private static void LoadMenu(object senderDoWork, DoWorkEventArgs eDoWork)
|
||||||
{
|
{
|
||||||
string path;
|
string? path;
|
||||||
int level = 0;
|
int level = 0;
|
||||||
RowData rowData = eDoWork.Argument as RowData;
|
RowData? rowData = eDoWork.Argument as RowData;
|
||||||
if (rowData != null)
|
if (rowData != null)
|
||||||
{
|
{
|
||||||
path = rowData.ResolvedPath;
|
path = rowData.ResolvedPath;
|
||||||
|
if (path == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
level = rowData.Level + 1;
|
level = rowData.Level + 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -521,8 +526,10 @@ namespace SystemTrayMenu.Business
|
||||||
foldersCount = 0;
|
foldersCount = 0;
|
||||||
filesCount = 0;
|
filesCount = 0;
|
||||||
|
|
||||||
|
ListView? lv = menu.GetDataGridView();
|
||||||
|
if (lv != null)
|
||||||
|
{
|
||||||
List<Menu.ListViewItemData> items = new();
|
List<Menu.ListViewItemData> items = new();
|
||||||
ListView lv = menu.GetDataGridView();
|
|
||||||
|
|
||||||
foreach (RowData rowData in data)
|
foreach (RowData rowData in data)
|
||||||
{
|
{
|
||||||
|
@ -540,14 +547,15 @@ namespace SystemTrayMenu.Business
|
||||||
|
|
||||||
rowData.RowIndex = items.Count; // Index
|
rowData.RowIndex = items.Count; // Index
|
||||||
items.Add(new(
|
items.Add(new(
|
||||||
(rowData.HiddenEntry ? IconReader.AddIconOverlay(rowData.Icon, Properties.Resources.White50Percentage) : rowData.Icon).ToImageSource(),
|
(rowData.HiddenEntry ? IconReader.AddIconOverlay(rowData.Icon, Properties.Resources.White50Percentage) : rowData.Icon)?.ToImageSource(),
|
||||||
rowData.Text,
|
rowData.Text ?? "?",
|
||||||
rowData,
|
rowData,
|
||||||
rowData.IsAddionalItem && Properties.Settings.Default.ShowOnlyAsSearchResult ? 99 : 0));
|
rowData.IsAddionalItem && Properties.Settings.Default.ShowOnlyAsSearchResult ? 99 : 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
lv.ItemsSource = items;
|
lv.ItemsSource = items;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private bool IsActive()
|
private bool IsActive()
|
||||||
{
|
{
|
||||||
|
@ -1135,7 +1143,7 @@ namespace SystemTrayMenu.Business
|
||||||
}
|
}
|
||||||
|
|
||||||
Menu menu;
|
Menu menu;
|
||||||
Menu menuPredecessor = null;
|
Menu? menuPredecessor = null;
|
||||||
for (int i = 0; i < list.Count; i++)
|
for (int i = 0; i < list.Count; i++)
|
||||||
{
|
{
|
||||||
menu = list[i];
|
menu = list[i];
|
||||||
|
@ -1219,16 +1227,15 @@ namespace SystemTrayMenu.Business
|
||||||
{
|
{
|
||||||
menus[0].Dispatcher.Invoke(() => RenameItem(renamedEventArgs));
|
menus[0].Dispatcher.Invoke(() => RenameItem(renamedEventArgs));
|
||||||
}
|
}
|
||||||
else
|
else if (e is FileSystemEventArgs fileSystemEventArgs)
|
||||||
{
|
{
|
||||||
FileSystemEventArgs fileSystemEventArgs = (FileSystemEventArgs)e;
|
|
||||||
if (fileSystemEventArgs.ChangeType == WatcherChangeTypes.Deleted)
|
if (fileSystemEventArgs.ChangeType == WatcherChangeTypes.Deleted)
|
||||||
{
|
{
|
||||||
menus[0].Dispatcher.Invoke(() => DeleteItem(e as FileSystemEventArgs));
|
menus[0].Dispatcher.Invoke(() => DeleteItem(fileSystemEventArgs));
|
||||||
}
|
}
|
||||||
else if (fileSystemEventArgs.ChangeType == WatcherChangeTypes.Created)
|
else if (fileSystemEventArgs.ChangeType == WatcherChangeTypes.Created)
|
||||||
{
|
{
|
||||||
menus[0].Dispatcher.Invoke(() => CreateItem(e as FileSystemEventArgs));
|
menus[0].Dispatcher.Invoke(() => CreateItem(fileSystemEventArgs));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1238,7 +1245,9 @@ namespace SystemTrayMenu.Business
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
List<RowData> rowDatas = new();
|
List<RowData> rowDatas = new();
|
||||||
ListView dgv = menus[0].GetDataGridView();
|
ListView? dgv = menus[0].GetDataGridView();
|
||||||
|
if (dgv != null)
|
||||||
|
{
|
||||||
foreach (ListViewItemData item in dgv.Items)
|
foreach (ListViewItemData item in dgv.Items)
|
||||||
{
|
{
|
||||||
RowData rowData = item.data;
|
RowData rowData = item.data;
|
||||||
|
@ -1267,6 +1276,7 @@ namespace SystemTrayMenu.Business
|
||||||
rowDatas.Add(rowData);
|
rowDatas.Add(rowData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
rowDatas = MenusHelpers.SortItems(rowDatas);
|
rowDatas = MenusHelpers.SortItems(rowDatas);
|
||||||
keyboardInput.ClearIsSelectedByKey();
|
keyboardInput.ClearIsSelectedByKey();
|
||||||
|
@ -1287,9 +1297,12 @@ namespace SystemTrayMenu.Business
|
||||||
private void DeleteItem(FileSystemEventArgs e)
|
private void DeleteItem(FileSystemEventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
ListView? dgv = menus[0].GetDataGridView();
|
||||||
|
if (dgv != null)
|
||||||
{
|
{
|
||||||
List<ListViewItemData> rowsToRemove = new();
|
List<ListViewItemData> rowsToRemove = new();
|
||||||
ListView dgv = menus[0].GetDataGridView();
|
|
||||||
foreach (ListViewItemData item in dgv.Items)
|
foreach (ListViewItemData item in dgv.Items)
|
||||||
{
|
{
|
||||||
RowData rowData = item.data;
|
RowData rowData = item.data;
|
||||||
|
@ -1305,6 +1318,7 @@ namespace SystemTrayMenu.Business
|
||||||
{
|
{
|
||||||
dgv.Items.Remove(rowToRemove);
|
dgv.Items.Remove(rowToRemove);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
keyboardInput.ClearIsSelectedByKey();
|
keyboardInput.ClearIsSelectedByKey();
|
||||||
|
|
||||||
|
@ -1339,11 +1353,14 @@ namespace SystemTrayMenu.Business
|
||||||
rowData,
|
rowData,
|
||||||
};
|
};
|
||||||
|
|
||||||
ListView dgv = menus[0].GetDataGridView();
|
ListView? dgv = menus[0].GetDataGridView();
|
||||||
|
if (dgv != null)
|
||||||
|
{
|
||||||
foreach (ListViewItemData item in dgv.Items)
|
foreach (ListViewItemData item in dgv.Items)
|
||||||
{
|
{
|
||||||
rowDatas.Add(item.data);
|
rowDatas.Add(item.data);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
rowDatas = MenusHelpers.SortItems(rowDatas);
|
rowDatas = MenusHelpers.SortItems(rowDatas);
|
||||||
keyboardInput.ClearIsSelectedByKey();
|
keyboardInput.ClearIsSelectedByKey();
|
||||||
|
|
|
@ -33,21 +33,17 @@ namespace SystemTrayMenu.DataClasses
|
||||||
{
|
{
|
||||||
public MenuData(int level)
|
public MenuData(int level)
|
||||||
{
|
{
|
||||||
RowDatas = new List<RowData>();
|
|
||||||
DirectoryState = MenuDataDirectoryState.Undefined;
|
|
||||||
Level = level;
|
Level = level;
|
||||||
RowDataParent = null;
|
|
||||||
IsNetworkRoot = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal List<RowData> RowDatas { get; set; }
|
internal List<RowData> RowDatas { get; set; } = new ();
|
||||||
|
|
||||||
internal MenuDataDirectoryState DirectoryState { get; set; }
|
internal MenuDataDirectoryState DirectoryState { get; set; } = MenuDataDirectoryState.Undefined;
|
||||||
|
|
||||||
internal int Level { get; }
|
internal int Level { get; }
|
||||||
|
|
||||||
internal RowData RowDataParent { get; set; }
|
internal RowData? RowDataParent { get; set; } = null;
|
||||||
|
|
||||||
internal bool IsNetworkRoot { get; set; }
|
internal bool IsNetworkRoot { get; set; } = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,7 +5,6 @@
|
||||||
namespace SystemTrayMenu.DataClasses
|
namespace SystemTrayMenu.DataClasses
|
||||||
{
|
{
|
||||||
using System;
|
using System;
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
@ -99,11 +98,11 @@ namespace SystemTrayMenu.DataClasses
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal Icon Icon { get; private set; }
|
internal Icon? Icon { get; private set; }
|
||||||
|
|
||||||
internal FileInfo FileInfo { get; }
|
internal FileInfo? FileInfo { get; }
|
||||||
|
|
||||||
internal string Path { get; }
|
internal string? Path { get; }
|
||||||
|
|
||||||
internal bool IsFolder { get; }
|
internal bool IsFolder { get; }
|
||||||
|
|
||||||
|
@ -113,23 +112,23 @@ namespace SystemTrayMenu.DataClasses
|
||||||
|
|
||||||
internal int Level { get; set; }
|
internal int Level { get; set; }
|
||||||
|
|
||||||
internal string FileExtension { get; }
|
internal string? FileExtension { get; }
|
||||||
|
|
||||||
internal bool IsLink { get; }
|
internal bool IsLink { get; }
|
||||||
|
|
||||||
internal string ResolvedPath { get; }
|
internal string? ResolvedPath { get; }
|
||||||
|
|
||||||
internal bool IsLinkToFolder { get; }
|
internal bool IsLinkToFolder { get; }
|
||||||
|
|
||||||
internal bool ShowOverlay { get; }
|
internal bool ShowOverlay { get; }
|
||||||
|
|
||||||
internal string Text { get; }
|
internal string? Text { get; }
|
||||||
|
|
||||||
internal bool ContainsMenu { get; }
|
internal bool ContainsMenu { get; }
|
||||||
|
|
||||||
internal bool IsMainMenu { get; }
|
internal bool IsMainMenu { get; }
|
||||||
|
|
||||||
internal Menu SubMenu { get; set; }
|
internal Menu? SubMenu { get; set; }
|
||||||
|
|
||||||
internal bool IsMenuOpen { get; set; }
|
internal bool IsMenuOpen { get; set; }
|
||||||
|
|
||||||
|
@ -147,7 +146,7 @@ namespace SystemTrayMenu.DataClasses
|
||||||
|
|
||||||
internal bool ProcessStarted { get; set; }
|
internal bool ProcessStarted { get; set; }
|
||||||
|
|
||||||
internal Icon ReadIcon(bool updateIconInBackground)
|
internal void ReadIcon(bool updateIconInBackground)
|
||||||
{
|
{
|
||||||
if (IsFolder || IsLinkToFolder)
|
if (IsFolder || IsLinkToFolder)
|
||||||
{
|
{
|
||||||
|
@ -171,8 +170,6 @@ namespace SystemTrayMenu.DataClasses
|
||||||
Icon = AddIconOverlay(Icon, Properties.Resources.White50Percentage);
|
Icon = AddIconOverlay(Icon, Properties.Resources.White50Percentage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Icon;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void MouseDown(ListView dgv, MouseButtonEventArgs e)
|
internal void MouseDown(ListView dgv, MouseButtonEventArgs e)
|
||||||
|
@ -217,8 +214,10 @@ namespace SystemTrayMenu.DataClasses
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string parentFolder = System.IO.Path.GetDirectoryName(Path);
|
string? parentFolder = System.IO.Path.GetDirectoryName(Path);
|
||||||
Directory.GetFiles(parentFolder);
|
|
||||||
|
// Assume folder is not null as failure will be catched any ways
|
||||||
|
Directory.GetFiles(parentFolder!);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -273,7 +272,7 @@ namespace SystemTrayMenu.DataClasses
|
||||||
(e == null || e.LeftButton == MouseButtonState.Pressed))
|
(e == null || e.LeftButton == MouseButtonState.Pressed))
|
||||||
{
|
{
|
||||||
ProcessStarted = true;
|
ProcessStarted = true;
|
||||||
string workingDirectory = System.IO.Path.GetDirectoryName(ResolvedPath);
|
string? workingDirectory = System.IO.Path.GetDirectoryName(ResolvedPath);
|
||||||
Log.ProcessStart(Path, string.Empty, false, workingDirectory, true, ResolvedPath);
|
Log.ProcessStart(Path, string.Empty, false, workingDirectory, true, ResolvedPath);
|
||||||
if (!Properties.Settings.Default.StaysOpenWhenItemClicked)
|
if (!Properties.Settings.Default.StaysOpenWhenItemClicked)
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,8 +6,6 @@ namespace SystemTrayMenu.Helpers
|
||||||
{
|
{
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Diagnostics.Metrics;
|
|
||||||
using System.Reflection.Metadata;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using SharpDX.DirectInput;
|
using SharpDX.DirectInput;
|
||||||
|
@ -17,7 +15,7 @@ namespace SystemTrayMenu.Helpers
|
||||||
{
|
{
|
||||||
private readonly System.Timers.Timer timerReadJoystick = new();
|
private readonly System.Timers.Timer timerReadJoystick = new();
|
||||||
private readonly object lockRead = new();
|
private readonly object lockRead = new();
|
||||||
private Joystick joystick;
|
private Joystick? joystick;
|
||||||
private Key pressingKey;
|
private Key pressingKey;
|
||||||
private int pressingKeyCounter;
|
private int pressingKeyCounter;
|
||||||
private bool joystickHelperEnabled;
|
private bool joystickHelperEnabled;
|
||||||
|
@ -38,7 +36,7 @@ namespace SystemTrayMenu.Helpers
|
||||||
Dispose(false);
|
Dispose(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public event Action<Key, ModifierKeys> KeyPressed;
|
public event Action<Key, ModifierKeys>? KeyPressed;
|
||||||
|
|
||||||
public void Enable()
|
public void Enable()
|
||||||
{
|
{
|
||||||
|
@ -105,7 +103,7 @@ namespace SystemTrayMenu.Helpers
|
||||||
return keys;
|
return keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ReadJoystickLoop(object sender, System.Timers.ElapsedEventArgs e)
|
private void ReadJoystickLoop(object? sender, System.Timers.ElapsedEventArgs e)
|
||||||
{
|
{
|
||||||
if (joystickHelperEnabled)
|
if (joystickHelperEnabled)
|
||||||
{
|
{
|
||||||
|
@ -128,6 +126,8 @@ namespace SystemTrayMenu.Helpers
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ReadJoystick()
|
private void ReadJoystick()
|
||||||
|
{
|
||||||
|
if (joystick != null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -169,6 +169,7 @@ namespace SystemTrayMenu.Helpers
|
||||||
joystick = null;
|
joystick = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void InitializeJoystick()
|
private void InitializeJoystick()
|
||||||
{
|
{
|
||||||
|
|
|
@ -43,9 +43,23 @@ namespace SystemTrayMenu.Properties
|
||||||
$"SystemTrayMenu"),
|
$"SystemTrayMenu"),
|
||||||
$"user-{Environment.MachineName}.config");
|
$"user-{Environment.MachineName}.config");
|
||||||
|
|
||||||
public static string ConfigPathAssembly => Path.Combine(
|
public static string? ConfigPathAssembly
|
||||||
Directory.GetParent(Assembly.GetEntryAssembly().Location).FullName,
|
{
|
||||||
$"user.config");
|
get
|
||||||
|
{
|
||||||
|
Assembly? assembly = Assembly.GetEntryAssembly();
|
||||||
|
if (assembly != null)
|
||||||
|
{
|
||||||
|
string? location = Directory.GetParent(assembly.Location)?.FullName;
|
||||||
|
if (location != null)
|
||||||
|
{
|
||||||
|
return Path.Combine(location, $"user.config");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets override.
|
/// Gets or sets override.
|
||||||
|
@ -81,7 +95,7 @@ namespace SystemTrayMenu.Properties
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
File.Delete(ConfigPathAssembly);
|
File.Delete(ConfigPathAssembly!);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -127,8 +141,12 @@ namespace SystemTrayMenu.Properties
|
||||||
};
|
};
|
||||||
|
|
||||||
// need the type of the value for the strong typing
|
// need the type of the value for the strong typing
|
||||||
Type t = Type.GetType(setting.PropertyType.FullName);
|
string? typename = setting.PropertyType.FullName;
|
||||||
|
if (typename != null)
|
||||||
|
{
|
||||||
|
Type? t = Type.GetType(typename);
|
||||||
|
if (t != null)
|
||||||
|
{
|
||||||
if (SettingsDictionary.ContainsKey(setting.Name))
|
if (SettingsDictionary.ContainsKey(setting.Name))
|
||||||
{
|
{
|
||||||
value.SerializedValue = SettingsDictionary[setting.Name].Value;
|
value.SerializedValue = SettingsDictionary[setting.Name].Value;
|
||||||
|
@ -143,6 +161,8 @@ namespace SystemTrayMenu.Properties
|
||||||
|
|
||||||
values.Add(value);
|
values.Add(value);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
@ -159,7 +179,7 @@ namespace SystemTrayMenu.Properties
|
||||||
{
|
{
|
||||||
SettingStruct setting = new()
|
SettingStruct setting = new()
|
||||||
{
|
{
|
||||||
Value = value.PropertyValue == null ? string.Empty : value.PropertyValue.ToString(),
|
Value = value.PropertyValue == null ? string.Empty : value.PropertyValue.ToString() ?? string.Empty,
|
||||||
Name = value.Name,
|
Name = value.Name,
|
||||||
SerializeAs = value.Property.SerializeAs.ToString(),
|
SerializeAs = value.Property.SerializeAs.ToString(),
|
||||||
};
|
};
|
||||||
|
@ -182,7 +202,7 @@ namespace SystemTrayMenu.Properties
|
||||||
/// Creates an empty user.config file...looks like the one MS creates.
|
/// Creates an empty user.config file...looks like the one MS creates.
|
||||||
/// This could be overkill a simple key/value pairing would probably do.
|
/// This could be overkill a simple key/value pairing would probably do.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static void CreateEmptyConfigIfNotExists(string path)
|
private static void CreateEmptyConfigIfNotExists(string? path)
|
||||||
{
|
{
|
||||||
if (!File.Exists(path))
|
if (!File.Exists(path))
|
||||||
{
|
{
|
||||||
|
@ -222,9 +242,9 @@ namespace SystemTrayMenu.Properties
|
||||||
return isconfigPathAssembly;
|
return isconfigPathAssembly;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static XDocument LoadOrGetNew(string path)
|
private static XDocument? LoadOrGetNew(string path)
|
||||||
{
|
{
|
||||||
XDocument xDocument = null;
|
XDocument? xDocument = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
xDocument = XDocument.Load(path);
|
xDocument = XDocument.Load(path);
|
||||||
|
@ -255,10 +275,10 @@ namespace SystemTrayMenu.Properties
|
||||||
CreateEmptyConfigIfNotExists(UserConfigPath);
|
CreateEmptyConfigIfNotExists(UserConfigPath);
|
||||||
|
|
||||||
// load the xml
|
// load the xml
|
||||||
XDocument configXml;
|
XDocument? configXml;
|
||||||
if (IsConfigPathAssembly())
|
if (IsConfigPathAssembly())
|
||||||
{
|
{
|
||||||
configXml = LoadOrGetNew(ConfigPathAssembly);
|
configXml = LoadOrGetNew(ConfigPathAssembly!);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -268,19 +288,27 @@ namespace SystemTrayMenu.Properties
|
||||||
if (configXml != null)
|
if (configXml != null)
|
||||||
{
|
{
|
||||||
// get all of the <setting name="..." serializeAs="..."> elements.
|
// get all of the <setting name="..." serializeAs="..."> elements.
|
||||||
IEnumerable<XElement> settingElements = configXml.Element(Config).Element(UserSettings).Element(typeof(Settings).FullName).Elements(Setting);
|
IEnumerable<XElement>? settingElements = configXml.Element(Config)?.Element(UserSettings)?.Element(typeof(Settings).FullName)?.Elements(Setting);
|
||||||
|
|
||||||
// iterate through, adding them to the dictionary, (checking for nulls, xml no likey nulls)
|
// iterate through, adding them to the dictionary, (checking for nulls, xml no likey nulls)
|
||||||
// using "String" as default serializeAs...just in case, no real good reason.
|
// using "String" as default serializeAs...just in case, no real good reason.
|
||||||
|
if (settingElements != null)
|
||||||
|
{
|
||||||
foreach (XElement element in settingElements)
|
foreach (XElement element in settingElements)
|
||||||
{
|
{
|
||||||
|
string? name = element.Attribute(NameOf)?.Value;
|
||||||
|
if (name != null)
|
||||||
|
{
|
||||||
|
string? serializeAs = element.Attribute(SerializeAs)?.Value;
|
||||||
SettingStruct newSetting = new()
|
SettingStruct newSetting = new()
|
||||||
{
|
{
|
||||||
Name = element.Attribute(NameOf) == null ? string.Empty : element.Attribute(NameOf).Value,
|
Name = element.Attribute(NameOf) == null ? string.Empty : name,
|
||||||
SerializeAs = element.Attribute(SerializeAs) == null ? "String" : element.Attribute(SerializeAs).Value,
|
SerializeAs = serializeAs == null ? "String" : serializeAs,
|
||||||
Value = element.Value ?? string.Empty,
|
Value = element.Value ?? string.Empty,
|
||||||
};
|
};
|
||||||
SettingsDictionary.Add(element.Attribute(NameOf).Value, newSetting);
|
SettingsDictionary.Add(name, newSetting);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -291,10 +319,10 @@ namespace SystemTrayMenu.Properties
|
||||||
private void SaveValuesToFile()
|
private void SaveValuesToFile()
|
||||||
{
|
{
|
||||||
// load the current xml from the file.
|
// load the current xml from the file.
|
||||||
XDocument configXml;
|
XDocument? configXml;
|
||||||
if (IsConfigPathAssembly())
|
if (IsConfigPathAssembly())
|
||||||
{
|
{
|
||||||
configXml = LoadOrGetNew(ConfigPathAssembly);
|
configXml = LoadOrGetNew(ConfigPathAssembly!);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -304,12 +332,12 @@ namespace SystemTrayMenu.Properties
|
||||||
if (configXml != null)
|
if (configXml != null)
|
||||||
{
|
{
|
||||||
// get the settings group (e.g. <Company.Project.Desktop.Settings>)
|
// get the settings group (e.g. <Company.Project.Desktop.Settings>)
|
||||||
XElement settingsSection = configXml.Element(Config).Element(UserSettings).Element(typeof(Settings).FullName);
|
XElement? settingsSection = configXml.Element(Config)?.Element(UserSettings)?.Element(typeof(Settings).FullName);
|
||||||
|
|
||||||
// iterate though the dictionary, either updating the value or adding the new setting.
|
// iterate though the dictionary, either updating the value or adding the new setting.
|
||||||
foreach (KeyValuePair<string, SettingStruct> entry in SettingsDictionary)
|
foreach (KeyValuePair<string, SettingStruct> entry in SettingsDictionary)
|
||||||
{
|
{
|
||||||
XElement setting = settingsSection.Elements().FirstOrDefault(e => e.Attribute(NameOf).Value == entry.Key);
|
XElement? setting = settingsSection?.Elements().FirstOrDefault(e => e.Attribute(NameOf)?.Value == entry.Key);
|
||||||
if (setting == null)
|
if (setting == null)
|
||||||
{
|
{
|
||||||
// this can happen if a new setting is added via the .settings designer.
|
// this can happen if a new setting is added via the .settings designer.
|
||||||
|
@ -317,7 +345,7 @@ namespace SystemTrayMenu.Properties
|
||||||
newSetting.Add(new XAttribute(NameOf, entry.Value.Name));
|
newSetting.Add(new XAttribute(NameOf, entry.Value.Name));
|
||||||
newSetting.Add(new XAttribute(SerializeAs, entry.Value.SerializeAs));
|
newSetting.Add(new XAttribute(SerializeAs, entry.Value.SerializeAs));
|
||||||
newSetting.Value = entry.Value.Value ?? string.Empty;
|
newSetting.Value = entry.Value.Value ?? string.Empty;
|
||||||
settingsSection.Add(newSetting);
|
settingsSection?.Add(newSetting);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -328,7 +356,7 @@ namespace SystemTrayMenu.Properties
|
||||||
|
|
||||||
if (IsConfigPathAssembly())
|
if (IsConfigPathAssembly())
|
||||||
{
|
{
|
||||||
configXml.Save(ConfigPathAssembly);
|
configXml.Save(ConfigPathAssembly!);
|
||||||
}
|
}
|
||||||
|
|
||||||
configXml.Save(UserConfigPath);
|
configXml.Save(UserConfigPath);
|
||||||
|
|
|
@ -6,7 +6,6 @@ namespace SystemTrayMenu.UserInterface
|
||||||
{
|
{
|
||||||
using System;
|
using System;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Input;
|
|
||||||
using Hardcodet.Wpf.TaskbarNotification;
|
using Hardcodet.Wpf.TaskbarNotification;
|
||||||
using SystemTrayMenu.Helper;
|
using SystemTrayMenu.Helper;
|
||||||
using SystemTrayMenu.Utilities;
|
using SystemTrayMenu.Utilities;
|
||||||
|
@ -23,20 +22,16 @@ namespace SystemTrayMenu.UserInterface
|
||||||
|
|
||||||
AppContextMenu contextMenus = new();
|
AppContextMenu contextMenus = new();
|
||||||
|
|
||||||
contextMenus.ClickedOpenLog += ClickedOpenLog;
|
contextMenus.ClickedOpenLog += () => OpenLog?.Invoke();
|
||||||
void ClickedOpenLog()
|
|
||||||
{
|
|
||||||
OpenLog?.Invoke();
|
|
||||||
}
|
|
||||||
|
|
||||||
notifyIcon.ContextMenu = contextMenus.Create();
|
notifyIcon.ContextMenu = contextMenus.Create();
|
||||||
notifyIcon.LeftClickCommand = new ActionCommand((_) => Click?.Invoke());
|
notifyIcon.LeftClickCommand = new ActionCommand((_) => Click?.Invoke());
|
||||||
notifyIcon.DoubleClickCommand = new ActionCommand((_) => Click?.Invoke());
|
notifyIcon.DoubleClickCommand = new ActionCommand((_) => Click?.Invoke());
|
||||||
}
|
}
|
||||||
|
|
||||||
public event Action Click;
|
public event Action? Click;
|
||||||
|
|
||||||
public event Action OpenLog;
|
public event Action? OpenLog;
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
|
|
@ -166,8 +166,8 @@ namespace SystemTrayMenu.UserInterface
|
||||||
#endif
|
#endif
|
||||||
#if TODO // TOUCH
|
#if TODO // TOUCH
|
||||||
bool isTouchEnabled = NativeMethods.IsTouchEnabled();
|
bool isTouchEnabled = NativeMethods.IsTouchEnabled();
|
||||||
if ((isTouchEnabled && Properties.Settings.Default.DragDropItemsEnabledTouch) ||
|
if ((isTouchEnabled && Settings.Default.DragDropItemsEnabledTouch) ||
|
||||||
(!isTouchEnabled && Properties.Settings.Default.DragDropItemsEnabled))
|
(!isTouchEnabled && Settings.Default.DragDropItemsEnabled))
|
||||||
{
|
{
|
||||||
AllowDrop = true;
|
AllowDrop = true;
|
||||||
DragEnter += DragDropHelper.DragEnter;
|
DragEnter += DragDropHelper.DragEnter;
|
||||||
|
@ -492,7 +492,7 @@ namespace SystemTrayMenu.UserInterface
|
||||||
/// <param name="isCustomLocationOutsideOfScreen">isCustomLocationOutsideOfScreen.</param>
|
/// <param name="isCustomLocationOutsideOfScreen">isCustomLocationOutsideOfScreen.</param>
|
||||||
internal void AdjustSizeAndLocation(
|
internal void AdjustSizeAndLocation(
|
||||||
Rect bounds,
|
Rect bounds,
|
||||||
Menu menuPredecessor,
|
Menu? menuPredecessor,
|
||||||
StartLocation startLocation,
|
StartLocation startLocation,
|
||||||
bool isCustomLocationOutsideOfScreen)
|
bool isCustomLocationOutsideOfScreen)
|
||||||
{
|
{
|
||||||
|
@ -500,7 +500,7 @@ namespace SystemTrayMenu.UserInterface
|
||||||
AdjustDataGridViewHeight(menuPredecessor, bounds.Height);
|
AdjustDataGridViewHeight(menuPredecessor, bounds.Height);
|
||||||
AdjustDataGridViewWidth();
|
AdjustDataGridViewWidth();
|
||||||
|
|
||||||
bool useCustomLocation = Properties.Settings.Default.UseCustomLocation || lastLocation.X > 0;
|
bool useCustomLocation = Settings.Default.UseCustomLocation || lastLocation.X > 0;
|
||||||
bool changeDirectionWhenOutOfBounds = true;
|
bool changeDirectionWhenOutOfBounds = true;
|
||||||
|
|
||||||
if (menuPredecessor != null)
|
if (menuPredecessor != null)
|
||||||
|
@ -519,13 +519,13 @@ namespace SystemTrayMenu.UserInterface
|
||||||
// Use this menu as predecessor and overwrite location with CustomLocation
|
// Use this menu as predecessor and overwrite location with CustomLocation
|
||||||
menuPredecessor = this;
|
menuPredecessor = this;
|
||||||
Tag = new RowData();
|
Tag = new RowData();
|
||||||
Left = Properties.Settings.Default.CustomLocationX;
|
Left = Settings.Default.CustomLocationX;
|
||||||
Top = Properties.Settings.Default.CustomLocationY;
|
Top = Settings.Default.CustomLocationY;
|
||||||
directionToRight = true;
|
directionToRight = true;
|
||||||
startLocation = StartLocation.Predecessor;
|
startLocation = StartLocation.Predecessor;
|
||||||
changeDirectionWhenOutOfBounds = false;
|
changeDirectionWhenOutOfBounds = false;
|
||||||
}
|
}
|
||||||
else if (Properties.Settings.Default.AppearAtMouseLocation)
|
else if (Settings.Default.AppearAtMouseLocation)
|
||||||
{
|
{
|
||||||
// Do not adjust location again because Cursor.Postion changed
|
// Do not adjust location again because Cursor.Postion changed
|
||||||
if (Tag != null)
|
if (Tag != null)
|
||||||
|
@ -635,16 +635,16 @@ namespace SystemTrayMenu.UserInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Level != 0 &&
|
if (Level != 0 &&
|
||||||
!Properties.Settings.Default.AppearNextToPreviousMenu &&
|
!Settings.Default.AppearNextToPreviousMenu &&
|
||||||
menuPredecessor != null && menuPredecessor.Width > Properties.Settings.Default.OverlappingOffsetPixels)
|
menuPredecessor != null && menuPredecessor.Width > Settings.Default.OverlappingOffsetPixels)
|
||||||
{
|
{
|
||||||
if (directionToRight)
|
if (directionToRight)
|
||||||
{
|
{
|
||||||
x = x - menuPredecessor.Width + Properties.Settings.Default.OverlappingOffsetPixels;
|
x = x - menuPredecessor.Width + Settings.Default.OverlappingOffsetPixels;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
x = x + menuPredecessor.Width - Properties.Settings.Default.OverlappingOffsetPixels;
|
x = x + menuPredecessor.Width - Settings.Default.OverlappingOffsetPixels;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -749,7 +749,7 @@ namespace SystemTrayMenu.UserInterface
|
||||||
Left = x;
|
Left = x;
|
||||||
Top = y;
|
Top = y;
|
||||||
|
|
||||||
if (Properties.Settings.Default.RoundCorners)
|
if (Settings.Default.RoundCorners)
|
||||||
{
|
{
|
||||||
windowFrame.CornerRadius = new CornerRadius(CornerRadius);
|
windowFrame.CornerRadius = new CornerRadius(CornerRadius);
|
||||||
}
|
}
|
||||||
|
@ -842,12 +842,12 @@ namespace SystemTrayMenu.UserInterface
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AdjustDataGridViewHeight(Menu menuPredecessor, double screenHeightMax)
|
private void AdjustDataGridViewHeight(Menu? menuPredecessor, double screenHeightMax)
|
||||||
{
|
{
|
||||||
double factor = Properties.Settings.Default.RowHeighteInPercentage / 100f;
|
double factor = Settings.Default.RowHeighteInPercentage / 100f;
|
||||||
if (NativeMethods.IsTouchEnabled())
|
if (NativeMethods.IsTouchEnabled())
|
||||||
{
|
{
|
||||||
factor = Properties.Settings.Default.RowHeighteInPercentageTouch / 100f;
|
factor = Settings.Default.RowHeighteInPercentageTouch / 100f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (menuPredecessor == null)
|
if (menuPredecessor == null)
|
||||||
|
@ -876,7 +876,7 @@ namespace SystemTrayMenu.UserInterface
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
double heightMaxByOptions = Scaling.Factor * Scaling.FactorByDpi *
|
double heightMaxByOptions = Scaling.Factor * Scaling.FactorByDpi *
|
||||||
450f * (Properties.Settings.Default.HeightMaxInPercent / 100f);
|
450f * (Settings.Default.HeightMaxInPercent / 100f);
|
||||||
MaxHeight = Math.Min(screenHeightMax, heightMaxByOptions);
|
MaxHeight = Math.Min(screenHeightMax, heightMaxByOptions);
|
||||||
#if TODO // SEARCH
|
#if TODO // SEARCH
|
||||||
dgvHeightSet = true;
|
dgvHeightSet = true;
|
||||||
|
@ -901,7 +901,7 @@ namespace SystemTrayMenu.UserInterface
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
double factorIconSizeInPercent = Properties.Settings.Default.IconSizeInPercent / 100f;
|
double factorIconSizeInPercent = Settings.Default.IconSizeInPercent / 100f;
|
||||||
|
|
||||||
// IcoWidth 100% = 21px, 175% is 33, +3+2 is padding from ColumnIcon
|
// IcoWidth 100% = 21px, 175% is 33, +3+2 is padding from ColumnIcon
|
||||||
double icoWidth = (16 * Scaling.FactorByDpi) + 5;
|
double icoWidth = (16 * Scaling.FactorByDpi) + 5;
|
||||||
|
@ -926,7 +926,7 @@ namespace SystemTrayMenu.UserInterface
|
||||||
|
|
||||||
Resources["ColumnTextWidth"] = Math.Min(
|
Resources["ColumnTextWidth"] = Math.Min(
|
||||||
renderedMaxWidth,
|
renderedMaxWidth,
|
||||||
(double)(Scaling.Factor * Scaling.FactorByDpi * 400f * (Properties.Settings.Default.WidthMaxInPercent / 100f)));
|
(double)(Scaling.Factor * Scaling.FactorByDpi * 400f * (Settings.Default.WidthMaxInPercent / 100f)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleScrollChanged(object sender, ScrollChangedEventArgs e)
|
private void HandleScrollChanged(object sender, ScrollChangedEventArgs e)
|
||||||
|
@ -981,7 +981,7 @@ namespace SystemTrayMenu.UserInterface
|
||||||
foreach (DataRow row in data.Rows)
|
foreach (DataRow row in data.Rows)
|
||||||
{
|
{
|
||||||
RowData rowData = (RowData)row[2];
|
RowData rowData = (RowData)row[2];
|
||||||
if (rowData.IsAddionalItem && Properties.Settings.Default.ShowOnlyAsSearchResult)
|
if (rowData.IsAddionalItem && Settings.Default.ShowOnlyAsSearchResult)
|
||||||
{
|
{
|
||||||
row[columnSortIndex] = 99;
|
row[columnSortIndex] = 99;
|
||||||
}
|
}
|
||||||
|
@ -1022,7 +1022,7 @@ namespace SystemTrayMenu.UserInterface
|
||||||
RowData rowData = (RowData)row.Cells[2].Value;
|
RowData rowData = (RowData)row.Cells[2].Value;
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(userPattern) ||
|
if (!string.IsNullOrEmpty(userPattern) ||
|
||||||
!(rowData.IsAddionalItem && Properties.Settings.Default.ShowOnlyAsSearchResult))
|
!(rowData.IsAddionalItem && Settings.Default.ShowOnlyAsSearchResult))
|
||||||
{
|
{
|
||||||
rowData.RowIndex = row.Index;
|
rowData.RowIndex = row.Index;
|
||||||
|
|
||||||
|
@ -1146,7 +1146,11 @@ namespace SystemTrayMenu.UserInterface
|
||||||
if (rowData.IconLoading)
|
if (rowData.IconLoading)
|
||||||
{
|
{
|
||||||
iconsToUpdate++;
|
iconsToUpdate++;
|
||||||
row.ColumnIcon = rowData.ReadIcon(false).ToImageSource();
|
rowData.ReadIcon(false);
|
||||||
|
if (rowData.Icon != null)
|
||||||
|
{
|
||||||
|
row.ColumnIcon = rowData.Icon.ToImageSource();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1179,19 +1183,19 @@ namespace SystemTrayMenu.UserInterface
|
||||||
Top = Top + mousePos.Y - lastLocation.Y;
|
Top = Top + mousePos.Y - lastLocation.Y;
|
||||||
lastLocation = mousePos;
|
lastLocation = mousePos;
|
||||||
|
|
||||||
Properties.Settings.Default.CustomLocationX = (int)Left;
|
Settings.Default.CustomLocationX = (int)Left;
|
||||||
Properties.Settings.Default.CustomLocationY = (int)Top;
|
Settings.Default.CustomLocationY = (int)Top;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Menu_MouseUp(object sender, MouseButtonEventArgs e)
|
private void Menu_MouseUp(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
mouseDown = false;
|
mouseDown = false;
|
||||||
if (Properties.Settings.Default.UseCustomLocation)
|
if (Settings.Default.UseCustomLocation)
|
||||||
{
|
{
|
||||||
if (!SettingsWindow.IsOpen())
|
if (!SettingsWindow.IsOpen())
|
||||||
{
|
{
|
||||||
Properties.Settings.Default.Save();
|
Settings.Default.Save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ namespace SystemTrayMenu.Utilities
|
||||||
|
|
||||||
public static void RemoveIconFromCache(string path)
|
public static void RemoveIconFromCache(string path)
|
||||||
{
|
{
|
||||||
if (DictIconCacheMainMenu.Remove(path, out Icon iconToRemove))
|
if (DictIconCacheMainMenu.Remove(path, out Icon? iconToRemove))
|
||||||
{
|
{
|
||||||
iconToRemove?.Dispose();
|
iconToRemove?.Dispose();
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ namespace SystemTrayMenu.Utilities
|
||||||
key = extension + linkOverlay;
|
key = extension + linkOverlay;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!DictIconCache(isMainMenu).TryGetValue(key, out Icon icon) &&
|
if (!DictIconCache(isMainMenu).TryGetValue(key, out Icon? icon) &&
|
||||||
!DictIconCache(!isMainMenu).TryGetValue(key, out icon))
|
!DictIconCache(!isMainMenu).TryGetValue(key, out icon))
|
||||||
{
|
{
|
||||||
icon = Resources.StaticResources.LoadingIcon;
|
icon = Resources.StaticResources.LoadingIcon;
|
||||||
|
@ -143,7 +143,7 @@ namespace SystemTrayMenu.Utilities
|
||||||
|
|
||||||
string key = path;
|
string key = path;
|
||||||
|
|
||||||
if (!DictIconCache(isMainMenu).TryGetValue(key, out Icon icon) &&
|
if (!DictIconCache(isMainMenu).TryGetValue(key, out Icon? icon) &&
|
||||||
!DictIconCache(!isMainMenu).TryGetValue(key, out icon))
|
!DictIconCache(!isMainMenu).TryGetValue(key, out icon))
|
||||||
{
|
{
|
||||||
icon = Resources.StaticResources.LoadingIcon;
|
icon = Resources.StaticResources.LoadingIcon;
|
||||||
|
@ -174,9 +174,9 @@ namespace SystemTrayMenu.Utilities
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Icon GetIconSTA(string path, string resolvedPath, bool linkOverlay, IconSize size, bool isFolder)
|
public static Icon? GetIconSTA(string path, string resolvedPath, bool linkOverlay, IconSize size, bool isFolder)
|
||||||
{
|
{
|
||||||
Icon icon = null;
|
Icon? icon = null;
|
||||||
if (Thread.CurrentThread.GetApartmentState() == ApartmentState.STA)
|
if (Thread.CurrentThread.GetApartmentState() == ApartmentState.STA)
|
||||||
{
|
{
|
||||||
icon = GetIcon(path, resolvedPath, linkOverlay, size, isFolder);
|
icon = GetIcon(path, resolvedPath, linkOverlay, size, isFolder);
|
||||||
|
@ -184,7 +184,7 @@ namespace SystemTrayMenu.Utilities
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Thread staThread = new(new ParameterizedThreadStart(StaThreadMethod));
|
Thread staThread = new(new ParameterizedThreadStart(StaThreadMethod));
|
||||||
void StaThreadMethod(object obj)
|
void StaThreadMethod(object? obj)
|
||||||
{
|
{
|
||||||
icon = GetIcon(path, resolvedPath, linkOverlay, size, isFolder);
|
icon = GetIcon(path, resolvedPath, linkOverlay, size, isFolder);
|
||||||
}
|
}
|
||||||
|
@ -197,9 +197,9 @@ namespace SystemTrayMenu.Utilities
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Icon AddIconOverlay(Icon originalIcon, Icon overlay)
|
public static Icon? AddIconOverlay(Icon? originalIcon, Icon overlay)
|
||||||
{
|
{
|
||||||
Icon icon = null;
|
Icon? icon = originalIcon;
|
||||||
if (originalIcon != null)
|
if (originalIcon != null)
|
||||||
{
|
{
|
||||||
using Bitmap target = new(originalIcon.Width, originalIcon.Height, PixelFormat.Format32bppArgb);
|
using Bitmap target = new(originalIcon.Width, originalIcon.Height, PixelFormat.Format32bppArgb);
|
||||||
|
@ -239,9 +239,9 @@ namespace SystemTrayMenu.Utilities
|
||||||
return isExtensionWithSameIcon;
|
return isExtensionWithSameIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Icon GetIcon(string path, string resolvedPath, bool linkOverlay, IconSize size, bool isFolder)
|
private static Icon? GetIcon(string path, string resolvedPath, bool linkOverlay, IconSize size, bool isFolder)
|
||||||
{
|
{
|
||||||
Icon icon;
|
Icon? icon;
|
||||||
if (Path.GetExtension(path).Equals(".ico", StringComparison.InvariantCultureIgnoreCase))
|
if (Path.GetExtension(path).Equals(".ico", StringComparison.InvariantCultureIgnoreCase))
|
||||||
{
|
{
|
||||||
icon = Icon.ExtractAssociatedIcon(path);
|
icon = Icon.ExtractAssociatedIcon(path);
|
||||||
|
@ -288,10 +288,10 @@ namespace SystemTrayMenu.Utilities
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Icon GetIcon(
|
private static Icon? GetIcon(
|
||||||
string path, bool linkOverlay, NativeMethods.SHFILEINFO shFileInfo, IntPtr imageList)
|
string path, bool linkOverlay, NativeMethods.SHFILEINFO shFileInfo, IntPtr imageList)
|
||||||
{
|
{
|
||||||
Icon icon = null;
|
Icon? icon = null;
|
||||||
if (imageList != IntPtr.Zero)
|
if (imageList != IntPtr.Zero)
|
||||||
{
|
{
|
||||||
IntPtr hIcon;
|
IntPtr hIcon;
|
||||||
|
|
|
@ -149,7 +149,7 @@ namespace SystemTrayMenu.Utilities
|
||||||
string fileName,
|
string fileName,
|
||||||
string arguments = "",
|
string arguments = "",
|
||||||
bool doubleQuoteArg = false,
|
bool doubleQuoteArg = false,
|
||||||
string workingDirectory = "",
|
string? workingDirectory = null,
|
||||||
bool createNoWindow = false,
|
bool createNoWindow = false,
|
||||||
string resolvedPath = "")
|
string resolvedPath = "")
|
||||||
{
|
{
|
||||||
|
@ -166,7 +166,7 @@ namespace SystemTrayMenu.Utilities
|
||||||
{
|
{
|
||||||
FileName = fileName,
|
FileName = fileName,
|
||||||
Arguments = arguments,
|
Arguments = arguments,
|
||||||
WorkingDirectory = workingDirectory,
|
WorkingDirectory = workingDirectory ?? string.Empty,
|
||||||
CreateNoWindow = createNoWindow,
|
CreateNoWindow = createNoWindow,
|
||||||
UseShellExecute = true,
|
UseShellExecute = true,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue