diff --git a/EverythingToolbar.Deskband/CSDeskBand.cs b/EverythingToolbar.Deskband/CSDeskBand.cs
index 33ac78f1b..605a30476 100644
--- a/EverythingToolbar.Deskband/CSDeskBand.cs
+++ b/EverythingToolbar.Deskband/CSDeskBand.cs
@@ -16,7 +16,6 @@
using CSDeskBand.ContextMenu;
using CSDeskBand.Interop;
using EverythingToolbar.Helpers;
-using EverythingToolbar.Properties;
using Microsoft.Win32;
using NLog;
using MSG = CSDeskBand.Interop.MSG;
@@ -38,7 +37,7 @@ internal sealed class CSDeskBandImpl : ICSDeskBand
private IntPtr _parentWindowHandle;
private object _parentSite; // Has these interfaces: IInputObjectSite, IOleWindow, IOleCommandTarget, IBandSite
private uint _id;
- private uint _menutStartId = 0;
+ private uint _menutStartId;
private Guid _deskbandCommandGroupId = new Guid("EB0FE172-1A3A-11D0-89B3-00A0C90A90AC"); // Command group id for deskband. Used for IOleCommandTarge.Exec
///
@@ -436,8 +435,8 @@ public sealed class CSDeskBandOptions : INotifyPropertyChanged
private int _maxVerticalWidth;
private DeskBandSize _minVerticalSize;
private string _title = "";
- private bool _showTitle = false;
- private bool _isFixed = false;
+ private bool _showTitle;
+ private bool _isFixed;
private int _heightIncrement = 1;
private bool _heightCanChange = true;
private ICollection _contextMenuItems = new List();
@@ -1064,11 +1063,9 @@ protected virtual IntPtr HwndSourceHook(IntPtr hwnd, int msg, IntPtr wparam, Int
handled = true;
return new IntPtr((int)HitTestMessageResults.HTCLIENT);
}
- else
- {
- handled = true;
- return new IntPtr((int)HitTestMessageResults.HTTRANSPARENT);
- }
+
+ handled = true;
+ return new IntPtr((int)HitTestMessageResults.HTTRANSPARENT);
}
handled = false;
@@ -1441,14 +1438,14 @@ public static void Register(Type t)
if (GetToolbarRequestToShow(t))
{
- Console.WriteLine($"Request to show deskband.");
+ Console.WriteLine("Request to show deskband.");
// https://www.pinvoke.net/default.aspx/Interfaces.ITrayDeskband
ITrayDeskband csdeskband = null;
try
{
- Type trayDeskbandType = Type.GetTypeFromCLSID(new Guid("E6442437-6C68-4f52-94DD-2CFED267EFB9"));
- Guid deskbandGuid = t.GUID;
+ var trayDeskbandType = Type.GetTypeFromCLSID(new Guid("E6442437-6C68-4f52-94DD-2CFED267EFB9"));
+ var deskbandGuid = t.GUID;
csdeskband = (ITrayDeskband)Activator.CreateInstance(trayDeskbandType);
if (csdeskband != null)
{
@@ -1458,7 +1455,7 @@ public static void Register(Type t)
{
if (csdeskband.ShowDeskBand(ref deskbandGuid) != HRESULT.S_OK)
{
- Console.WriteLine($"Error while trying to show deskband.");
+ Console.WriteLine("Error while trying to show deskband.");
}
if (csdeskband.DeskBandRegistrationChanged() == HRESULT.S_OK)
@@ -1470,7 +1467,7 @@ public static void Register(Type t)
}
catch (Exception e)
{
- Console.WriteLine($"Error while trying to show deskband: {e.ToString()}");
+ Console.WriteLine($"Error while trying to show deskband: {e}");
}
finally
{
@@ -1678,7 +1675,7 @@ private set
///
internal void UpdateInfo()
{
- APPBARDATA data = new APPBARDATA
+ var data = new APPBARDATA
{
hWnd = IntPtr.Zero,
cbSize = Marshal.SizeOf()
@@ -2075,7 +2072,7 @@ internal enum tagDESKBANDCID
DBID_SHOWONLY = 1,
DBID_MAXIMIZEBAND = 2,
DBID_PUSHCHEVRON = 3
- };
+ }
[StructLayout(LayoutKind.Sequential)]
public struct RECT
@@ -2216,7 +2213,7 @@ internal class HRESULT
public static int MakeHResult(uint sev, uint facility, uint errorNo)
{
- uint result = sev << 31 | facility << 16 | errorNo;
+ var result = sev << 31 | facility << 16 | errorNo;
return unchecked((int)result);
}
}
@@ -2548,7 +2545,7 @@ internal sealed class DeskBandMenuSeparator : DeskBandMenuItem
///
internal override void AddToMenu(IntPtr menu, uint itemPosition, ref uint itemId, Dictionary callbacks)
{
- _menuiteminfo = new MENUITEMINFO()
+ _menuiteminfo = new MENUITEMINFO
{
cbSize = Marshal.SizeOf(),
fMask = MENUITEMINFO.MIIM.MIIM_TYPE,
@@ -2618,7 +2615,7 @@ internal void DoAction()
///
internal override void AddToMenu(IntPtr menu, uint itemPosition, ref uint itemId, Dictionary callbacks)
{
- _menuiteminfo = new MENUITEMINFO()
+ _menuiteminfo = new MENUITEMINFO
{
cbSize = Marshal.SizeOf(),
fMask = MENUITEMINFO.MIIM.MIIM_TYPE | MENUITEMINFO.MIIM.MIIM_STATE | MENUITEMINFO.MIIM.MIIM_ID,
@@ -2714,7 +2711,7 @@ internal override void AddToMenu(IntPtr menu, uint itemPosition, ref uint itemId
item.AddToMenu(_menu, index++, ref itemId, callbacks);
}
- _menuiteminfo = new MENUITEMINFO()
+ _menuiteminfo = new MENUITEMINFO
{
cbSize = Marshal.SizeOf(),
fMask = MENUITEMINFO.MIIM.MIIM_SUBMENU | MENUITEMINFO.MIIM.MIIM_STRING | MENUITEMINFO.MIIM.MIIM_STATE,
diff --git a/EverythingToolbar.Deskband/Converters/SearchControlVisibilityConverter.cs b/EverythingToolbar.Deskband/Converters/SearchControlVisibilityConverter.cs
index 2c4a486c3..90347cfbc 100644
--- a/EverythingToolbar.Deskband/Converters/SearchControlVisibilityConverter.cs
+++ b/EverythingToolbar.Deskband/Converters/SearchControlVisibilityConverter.cs
@@ -5,7 +5,6 @@
using System.Windows.Data;
using System.Windows.Markup;
using CSDeskBand.Interop;
-using EverythingToolbar.Helpers;
namespace EverythingToolbar.Deskband.Converters
{
diff --git a/EverythingToolbar.Launcher/SetupAssistant.xaml b/EverythingToolbar.Launcher/SetupAssistant.xaml
index 726f0fc6b..0c0ca77f4 100644
--- a/EverythingToolbar.Launcher/SetupAssistant.xaml
+++ b/EverythingToolbar.Launcher/SetupAssistant.xaml
@@ -116,9 +116,9 @@
-
-
-
+
+
+
-
-
-
+
+
+
+ systemThemeWatcher.OnChangeValue += newValue =>
{
Dispatcher.Invoke(() => {
ApplyTheme((int)newValue == 1);
@@ -133,7 +134,7 @@ private void ApplyTheme(bool isLightTheme)
}
// Notify resource change
- ResourceChanged?.Invoke(this, new ResourcesChangedEventArgs()
+ ResourceChanged?.Invoke(this, new ResourcesChangedEventArgs
{
NewResource = _currentResources,
NewTheme = isLightTheme ? Theme.Light : Theme.Dark
@@ -152,7 +153,7 @@ private static void AddResource(string path, string fallbackPath = null)
return;
}
- var resDict = new ResourceDictionary() { Source = new Uri(path) };
+ var resDict = new ResourceDictionary { Source = new Uri(path) };
_currentResources.MergedDictionaries.Add(resDict);
}
@@ -163,9 +164,9 @@ private void SetAccentColor(SolidColorBrush brush)
_currentResources.MergedDictionaries.Add(resDict);
}
- private static SolidColorBrush GetBrush(Windows.UI.Color color)
+ private static SolidColorBrush GetBrush(Color color)
{
- return new SolidColorBrush(Color.FromArgb(color.A, color.R, color.G, color.B));
+ return new SolidColorBrush(System.Windows.Media.Color.FromArgb(color.A, color.R, color.G, color.B));
}
}
}
diff --git a/EverythingToolbar/Controls/SearchBox.xaml.cs b/EverythingToolbar/Controls/SearchBox.xaml.cs
index a18ebd3ca..c61852361 100644
--- a/EverythingToolbar/Controls/SearchBox.xaml.cs
+++ b/EverythingToolbar/Controls/SearchBox.xaml.cs
@@ -13,7 +13,7 @@ public partial class SearchBox : UserControl
{
public event EventHandler TextChanged;
- private int LastCaretIndex = 0;
+ private int LastCaretIndex;
public SearchBox()
{
@@ -124,7 +124,7 @@ private void OnLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
private void SelectivelyIgnoreMouseButton(object sender, MouseButtonEventArgs e)
{
- TextBox textBox = (sender as TextBox);
+ var textBox = (sender as TextBox);
if (textBox != null)
{
if (!textBox.IsKeyboardFocusWithin)
diff --git a/EverythingToolbar/Controls/SearchButton.xaml.cs b/EverythingToolbar/Controls/SearchButton.xaml.cs
index de2dd04a8..2804218e0 100644
--- a/EverythingToolbar/Controls/SearchButton.xaml.cs
+++ b/EverythingToolbar/Controls/SearchButton.xaml.cs
@@ -21,19 +21,19 @@ public SearchButton()
private void OnSearchWindowDeactivated(object sender, EventArgs e)
{
- Border border = Template.FindName("OuterBorder", this) as Border;
+ var border = Template.FindName("OuterBorder", this) as Border;
border.Background = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
}
private void OnSearchWindowActivated(object sender, EventArgs e)
{
- Border border = Template.FindName("OuterBorder", this) as Border;
+ var border = Template.FindName("OuterBorder", this) as Border;
border.Background = new SolidColorBrush(Color.FromArgb(64, 255, 255, 255));
}
private void UpdateTheme(Theme newTheme)
{
- Border border = Template.FindName("OuterBorder", this) as Border;
+ var border = Template.FindName("OuterBorder", this) as Border;
if (newTheme == Theme.Light)
{
Foreground = new SolidColorBrush(Colors.Black);
diff --git a/EverythingToolbar/Controls/SearchResultsView.xaml.cs b/EverythingToolbar/Controls/SearchResultsView.xaml.cs
index 7c58809f6..7922da63a 100644
--- a/EverythingToolbar/Controls/SearchResultsView.xaml.cs
+++ b/EverythingToolbar/Controls/SearchResultsView.xaml.cs
@@ -59,10 +59,10 @@ private void RegisterItemContainerStyleProperties(object sender, ResourcesChange
Event = MouseMoveEvent,
Handler = new MouseEventHandler(OnListViewItemMouseMove)
});
- SearchResultsListView.ItemContainerStyle.Setters.Add(new Setter()
+ SearchResultsListView.ItemContainerStyle.Setters.Add(new Setter
{
Property = ContextMenuProperty,
- Value = new Binding() { Source = Resources["ListViewItemContextMenu"] }
+ Value = new Binding { Source = Resources["ListViewItemContextMenu"] }
});
}
@@ -370,7 +370,7 @@ private void OnOpenWithMenuLoaded(object sender, RoutedEventArgs e)
for (var i = rules.Count - 1; i >= 0; i--)
{
var rule = rules[i];
- var ruleMenuItem = new MenuItem() { Header = rule.Name, Tag = rule.Command };
+ var ruleMenuItem = new MenuItem { Header = rule.Name, Tag = rule.Command };
ruleMenuItem.Click += OpenWithRule;
mi.Items.Insert(0, ruleMenuItem);
}
diff --git a/EverythingToolbar/Controls/SettingsControl.xaml.cs b/EverythingToolbar/Controls/SettingsControl.xaml.cs
index 80cb1bb0f..abd747d17 100644
--- a/EverythingToolbar/Controls/SettingsControl.xaml.cs
+++ b/EverythingToolbar/Controls/SettingsControl.xaml.cs
@@ -19,9 +19,9 @@ public SettingsControl()
(SortByMenu.Items[Settings.Default.sortBy - 1] as MenuItem).IsChecked = true;
// Preselect active datatemplate
- for (int i = 0; i < ItemTemplateMenu.Items.Count; i++)
+ for (var i = 0; i < ItemTemplateMenu.Items.Count; i++)
{
- MenuItem menuItem = ItemTemplateMenu.Items[i] as MenuItem;
+ var menuItem = ItemTemplateMenu.Items[i] as MenuItem;
if (menuItem.Tag.ToString() == Settings.Default.itemTemplate)
menuItem.IsChecked = true;
else
@@ -58,13 +58,13 @@ private void OpenInstanceNameDialog(object sender, RoutedEventArgs e)
private void OpenShortcutWindow(object sender, RoutedEventArgs e)
{
SearchWindow.Instance.Hide();
- ShortcutSelector shortcutSelector = new ShortcutSelector();
+ var shortcutSelector = new ShortcutSelector();
if (shortcutSelector.ShowDialog().Value)
{
if (shortcutSelector.Modifiers == ModifierKeys.Windows)
{
ShortcutManager.Instance.SetShortcut(shortcutSelector.Key, shortcutSelector.Modifiers);
- foreach (Process exe in Process.GetProcesses())
+ foreach (var exe in Process.GetProcesses())
{
if (exe.ProcessName == "explorer")
exe.Kill();
@@ -89,7 +89,7 @@ private void OnSortByClicked(object sender, RoutedEventArgs e)
{
var selectedItem = sender as MenuItem;
var menu = selectedItem.Parent as MenuItem;
- int selectedIndex = menu.Items.IndexOf(selectedItem);
+ var selectedIndex = menu.Items.IndexOf(selectedItem);
(menu.Items[Settings.Default.sortBy - 1] as MenuItem).IsChecked = false;
(menu.Items[selectedIndex] as MenuItem).IsChecked = false;
@@ -116,7 +116,7 @@ private void OnItemTemplateClicked(object sender, RoutedEventArgs e)
var selectedItem = sender as MenuItem;
var menu = selectedItem.Parent as MenuItem;
- for (int i = 0; i < menu.Items.Count; i++)
+ for (var i = 0; i < menu.Items.Count; i++)
{
var menuItem = menu.Items[i] as MenuItem;
if (menuItem == selectedItem)
diff --git a/EverythingToolbar/Converters/BoolToVisibilityConverter.cs b/EverythingToolbar/Converters/BoolToVisibilityConverter.cs
index ad3a5493f..92e8796e3 100644
--- a/EverythingToolbar/Converters/BoolToVisibilityConverter.cs
+++ b/EverythingToolbar/Converters/BoolToVisibilityConverter.cs
@@ -10,7 +10,7 @@ public class BoolToVisibilityConverter : MarkupExtension, IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
- bool invert = System.Convert.ToBoolean(parameter);
+ var invert = System.Convert.ToBoolean(parameter);
if ((bool)value)
{
diff --git a/EverythingToolbar/Converters/HighlightedTextConverter.cs b/EverythingToolbar/Converters/HighlightedTextConverter.cs
index 147d84116..9f1f290ff 100644
--- a/EverythingToolbar/Converters/HighlightedTextConverter.cs
+++ b/EverythingToolbar/Converters/HighlightedTextConverter.cs
@@ -14,12 +14,12 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
{
if (value is string input)
{
- TextBlock textBlock = new TextBlock
+ var textBlock = new TextBlock
{
TextTrimming = TextTrimming.CharacterEllipsis
};
- string[] segments = input.Split('*');
- for (int j = 0; j < segments.Length; j++)
+ var segments = input.Split('*');
+ for (var j = 0; j < segments.Length; j++)
{
if (j % 2 > 0)
{
diff --git a/EverythingToolbar/Converters/SearchResultsCountConverter.cs b/EverythingToolbar/Converters/SearchResultsCountConverter.cs
index e71895bbe..c4c18ada3 100644
--- a/EverythingToolbar/Converters/SearchResultsCountConverter.cs
+++ b/EverythingToolbar/Converters/SearchResultsCountConverter.cs
@@ -13,9 +13,9 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
if (value == null)
return "";
- string formattedValue = ((int)value).ToString("N0", culture);
+ var formattedValue = ((int)value).ToString("N0", culture);
- string suffix = (int)value == 1 ? Resources.SearchResult : Resources.SearchResults;
+ var suffix = (int)value == 1 ? Resources.SearchResult : Resources.SearchResults;
return $"{formattedValue} {suffix}";
}
diff --git a/EverythingToolbar/Data/Rule.cs b/EverythingToolbar/Data/Rule.cs
index b28052cd5..6a7174c77 100644
--- a/EverythingToolbar/Data/Rule.cs
+++ b/EverythingToolbar/Data/Rule.cs
@@ -12,7 +12,7 @@ public enum FileType
Folder
}
- [Serializable()]
+ [Serializable]
public class Rule : INotifyPropertyChanged
{
[field: NonSerialized]
diff --git a/EverythingToolbar/Data/SearchResult.cs b/EverythingToolbar/Data/SearchResult.cs
index 802b8f2ef..c09c6f484 100644
--- a/EverythingToolbar/Data/SearchResult.cs
+++ b/EverythingToolbar/Data/SearchResult.cs
@@ -3,6 +3,7 @@
using System.Diagnostics;
using System.IO;
using System.IO.Pipes;
+using System.Runtime.InteropServices;
using System.Security.Principal;
using System.Threading.Tasks;
using System.Windows;
@@ -16,7 +17,6 @@
using Clipboard = System.Windows.Clipboard;
using DataObject = System.Windows.DataObject;
using MessageBox = System.Windows.MessageBox;
-using System.Runtime.InteropServices;
namespace EverythingToolbar.Data
{
diff --git a/EverythingToolbar/EverythingSearch.cs b/EverythingToolbar/EverythingSearch.cs
index b0354534f..8eb085100 100644
--- a/EverythingToolbar/EverythingSearch.cs
+++ b/EverythingToolbar/EverythingSearch.cs
@@ -244,7 +244,7 @@ public void QueryBatch(bool append)
lock (_lock)
{
- SearchResults.AddSilent(new SearchResult()
+ SearchResults.AddSilent(new SearchResult
{
HighlightedPath = highlightedPath,
HighlightedFileName = highlightedFileName,
diff --git a/EverythingToolbar/Helpers/FilterLoader.cs b/EverythingToolbar/Helpers/FilterLoader.cs
index cfeb5d553..48b87b64d 100644
--- a/EverythingToolbar/Helpers/FilterLoader.cs
+++ b/EverythingToolbar/Helpers/FilterLoader.cs
@@ -58,7 +58,7 @@ public ObservableCollection DefaultFilters
}
}
- public readonly ObservableCollection DefaultUserFilters = new ObservableCollection()
+ public readonly ObservableCollection DefaultUserFilters = new ObservableCollection
{
new Filter {
Name = Resources.UserFilterAudio,
@@ -253,7 +253,7 @@ private ObservableCollection LoadFilters()
filter["Name"] = filter["Name"].Replace("PICTURE", Resources.UserFilterPicture);
filter["Name"] = filter["Name"].Replace("VIDEO", Resources.UserFilterVideo);
- filters.Add(new Filter()
+ filters.Add(new Filter
{
Name = filter["Name"],
IsMatchCase = filter["Case"] == "1",
diff --git a/EverythingToolbar/Helpers/RegistryWatcher.cs b/EverythingToolbar/Helpers/RegistryWatcher.cs
index 618d42c08..6c978e97d 100644
--- a/EverythingToolbar/Helpers/RegistryWatcher.cs
+++ b/EverythingToolbar/Helpers/RegistryWatcher.cs
@@ -84,12 +84,12 @@ private ManagementEventWatcher CreateWatcher()
target.keyPath = WindowsIdentity.GetCurrent().User.Value + @"\" + target.keyPath;
}
- string qu = "SELECT * FROM RegistryValueChangeEvent WHERE " +
- $"Hive='{target.hive}' " +
- $"AND KeyPath='{EscapeBackticks(target.keyPath)}' " +
- $"AND ValueName='{target.valueName}'";
+ var qu = "SELECT * FROM RegistryValueChangeEvent WHERE " +
+ $"Hive='{target.hive}' " +
+ $"AND KeyPath='{EscapeBackticks(target.keyPath)}' " +
+ $"AND ValueName='{target.valueName}'";
- WqlEventQuery query = new WqlEventQuery(qu);
+ var query = new WqlEventQuery(qu);
return new ManagementEventWatcher(query);
}
diff --git a/EverythingToolbar/Helpers/ShellContextMenu.cs b/EverythingToolbar/Helpers/ShellContextMenu.cs
index 1ff28d116..5f3a27cb9 100644
--- a/EverythingToolbar/Helpers/ShellContextMenu.cs
+++ b/EverythingToolbar/Helpers/ShellContextMenu.cs
@@ -38,7 +38,7 @@ public class ShellContextMenu : NativeWindow
/// Default constructor
public ShellContextMenu()
{
- this.CreateHandle(new CreateParams());
+ CreateHandle(new CreateParams());
}
#endregion
@@ -57,7 +57,7 @@ public ShellContextMenu()
/// true if it got the interfaces, otherwise false
private bool GetContextMenuInterfaces(IShellFolder oParentFolder, IntPtr[] arrPIDLs, out IntPtr ctxMenuPtr)
{
- int nResult = oParentFolder.GetUIObjectOf(
+ var nResult = oParentFolder.GetUIObjectOf(
IntPtr.Zero,
(uint)arrPIDLs.Length,
arrPIDLs,
@@ -71,12 +71,10 @@ private bool GetContextMenuInterfaces(IShellFolder oParentFolder, IntPtr[] arrPI
return true;
}
- else
- {
- ctxMenuPtr = IntPtr.Zero;
- _oContextMenu = null;
- return false;
- }
+
+ ctxMenuPtr = IntPtr.Zero;
+ _oContextMenu = null;
+ return false;
}
#endregion
@@ -125,7 +123,7 @@ protected override void WndProc(ref Message m)
#region InvokeCommand
private void InvokeCommand(IContextMenu oContextMenu, uint nCmd, string strFolder, Point pointInvoke)
{
- CMINVOKECOMMANDINFOEX invoke = new CMINVOKECOMMANDINFOEX
+ var invoke = new CMINVOKECOMMANDINFOEX
{
cbSize = cbInvokeCommand,
lpVerb = (IntPtr)(nCmd - CMD_FIRST),
@@ -192,7 +190,7 @@ private IShellFolder GetDesktopFolder()
if (null == _oDesktopFolder)
{
// Get desktop IShellFolder
- int nResult = SHGetDesktopFolder(out IntPtr pUnkownDesktopFolder);
+ var nResult = SHGetDesktopFolder(out var pUnkownDesktopFolder);
if (S_OK != nResult)
{
throw new ShellContextMenuException("Failed to get the desktop shell folder");
@@ -214,7 +212,7 @@ private IShellFolder GetParentFolder(string folderName)
{
if (null == _oParentFolder)
{
- IShellFolder oDesktopFolder = GetDesktopFolder();
+ var oDesktopFolder = GetDesktopFolder();
if (null == oDesktopFolder)
{
return null;
@@ -223,22 +221,22 @@ private IShellFolder GetParentFolder(string folderName)
// Get the PIDL for the folder file is in
uint pchEaten = 0;
SFGAO pdwAttributes = 0;
- int nResult = oDesktopFolder.ParseDisplayName(IntPtr.Zero, IntPtr.Zero, folderName, ref pchEaten, out IntPtr pPIDL, ref pdwAttributes);
+ var nResult = oDesktopFolder.ParseDisplayName(IntPtr.Zero, IntPtr.Zero, folderName, ref pchEaten, out var pPIDL, ref pdwAttributes);
if (S_OK != nResult)
{
return null;
}
- IntPtr pStrRet = Marshal.AllocCoTaskMem(MAX_PATH * 2 + 4);
+ var pStrRet = Marshal.AllocCoTaskMem(MAX_PATH * 2 + 4);
Marshal.WriteInt32(pStrRet, 0, 0);
_ = _oDesktopFolder.GetDisplayNameOf(pPIDL, SHGNO.FORPARSING, pStrRet);
- StringBuilder strFolder = new StringBuilder(MAX_PATH);
+ var strFolder = new StringBuilder(MAX_PATH);
StrRetToBuf(pStrRet, pPIDL, strFolder, MAX_PATH);
Marshal.FreeCoTaskMem(pStrRet);
_strParentFolder = strFolder.ToString();
// Get the IShellFolder for folder
- nResult = oDesktopFolder.BindToObject(pPIDL, IntPtr.Zero, ref IID_IShellFolder, out IntPtr pUnknownParentFolder);
+ nResult = oDesktopFolder.BindToObject(pPIDL, IntPtr.Zero, ref IID_IShellFolder, out var pUnknownParentFolder);
// Free the PIDL first
Marshal.FreeCoTaskMem(pPIDL);
if (S_OK != nResult)
@@ -265,21 +263,21 @@ protected IntPtr[] GetPIDLs(FileInfo[] arrFI)
return null;
}
- IShellFolder oParentFolder = GetParentFolder(arrFI[0].DirectoryName);
+ var oParentFolder = GetParentFolder(arrFI[0].DirectoryName);
if (null == oParentFolder)
{
return null;
}
- IntPtr[] arrPIDLs = new IntPtr[arrFI.Length];
- int n = 0;
- foreach (FileInfo fi in arrFI)
+ var arrPIDLs = new IntPtr[arrFI.Length];
+ var n = 0;
+ foreach (var fi in arrFI)
{
// Get the file relative to folder
uint pchEaten = 0;
SFGAO pdwAttributes = 0;
- IntPtr pPIDL = IntPtr.Zero;
- int nResult = oParentFolder.ParseDisplayName(IntPtr.Zero, IntPtr.Zero, fi.Name, ref pchEaten, out pPIDL, ref pdwAttributes);
+ var pPIDL = IntPtr.Zero;
+ var nResult = oParentFolder.ParseDisplayName(IntPtr.Zero, IntPtr.Zero, fi.Name, ref pchEaten, out pPIDL, ref pdwAttributes);
if (S_OK != nResult)
{
FreePIDLs(arrPIDLs);
@@ -304,21 +302,21 @@ protected IntPtr[] GetPIDLs(DirectoryInfo[] arrFI)
return null;
}
- IShellFolder oParentFolder = GetParentFolder(arrFI[0].Parent.FullName);
+ var oParentFolder = GetParentFolder(arrFI[0].Parent.FullName);
if (null == oParentFolder)
{
return null;
}
- IntPtr[] arrPIDLs = new IntPtr[arrFI.Length];
- int n = 0;
- foreach (DirectoryInfo fi in arrFI)
+ var arrPIDLs = new IntPtr[arrFI.Length];
+ var n = 0;
+ foreach (var fi in arrFI)
{
// Get the file relative to folder
uint pchEaten = 0;
SFGAO pdwAttributes = 0;
- IntPtr pPIDL = IntPtr.Zero;
- int nResult = oParentFolder.ParseDisplayName(IntPtr.Zero, IntPtr.Zero, fi.Name, ref pchEaten, out pPIDL, ref pdwAttributes);
+ var pPIDL = IntPtr.Zero;
+ var nResult = oParentFolder.ParseDisplayName(IntPtr.Zero, IntPtr.Zero, fi.Name, ref pchEaten, out pPIDL, ref pdwAttributes);
if (S_OK != nResult)
{
FreePIDLs(arrPIDLs);
@@ -341,7 +339,7 @@ protected void FreePIDLs(IntPtr[] arrPIDLs)
{
if (null != arrPIDLs)
{
- for (int n = 0; n < arrPIDLs.Length; n++)
+ for (var n = 0; n < arrPIDLs.Length; n++)
{
if (arrPIDLs[n] != IntPtr.Zero)
{
@@ -365,7 +363,7 @@ public void ShowContextMenu(FileInfo[] files, Point pointScreen)
// Release all resources first.
ReleaseAll();
_arrPIDLs = GetPIDLs(files);
- this.ShowContextMenu(pointScreen);
+ ShowContextMenu(pointScreen);
}
///
@@ -378,7 +376,7 @@ public void ShowContextMenu(DirectoryInfo[] dirs, Point pointScreen)
// Release all resources first.
ReleaseAll();
_arrPIDLs = GetPIDLs(dirs);
- this.ShowContextMenu(pointScreen);
+ ShowContextMenu(pointScreen);
}
///
@@ -424,12 +422,12 @@ private void ShowContextMenu(Point pointScreen)
_oContextMenu2 = (IContextMenu2)Marshal.GetTypedObjectForIUnknown(iContextMenuPtr2, typeof(IContextMenu2));
_oContextMenu3 = (IContextMenu3)Marshal.GetTypedObjectForIUnknown(iContextMenuPtr3, typeof(IContextMenu3));
- uint nSelected = TrackPopupMenuEx(
+ var nSelected = TrackPopupMenuEx(
pMenu,
TPM.RETURNCMD,
pointScreen.X,
pointScreen.Y,
- this.Handle,
+ Handle,
IntPtr.Zero);
DestroyMenu(pMenu);
@@ -440,10 +438,6 @@ private void ShowContextMenu(Point pointScreen)
InvokeCommand(_oContextMenu, nSelected, _strParentFolder, pointScreen);
}
}
- catch
- {
- throw;
- }
finally
{
//hook.Uninstall();
@@ -1161,7 +1155,7 @@ Int32 GetUIObjectOf(
// Retrieves the display name for the specified file object or subfolder.
// Return value: error code, if any
- [PreserveSig()]
+ [PreserveSig]
Int32 GetDisplayNameOf(
IntPtr pidl,
SHGNO uFlags,
@@ -1182,13 +1176,13 @@ Int32 SetNameOf(
#endregion
#region IContextMenu
- [ComImport()]
+ [ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[GuidAttribute("000214e4-0000-0000-c000-000000000046")]
private interface IContextMenu
{
// Adds commands to a shortcut menu
- [PreserveSig()]
+ [PreserveSig]
Int32 QueryContextMenu(
IntPtr hmenu,
uint iMenu,
@@ -1197,14 +1191,14 @@ Int32 QueryContextMenu(
CMF uFlags);
// Carries out the command associated with a shortcut menu item
- [PreserveSig()]
+ [PreserveSig]
Int32 InvokeCommand(
ref CMINVOKECOMMANDINFOEX info);
// Retrieves information about a shortcut menu command,
// including the help string and the language-independent,
// or canonical, name for the command
- [PreserveSig()]
+ [PreserveSig]
Int32 GetCommandString(
uint idcmd,
GCS uflags,
@@ -1219,7 +1213,7 @@ Int32 GetCommandString(
private interface IContextMenu2
{
// Adds commands to a shortcut menu
- [PreserveSig()]
+ [PreserveSig]
Int32 QueryContextMenu(
IntPtr hmenu,
uint iMenu,
@@ -1228,14 +1222,14 @@ Int32 QueryContextMenu(
CMF uFlags);
// Carries out the command associated with a shortcut menu item
- [PreserveSig()]
+ [PreserveSig]
Int32 InvokeCommand(
ref CMINVOKECOMMANDINFOEX info);
// Retrieves information about a shortcut menu command,
// including the help string and the language-independent,
// or canonical, name for the command
- [PreserveSig()]
+ [PreserveSig]
Int32 GetCommandString(
uint idcmd,
GCS uflags,
@@ -1258,7 +1252,7 @@ Int32 HandleMenuMsg(
private interface IContextMenu3
{
// Adds commands to a shortcut menu
- [PreserveSig()]
+ [PreserveSig]
Int32 QueryContextMenu(
IntPtr hmenu,
uint iMenu,
@@ -1267,14 +1261,14 @@ Int32 QueryContextMenu(
CMF uFlags);
// Carries out the command associated with a shortcut menu item
- [PreserveSig()]
+ [PreserveSig]
Int32 InvokeCommand(
ref CMINVOKECOMMANDINFOEX info);
// Retrieves information about a shortcut menu command,
// including the help string and the language-independent,
// or canonical, name for the command
- [PreserveSig()]
+ [PreserveSig]
Int32 GetCommandString(
uint idcmd,
GCS uflags,
@@ -1331,7 +1325,7 @@ public class HookEventArgs : EventArgs
#region Enum HookType
// Hook Types
- public enum HookType : int
+ public enum HookType
{
WH_JOURNALRECORD = 0,
WH_JOURNALPLAYBACK = 1,
@@ -1362,7 +1356,7 @@ public class LocalWindowsHook
// ************************************************************************
// Internal properties
protected IntPtr m_hhook = IntPtr.Zero;
- protected HookProc m_filterFunc = null;
+ protected HookProc m_filterFunc;
protected HookType m_hookType;
// ************************************************************************
@@ -1385,7 +1379,7 @@ protected void OnHookInvoked(HookEventArgs e)
public LocalWindowsHook(HookType hook)
{
m_hookType = hook;
- m_filterFunc = new HookProc(this.CoreHookProc);
+ m_filterFunc = CoreHookProc;
}
public LocalWindowsHook(HookType hook, HookProc func)
{
@@ -1402,7 +1396,7 @@ protected int CoreHookProc(int code, IntPtr wParam, IntPtr lParam)
return CallNextHookEx(m_hhook, code, wParam, lParam);
// Let clients determine what to do
- HookEventArgs e = new HookEventArgs
+ var e = new HookEventArgs
{
HookCode = code,
wParam = wParam,
diff --git a/EverythingToolbar/Helpers/ShellUtils.cs b/EverythingToolbar/Helpers/ShellUtils.cs
index a85d0799c..a6ceb675c 100644
--- a/EverythingToolbar/Helpers/ShellUtils.cs
+++ b/EverythingToolbar/Helpers/ShellUtils.cs
@@ -44,7 +44,7 @@ public struct SHELLEXECUTEINFO
public static void ShowFileProperties(string path)
{
- SHELLEXECUTEINFO info = new SHELLEXECUTEINFO();
+ var info = new SHELLEXECUTEINFO();
info.cbSize = Marshal.SizeOf(info);
info.lpVerb = "properties";
info.lpFile = path;
@@ -112,7 +112,7 @@ public static void CreateProcessFromCommandLine(string commandLine, string worki
IntPtr.Zero,
workingDirectory,
ref si,
- out PROCESS_INFORMATION _);
+ out var _);
}
public static void OpenWithDialog(string path)
diff --git a/EverythingToolbar/Helpers/ShortcutManager.cs b/EverythingToolbar/Helpers/ShortcutManager.cs
index ce756dbf5..1618f27e2 100644
--- a/EverythingToolbar/Helpers/ShortcutManager.cs
+++ b/EverythingToolbar/Helpers/ShortcutManager.cs
@@ -29,7 +29,7 @@ public WinKeyEventArgs(bool isDown, Key key)
public static readonly ShortcutManager Instance = new ShortcutManager();
private static readonly ILogger _logger = ToolbarLogger.GetLogger();
- private WinEventDelegate winEventDelegate = null;
+ private WinEventDelegate winEventDelegate;
private static readonly Dictionary> shortcuts = new Dictionary>();
private static Action