Add tree view to main window.

This commit is contained in:
2020-04-11 04:35:38 +01:00
parent f8f334737b
commit 95f30ce5a5
8 changed files with 115 additions and 13 deletions

View File

@@ -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()
{