Skip to content

Commit 2367901

Browse files
authored
Migrate to Windows App SDK 1.6 (#3)
1 parent a9a882f commit 2367901

33 files changed

+407
-238
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ publish/
184184
*.azurePubxml
185185
# Note: Comment the next line if you want to checkin your web deploy settings,
186186
# but database connection strings (with potential passwords) will be unencrypted
187-
*.pubxml
187+
#*.pubxml
188188
*.publishproj
189189

190190
# Microsoft Azure Web App publish settings. Comment the next line if you want to

SUBSTitute.sln

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 17
3+
# 17
44
VisualStudioVersion = 17.9.34723.18
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SUBSTitute", "src\SUBSTitute.csproj", "{3DA68281-59F8-46A1-B263-31EC608AFCE3}"
@@ -14,13 +14,8 @@ Global
1414
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1515
Debug|ARM64 = Debug|ARM64
1616
Debug|x64 = Debug|x64
17-
Debug|x86 = Debug|x86
1817
Release|ARM64 = Release|ARM64
1918
Release|x64 = Release|x64
20-
Release|x86 = Release|x86
21-
ReleaseSigned|ARM64 = ReleaseSigned|ARM64
22-
ReleaseSigned|x64 = ReleaseSigned|x64
23-
ReleaseSigned|x86 = ReleaseSigned|x86
2419
EndGlobalSection
2520
GlobalSection(ProjectConfigurationPlatforms) = postSolution
2621
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.Debug|ARM64.ActiveCfg = Debug|ARM64
@@ -29,27 +24,12 @@ Global
2924
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.Debug|x64.ActiveCfg = Debug|x64
3025
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.Debug|x64.Build.0 = Debug|x64
3126
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.Debug|x64.Deploy.0 = Debug|x64
32-
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.Debug|x86.ActiveCfg = Debug|x86
33-
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.Debug|x86.Build.0 = Debug|x86
34-
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.Debug|x86.Deploy.0 = Debug|x86
3527
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.Release|ARM64.ActiveCfg = Release|ARM64
3628
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.Release|ARM64.Build.0 = Release|ARM64
3729
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.Release|ARM64.Deploy.0 = Release|ARM64
3830
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.Release|x64.ActiveCfg = Release|x64
3931
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.Release|x64.Build.0 = Release|x64
4032
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.Release|x64.Deploy.0 = Release|x64
41-
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.Release|x86.ActiveCfg = Release|x86
42-
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.Release|x86.Build.0 = Release|x86
43-
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.Release|x86.Deploy.0 = Release|x86
44-
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.ReleaseSigned|ARM64.ActiveCfg = ReleaseSigned|ARM64
45-
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.ReleaseSigned|ARM64.Build.0 = ReleaseSigned|ARM64
46-
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.ReleaseSigned|ARM64.Deploy.0 = ReleaseSigned|ARM64
47-
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.ReleaseSigned|x64.ActiveCfg = ReleaseSigned|x64
48-
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.ReleaseSigned|x64.Build.0 = ReleaseSigned|x64
49-
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.ReleaseSigned|x64.Deploy.0 = ReleaseSigned|x64
50-
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.ReleaseSigned|x86.ActiveCfg = ReleaseSigned|x86
51-
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.ReleaseSigned|x86.Build.0 = ReleaseSigned|x86
52-
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.ReleaseSigned|x86.Deploy.0 = ReleaseSigned|x86
5333
EndGlobalSection
5434
GlobalSection(SolutionProperties) = preSolution
5535
HideSolutionNode = FALSE

src/App.manifest

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
33
<assemblyIdentity type="win32"
44
name="Sungaila.SUBSTitute"
5-
version="2.0.3.0" />
5+
version="2.1.0.0" />
66

77
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
88
<application>
99
<!-- Windows 10 and Windows 11 -->
10-
<maxversiontested Id="10.0.22000.0"/>
10+
<maxversiontested Id="10.0.26100.0"/>
1111
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
1212
</application>
1313
</compatibility>

src/Commands/MappingCommands.cs

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using CommunityToolkit.Mvvm.Input;
2+
using Microsoft.UI.Dispatching;
23
using Microsoft.UI.Xaml;
34
using Microsoft.UI.Xaml.Controls;
45
using Sungaila.SUBSTitute.ViewModels;
@@ -7,6 +8,7 @@
78
using System.IO;
89
using System.Linq;
910
using System.Threading.Tasks;
11+
using Windows.Storage;
1012
using Windows.Win32;
1113

1214
namespace Sungaila.SUBSTitute.Commands
@@ -48,24 +50,44 @@ private static bool IsVirtualDrive(string driveName)
4850

4951
internal static DriveViewModel GetDriveViewModel(MappingViewModel mappingViewModel, DriveInfo driveInfo)
5052
{
51-
string volumeLabel = string.Empty;
52-
string driveFormat = string.Empty;
53-
54-
if (driveInfo.IsReady)
55-
{
56-
volumeLabel = driveInfo.VolumeLabel;
57-
driveFormat = driveInfo.DriveFormat;
58-
}
59-
60-
return new DriveViewModel
53+
var result = new DriveViewModel
6154
{
6255
ParentViewModel = mappingViewModel,
6356
Letter = driveInfo.Name.First(),
64-
Label = volumeLabel,
65-
DriveFormat = driveFormat,
57+
Label = driveInfo.Name,
6658
DriveType = driveInfo.DriveType,
6759
IsVirtual = IsVirtualDrive(driveInfo.Name)
6860
};
61+
62+
Task.Run(() =>
63+
{
64+
// get the disk label
65+
try
66+
{
67+
string driveDisplayName = StorageFolder.GetFolderFromPathAsync(driveInfo.Name).GetAwaiter().GetResult().DisplayName;
68+
69+
App.MainWindow?.DispatcherQueue.TryEnqueue(DispatcherQueuePriority.Low, () =>
70+
{
71+
result.Label = driveDisplayName;
72+
});
73+
}
74+
catch { }
75+
76+
// get the disk format
77+
try
78+
{
79+
if (!driveInfo.IsReady)
80+
return;
81+
82+
App.MainWindow?.DispatcherQueue.TryEnqueue(DispatcherQueuePriority.Low, () =>
83+
{
84+
result.DriveFormat = driveInfo.DriveFormat;
85+
});
86+
}
87+
catch { }
88+
});
89+
90+
return result;
6991
}
7092

7193
public static readonly IAsyncRelayCommand<MappingViewModel> AddVirtualDrive = new AsyncRelayCommand<MappingViewModel>(async parameter =>

src/Converters/BoolToOpacityConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Sungaila.SUBSTitute.Converters
66
{
7-
public class BoolToOpacityConverter : IValueConverter
7+
public partial class BoolToOpacityConverter : IValueConverter
88
{
99
public object Convert(object value, Type targetType, object parameter, string language)
1010
{

src/Converters/EnumToStringConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Sungaila.SUBSTitute.Converters
66
{
7-
public class EnumToStringConverter : IValueConverter
7+
public partial class EnumToStringConverter : IValueConverter
88
{
99
public object? Convert(object value, Type targetType, object parameter, string language)
1010
{

src/Converters/NullToVisibilityConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Sungaila.SUBSTitute.Converters
66
{
7-
public class NullToVisibilityConverter : IValueConverter
7+
public partial class NullToVisibilityConverter : IValueConverter
88
{
99
public object Convert(object value, Type targetType, object parameter, string language)
1010
{

src/Converters/ThumbnailConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace Sungaila.SUBSTitute.Converters
99
{
10-
public class ThumbnailConverter : IValueConverter
10+
public partial class ThumbnailConverter : IValueConverter
1111
{
1212
public object? Convert(object value, Type targetType, object parameter, string language)
1313
{
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System;
6+
7+
namespace Sungaila.SUBSTitute.Extensions;
8+
9+
/// <summary>
10+
/// A collection view implementation that supports filtering, grouping, sorting and incremental loading
11+
/// </summary>
12+
public partial class HackedCollectionView
13+
{
14+
/// <summary>
15+
/// Stops refreshing until it is disposed
16+
/// </summary>
17+
/// <returns>An disposable object</returns>
18+
public IDisposable DeferRefresh()
19+
{
20+
return new NotificationDeferrer(this);
21+
}
22+
23+
/// <summary>
24+
/// Notification deferrer helper class
25+
/// </summary>
26+
#pragma warning disable CA1063 // Implement IDisposable Correctly
27+
public partial class NotificationDeferrer : IDisposable
28+
#pragma warning restore CA1063 // Implement IDisposable Correctly
29+
{
30+
private readonly HackedCollectionView _acvs;
31+
private readonly object _currentItem;
32+
33+
/// <summary>
34+
/// Initializes a new instance of the <see cref="NotificationDeferrer"/> class.
35+
/// </summary>
36+
/// <param name="acvs">Source ACVS</param>
37+
public NotificationDeferrer(HackedCollectionView acvs)
38+
{
39+
_acvs = acvs;
40+
_currentItem = _acvs.CurrentItem;
41+
_acvs._deferCounter++;
42+
}
43+
44+
/// <summary>
45+
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
46+
/// </summary>
47+
/// <filterpriority>2</filterpriority>
48+
#pragma warning disable CA1063 // Implement IDisposable Correctly
49+
public void Dispose()
50+
#pragma warning restore CA1063 // Implement IDisposable Correctly
51+
{
52+
_acvs.MoveCurrentTo(_currentItem);
53+
_acvs._deferCounter--;
54+
_acvs.Refresh();
55+
}
56+
}
57+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using Microsoft.UI.Xaml.Data;
6+
using Windows.Foundation.Collections;
7+
8+
namespace Sungaila.SUBSTitute.Extensions;
9+
10+
/// <summary>
11+
/// A collection view implementation that supports filtering, grouping, sorting and incremental loading
12+
/// </summary>
13+
public partial class HackedCollectionView
14+
{
15+
/// <summary>
16+
/// Currently selected item changing event
17+
/// </summary>
18+
/// <param name="e">event args</param>
19+
private void OnCurrentChanging(CurrentChangingEventArgs e)
20+
{
21+
if (_deferCounter > 0)
22+
{
23+
return;
24+
}
25+
26+
CurrentChanging?.Invoke(this, e);
27+
}
28+
29+
/// <summary>
30+
/// Currently selected item changed event
31+
/// </summary>
32+
/// <param name="e">event args</param>
33+
private void OnCurrentChanged(object e)
34+
{
35+
if (_deferCounter > 0)
36+
{
37+
return;
38+
}
39+
40+
CurrentChanged?.Invoke(this, e);
41+
42+
// ReSharper disable once ExplicitCallerInfoArgument
43+
OnPropertyChanged(nameof(CurrentItem));
44+
}
45+
46+
/// <summary>
47+
/// Vector changed event
48+
/// </summary>
49+
/// <param name="e">event args</param>
50+
private void OnVectorChanged(IVectorChangedEventArgs e)
51+
{
52+
if (_deferCounter > 0)
53+
{
54+
return;
55+
}
56+
57+
VectorChanged?.Invoke(this, e);
58+
59+
// ReSharper disable once ExplicitCallerInfoArgument
60+
OnPropertyChanged(nameof(Count));
61+
}
62+
}

0 commit comments

Comments
 (0)