|
|
|
@ -5,7 +5,10 @@ |
|
|
|
using System; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Windows.Input; |
|
|
|
using System.Windows.Input; |
|
|
|
|
|
|
|
using Avalonia.Controls; |
|
|
|
using Lib.Audio.Interfaces; |
|
|
|
using Lib.Audio.Interfaces; |
|
|
|
|
|
|
|
using Lib.Driver; |
|
|
|
|
|
|
|
using Mystify.Views; |
|
|
|
using ReactiveUI; |
|
|
|
using ReactiveUI; |
|
|
|
|
|
|
|
|
|
|
|
namespace Mystify.ViewModels |
|
|
|
namespace Mystify.ViewModels |
|
|
|
@ -13,6 +16,7 @@ namespace Mystify.ViewModels |
|
|
|
public class MainWindowViewModel : ViewModelBase |
|
|
|
public class MainWindowViewModel : ViewModelBase |
|
|
|
{ |
|
|
|
{ |
|
|
|
private readonly MainModel? _mainModel; |
|
|
|
private readonly MainModel? _mainModel; |
|
|
|
|
|
|
|
private readonly MainWindow? _mainWindow; |
|
|
|
|
|
|
|
|
|
|
|
public MainWindowViewModel() |
|
|
|
public MainWindowViewModel() |
|
|
|
{ |
|
|
|
{ |
|
|
|
@ -20,7 +24,11 @@ namespace Mystify.ViewModels |
|
|
|
throw new InvalidOperationException("Constructor is for design time usage only."); |
|
|
|
throw new InvalidOperationException("Constructor is for design time usage only."); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public MainWindowViewModel(MainModel mainModel) => _mainModel = mainModel; |
|
|
|
public MainWindowViewModel(MainModel mainModel, MainWindow? mainWindow) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
_mainModel = mainModel; |
|
|
|
|
|
|
|
_mainWindow = mainWindow; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public List<IChannel>? Channels => _mainModel?.Channels; |
|
|
|
public List<IChannel>? Channels => _mainModel?.Channels; |
|
|
|
public List<IControllable>? Controllables => _mainModel?.Controllables; |
|
|
|
public List<IControllable>? Controllables => _mainModel?.Controllables; |
|
|
|
@ -28,6 +36,19 @@ namespace Mystify.ViewModels |
|
|
|
public IChannel? SelectedChannel { get; set; } |
|
|
|
public IChannel? SelectedChannel { get; set; } |
|
|
|
public IControllable? SelectedControllable { get; set; } |
|
|
|
public IControllable? SelectedControllable { get; set; } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public string SelectedDeviceText => $"Selected Device: {_mainModel?.DeviceName ?? "-"}"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ICommand SelectDriverCommand => ReactiveCommand.CreateFromTask(async () => |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
OpenFileDialog openFileDialog = new() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Filters = new List<FileDialogFilter> {new() {Extensions = new List<string> {DriverLoader.DRIVER_FILE_EXTENSION}, Name = "Mystify Driver"}} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await openFileDialog.ShowAsync(_mainWindow); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_mainModel?.LoadDriverAndDevice(openFileDialog.Directory); |
|
|
|
|
|
|
|
}); |
|
|
|
public ICommand AllocateControllableCommand => |
|
|
|
public ICommand AllocateControllableCommand => |
|
|
|
ReactiveCommand.Create(() => |
|
|
|
ReactiveCommand.Create(() => |
|
|
|
{ |
|
|
|
{ |
|
|
|
|