Skip to content

Commit

Permalink
Update WpfApp library dependency then migrate to CommunityToolkit.Mvvm
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxhy committed Sep 27, 2023
1 parent bc452af commit 23509c7
Show file tree
Hide file tree
Showing 45 changed files with 205 additions and 232 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Leosac.KeyManager.Library.UI.Domain;
using CommunityToolkit.Mvvm.Input;
using Leosac.KeyManager.Library.UI.Domain;
using Leosac.WpfApp;
using Leosac.WpfApp.Domain;
using MaterialDesignThemes.Wpf;
Expand All @@ -18,10 +19,9 @@ public SAMKeyStoreKeyCounterControlViewModel()
{
CounterIdentifiers.Add(i);
}
EditKeyUsageCounterCommand = new LeosacAppCommand(
parameter =>
EditKeyUsageCounterCommand = new RelayCommand<byte?>(
identifier =>
{
var identifier = parameter as byte?;
if (identifier != null)
{
try
Expand Down Expand Up @@ -57,7 +57,7 @@ public byte SelectedCounterIdentifier

public ObservableCollection<byte> CounterIdentifiers { get; set; }

public LeosacAppCommand EditKeyUsageCounterCommand { get; set; }
public RelayCommand<byte?> EditKeyUsageCounterCommand { get; set; }

private async void UpdateKeyCounter(SAMKeyUsageCounterDialog dialog)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using LibLogicalAccess.Card;
using LibLogicalAccess.Reader;
using System.Collections.ObjectModel;
using CommunityToolkit.Mvvm.Input;

namespace Leosac.KeyManager.Library.KeyStore.NXP_SAM.UI.Domain
{
Expand All @@ -24,32 +25,32 @@ public SAMKeyStoreToolsControlViewModel()
KeyTypes = new ObservableCollection<SAMKeyType>(Enum.GetValues<SAMKeyType>());
UnlockActions = new ObservableCollection<SAMLockUnlock>(Enum.GetValues<SAMLockUnlock>());

SAMAuthCommand = new LeosacAppCommand(
parameter =>
SAMAuthCommand = new RelayCommand(
() =>
{
SAMAuthenticate();
});

SAMSwitchAV2Command = new LeosacAppCommand(
parameter =>
SAMSwitchAV2Command = new RelayCommand(
() =>
{
SAMSwitchAV2();
});

SAMLockUnlockCommand = new LeosacAppCommand(
parameter =>
SAMLockUnlockCommand = new RelayCommand(
() =>
{
SAMLockUnlock();
});

SAMGetVersionCommand = new LeosacAppCommand(
parameter =>
SAMGetVersionCommand = new RelayCommand(
() =>
{
SAMGetVersion();
});

SAMActivateMifareSAMCommand = new LeosacAppCommand(
parameter =>
SAMActivateMifareSAMCommand = new RelayCommand(
() =>
{
SAMActivateMifareSAM();
});
Expand Down Expand Up @@ -101,15 +102,15 @@ public SAMLockUnlock SAMUnlockAction

public ObservableCollection<SAMLockUnlock> UnlockActions { get; set; }

public LeosacAppCommand SAMAuthCommand { get; }
public RelayCommand SAMAuthCommand { get; }

public LeosacAppCommand SAMSwitchAV2Command { get; }
public RelayCommand SAMSwitchAV2Command { get; }

public LeosacAppCommand SAMLockUnlockCommand { get; }
public RelayCommand SAMLockUnlockCommand { get; }

public LeosacAppCommand SAMGetVersionCommand { get; }
public RelayCommand SAMGetVersionCommand { get; }

public LeosacAppCommand SAMActivateMifareSAMCommand { get; }
public RelayCommand SAMActivateMifareSAMCommand { get; }

private void SAMGetVersion()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Leosac.KeyManager.Library.Plugin.UI.Domain;
using CommunityToolkit.Mvvm.ComponentModel;

namespace Leosac.KeyManager.Library.KeyStore.NXP_SAM.UI.Domain
{
public class SAMKeyUsageCounterDialogViewModel : KMObject
public class SAMKeyUsageCounterDialogViewModel : ObservableValidator
{
public SAMKeyUsageCounterDialogViewModel()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Leosac.WpfApp" Version="1.10.0">
<PackageReference Include="Leosac.WpfApp" Version="1.11.0">
<ExcludeAssets>runtime</ExcludeAssets>
</PackageReference>
<PackageReference Include="MaterialDesignThemes" Version="4.9.0">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using Leosac.KeyManager.Library.Plugin.UI.Domain;
using CommunityToolkit.Mvvm.ComponentModel;
using Leosac.KeyManager.Library.Plugin.UI.Domain;

namespace Leosac.KeyManager.Library.KeyStore.NXP_SAM.UI.Wizard.Domain
{
public class SAMAccessControlWizardWindowViewModel : KMObject
public class SAMAccessControlWizardWindowViewModel : ObservableValidator
{
public SAMAccessControlWizardWindowViewModel()
{
Expand Down
8 changes: 2 additions & 6 deletions KeyManager.Library.KeyStore.NXP_SAM/SAMKeyUsageCounter.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CommunityToolkit.Mvvm.ComponentModel;

namespace Leosac.KeyManager.Library.KeyStore.NXP_SAM
{
public class SAMKeyUsageCounter : KMObject
public class SAMKeyUsageCounter : ObservableValidator
{
public SAMKeyUsageCounter()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using Leosac.KeyManager.Library.KeyStore;
using CommunityToolkit.Mvvm.ComponentModel;
using Leosac.KeyManager.Library.KeyStore;

namespace Leosac.KeyManager.Library.Plugin.UI.Domain
{
public abstract class KeyEntryPropertiesControlViewModel : KMObject
public abstract class KeyEntryPropertiesControlViewModel : ObservableValidator
{
protected KeyEntryProperties? _properties;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using Leosac.KeyManager.Library.KeyStore;
using CommunityToolkit.Mvvm.ComponentModel;
using Leosac.KeyManager.Library.KeyStore;

namespace Leosac.KeyManager.Library.Plugin.UI.Domain
{
public abstract class KeyStorePropertiesControlViewModel : KMObject
public abstract class KeyStorePropertiesControlViewModel : ObservableValidator
{
protected KeyStoreProperties? _properties;

Expand Down
20 changes: 11 additions & 9 deletions KeyManager.Library.UI/Domain/FolderBrowserDialogViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
using Leosac.KeyManager.Library.Plugin.UI.Domain;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Leosac.KeyManager.Library.Plugin.UI.Domain;
using Leosac.WpfApp.Domain;
using System.Collections.ObjectModel;
using System.IO;

namespace Leosac.KeyManager.Library.UI.Domain
{
public class FolderBrowserDialogViewModel : KMObject
public class FolderBrowserDialogViewModel : ObservableValidator
{
public FolderBrowserDialogViewModel()
{
Drives = new ObservableCollection<DriveInfo>(DriveInfo.GetDrives());
Directories = new ObservableCollection<DirectoryInfo>();

GoToParentCommand = new LeosacAppCommand(
parameter =>
GoToParentCommand = new RelayCommand(
() =>
{
if (SelectedDirectory?.Parent != null)
{
Expand All @@ -22,10 +24,10 @@ public FolderBrowserDialogViewModel()
}
);

CreateFolderCommand = new LeosacAppCommand(
parameter =>
CreateFolderCommand = new RelayCommand<string>(
newFolder =>
{
if (SelectedDirectory != null && parameter is string newFolder)
if (SelectedDirectory != null && !string.IsNullOrEmpty(newFolder))
{
var newFolderFullpath = Path.Combine(SelectedDirectory.FullName, newFolder);
SelectedDirectory = Directory.CreateDirectory(newFolderFullpath);
Expand Down Expand Up @@ -127,8 +129,8 @@ private void UpdateDirectories(DirectoryInfo? parent)
noDirUpdate = false;
}

public LeosacAppCommand GoToParentCommand { get; }
public RelayCommand GoToParentCommand { get; }

public LeosacAppCommand CreateFolderCommand { get; }
public RelayCommand<string> CreateFolderCommand { get; }
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using Leosac.KeyManager.Library.KeyStore;
using CommunityToolkit.Mvvm.ComponentModel;
using Leosac.KeyManager.Library.KeyStore;
using Leosac.KeyManager.Library.Plugin.UI.Domain;
using Leosac.WpfApp.Domain;

namespace Leosac.KeyManager.Library.UI.Domain
{
public class ImportCryptogramDialogViewModel : KMObject
public class ImportCryptogramDialogViewModel : ObservableValidator
{
public ImportCryptogramDialogViewModel()
{
Expand Down
5 changes: 3 additions & 2 deletions KeyManager.Library.UI/Domain/KeyCeremonyDialogViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using Leosac.KeyManager.Library.Plugin.UI.Domain;
using CommunityToolkit.Mvvm.ComponentModel;
using Leosac.KeyManager.Library.Plugin.UI.Domain;
using Leosac.WpfApp.Domain;
using System.Collections.ObjectModel;

namespace Leosac.KeyManager.Library.UI.Domain
{
public class KeyCeremonyDialogViewModel : KMObject
public class KeyCeremonyDialogViewModel : ObservableValidator
{
public KeyCeremonyDialogViewModel()
{
Expand Down
Loading

0 comments on commit 23509c7

Please sign in to comment.