Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
srwi committed Aug 30, 2024
1 parent 8b5a2e7 commit 55a3852
Show file tree
Hide file tree
Showing 26 changed files with 150 additions and 164 deletions.
37 changes: 17 additions & 20 deletions EverythingToolbar.Deskband/CSDeskBand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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

/// <summary>
Expand Down Expand Up @@ -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<DeskBandMenuItem> _contextMenuItems = new List<DeskBandMenuItem>();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand All @@ -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)
Expand All @@ -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
{
Expand Down Expand Up @@ -1678,7 +1675,7 @@ private set
/// </summary>
internal void UpdateInfo()
{
APPBARDATA data = new APPBARDATA
var data = new APPBARDATA
{
hWnd = IntPtr.Zero,
cbSize = Marshal.SizeOf<APPBARDATA>()
Expand Down Expand Up @@ -2075,7 +2072,7 @@ internal enum tagDESKBANDCID
DBID_SHOWONLY = 1,
DBID_MAXIMIZEBAND = 2,
DBID_PUSHCHEVRON = 3
};
}

[StructLayout(LayoutKind.Sequential)]
public struct RECT
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -2548,7 +2545,7 @@ internal sealed class DeskBandMenuSeparator : DeskBandMenuItem
/// <inheritdoc/>
internal override void AddToMenu(IntPtr menu, uint itemPosition, ref uint itemId, Dictionary<uint, DeskBandMenuAction> callbacks)
{
_menuiteminfo = new MENUITEMINFO()
_menuiteminfo = new MENUITEMINFO
{
cbSize = Marshal.SizeOf<MENUITEMINFO>(),
fMask = MENUITEMINFO.MIIM.MIIM_TYPE,
Expand Down Expand Up @@ -2618,7 +2615,7 @@ internal void DoAction()
/// <inheritdoc/>
internal override void AddToMenu(IntPtr menu, uint itemPosition, ref uint itemId, Dictionary<uint, DeskBandMenuAction> callbacks)
{
_menuiteminfo = new MENUITEMINFO()
_menuiteminfo = new MENUITEMINFO
{
cbSize = Marshal.SizeOf<MENUITEMINFO>(),
fMask = MENUITEMINFO.MIIM.MIIM_TYPE | MENUITEMINFO.MIIM.MIIM_STATE | MENUITEMINFO.MIIM.MIIM_ID,
Expand Down Expand Up @@ -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<MENUITEMINFO>(),
fMask = MENUITEMINFO.MIIM.MIIM_SUBMENU | MENUITEMINFO.MIIM.MIIM_STRING | MENUITEMINFO.MIIM.MIIM_STATE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Windows.Data;
using System.Windows.Markup;
using CSDeskBand.Interop;
using EverythingToolbar.Helpers;

namespace EverythingToolbar.Deskband.Converters
{
Expand Down
12 changes: 6 additions & 6 deletions EverythingToolbar.Launcher/SetupAssistant.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@
<TabItem Visibility="Collapsed">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock FontSize="14" Grid.Row="0"
Text="{x:Static properties:Resources.SetupAssistantFirstStepTitle}"
Expand Down Expand Up @@ -149,9 +149,9 @@
<TabItem Visibility="Collapsed">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock FontSize="14"
Grid.Row="0"
Expand Down
2 changes: 0 additions & 2 deletions EverythingToolbar.Launcher/WindowPlacement.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Forms;
Expand Down
2 changes: 1 addition & 1 deletion EverythingToolbar/Behaviors/DpiScaling.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ private void UpdateDpi(double newDpi, bool updateSize = true)
}

var child = VisualTreeHelper.GetChild(AssociatedObject, 0);
double renderScale = newDpi / InitialDpi;
var renderScale = newDpi / InitialDpi;

var scaleTransform = Math.Abs(renderScale - 1) < 0.0001
? Transform.Identity
Expand Down
11 changes: 6 additions & 5 deletions EverythingToolbar/Behaviors/ThemeAwareness.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using EverythingToolbar.Properties;
using Microsoft.Xaml.Behaviors;
using NLog;
using Color = Windows.UI.Color;

namespace EverythingToolbar.Behaviors
{
Expand Down Expand Up @@ -57,7 +58,7 @@ public ThemeAwareness()
_currentResources = new ResourceDictionary();

var systemThemeWatcher = new RegistryWatcher(SystemThemeRegistryEntry);
systemThemeWatcher.OnChangeValue += (newValue) =>
systemThemeWatcher.OnChangeValue += newValue =>
{
Dispatcher.Invoke(() => {
ApplyTheme((int)newValue == 1);
Expand Down Expand Up @@ -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
Expand All @@ -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);
}

Expand All @@ -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));
}
}
}
4 changes: 2 additions & 2 deletions EverythingToolbar/Controls/SearchBox.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public partial class SearchBox : UserControl
{
public event EventHandler<TextChangedEventArgs> TextChanged;

private int LastCaretIndex = 0;
private int LastCaretIndex;

public SearchBox()
{
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions EverythingToolbar/Controls/SearchButton.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions EverythingToolbar/Controls/SearchResultsView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
});
}

Expand Down Expand Up @@ -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);
}
Expand Down
12 changes: 6 additions & 6 deletions EverythingToolbar/Controls/SettingsControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand All @@ -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;
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion EverythingToolbar/Converters/BoolToVisibilityConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
6 changes: 3 additions & 3 deletions EverythingToolbar/Converters/HighlightedTextConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
4 changes: 2 additions & 2 deletions EverythingToolbar/Converters/SearchResultsCountConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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}";
}

Expand Down
2 changes: 1 addition & 1 deletion EverythingToolbar/Data/Rule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public enum FileType
Folder
}

[Serializable()]
[Serializable]
public class Rule : INotifyPropertyChanged
{
[field: NonSerialized]
Expand Down
Loading

0 comments on commit 55a3852

Please sign in to comment.