Skip to content

Commit a8edc78

Browse files
authored
CodeMaid (#3632)
1 parent 18a2e03 commit a8edc78

36 files changed

+271
-170
lines changed

Files.Launcher/NetworkDrivesAPI.cs

+98-98
Original file line numberDiff line numberDiff line change
@@ -10,113 +10,113 @@ namespace FilesFullTrust
1010
{
1111
public class NetworkDrivesAPI
1212
{
13-
/// <summary>
14-
/// A dialog box that allows the user to browse and connect to network resources.
15-
/// </summary>
16-
public class NetworkConnectionDialog : CommonDialog
17-
{
18-
private NETRESOURCE nres = new NETRESOURCE();
19-
private CONNECTDLGSTRUCT opts;
13+
/// <summary>
14+
/// A dialog box that allows the user to browse and connect to network resources.
15+
/// </summary>
16+
public class NetworkConnectionDialog : CommonDialog
17+
{
18+
private NETRESOURCE nres = new NETRESOURCE();
19+
private CONNECTDLGSTRUCT opts;
2020

21-
/// <summary>Initializes a new instance of the <see cref="NetworkConnectionDialog"/> class.</summary>
22-
public NetworkConnectionDialog()
23-
{
24-
opts.cbStructure = (uint)Marshal.SizeOf(typeof(CONNECTDLGSTRUCT));
25-
nres.dwType = NETRESOURCEType.RESOURCETYPE_DISK;
26-
}
21+
/// <summary>Initializes a new instance of the <see cref="NetworkConnectionDialog"/> class.</summary>
22+
public NetworkConnectionDialog()
23+
{
24+
opts.cbStructure = (uint)Marshal.SizeOf(typeof(CONNECTDLGSTRUCT));
25+
nres.dwType = NETRESOURCEType.RESOURCETYPE_DISK;
26+
}
2727

28-
/// <summary>Gets the connected device number. This value is only valid after successfully running the dialog.</summary>
29-
/// <value>The connected device number. The value is 1 for A:, 2 for B:, 3 for C:, and so on. If the user made a deviceless connection, the value is –1.</value>
30-
[Browsable(false)]
31-
public int ConnectedDeviceNumber => opts.dwDevNum;
28+
/// <summary>Gets the connected device number. This value is only valid after successfully running the dialog.</summary>
29+
/// <value>The connected device number. The value is 1 for A:, 2 for B:, 3 for C:, and so on. If the user made a deviceless connection, the value is –1.</value>
30+
[Browsable(false)]
31+
public int ConnectedDeviceNumber => opts.dwDevNum;
3232

33-
/// <summary>Gets or sets a value indicating whether to hide the check box allowing the user to restore the connection at logon.</summary>
34-
/// <value><c>true</c> if hiding restore connection check box; otherwise, <c>false</c>.</value>
35-
[DefaultValue(false), Category("Appearance"), Description("Hide the check box allowing the user to restore the connection at logon.")]
36-
public bool HideRestoreConnectionCheckBox
37-
{
38-
get => opts.dwFlags.IsFlagSet(CONN_DLG.CONNDLG_HIDE_BOX);
39-
set => opts.dwFlags = opts.dwFlags.SetFlags(CONN_DLG.CONNDLG_HIDE_BOX, value);
40-
}
33+
/// <summary>Gets or sets a value indicating whether to hide the check box allowing the user to restore the connection at logon.</summary>
34+
/// <value><c>true</c> if hiding restore connection check box; otherwise, <c>false</c>.</value>
35+
[DefaultValue(false), Category("Appearance"), Description("Hide the check box allowing the user to restore the connection at logon.")]
36+
public bool HideRestoreConnectionCheckBox
37+
{
38+
get => opts.dwFlags.IsFlagSet(CONN_DLG.CONNDLG_HIDE_BOX);
39+
set => opts.dwFlags = opts.dwFlags.SetFlags(CONN_DLG.CONNDLG_HIDE_BOX, value);
40+
}
4141

42-
/// <summary>Gets or sets a value indicating whether restore the connection at logon.</summary>
43-
/// <value><c>true</c> to restore connection at logon; otherwise, <c>false</c>.</value>
44-
[DefaultValue(false), Category("Behavior"), Description("Restore the connection at logon.")]
45-
public bool PersistConnectionAtLogon
46-
{
47-
get => opts.dwFlags.IsFlagSet(CONN_DLG.CONNDLG_PERSIST);
48-
set
49-
{
50-
opts.dwFlags = opts.dwFlags.SetFlags(CONN_DLG.CONNDLG_PERSIST, value);
51-
opts.dwFlags = opts.dwFlags.SetFlags(CONN_DLG.CONNDLG_NOT_PERSIST, !value);
52-
}
53-
}
42+
/// <summary>Gets or sets a value indicating whether restore the connection at logon.</summary>
43+
/// <value><c>true</c> to restore connection at logon; otherwise, <c>false</c>.</value>
44+
[DefaultValue(false), Category("Behavior"), Description("Restore the connection at logon.")]
45+
public bool PersistConnectionAtLogon
46+
{
47+
get => opts.dwFlags.IsFlagSet(CONN_DLG.CONNDLG_PERSIST);
48+
set
49+
{
50+
opts.dwFlags = opts.dwFlags.SetFlags(CONN_DLG.CONNDLG_PERSIST, value);
51+
opts.dwFlags = opts.dwFlags.SetFlags(CONN_DLG.CONNDLG_NOT_PERSIST, !value);
52+
}
53+
}
5454

55-
/// <summary>
56-
/// Gets or sets a value indicating whether to display a read-only path instead of allowing the user to type in a path. This is only
57-
/// valid if <see cref="RemoteNetworkName"/> is not <see langword="null"/>.
58-
/// </summary>
59-
/// <value><c>true</c> to display a read only path; otherwise, <c>false</c>.</value>
60-
[DefaultValue(false), Category("Appearance"), Description("Display a read-only path instead of allowing the user to type in a path.")]
61-
public bool ReadOnlyPath { get; set; }
55+
/// <summary>
56+
/// Gets or sets a value indicating whether to display a read-only path instead of allowing the user to type in a path. This is only
57+
/// valid if <see cref="RemoteNetworkName"/> is not <see langword="null"/>.
58+
/// </summary>
59+
/// <value><c>true</c> to display a read only path; otherwise, <c>false</c>.</value>
60+
[DefaultValue(false), Category("Appearance"), Description("Display a read-only path instead of allowing the user to type in a path.")]
61+
public bool ReadOnlyPath { get; set; }
6262

63-
/// <summary>Gets or sets the name of the remote network.</summary>
64-
/// <value>The name of the remote network.</value>
65-
[DefaultValue(null), Category("Behavior"), Description("The value displayed in the path field.")]
66-
public string RemoteNetworkName { get => nres.lpRemoteName; set => nres.lpRemoteName = value; }
63+
/// <summary>Gets or sets the name of the remote network.</summary>
64+
/// <value>The name of the remote network.</value>
65+
[DefaultValue(null), Category("Behavior"), Description("The value displayed in the path field.")]
66+
public string RemoteNetworkName { get => nres.lpRemoteName; set => nres.lpRemoteName = value; }
6767

68-
/// <summary>Gets or sets a value indicating whether to enter the most recently used paths into the combination box.</summary>
69-
/// <value><c>true</c> to use MRU path; otherwise, <c>false</c>.</value>
70-
/// <exception cref="InvalidOperationException">UseMostRecentPath</exception>
71-
[DefaultValue(false), Category("Behavior"), Description("Enter the most recently used paths into the combination box.")]
72-
public bool UseMostRecentPath
73-
{
74-
get => opts.dwFlags.IsFlagSet(CONN_DLG.CONNDLG_USE_MRU);
75-
set
76-
{
77-
if (value && !string.IsNullOrEmpty(RemoteNetworkName))
78-
throw new InvalidOperationException($"{nameof(UseMostRecentPath)} cannot be set to true if {nameof(RemoteNetworkName)} has a value.");
79-
opts.dwFlags = opts.dwFlags.SetFlags(CONN_DLG.CONNDLG_USE_MRU, value);
80-
}
81-
}
68+
/// <summary>Gets or sets a value indicating whether to enter the most recently used paths into the combination box.</summary>
69+
/// <value><c>true</c> to use MRU path; otherwise, <c>false</c>.</value>
70+
/// <exception cref="InvalidOperationException">UseMostRecentPath</exception>
71+
[DefaultValue(false), Category("Behavior"), Description("Enter the most recently used paths into the combination box.")]
72+
public bool UseMostRecentPath
73+
{
74+
get => opts.dwFlags.IsFlagSet(CONN_DLG.CONNDLG_USE_MRU);
75+
set
76+
{
77+
if (value && !string.IsNullOrEmpty(RemoteNetworkName))
78+
throw new InvalidOperationException($"{nameof(UseMostRecentPath)} cannot be set to true if {nameof(RemoteNetworkName)} has a value.");
79+
opts.dwFlags = opts.dwFlags.SetFlags(CONN_DLG.CONNDLG_USE_MRU, value);
80+
}
81+
}
8282

83-
/// <inheritdoc/>
84-
public override void Reset()
85-
{
86-
opts.dwDevNum = -1;
87-
opts.dwFlags = 0;
88-
opts.lpConnRes = IntPtr.Zero;
89-
ReadOnlyPath = false;
90-
}
83+
/// <inheritdoc/>
84+
public override void Reset()
85+
{
86+
opts.dwDevNum = -1;
87+
opts.dwFlags = 0;
88+
opts.lpConnRes = IntPtr.Zero;
89+
ReadOnlyPath = false;
90+
}
9191

92-
/// <inheritdoc/>
93-
protected override bool RunDialog(IntPtr hwndOwner)
94-
{
95-
using (var lpnres = SafeCoTaskMemHandle.CreateFromStructure(nres))
96-
{
97-
opts.hwndOwner = hwndOwner;
98-
opts.lpConnRes = lpnres.DangerousGetHandle();
99-
if (ReadOnlyPath && !string.IsNullOrEmpty(nres.lpRemoteName))
100-
opts.dwFlags |= CONN_DLG.CONNDLG_RO_PATH;
101-
var ret = WNetConnectionDialog1(opts);
102-
opts.lpConnRes = IntPtr.Zero;
103-
if (ret == unchecked((uint)-1)) return false;
104-
ret.ThrowIfFailed();
105-
return true;
106-
}
107-
}
108-
}
92+
/// <inheritdoc/>
93+
protected override bool RunDialog(IntPtr hwndOwner)
94+
{
95+
using (var lpnres = SafeCoTaskMemHandle.CreateFromStructure(nres))
96+
{
97+
opts.hwndOwner = hwndOwner;
98+
opts.lpConnRes = lpnres.DangerousGetHandle();
99+
if (ReadOnlyPath && !string.IsNullOrEmpty(nres.lpRemoteName))
100+
opts.dwFlags |= CONN_DLG.CONNDLG_RO_PATH;
101+
var ret = WNetConnectionDialog1(opts);
102+
opts.lpConnRes = IntPtr.Zero;
103+
if (ret == unchecked((uint)-1)) return false;
104+
ret.ThrowIfFailed();
105+
return true;
106+
}
107+
}
108+
}
109109

110-
public static bool OpenMapNetworkDriveDialog()
110+
public static bool OpenMapNetworkDriveDialog()
111111
{
112-
using var ncd = new NetworkConnectionDialog { UseMostRecentPath = true };
113-
ncd.HideRestoreConnectionCheckBox = false;
114-
return ncd.ShowDialog() == DialogResult.OK;
115-
}
112+
using var ncd = new NetworkConnectionDialog { UseMostRecentPath = true };
113+
ncd.HideRestoreConnectionCheckBox = false;
114+
return ncd.ShowDialog() == DialogResult.OK;
115+
}
116116

117-
public static bool DisconnectNetworkDrive(string drive)
118-
{
119-
return !WNetCancelConnection2(drive.TrimEnd('\\'), CONNECT.CONNECT_UPDATE_PROFILE, true).Failed;
120-
}
121-
}
122-
}
117+
public static bool DisconnectNetworkDrive(string drive)
118+
{
119+
return !WNetCancelConnection2(drive.TrimEnd('\\'), CONNECT.CONNECT_UPDATE_PROFILE, true).Failed;
120+
}
121+
}
122+
}

Files.Package/Package.appxmanifest

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
xmlns:uap4="http://schemas.microsoft.com/appx/manifest/uap/windows10/4"
1010
xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5"
1111
IgnorableNamespaces="uap uap5 mp rescap desktop4 desktop">
12-
<Identity Name="FilesDev" Publisher="CN=53EC4384-7F5B-4CF6-8C23-513FFE9D1AB7" Version="1.2.2.0" />
12+
<Identity Name="FilesDev" Publisher="CN=53EC4384-7F5B-4CF6-8C23-513FFE9D1AB7" Version="1.3.0.0" />
1313
<Properties>
1414
<DisplayName>Files - Dev</DisplayName>
1515
<PublisherDisplayName>Yair A</PublisherDisplayName>

Files/App.xaml.cs

+2
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,7 @@ public class WSLDistroItem : INavigationControlItem
485485
public string Text { get; set; }
486486

487487
private string path;
488+
488489
public string Path
489490
{
490491
get => path;
@@ -494,6 +495,7 @@ public string Path
494495
HoverDisplayText = Path.Contains("?") ? Text : Path;
495496
}
496497
}
498+
497499
public string HoverDisplayText { get; private set; }
498500

499501
public NavigationControlItemType ItemType => NavigationControlItemType.LinuxDistro;

Files/BaseLayout.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1050,4 +1050,4 @@ public void BaseLayout_PointerWheelChanged(object sender, PointerRoutedEventArgs
10501050
}
10511051
}
10521052
}
1053-
}
1053+
}

Files/Constants.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public static class PreviewPane
5353
/// The maximum number of pages loaded into the PDF preview.
5454
/// </summary>
5555
public const int PDFPageLimit = 50;
56+
5657
/// <summary>
5758
/// The maximum file size, in bytes, that will attempted to be loaded as text if the extension is unknown.
5859
/// </summary>
@@ -72,4 +73,4 @@ public static class ResourceFilePaths
7273
public const string PreviewPaneDetailsPropertiesJsonPath = @"ms-appx:///Resources/PreviewPanePropertiesInformation.json";
7374
}
7475
}
75-
}
76+
}

Files/Converters/BoolToSelectionMode.cs

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
62
using Windows.UI.Xaml.Controls;
73
using Windows.UI.Xaml.Data;
84

@@ -20,4 +16,4 @@ public object ConvertBack(object value, Type targetType, object parameter, strin
2016
return ((value as ListViewSelectionMode?) ?? ListViewSelectionMode.Extended) == ListViewSelectionMode.Multiple;
2117
}
2218
}
23-
}
19+
}

Files/DataModels/SidebarPinnedModel.cs

-3
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,12 @@
33
using Files.ViewModels;
44
using Files.Views;
55
using Newtonsoft.Json;
6-
using NLog;
76
using System;
87
using System.Collections.Generic;
98
using System.Diagnostics;
109
using System.IO;
1110
using System.Linq;
1211
using System.Threading.Tasks;
13-
using Windows.ApplicationModel.Core;
14-
using Windows.UI.Core;
1512
using Windows.UI.Xaml.Media;
1613

1714
namespace Files.DataModels

Files/Dialogs/DynamicDialog.xaml

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:helpers="using:Files.Helpers"
67
xmlns:i="using:Microsoft.Xaml.Interactivity"
78
xmlns:icore="using:Microsoft.Xaml.Interactions.Core"
89
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
9-
xmlns:helpers="using:Files.Helpers"
1010
Title="{Binding TitleText, Mode=OneWay}"
11-
RequestedTheme="{x:Bind helpers:ThemeHelper.RootTheme}"
1211
CloseButtonStyle="{StaticResource DefaultButtonStyle}"
1312
CloseButtonText="{Binding CloseButtonText, Mode=OneWay}"
1413
CornerRadius="4"
1514
DefaultButton="Primary"
15+
IsPrimaryButtonEnabled="{Binding IsPrimaryButtonEnabled, Mode=OneWay}"
16+
IsSecondaryButtonEnabled="{Binding IsSecondaryButtonEnabled, Mode=OneWay}"
1617
PrimaryButtonStyle="{StaticResource AccentButtonStyle}"
1718
PrimaryButtonText="{Binding PrimaryButtonText, Mode=OneWay}"
19+
RequestedTheme="{x:Bind helpers:ThemeHelper.RootTheme}"
1820
SecondaryButtonStyle="{StaticResource DefaultButtonStyle}"
1921
SecondaryButtonText="{Binding SecondaryButtonText, Mode=OneWay}"
20-
IsPrimaryButtonEnabled="{Binding IsPrimaryButtonEnabled, Mode=OneWay}"
21-
IsSecondaryButtonEnabled="{Binding IsSecondaryButtonEnabled, Mode=OneWay}"
2222
mc:Ignorable="d">
2323
<i:Interaction.Behaviors>
2424
<!-- No need to specify CommandParameter - `e` is passed by default -->
@@ -47,23 +47,23 @@
4747

4848
<!-- Subtitle -->
4949
<TextBlock
50+
x:Name="Subtitle"
5051
Grid.Row="0"
5152
HorizontalAlignment="Left"
5253
VerticalAlignment="Center"
53-
Text="{Binding SubtitleText, Mode=OneWay}"
5454
x:Load="{x:Bind ViewModel.SubtitleLoad, Mode=OneWay}"
55-
x:Name="Subtitle"
55+
Text="{Binding SubtitleText, Mode=OneWay}"
5656
TextWrapping="WrapWholeWords" />
5757

5858
<!-- The dynamic content control -->
5959
<ContentControl
60+
x:Name="DisplayControl"
6061
Grid.Row="1"
6162
HorizontalAlignment="Stretch"
6263
VerticalAlignment="Stretch"
6364
HorizontalContentAlignment="Stretch"
6465
VerticalContentAlignment="Stretch"
6566
x:Load="{x:Bind ViewModel.DisplayControlLoad, Mode=OneWay}"
66-
x:Name="DisplayControl"
6767
Content="{Binding DisplayControl, Mode=OneWay}" />
6868
</Grid>
6969
</ContentDialog>

Files/Dialogs/DynamicDialog.xaml.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ public void Dispose()
3636
ViewModel = null;
3737
}
3838

39-
#endregion
39+
#endregion IDisposable
4040
}
4141
}

Files/Enums/DynamicDialogButtons.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ public enum DynamicDialogButtons
77
Cancel = 4,
88
None = 8
99
}
10-
}
10+
}

Files/Enums/DynamicDialogResult.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ public enum DynamicDialogResult
66
Secondary = 2,
77
Cancel = 4,
88
}
9-
}
9+
}

Files/Extensions/TaskExtensions.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ internal static class TaskExtensions
66
{
77
#pragma warning disable RCS1175 // Unused this parameter.
88
#pragma warning disable IDE0060 // Remove unused parameter
9+
910
/// <summary>
1011
/// This function is to explicitly state that we know that we're running task without awaiting.
1112
/// This makes Visual Studio drop the warning, but the programmer intent is still clearly stated.
@@ -15,7 +16,8 @@ internal static void Forget(this Task task)
1516
{
1617
// do nothing, just forget about the task
1718
}
19+
1820
#pragma warning restore IDE0060 // Remove unused parameter
1921
#pragma warning restore RCS1175 // Unused this parameter.
2022
}
21-
}
23+
}

Files/Filesystem/Cloud/CloudDriveSyncStatusUI.cs

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public string Glyph
2424
}
2525

2626
private string syncStatusString = "CloudDriveSyncStatus_Unknown".GetLocalized();
27+
2728
public string SyncStatusString
2829
{
2930
get => syncStatusString;

0 commit comments

Comments
 (0)