mirror of
https://github.com/aaru-dps/Aaru.git
synced 2026-07-08 18:16:24 +00:00
Add tree view to main window.
This commit is contained in:
5
.idea/.idea.Aaru/.idea/contentModel.xml
generated
5
.idea/.idea.Aaru/.idea/contentModel.xml
generated
@@ -1240,11 +1240,16 @@
|
||||
</e>
|
||||
<e p="Models" t="Include">
|
||||
<e p="AssemblyModel.cs" t="Include" />
|
||||
<e p="DeviceModel.cs" t="Include" />
|
||||
<e p="DevicesRootModel.cs" t="Include" />
|
||||
<e p="DeviceStatsModel.cs" t="Include" />
|
||||
<e p="EncodingModel.cs" t="Include" />
|
||||
<e p="ImageModel.cs" t="Include" />
|
||||
<e p="ImagesRootModel.cs" t="Include" />
|
||||
<e p="MediaStatsModel.cs" t="Include" />
|
||||
<e p="NameCountModel.cs" t="Include" />
|
||||
<e p="PluginModel.cs" t="Include" />
|
||||
<e p="RootModel.cs" t="Include" />
|
||||
</e>
|
||||
<e p="obj" t="ExcludeRecursive">
|
||||
<e p="Debug" t="Include">
|
||||
|
||||
4
Aaru.Gui/Models/DeviceModel.cs
Normal file
4
Aaru.Gui/Models/DeviceModel.cs
Normal file
@@ -0,0 +1,4 @@
|
||||
namespace Aaru.Gui.Models
|
||||
{
|
||||
public class DeviceModel {}
|
||||
}
|
||||
11
Aaru.Gui/Models/DevicesRootModel.cs
Normal file
11
Aaru.Gui/Models/DevicesRootModel.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Aaru.Gui.Models
|
||||
{
|
||||
public class DevicesRootModel : RootModel
|
||||
{
|
||||
public DevicesRootModel() => Devices = new ObservableCollection<DeviceModel>();
|
||||
|
||||
public ObservableCollection<DeviceModel> Devices { get; }
|
||||
}
|
||||
}
|
||||
4
Aaru.Gui/Models/ImageModel.cs
Normal file
4
Aaru.Gui/Models/ImageModel.cs
Normal file
@@ -0,0 +1,4 @@
|
||||
namespace Aaru.Gui.Models
|
||||
{
|
||||
public class ImageModel {}
|
||||
}
|
||||
11
Aaru.Gui/Models/ImagesRootModel.cs
Normal file
11
Aaru.Gui/Models/ImagesRootModel.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Aaru.Gui.Models
|
||||
{
|
||||
public class ImagesRootModel : RootModel
|
||||
{
|
||||
public ImagesRootModel() => Images = new ObservableCollection<ImageModel>();
|
||||
|
||||
public ObservableCollection<ImageModel> Images { get; }
|
||||
}
|
||||
}
|
||||
7
Aaru.Gui/Models/RootModel.cs
Normal file
7
Aaru.Gui/Models/RootModel.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace Aaru.Gui.Models
|
||||
{
|
||||
public class RootModel
|
||||
{
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
using System.Linq;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Reactive;
|
||||
using Aaru.CommonTypes.Interop;
|
||||
using Aaru.Database;
|
||||
using Aaru.Gui.Models;
|
||||
using Aaru.Gui.Views;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
@@ -12,8 +15,11 @@ namespace Aaru.Gui.ViewModels
|
||||
{
|
||||
public class MainWindowViewModel : ViewModelBase
|
||||
{
|
||||
readonly MainWindow _view;
|
||||
ConsoleWindow _consoleWindow;
|
||||
readonly DevicesRootModel _devicesRoot;
|
||||
readonly ImagesRootModel _imagesRoot;
|
||||
readonly MainWindow _view;
|
||||
ConsoleWindow _consoleWindow;
|
||||
bool _devicesSupported;
|
||||
|
||||
public MainWindowViewModel(MainWindow view)
|
||||
{
|
||||
@@ -25,21 +31,51 @@ namespace Aaru.Gui.ViewModels
|
||||
SettingsCommand = ReactiveCommand.Create(ExecuteSettingsCommand);
|
||||
ConsoleCommand = ReactiveCommand.Create(ExecuteConsoleCommand);
|
||||
_view = view;
|
||||
TreeRoot = new ObservableCollection<RootModel>();
|
||||
|
||||
_imagesRoot = new ImagesRootModel
|
||||
{
|
||||
Name = "Images"
|
||||
};
|
||||
|
||||
TreeRoot.Add(_imagesRoot);
|
||||
|
||||
switch(DetectOS.GetRealPlatformID())
|
||||
{
|
||||
case PlatformID.Win32NT:
|
||||
case PlatformID.Linux:
|
||||
case PlatformID.FreeBSD:
|
||||
_devicesRoot = new DevicesRootModel
|
||||
{
|
||||
Name = "Devices"
|
||||
};
|
||||
|
||||
TreeRoot.Add(_devicesRoot);
|
||||
DevicesSupported = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public string Greeting => "Welcome to Aaru!";
|
||||
public bool DevicesSupported
|
||||
{
|
||||
get => _devicesSupported;
|
||||
set => this.RaiseAndSetIfChanged(ref _devicesSupported, value);
|
||||
}
|
||||
|
||||
public bool NativeMenuSupported =>
|
||||
NativeMenu.GetIsNativeMenuExported((Application.Current.ApplicationLifetime as
|
||||
IClassicDesktopStyleApplicationLifetime)?.MainWindow);
|
||||
|
||||
public ReactiveCommand<Unit, Unit> AboutCommand { get; }
|
||||
public ReactiveCommand<Unit, Unit> ConsoleCommand { get; }
|
||||
public ReactiveCommand<Unit, Unit> EncodingsCommand { get; }
|
||||
public ReactiveCommand<Unit, Unit> PluginsCommand { get; }
|
||||
public ReactiveCommand<Unit, Unit> StatisticsCommand { get; }
|
||||
public ReactiveCommand<Unit, Unit> ExitCommand { get; }
|
||||
public ReactiveCommand<Unit, Unit> SettingsCommand { get; }
|
||||
public string Greeting => "Welcome to Aaru!";
|
||||
public ObservableCollection<RootModel> TreeRoot { get; }
|
||||
public ReactiveCommand<Unit, Unit> AboutCommand { get; }
|
||||
public ReactiveCommand<Unit, Unit> ConsoleCommand { get; }
|
||||
public ReactiveCommand<Unit, Unit> EncodingsCommand { get; }
|
||||
public ReactiveCommand<Unit, Unit> PluginsCommand { get; }
|
||||
public ReactiveCommand<Unit, Unit> StatisticsCommand { get; }
|
||||
public ReactiveCommand<Unit, Unit> ExitCommand { get; }
|
||||
public ReactiveCommand<Unit, Unit> SettingsCommand { get; }
|
||||
|
||||
internal void ExecuteAboutCommand()
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<Window xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:models="clr-namespace:Aaru.Gui.Models;assembly=Aaru.Gui"
|
||||
xmlns:vm="clr-namespace:Aaru.Gui.ViewModels;assembly=Aaru.Gui"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignWidth="800"
|
||||
@@ -15,7 +16,7 @@
|
||||
<Separator />
|
||||
<MenuItem Header="E_xit" IsVisible="{Binding !NativeMenuSupported}" Command="{Binding ExitCommand}" />
|
||||
</MenuItem>
|
||||
<MenuItem Header="_Devices">
|
||||
<MenuItem Header="_Devices" IsVisible="{Binding DevicesSupported}">
|
||||
<MenuItem Header="_Refresh" />
|
||||
</MenuItem>
|
||||
<MenuItem Header="_Window">
|
||||
@@ -30,6 +31,29 @@
|
||||
Command="{Binding AboutCommand}" />
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
<TextBlock Text="{Binding Greeting}" HorizontalAlignment="Center" VerticalAlignment="Center" />
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" /><ColumnDefinition Width="5" /><ColumnDefinition Width="6*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TreeView Items="{Binding TreeRoot}">
|
||||
<TreeView.DataTemplates>
|
||||
<TreeDataTemplate DataType="models:DevicesRootModel" ItemsSource="{Binding Devices}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Image Width="24" Height="24" Source="/Assets/Icons/oxygen/32x32/computer.png" />
|
||||
<TextBlock Text="{Binding Name}" />
|
||||
</StackPanel>
|
||||
</TreeDataTemplate>
|
||||
<TreeDataTemplate DataType="models:ImagesRootModel" ItemsSource="{Binding Images}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Image Width="24" Height="24" Source="/Assets/Icons/oxygen/32x32/inode-directory.png" />
|
||||
<TextBlock Text="{Binding Name}" />
|
||||
</StackPanel>
|
||||
</TreeDataTemplate>
|
||||
</TreeView.DataTemplates>
|
||||
</TreeView>
|
||||
<GridSplitter Grid.Column="1" Width="5" HorizontalAlignment="Stretch" />
|
||||
<TextBlock Grid.Column="2" Text="{Binding Greeting}" HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center" />
|
||||
</Grid>
|
||||
</DockPanel>
|
||||
</Window>
|
||||
Reference in New Issue
Block a user