Migrate filesystem panel from Eto.Forms to Avalonia.

This commit is contained in:
2020-04-14 20:20:43 +01:00
parent 754f8d5adb
commit fcaf7d8148
8 changed files with 132 additions and 176 deletions

View File

@@ -1252,14 +1252,14 @@
<e p="TrackEntropyModel.cs" t="Include" />
</e>
<e p="Panels" t="Include">
<e p="FileSystemPanel.xaml" t="Include" />
<e p="FileSystemPanel.xaml.cs" t="Include" />
<e p="ImageInfoPanel.xaml" t="Include" />
<e p="ImageInfoPanel.xaml.cs" t="Include" />
<e p="PartitionPanel.xaml" t="Include" />
<e p="PartitionPanel.xaml.cs" t="Include" />
<e p="pnlDeviceInfo.xeto" t="Include" />
<e p="pnlDeviceInfo.xeto.cs" t="Include" />
<e p="pnlFilesystem.xeto" t="Include" />
<e p="pnlFilesystem.xeto.cs" t="Include" />
<e p="pnlListFiles.xeto" t="Include" />
<e p="pnlListFiles.xeto.cs" t="Include" />
<e p="pnlScsiInfo.xeto" t="Include" />
@@ -1297,6 +1297,7 @@
<e p="DvdInfoViewModel.cs" t="Include" />
<e p="DvdWritableInfoViewModel.cs" t="Include" />
<e p="EncodingsDialogViewModel.cs" t="Include" />
<e p="FileSystemViewModel.cs" t="Include" />
<e p="ImageChecksumViewModel.cs" t="Include" />
<e p="ImageConvertViewModel.cs" t="Include" />
<e p="ImageEntropyViewModel.cs" t="Include" />

View File

@@ -1,4 +1,5 @@
using Aaru.CommonTypes.Interfaces;
using Aaru.Gui.ViewModels;
namespace Aaru.Gui.Models
{
@@ -7,5 +8,6 @@ namespace Aaru.Gui.Models
public string VolumeName { get; set; }
public IFilesystem Filesystem { get; set; }
public IReadOnlyFilesystem ReadOnlyFilesystem { get; set; }
public FileSystemViewModel ViewModel { get; set; }
}
}

View File

@@ -0,0 +1,35 @@
<UserControl xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:Aaru.Gui.ViewModels" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Aaru.Gui.Panels.FileSystemPanel">
<Design.DataContext>
<vm:FileSystemViewModel />
</Design.DataContext>
<StackPanel>
<TextBlock Text="{Binding TypeText}" />
<TextBlock Text="{Binding VolumeNameText}" IsVisible="{Binding !!VolumeNameText}" />
<TextBlock Text="{Binding SerialNumberText}" IsVisible="{Binding !!VolumeNameText}" />
<TextBlock Text="{Binding ApplicationIdentifierText}" IsVisible="{Binding !!VolumeNameText}" />
<TextBlock Text="{Binding SystemIdentifierText}" IsVisible="{Binding !!VolumeNameText}" />
<TextBlock Text="{Binding VolumeSetIdentifierText}" IsVisible="{Binding !!VolumeNameText}" />
<TextBlock Text="{Binding DataPreparerIdentifierText}" IsVisible="{Binding !!VolumeNameText}" />
<TextBlock Text="{Binding PublisherIdentifierText}" IsVisible="{Binding !!VolumeNameText}" />
<TextBlock Text="{Binding CreationDateText}" IsVisible="{Binding CreationDateVisible}" />
<TextBlock Text="{Binding EffectiveDateText}" IsVisible="{Binding EffectiveDateVisible}" />
<TextBlock Text="{Binding ModificationDateText}" IsVisible="{Binding ModificationDateVisible}" />
<TextBlock Text="{Binding ExpirationDateText}" IsVisible="{Binding ExpirationDateVisible}" />
<TextBlock Text="{Binding BackupDateText}" IsVisible="{Binding BackupDateVisible}" />
<TextBlock Text="{Binding ClustersText}" />
<TextBlock Text="{Binding FreeClustersText}" IsVisible="{Binding FreeClustersVisible}" />
<TextBlock Text="{Binding FilesText}" IsVisible="{Binding FilesVisible}" />
<CheckBox IsEnabled="{Binding BootableChecked}">
<TextBlock Text="Filesystem contains boot code" />
</CheckBox>
<CheckBox IsEnabled="{Binding DirtyChecked}">
<TextBlock Text="Filesystem has not been unmounted correctly or contains errors" />
</CheckBox>
<TextBlock Text="Details" IsVisible="{Binding !!InformationText}" />
<TextBox Text="{Binding InformationText}" IsReadOnly="True" />
</StackPanel>
</UserControl>

View File

@@ -0,0 +1,12 @@
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace Aaru.Gui.Panels
{
public class FileSystemPanel : UserControl
{
public FileSystemPanel() => InitializeComponent();
void InitializeComponent() => AvaloniaXamlLoader.Load(this);
}
}

View File

@@ -1,58 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?><!--
// /***************************************************************************
// The Disc Image Chef
// ============================================================================
//
// Filename : pnlFilesystemInfo.xeto
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Filesystem information panel.
//
// ==[ Description ] ==========================================================
//
// Defines the structure for the filesystem information panel.
//
// ==[ License ] ==============================================================
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General public License for more details.
//
// You should have received a copy of the GNU General public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// ============================================================================
// Copyright © 2011-2020 Natalia Portillo
// ****************************************************************************/
-->
<Panel xmlns="http://schema.picoe.ca/eto.forms" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackLayout Orientation="Vertical">
<Label ID="lblType"/>
<Label ID="lblVolumeName"/>
<Label ID="lblSerialNumber"/>
<Label ID="lblApplicationIdentifier"/>
<Label ID="lblSystemIdentifier"/>
<Label ID="lblVolumeSetIdentifier"/>
<Label ID="lblDataPreparerIdentifier"/>
<Label ID="lblPublisherIdentifier"/>
<Label ID="lblCreationDate"/>
<Label ID="lblEffectiveDate"/>
<Label ID="lblModificationDate"/>
<Label ID="lblExpirationDate"/>
<Label ID="lblBackupDate"/>
<Label ID="lblClusters"/>
<Label ID="lblFreeClusters"/>
<Label ID="lblFiles"/>
<CheckBox ID="chkBootable" Enabled="False" Text="Filesystem contains boot code"/>
<CheckBox ID="chkDirty" Enabled="False" Text="Filesystem has not been unmounted correctly or contains errors"/>
<GroupBox ID="grpInformation" Text="Details">
<TextArea ID="txtInformation" ReadOnly="True"/>
</GroupBox>
</StackLayout>
</Panel>

View File

@@ -1,114 +0,0 @@
// /***************************************************************************
// Aaru Data Preservation Suite
// ----------------------------------------------------------------------------
//
// Filename : pnlFilesystem.xeto.cs
// Author(s) : Natalia Portillo claunia@claunia.com>
//
// Component : Filesystem information panel.
//
// --[ Description ] ----------------------------------------------------------
//
// Implements the filesystem information panel.
//
// --[ License ] --------------------------------------------------------------
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General public License for more details.
//
// You should have received a copy of the GNU General public License
// along with this program. If not, see http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2020 Natalia Portillo
// ****************************************************************************/
using Eto.Forms;
using Eto.Serialization.Xaml;
using Schemas;
namespace Aaru.Gui.Panels
{
public class pnlFilesystem : Panel
{
public pnlFilesystem(FileSystemType xmlFsType, string information)
{
XamlReader.Load(this);
lblType.Text = $"Filesystem type: {xmlFsType.Type}";
lblVolumeName.Text = $"Volume name: {xmlFsType.VolumeName}";
lblSerialNumber.Text = $"Serial number: {xmlFsType.VolumeSerial}";
lblApplicationIdentifier.Text = $"Application identifier: {xmlFsType.ApplicationIdentifier}";
lblSystemIdentifier.Text = $"System identifier: {xmlFsType.SystemIdentifier}";
lblVolumeSetIdentifier.Text = $"Volume set identifier: {xmlFsType.VolumeSetIdentifier}";
lblDataPreparerIdentifier.Text = $"Data preparer identifier: {xmlFsType.DataPreparerIdentifier}";
lblPublisherIdentifier.Text = $"Publisher identifier: {xmlFsType.PublisherIdentifier}";
lblCreationDate.Text = $"Volume created on {xmlFsType.CreationDate:F}";
lblEffectiveDate.Text = $"Volume effective from {xmlFsType.EffectiveDate:F}";
lblModificationDate.Text = $"Volume last modified on {xmlFsType.ModificationDate:F}";
lblExpirationDate.Text = $"Volume expired on {xmlFsType.ExpirationDate:F}";
lblBackupDate.Text = $"Volume last backed up on {xmlFsType.BackupDate:F}";
lblClusters.Text =
$"Volume has {xmlFsType.Clusters} clusters of {xmlFsType.ClusterSize} bytes each (total of {xmlFsType.Clusters * xmlFsType.ClusterSize} bytes)";
lblFreeClusters.Text =
$"Volume has {xmlFsType.FreeClusters} {xmlFsType.FreeClusters / xmlFsType.Clusters:P}";
lblFiles.Text = $"Volume contains {xmlFsType.Files} files";
chkBootable.Checked = xmlFsType.Bootable;
chkDirty.Checked = xmlFsType.Dirty;
txtInformation.Text = information;
lblVolumeName.Visible = !string.IsNullOrEmpty(xmlFsType.VolumeName);
lblSerialNumber.Visible = !string.IsNullOrEmpty(xmlFsType.VolumeSerial);
lblApplicationIdentifier.Visible = !string.IsNullOrEmpty(xmlFsType.ApplicationIdentifier);
lblSystemIdentifier.Visible = !string.IsNullOrEmpty(xmlFsType.SystemIdentifier);
lblVolumeSetIdentifier.Visible = !string.IsNullOrEmpty(xmlFsType.VolumeSetIdentifier);
lblDataPreparerIdentifier.Visible = !string.IsNullOrEmpty(xmlFsType.DataPreparerIdentifier);
lblPublisherIdentifier.Visible = !string.IsNullOrEmpty(xmlFsType.PublisherIdentifier);
lblCreationDate.Visible = xmlFsType.CreationDateSpecified;
lblEffectiveDate.Visible = xmlFsType.EffectiveDateSpecified;
lblModificationDate.Visible = xmlFsType.ModificationDateSpecified;
lblExpirationDate.Visible = xmlFsType.ExpirationDateSpecified;
lblBackupDate.Visible = xmlFsType.BackupDateSpecified;
lblFreeClusters.Visible = xmlFsType.FreeClustersSpecified;
lblFiles.Visible = xmlFsType.FilesSpecified;
grpInformation.Visible = !string.IsNullOrEmpty(information);
}
#region XAML controls
#pragma warning disable 169
#pragma warning disable 649
Label lblType;
Label lblVolumeName;
Label lblSerialNumber;
Label lblApplicationIdentifier;
Label lblSystemIdentifier;
Label lblVolumeSetIdentifier;
Label lblDataPreparerIdentifier;
Label lblPublisherIdentifier;
Label lblCreationDate;
Label lblEffectiveDate;
Label lblModificationDate;
Label lblExpirationDate;
Label lblBackupDate;
Label lblClusters;
Label lblFreeClusters;
Label lblFiles;
CheckBox chkBootable;
CheckBox chkDirty;
GroupBox grpInformation;
TextArea txtInformation;
#pragma warning restore 169
#pragma warning restore 649
#endregion
}
}

View File

@@ -0,0 +1,70 @@
using Schemas;
namespace Aaru.Gui.ViewModels
{
public class FileSystemViewModel
{
public FileSystemViewModel(FileSystemType xmlFsType, string information)
{
TypeText = $"Filesystem type: {xmlFsType.Type}";
VolumeNameText = $"Volume name: {xmlFsType.VolumeName}";
SerialNumberText = $"Serial number: {xmlFsType.VolumeSerial}";
ApplicationIdentifierText = $"Application identifier: {xmlFsType.ApplicationIdentifier}";
SystemIdentifierText = $"System identifier: {xmlFsType.SystemIdentifier}";
VolumeSetIdentifierText = $"Volume set identifier: {xmlFsType.VolumeSetIdentifier}";
DataPreparerIdentifierText = $"Data preparer identifier: {xmlFsType.DataPreparerIdentifier}";
PublisherIdentifierText = $"Publisher identifier: {xmlFsType.PublisherIdentifier}";
CreationDateText = $"Volume created on {xmlFsType.CreationDate:F}";
EffectiveDateText = $"Volume effective from {xmlFsType.EffectiveDate:F}";
ModificationDateText = $"Volume last modified on {xmlFsType.ModificationDate:F}";
ExpirationDateText = $"Volume expired on {xmlFsType.ExpirationDate:F}";
BackupDateText = $"Volume last backed up on {xmlFsType.BackupDate:F}";
ClustersText =
$"Volume has {xmlFsType.Clusters} clusters of {xmlFsType.ClusterSize} bytes each (total of {xmlFsType.Clusters * xmlFsType.ClusterSize} bytes)";
FreeClustersText =
$"Volume has {xmlFsType.FreeClusters} clusters free ({xmlFsType.FreeClusters / xmlFsType.Clusters:P})";
FilesText = $"Volume contains {xmlFsType.Files} files";
BootableChecked = xmlFsType.Bootable;
DirtyChecked = xmlFsType.Dirty;
InformationText = information;
CreationDateVisible = xmlFsType.CreationDateSpecified;
EffectiveDateVisible = xmlFsType.EffectiveDateSpecified;
ModificationDateVisible = xmlFsType.ModificationDateSpecified;
ExpirationDateVisible = xmlFsType.ExpirationDateSpecified;
BackupDateVisible = xmlFsType.BackupDateSpecified;
FreeClustersVisible = xmlFsType.FreeClustersSpecified;
FilesVisible = xmlFsType.FilesSpecified;
}
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; }
}
}

View File

@@ -154,6 +154,12 @@ namespace Aaru.Gui.ViewModels
DataContext = partitionModel.ViewModel
};
if(value is FileSystemModel fileSystemModel)
ContentPanel = new FileSystemPanel
{
DataContext = fileSystemModel.ViewModel
};
this.RaiseAndSetIfChanged(ref _treeViewSelectedItem, value);
}
}
@@ -464,7 +470,8 @@ namespace Aaru.Gui.ViewModels
VolumeName =
plugin.XmlFsType.VolumeName is null ? $"{plugin.XmlFsType.Type}"
: $"{plugin.XmlFsType.VolumeName} ({plugin.XmlFsType.Type})",
Filesystem = plugin, ReadOnlyFilesystem = fsPlugin
Filesystem = plugin, ReadOnlyFilesystem = fsPlugin,
ViewModel = new FileSystemViewModel(plugin.XmlFsType, information)
};
/* TODO: Trap expanding item
@@ -520,7 +527,8 @@ namespace Aaru.Gui.ViewModels
{
VolumeName = plugin.XmlFsType.VolumeName is null ? $"{plugin.XmlFsType.Type}"
: $"{plugin.XmlFsType.VolumeName} ({plugin.XmlFsType.Type})",
Filesystem = plugin, ReadOnlyFilesystem = fsPlugin
Filesystem = plugin, ReadOnlyFilesystem = fsPlugin,
ViewModel = new FileSystemViewModel(plugin.XmlFsType, information)
};
/* TODO: Trap expanding item