Convert into primary constructor.

This commit is contained in:
2023-10-04 08:29:56 +01:00
parent ef6be56f5f
commit ac79d1e94e
113 changed files with 181 additions and 429 deletions

View File

@@ -36,81 +36,63 @@ using JetBrains.Annotations;
namespace Aaru.Gui.ViewModels.Panels;
public sealed class FileSystemViewModel
public sealed class FileSystemViewModel([NotNull] FileSystem metadata, string information)
{
public FileSystemViewModel([NotNull] FileSystem metadata, string information)
{
TypeText = string.Format(Localization.Core.Filesystem_type_0, metadata.Type);
VolumeNameText = string.Format(Localization.Core.Volume_name_0, metadata.VolumeName);
SerialNumberText = string.Format(Localization.Core.Volume_serial_0, metadata.VolumeSerial);
ApplicationIdentifierText =
string.Format(Localization.Core.Application_identifier_0, metadata.ApplicationIdentifier);
SystemIdentifierText = string.Format(Localization.Core.System_identifier_0, metadata.SystemIdentifier);
VolumeSetIdentifierText =
string.Format(Localization.Core.Volume_set_identifier_0, metadata.VolumeSetIdentifier);
DataPreparerIdentifierText =
string.Format(Localization.Core.Data_preparer_identifier_0, metadata.DataPreparerIdentifier);
PublisherIdentifierText = string.Format(Localization.Core.Publisher_identifier_0, metadata.PublisherIdentifier);
CreationDateText = string.Format(Localization.Core.Volume_created_on_0, metadata.CreationDate);
EffectiveDateText = string.Format(Localization.Core.Volume_effective_from_0, metadata.EffectiveDate);
ModificationDateText = string.Format(Localization.Core.Volume_last_modified_on_0, metadata.ModificationDate);
ExpirationDateText = string.Format(Localization.Core.Volume_expired_on_0, metadata.ExpirationDate);
BackupDateText = string.Format(Localization.Core.Volume_last_backed_up_on_0, metadata.BackupDate);
ClustersText = string.Format(Localization.Core.Volume_has_0_clusters_of_1_bytes_each_total_of_2_bytes,
metadata.Clusters, metadata.ClusterSize, metadata.Clusters * metadata.ClusterSize);
FreeClustersText = string.Format(Localization.Core.Volume_has_0_clusters_free_1, metadata.FreeClusters,
metadata.FreeClusters / metadata.Clusters);
FilesText = string.Format(Localization.Core.Volume_contains_0_files, metadata.Files);
BootableChecked = metadata.Bootable;
DirtyChecked = metadata.Dirty;
InformationText = information;
CreationDateVisible = metadata.CreationDate != null;
EffectiveDateVisible = metadata.EffectiveDate != null;
ModificationDateVisible = metadata.ModificationDate != null;
ExpirationDateVisible = metadata.ExpirationDate != null;
BackupDateVisible = metadata.BackupDate != null;
FreeClustersVisible = metadata.FreeClusters != null;
FilesVisible = metadata.Files != null;
}
public string BootableLabel => Localization.Core.Filesystem_contains_boot_code;
public string DirtyLabel => Localization.Core.Filesystem_has_not_been_unmounted_correctly_or_contains_errors;
public string DetailsLabel => UI.Title_Details;
public string TypeText { get; }
public string VolumeNameText { get; }
public string SerialNumberText { get; }
public string ApplicationIdentifierText { get; }
public string SystemIdentifierText { get; }
public string VolumeSetIdentifierText { get; }
public string DataPreparerIdentifierText { get; }
public string PublisherIdentifierText { get; }
public string CreationDateText { get; }
public string EffectiveDateText { get; }
public string ModificationDateText { get; }
public string ExpirationDateText { get; }
public string BackupDateText { get; }
public string ClustersText { get; }
public string FreeClustersText { get; }
public string FilesText { get; }
public bool BootableChecked { get; }
public bool DirtyChecked { get; }
public string InformationText { get; }
public bool CreationDateVisible { get; }
public bool EffectiveDateVisible { get; }
public bool ModificationDateVisible { get; }
public bool ExpirationDateVisible { get; }
public bool BackupDateVisible { get; }
public bool FreeClustersVisible { get; }
public bool FilesVisible { get; }
public string TypeText { get; } = string.Format(Localization.Core.Filesystem_type_0, metadata.Type);
public string VolumeNameText { get; } = string.Format(Localization.Core.Volume_name_0, metadata.VolumeName);
public string SerialNumberText { get; } = string.Format(Localization.Core.Volume_serial_0, metadata.VolumeSerial);
public string ApplicationIdentifierText { get; } =
string.Format(Localization.Core.Application_identifier_0, metadata.ApplicationIdentifier);
public string SystemIdentifierText { get; } =
string.Format(Localization.Core.System_identifier_0, metadata.SystemIdentifier);
public string VolumeSetIdentifierText { get; } =
string.Format(Localization.Core.Volume_set_identifier_0, metadata.VolumeSetIdentifier);
public string DataPreparerIdentifierText { get; } =
string.Format(Localization.Core.Data_preparer_identifier_0, metadata.DataPreparerIdentifier);
public string PublisherIdentifierText { get; } =
string.Format(Localization.Core.Publisher_identifier_0, metadata.PublisherIdentifier);
public string CreationDateText { get; } =
string.Format(Localization.Core.Volume_created_on_0, metadata.CreationDate);
public string EffectiveDateText { get; } =
string.Format(Localization.Core.Volume_effective_from_0, metadata.EffectiveDate);
public string ModificationDateText { get; } =
string.Format(Localization.Core.Volume_last_modified_on_0, metadata.ModificationDate);
public string ExpirationDateText { get; } =
string.Format(Localization.Core.Volume_expired_on_0, metadata.ExpirationDate);
public string BackupDateText { get; } =
string.Format(Localization.Core.Volume_last_backed_up_on_0, metadata.BackupDate);
public string ClustersText { get; } = string.Format(
Localization.Core.Volume_has_0_clusters_of_1_bytes_each_total_of_2_bytes,
metadata.Clusters, metadata.ClusterSize, metadata.Clusters * metadata.ClusterSize);
public string FreeClustersText { get; } = string.Format(Localization.Core.Volume_has_0_clusters_free_1,
metadata.FreeClusters,
metadata.FreeClusters / metadata.Clusters);
public string FilesText { get; } = string.Format(Localization.Core.Volume_contains_0_files, metadata.Files);
public bool BootableChecked { get; } = metadata.Bootable;
public bool DirtyChecked { get; } = metadata.Dirty;
public string InformationText { get; } = information;
public bool CreationDateVisible { get; } = metadata.CreationDate != null;
public bool EffectiveDateVisible { get; } = metadata.EffectiveDate != null;
public bool ModificationDateVisible { get; } = metadata.ModificationDate != null;
public bool ExpirationDateVisible { get; } = metadata.ExpirationDate != null;
public bool BackupDateVisible { get; } = metadata.BackupDate != null;
public bool FreeClustersVisible { get; } = metadata.FreeClusters != null;
public bool FilesVisible { get; } = metadata.Files != null;
}

View File

@@ -34,25 +34,18 @@ using Aaru.CommonTypes;
namespace Aaru.Gui.ViewModels.Panels;
public sealed class PartitionViewModel
public sealed class PartitionViewModel(Partition partition)
{
public PartitionViewModel(Partition partition)
{
NameText = string.Format(Localization.Core.Partition_name_0, partition.Name);
TypeText = string.Format(Localization.Core.Partition_type_0, partition.Type);
StartText = string.Format(Localization.Core.Partition_start_sector_0_byte_1, partition.Start, partition.Offset);
public string NameText { get; } = string.Format(Localization.Core.Partition_name_0, partition.Name);
public string TypeText { get; } = string.Format(Localization.Core.Partition_type_0, partition.Type);
LengthText = string.Format(Localization.Core.Partition_length_0_sectors_1_bytes, partition.Length,
partition.Size);
public string StartText { get; } =
string.Format(Localization.Core.Partition_start_sector_0_byte_1, partition.Start, partition.Offset);
DescriptionLabelText = Localization.Core.Title_Partition_description;
DescriptionText = partition.Description;
}
public string LengthText { get; } = string.Format(Localization.Core.Partition_length_0_sectors_1_bytes,
partition.Length,
partition.Size);
public string NameText { get; }
public string TypeText { get; }
public string StartText { get; }
public string LengthText { get; }
public string DescriptionLabelText { get; }
public string DescriptionText { get; }
public string DescriptionLabelText { get; } = Localization.Core.Title_Partition_description;
public string DescriptionText { get; } = partition.Description;
}

View File

@@ -50,14 +50,11 @@ using ReactiveUI;
namespace Aaru.Gui.ViewModels.Windows;
public sealed class SplashWindowViewModel : ViewModelBase
public sealed class SplashWindowViewModel(SplashWindow view) : ViewModelBase
{
readonly SplashWindow _view;
double _currentProgress;
double _maxProgress;
string _message;
public SplashWindowViewModel(SplashWindow view) => _view = view;
double _currentProgress;
double _maxProgress;
string _message;
public string Message
{
@@ -234,7 +231,7 @@ public sealed class SplashWindowViewModel : ViewModelBase
var settingsDialog = new SettingsDialog();
var settingsDialogViewModel = new SettingsViewModel(settingsDialog, true);
settingsDialog.DataContext = settingsDialogViewModel;
await settingsDialog.ShowDialog(_view);
await settingsDialog.ShowDialog(view);
}
LoadStatistics();