Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to Windows App SDK 1.6 #3

Merged
merged 3 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ publish/
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
#*.pubxml
*.publishproj

# Microsoft Azure Web App publish settings. Comment the next line if you want to
Expand Down
22 changes: 1 addition & 21 deletions SUBSTitute.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
# 17
VisualStudioVersion = 17.9.34723.18
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SUBSTitute", "src\SUBSTitute.csproj", "{3DA68281-59F8-46A1-B263-31EC608AFCE3}"
Expand All @@ -14,13 +14,8 @@ Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM64 = Debug|ARM64
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|ARM64 = Release|ARM64
Release|x64 = Release|x64
Release|x86 = Release|x86
ReleaseSigned|ARM64 = ReleaseSigned|ARM64
ReleaseSigned|x64 = ReleaseSigned|x64
ReleaseSigned|x86 = ReleaseSigned|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.Debug|ARM64.ActiveCfg = Debug|ARM64
Expand All @@ -29,27 +24,12 @@ Global
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.Debug|x64.ActiveCfg = Debug|x64
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.Debug|x64.Build.0 = Debug|x64
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.Debug|x64.Deploy.0 = Debug|x64
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.Debug|x86.ActiveCfg = Debug|x86
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.Debug|x86.Build.0 = Debug|x86
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.Debug|x86.Deploy.0 = Debug|x86
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.Release|ARM64.ActiveCfg = Release|ARM64
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.Release|ARM64.Build.0 = Release|ARM64
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.Release|ARM64.Deploy.0 = Release|ARM64
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.Release|x64.ActiveCfg = Release|x64
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.Release|x64.Build.0 = Release|x64
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.Release|x64.Deploy.0 = Release|x64
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.Release|x86.ActiveCfg = Release|x86
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.Release|x86.Build.0 = Release|x86
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.Release|x86.Deploy.0 = Release|x86
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.ReleaseSigned|ARM64.ActiveCfg = ReleaseSigned|ARM64
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.ReleaseSigned|ARM64.Build.0 = ReleaseSigned|ARM64
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.ReleaseSigned|ARM64.Deploy.0 = ReleaseSigned|ARM64
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.ReleaseSigned|x64.ActiveCfg = ReleaseSigned|x64
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.ReleaseSigned|x64.Build.0 = ReleaseSigned|x64
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.ReleaseSigned|x64.Deploy.0 = ReleaseSigned|x64
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.ReleaseSigned|x86.ActiveCfg = ReleaseSigned|x86
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.ReleaseSigned|x86.Build.0 = ReleaseSigned|x86
{3DA68281-59F8-46A1-B263-31EC608AFCE3}.ReleaseSigned|x86.Deploy.0 = ReleaseSigned|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
4 changes: 2 additions & 2 deletions src/App.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity type="win32"
name="Sungaila.SUBSTitute"
version="2.0.3.0" />
version="2.1.0.0" />

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows 10 and Windows 11 -->
<maxversiontested Id="10.0.22000.0"/>
<maxversiontested Id="10.0.26100.0"/>
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
</application>
</compatibility>
Expand Down
46 changes: 34 additions & 12 deletions src/Commands/MappingCommands.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using CommunityToolkit.Mvvm.Input;
using Microsoft.UI.Dispatching;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Sungaila.SUBSTitute.ViewModels;
Expand All @@ -7,6 +8,7 @@
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Windows.Storage;
using Windows.Win32;

namespace Sungaila.SUBSTitute.Commands
Expand All @@ -25,7 +27,7 @@
{
parameter.Drives.Add(GetDriveViewModel(parameter, drive));
}
catch { }

Check warning on line 30 in src/Commands/MappingCommands.cs

View workflow job for this annotation

GitHub Actions / SonarCloud

Handle the exception or explain in a comment why it can be ignored. (https://rules.sonarsource.com/csharp/RSPEC-2486)
}
});

Expand All @@ -48,24 +50,44 @@

internal static DriveViewModel GetDriveViewModel(MappingViewModel mappingViewModel, DriveInfo driveInfo)
{
string volumeLabel = string.Empty;
string driveFormat = string.Empty;

if (driveInfo.IsReady)
{
volumeLabel = driveInfo.VolumeLabel;
driveFormat = driveInfo.DriveFormat;
}

return new DriveViewModel
var result = new DriveViewModel
{
ParentViewModel = mappingViewModel,
Letter = driveInfo.Name.First(),
Label = volumeLabel,
DriveFormat = driveFormat,
Label = driveInfo.Name,
DriveType = driveInfo.DriveType,
IsVirtual = IsVirtualDrive(driveInfo.Name)
};

Task.Run(() =>
{
// get the disk label
try
{
string driveDisplayName = StorageFolder.GetFolderFromPathAsync(driveInfo.Name).GetAwaiter().GetResult().DisplayName;

App.MainWindow?.DispatcherQueue.TryEnqueue(DispatcherQueuePriority.Low, () =>
{
result.Label = driveDisplayName;
});
}
catch { }

// get the disk format
try
{
if (!driveInfo.IsReady)
return;

App.MainWindow?.DispatcherQueue.TryEnqueue(DispatcherQueuePriority.Low, () =>
{
result.DriveFormat = driveInfo.DriveFormat;
});
}
catch { }
});

return result;
}

public static readonly IAsyncRelayCommand<MappingViewModel> AddVirtualDrive = new AsyncRelayCommand<MappingViewModel>(async parameter =>
Expand Down
2 changes: 1 addition & 1 deletion src/Converters/BoolToOpacityConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Sungaila.SUBSTitute.Converters
{
public class BoolToOpacityConverter : IValueConverter
public partial class BoolToOpacityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Converters/EnumToStringConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Sungaila.SUBSTitute.Converters
{
public class EnumToStringConverter : IValueConverter
public partial class EnumToStringConverter : IValueConverter
{
public object? Convert(object value, Type targetType, object parameter, string language)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Converters/NullToVisibilityConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Sungaila.SUBSTitute.Converters
{
public class NullToVisibilityConverter : IValueConverter
public partial class NullToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Converters/ThumbnailConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Sungaila.SUBSTitute.Converters
{
public class ThumbnailConverter : IValueConverter
public partial class ThumbnailConverter : IValueConverter
{
public object? Convert(object value, Type targetType, object parameter, string language)
{
Expand Down
57 changes: 57 additions & 0 deletions src/Extensions/HackedCollectionView.Defer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;

namespace Sungaila.SUBSTitute.Extensions;

/// <summary>
/// A collection view implementation that supports filtering, grouping, sorting and incremental loading
/// </summary>
public partial class HackedCollectionView
{
/// <summary>
/// Stops refreshing until it is disposed
/// </summary>
/// <returns>An disposable object</returns>
public IDisposable DeferRefresh()
{
return new NotificationDeferrer(this);
}

/// <summary>
/// Notification deferrer helper class
/// </summary>
#pragma warning disable CA1063 // Implement IDisposable Correctly
public partial class NotificationDeferrer : IDisposable
#pragma warning restore CA1063 // Implement IDisposable Correctly
{
private readonly HackedCollectionView _acvs;
private readonly object _currentItem;

/// <summary>
/// Initializes a new instance of the <see cref="NotificationDeferrer"/> class.
/// </summary>
/// <param name="acvs">Source ACVS</param>
public NotificationDeferrer(HackedCollectionView acvs)
{
_acvs = acvs;
_currentItem = _acvs.CurrentItem;
_acvs._deferCounter++;
}

/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary>
/// <filterpriority>2</filterpriority>
#pragma warning disable CA1063 // Implement IDisposable Correctly
public void Dispose()
#pragma warning restore CA1063 // Implement IDisposable Correctly
{
_acvs.MoveCurrentTo(_currentItem);
_acvs._deferCounter--;
_acvs.Refresh();
}
}
}
62 changes: 62 additions & 0 deletions src/Extensions/HackedCollectionView.Events.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Microsoft.UI.Xaml.Data;
using Windows.Foundation.Collections;

namespace Sungaila.SUBSTitute.Extensions;

/// <summary>
/// A collection view implementation that supports filtering, grouping, sorting and incremental loading
/// </summary>
public partial class HackedCollectionView
{
/// <summary>
/// Currently selected item changing event
/// </summary>
/// <param name="e">event args</param>
private void OnCurrentChanging(CurrentChangingEventArgs e)
{
if (_deferCounter > 0)
{
return;
}

CurrentChanging?.Invoke(this, e);
}

/// <summary>
/// Currently selected item changed event
/// </summary>
/// <param name="e">event args</param>
private void OnCurrentChanged(object e)
{
if (_deferCounter > 0)
{
return;
}

CurrentChanged?.Invoke(this, e);

// ReSharper disable once ExplicitCallerInfoArgument
OnPropertyChanged(nameof(CurrentItem));
}

/// <summary>
/// Vector changed event
/// </summary>
/// <param name="e">event args</param>
private void OnVectorChanged(IVectorChangedEventArgs e)
{
if (_deferCounter > 0)
{
return;
}

VectorChanged?.Invoke(this, e);

// ReSharper disable once ExplicitCallerInfoArgument
OnPropertyChanged(nameof(Count));
}
}
Loading
Loading