Skip to content

Commit

Permalink
[Feature] Gamepad support (#451), version 1.3.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Hofknecht committed Sep 26, 2022
1 parent 5069e00 commit 18f1570
Show file tree
Hide file tree
Showing 85 changed files with 784 additions and 250 deletions.
75 changes: 75 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,78 @@

# WFAC010: Unsupported high DPI configuration
dotnet_diagnostic.WFAC010.severity = silent
csharp_indent_labels = one_less_than_current
csharp_using_directive_placement = outside_namespace:silent
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_braces = true:silent
csharp_style_namespace_declarations = block_scoped:silent
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_style_expression_bodied_methods = false:silent
csharp_style_expression_bodied_constructors = false:silent
csharp_style_expression_bodied_operators = false:silent
csharp_style_expression_bodied_properties = true:silent
csharp_style_expression_bodied_indexers = true:silent
csharp_style_expression_bodied_accessors = true:silent
csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = false:silent
dotnet_diagnostic.SX1101.severity = warning
dotnet_diagnostic.SA1101.severity = silent

[*.{cs,vb}]
#### Naming styles ####

# Naming rules

dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i

dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case

dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case

# Symbol specifications

dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.interface.required_modifiers =

dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.types.required_modifiers =

dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.non_field_members.required_modifiers =

# Naming styles

dotnet_naming_style.begins_with_i.required_prefix = I
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.capitalization = pascal_case

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case
dotnet_style_operator_placement_when_wrapping = beginning_of_line
tab_width = 4
indent_size = 4
end_of_line = crlf
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
dotnet_style_prefer_auto_properties = true:silent
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
14 changes: 9 additions & 5 deletions Business/KeyboardInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ internal void ResetSelectedByKey()

internal void CmdKeyProcessed(object sender, Keys keys)
{
sender ??= menus[iMenuKey];

switch (keys)
{
case Keys.Enter:
Expand Down Expand Up @@ -352,23 +354,25 @@ private void SelectByKey(Keys keys, string keyInput = "", bool keepSelection = f
break;
case Keys.Left:
bool nextMenuLocationIsLeft = menus[iMenuKey + 1] != null && menus[iMenuKey + 1].Location.X < menus[iMenuKey].Location.X;
if (nextMenuLocationIsLeft)
bool previousMenuLocationIsRight = iMenuKey > 0 && menus[iMenuKey]?.Location.X < menus[iMenuKey - 1]?.Location.X;
if (nextMenuLocationIsLeft || previousMenuLocationIsRight)
{
SelectNextMenu(iRowBefore, ref dgv, dgvBefore, menuFromSelected, isStillSelected, ref toClear);
}
else
else if (iMenuKey > 0)
{
SelectPreviousMenu(iRowBefore, ref menu, ref dgv, dgvBefore, ref toClear);
}

break;
case Keys.Right:
bool nextMenuLocationIsRight = menus[iMenuKey + 1] != null && menus[iMenuKey + 1].Location.X > menus[iMenuKey].Location.X;
if (nextMenuLocationIsRight)
bool nextMenuLocationIsRight = menus[iMenuKey + 1]?.Location.X > menus[iMenuKey]?.Location.X;
bool previousMenuLocationIsLeft = iMenuKey > 0 && menus[iMenuKey]?.Location.X > menus[iMenuKey - 1]?.Location.X;
if (nextMenuLocationIsRight || previousMenuLocationIsLeft)
{
SelectNextMenu(iRowBefore, ref dgv, dgvBefore, menuFromSelected, isStillSelected, ref toClear);
}
else
else if (iMenuKey > 0)
{
SelectPreviousMenu(iRowBefore, ref menu, ref dgv, dgvBefore, ref toClear);
}
Expand Down
28 changes: 20 additions & 8 deletions Business/Menus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace SystemTrayMenu.Business
using SystemTrayMenu.DllImports;
using SystemTrayMenu.Handler;
using SystemTrayMenu.Helper;
using SystemTrayMenu.Helpers;
using SystemTrayMenu.UserInterface;
using SystemTrayMenu.Utilities;
using Menu = SystemTrayMenu.UserInterface.Menu;
Expand All @@ -29,6 +30,7 @@ internal class Menus : IDisposable
private readonly DgvMouseRow dgvMouseRow = new();
private readonly WaitToLoadMenu waitToOpenMenu = new();
private readonly KeyboardInput keyboardInput;
private readonly JoystickHelper joystickHelper;
private readonly List<FileSystemWatcher> watchers = new();
private readonly List<EventArgs> watcherHistory = new();
private readonly Timer timerShowProcessStartedAsLoadingIcon = new();
Expand Down Expand Up @@ -251,7 +253,7 @@ void CloseMenu(int level)
dgvMouseRow.RowMouseLeave += waitToOpenMenu.MouseLeave;
dgvMouseRow.RowMouseLeave += Dgv_RowMouseLeave;

keyboardInput = new KeyboardInput(menus);
keyboardInput = new(menus);
keyboardInput.RegisterHotKey();
keyboardInput.HotKeyPressed += () => SwitchOpenClose(false);
keyboardInput.ClosePressed += MenusFadeOut;
Expand All @@ -265,6 +267,9 @@ void AdjustScrollbarToDisplayedRow(DataGridView dgv, int index)
menu.AdjustScrollbar();
}

joystickHelper = new();
joystickHelper.KeyPressed += (key) => menus[0].Invoke(keyboardInput.CmdKeyProcessed, null, key);

timerShowProcessStartedAsLoadingIcon.Interval = Properties.Settings.Default.TimeUntilClosesAfterEnterPressed;
timerStillActiveCheck.Interval = Properties.Settings.Default.TimeUntilClosesAfterEnterPressed + 20;
timerStillActiveCheck.Tick += (sender, e) => StillActiveTick();
Expand All @@ -290,13 +295,15 @@ void CreateWatcher(string path, bool recursiv)
{
try
{
FileSystemWatcher watcher = new();
watcher.Path = path;
watcher.NotifyFilter = NotifyFilters.Attributes |
FileSystemWatcher watcher = new()
{
Path = path,
NotifyFilter = NotifyFilters.Attributes |
NotifyFilters.DirectoryName |
NotifyFilters.FileName |
NotifyFilters.LastWrite;
watcher.Filter = "*.*";
NotifyFilters.LastWrite,
Filter = "*.*",
};
watcher.Created += WatcherProcessItem;
watcher.Deleted += WatcherProcessItem;
watcher.Renamed += WatcherProcessItem;
Expand Down Expand Up @@ -337,6 +344,7 @@ public void Dispose()

waitToOpenMenu.Dispose();
keyboardInput.Dispose();
joystickHelper.Dispose();
timerShowProcessStartedAsLoadingIcon.Dispose();
timerStillActiveCheck.Dispose();
waitLeave.Dispose();
Expand Down Expand Up @@ -429,6 +437,7 @@ internal void SwitchOpenClose(bool byClick, bool isMainPreload = false)
else
{
openCloseState = OpenCloseState.Opening;
joystickHelper.Enable();
StartWorker();
}

Expand Down Expand Up @@ -1130,6 +1139,7 @@ private void MenusFadeOut()
});

Config.AlwaysOpenByPin = false;
joystickHelper.Disable();
}

private void AdjustMenusSizeAndLocation()
Expand Down Expand Up @@ -1402,8 +1412,10 @@ private void CreateItem(FileSystemEventArgs e)

rowData.ReadIcon(true);

List<RowData> rowDatas = new();
rowDatas.Add(rowData);
List<RowData> rowDatas = new()
{
rowData,
};

DataTable dataTable = (DataTable)menus[0].GetDataGridView().DataSource;
foreach (DataRow row in dataTable.Rows)
Expand Down
Loading

0 comments on commit 18f1570

Please sign in to comment.