Skip to content

Commit 50e9fa0

Browse files
authored
CodeMaid (#1818)
1 parent 983af95 commit 50e9fa0

File tree

19 files changed

+236
-204
lines changed

19 files changed

+236
-204
lines changed

Common/ContextMenu.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ public class Win32ContextMenuItem
3030
public MenuItemType Type { get; set; }
3131
public List<Win32ContextMenuItem> SubItems { get; set; }
3232
}
33-
}
33+
}

Files.Launcher/Program.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
using System.Text.RegularExpressions;
1212
using System.Threading;
1313
using System.Threading.Tasks;
14-
using System.Windows.Forms;
1514
using Vanara.PInvoke;
1615
using Vanara.Windows.Shell;
1716
using Windows.ApplicationModel;
@@ -255,9 +254,9 @@ private static async Task parseArguments(AppServiceRequestReceivedEventArgs args
255254
{
256255
await execThreadWithMessageQueue.PostMessage(args.Request.Message);
257256
}
258-
// The following line is needed to cleanup resources when menu is closed.
257+
// The following line is needed to cleanup resources when menu is closed.
259258
// Unfortunately if you uncomment it some menu items will randomly stop working.
260-
// Resource cleanup is currently done on app closing,
259+
// Resource cleanup is currently done on app closing,
261260
// if we find a solution for the issue above, we should cleanup as soon as a menu is closed.
262261
//handleTable.RemoveValue(menuKey);
263262
break;
@@ -319,9 +318,9 @@ private static object HandleMenuMessage(ValueSet message, Win32API.DisposableDic
319318
case "ExecAndCloseContextMenu":
320319
var cMenuExec = table.GetValue<Win32API.ContextMenu>("MENU");
321320
cMenuExec?.InvokeItem(message.Get("ItemID", -1));
322-
// The following line is needed to cleanup resources when menu is closed.
321+
// The following line is needed to cleanup resources when menu is closed.
323322
// Unfortunately if you uncomment it some menu items will randomly stop working.
324-
// Resource cleanup is currently done on app closing,
323+
// Resource cleanup is currently done on app closing,
325324
// if we find a solution for the issue above, we should cleanup as soon as a menu is closed.
326325
//table.RemoveValue("MENU");
327326
return null;

Files.Launcher/Win32API.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using System.Threading;
99
using System.Threading.Tasks;
1010
using Vanara.PInvoke;
11-
using Vanara.Windows.Shell;
1211
using Windows.System;
1312

1413
namespace FilesFullTrust
@@ -117,7 +116,4 @@ public static void UnlockBitlockerDrive(string drive, string password)
117116
// There is usually no need to define Win32 COM interfaces/P-Invoke methods here.
118117
// The Vanara library contains the definitions for all members of Shell32.dll, User32.dll and more
119118
// The ones below are due to bugs in the current version of the library and can be removed once fixed
120-
#region WIN32_INTERFACES
121-
122-
#endregion
123119
}

Files.Launcher/Win32API_ContextMenu.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
using Vanara.InteropServices;
1313
using Vanara.PInvoke;
1414
using Vanara.Windows.Shell;
15-
using Windows.Foundation.Collections;
1615
using static Vanara.PInvoke.Gdi32;
1716

1817
namespace FilesFullTrust
@@ -174,6 +173,7 @@ public void InvokeItem(int itemID)
174173
}
175174

176175
#region FactoryMethods
176+
177177
public static ContextMenu GetContextMenuForFiles(string[] filePathList, Shell32.CMF flags, Func<string, bool> itemFilter = null)
178178
{
179179
List<ShellItem> shellItems = new List<ShellItem>();
@@ -208,12 +208,13 @@ public static ContextMenu GetContextMenuForFiles(ShellItem[] shellItems, Shell32
208208
User32.DestroyMenu(hMenu);
209209
return contextMenu;
210210
}
211-
#endregion
211+
212+
#endregion FactoryMethods
212213

213214
private static void EnumMenuItems(
214-
Shell32.IContextMenu cMenu,
215-
HMENU hMenu,
216-
List<Win32ContextMenuItem> menuItemsResult,
215+
Shell32.IContextMenu cMenu,
216+
HMENU hMenu,
217+
List<Win32ContextMenuItem> menuItemsResult,
217218
Func<string, bool> itemFilter = null)
218219
{
219220
var itemCount = User32.GetMenuItemCount(hMenu);
@@ -338,6 +339,7 @@ private static Bitmap GetTransparentBitmap(HBITMAP hbitmap)
338339
}
339340

340341
#region IDisposable Support
342+
341343
private bool disposedValue = false; // To detect redundant calls
342344

343345
protected virtual void Dispose(bool disposing)
@@ -376,12 +378,14 @@ public void Dispose()
376378
Dispose(true);
377379
GC.SuppressFinalize(this);
378380
}
379-
#endregion
381+
382+
#endregion IDisposable Support
380383
}
381384

382385
public class ContextMenuItem : Win32ContextMenuItem, IDisposable
383386
{
384387
private Bitmap _Icon;
388+
385389
[JsonIgnore]
386390
public Bitmap Icon
387391
{
@@ -418,7 +422,4 @@ public void Dispose()
418422
// There is usually no need to define Win32 COM interfaces/P-Invoke methods here.
419423
// The Vanara library contains the definitions for all members of Shell32.dll, User32.dll and more
420424
// The ones below are due to bugs in the current version of the library and can be removed once fixed
421-
#region WIN32_INTERFACES
422-
423-
#endregion
424-
}
425+
}

Files/App.xaml.cs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,10 @@
44
using Files.Controls;
55
using Files.Filesystem;
66
using Files.Helpers;
7-
using Files.UserControls;
87
using Files.View_Models;
98
using Files.Views;
10-
using Microsoft.AppCenter;
11-
using Microsoft.AppCenter.Analytics;
12-
using Microsoft.AppCenter.Crashes;
139
using Microsoft.Toolkit.Uwp.Helpers;
10+
using Microsoft.Toolkit.Uwp.Notifications;
1411
using Newtonsoft.Json;
1512
using NLog;
1613
using System;
@@ -23,17 +20,15 @@
2320
using Windows.ApplicationModel.AppService;
2421
using Windows.Storage;
2522
using Windows.UI.Core;
23+
using Windows.UI.Notifications;
2624
using Windows.UI.ViewManagement;
2725
using Windows.UI.Xaml;
26+
using Microsoft.AppCenter;
27+
using Microsoft.AppCenter.Analytics;
28+
using Microsoft.AppCenter.Crashes;
2829
using Windows.UI.Xaml.Controls;
2930
using Windows.UI.Xaml.Media.Animation;
3031
using Windows.UI.Xaml.Navigation;
31-
using System.Threading.Tasks;
32-
using Microsoft.Toolkit.Uwp.Notifications;
33-
using Windows.UI.Notifications;
34-
using System.Linq;
35-
using Newtonsoft.Json;
36-
using Files.Common;
3732

3833
namespace Files
3934
{
@@ -56,6 +51,7 @@ public static IShellPage CurrentInstance
5651
}
5752
}
5853
}
54+
5955
public static SettingsViewModel AppSettings { get; set; }
6056
public static InteractionViewModel InteractionViewModel { get; set; }
6157
public static JumpListManager JumpList { get; } = new JumpListManager();
@@ -487,4 +483,4 @@ public class WSLDistroItem : INavigationControlItem
487483
public NavigationControlItemType ItemType => NavigationControlItemType.LinuxDistro;
488484
public Uri Logo { get; set; }
489485
}
490-
}
486+
}

Files/BaseLayout.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
using System.IO;
1414
using System.Linq;
1515
using System.Runtime.CompilerServices;
16-
using System.Threading.Tasks;
1716
using Windows.ApplicationModel.DataTransfer;
1817
using Windows.Foundation.Collections;
1918
using Windows.Storage;
@@ -333,7 +332,7 @@ private void LoadMenuFlyoutItem(IList<MenuFlyoutItemBase> MenuItemsList, IEnumer
333332
};
334333
MenuItemsList.Insert(0, menuLayoutItem);
335334
}
336-
else if (menuFlyoutItem.SubItems.Where(x => x.Type != MenuItemType.MFT_SEPARATOR).Any()
335+
else if (menuFlyoutItem.SubItems.Where(x => x.Type != MenuItemType.MFT_SEPARATOR).Any()
337336
&& !string.IsNullOrEmpty(menuFlyoutItem.Label))
338337
{
339338
var menuLayoutSubItem = new MenuFlyoutSubItem()
@@ -400,8 +399,8 @@ await App.Connection.SendMessageAsync(new ValueSet() {
400399
public void RightClickItemContextMenu_Opening(object sender, object e)
401400
{
402401
var shiftPressed = Window.Current.CoreWindow.GetKeyState(VirtualKey.Shift).HasFlag(CoreVirtualKeyStates.Down);
403-
var showOpenMenu = (SelectedItems.Count == 1)
404-
&& SelectedItem.PrimaryItemAttribute == StorageItemTypes.File
402+
var showOpenMenu = (SelectedItems.Count == 1)
403+
&& SelectedItem.PrimaryItemAttribute == StorageItemTypes.File
405404
&& !string.IsNullOrEmpty(SelectedItem.FileExtension)
406405
&& SelectedItem.FileExtension.Equals(".msi", StringComparison.OrdinalIgnoreCase);
407406
SetShellContextmenu(shiftPressed, showOpenMenu);

Files/Interacts/Interaction.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ public async Task<bool> RenameFileItem(ListedItem item, string oldName, string n
976976
{
977977
return false;
978978
}
979-
979+
980980
CurrentInstance.NavigationToolbar.CanGoForward = false;
981981
return true;
982982
}
@@ -1657,4 +1657,4 @@ public async Task<string> GetHashForFile(ListedItem fileItem, string nameOfAlg,
16571657
return CryptographicBuffer.EncodeToHexString(hash.GetValueAndReset()).ToLower();
16581658
}
16591659
}
1660-
}
1660+
}

0 commit comments

Comments
 (0)