[GUI] Pick tree selected item and show corresponding panel in main window.

This commit is contained in:
2025-10-25 16:04:23 +01:00
parent 1d728abf2b
commit 1e78923eed
3 changed files with 48 additions and 7 deletions

View File

@@ -6,7 +6,6 @@ using System.Linq;
using System.Threading.Tasks;
using System.Windows.Input;
using Aaru.CommonTypes;
using Aaru.CommonTypes.AaruMetadata;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Interop;
@@ -16,6 +15,7 @@ using Aaru.Gui.Models;
using Aaru.Gui.ViewModels.Dialogs;
using Aaru.Gui.ViewModels.Panels;
using Aaru.Gui.Views.Dialogs;
using Aaru.Gui.Views.Panels;
using Aaru.Localization;
using Aaru.Logging;
using Avalonia;
@@ -26,11 +26,14 @@ using Avalonia.Platform;
using Avalonia.Platform.Storage;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using JetBrains.Annotations;
using MsBox.Avalonia;
using MsBox.Avalonia.Base;
using MsBox.Avalonia.Enums;
using Spectre.Console;
using Console = Aaru.Gui.Views.Dialogs.Console;
using FileSystem = Aaru.CommonTypes.AaruMetadata.FileSystem;
using ImageInfo = Aaru.Gui.Views.Panels.ImageInfo;
using Partition = Aaru.CommonTypes.Partition;
using PlatformID = Aaru.CommonTypes.Interop.PlatformID;
@@ -46,6 +49,7 @@ public partial class MainWindowViewModel : ViewModelBase
readonly Window _view;
Console _console;
[ObservableProperty]
[CanBeNull]
object _contentPanel;
[ObservableProperty]
bool _devicesSupported;
@@ -125,7 +129,46 @@ public partial class MainWindowViewModel : ViewModelBase
public object TreeViewSelectedItem
{
get => _treeViewSelectedItem;
set => SetProperty(ref _treeViewSelectedItem, value);
set
{
if(value == _treeViewSelectedItem) return;
SetProperty(ref _treeViewSelectedItem, value);
ContentPanel = null;
switch(value)
{
case ImageModel imageModel:
ContentPanel = new ImageInfo
{
DataContext = imageModel.ViewModel
};
break;
case PartitionModel partitionModel:
ContentPanel = new Aaru.Gui.Views.Panels.Partition
{
DataContext = partitionModel.ViewModel
};
break;
case FileSystemModel fileSystemModel:
ContentPanel = new Aaru.Gui.Views.Panels.FileSystem
{
DataContext = fileSystemModel.ViewModel
};
break;
case SubdirectoryModel subdirectoryModel:
ContentPanel = new Subdirectory
{
DataContext = new SubdirectoryViewModel(subdirectoryModel, _view)
};
break;
}
}
}
async Task OpenAsync()

View File

@@ -52,7 +52,7 @@
</Menu>
<Grid ColumnDefinitions="*,5,4*">
<TreeView ItemsSource="{Binding TreeRoot, Mode=OneWay}"
SelectedItem="{Binding TreeViewSelectedItem, Mode=OneWay}"
SelectedItem="{Binding TreeViewSelectedItem, Mode=TwoWay}"
Background="#111111"
BorderBrush="LightGray"
BorderThickness="1"

View File

@@ -1,7 +1,4 @@
<wpf:ResourceDictionary xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="clr-namespace:System;assembly=mscorlib"
xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xml:space="preserve">
<wpf:ResourceDictionary xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xml:space="preserve">
<s:String x:Key="/Default/CodeInspection/CppInitialization/DefaultPointerInitializer/@EntryValue">Null</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=858398D1_002D7321_002D4763_002D8BAB_002D56BBFEC74E29_002Fd_003Acuetools_002Enet/@EntryIndexedValue">ExplicitlyExcluded</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=AnnotateCanBeNullTypeMember/@EntryIndexedValue"></s:String>
@@ -1386,6 +1383,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=MODEPAGE/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=modesense/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=mountpt/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=msbox/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=msdos/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=msos/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=mspw/@EntryIndexedValue">True</s:Boolean>