|
|
|
|
@ -2,8 +2,10 @@ |
|
|
|
|
// Created: 2021-04-14 |
|
|
|
|
// Copyright(c) 2021 SimonG. All Rights Reserved. |
|
|
|
|
|
|
|
|
|
using System.Threading.Tasks; |
|
|
|
|
using System.Windows.Input; |
|
|
|
|
using Lib.Audio.Interfaces; |
|
|
|
|
using Mystify.Views; |
|
|
|
|
using ReactiveUI; |
|
|
|
|
|
|
|
|
|
namespace Mystify.ViewModels |
|
|
|
|
@ -11,24 +13,39 @@ namespace Mystify.ViewModels |
|
|
|
|
public class ChannelViewModel : ViewModelBase |
|
|
|
|
{ |
|
|
|
|
private readonly IChannel _channel; |
|
|
|
|
private readonly MainWindow? _mainWindow; |
|
|
|
|
private readonly MainModel _mainModel; |
|
|
|
|
|
|
|
|
|
public ChannelViewModel(IChannel channel) => _channel = channel; |
|
|
|
|
public ChannelViewModel(IChannel channel, MainWindow? mainWindow, MainModel mainModel) |
|
|
|
|
{ |
|
|
|
|
_channel = channel; |
|
|
|
|
_mainWindow = mainWindow; |
|
|
|
|
_mainModel = mainModel; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public IControllable? Controllable |
|
|
|
|
public ControllableViewModel? Controllable |
|
|
|
|
{ |
|
|
|
|
get => _channel.Controllable; |
|
|
|
|
get => _channel.Controllable == null ? null : new ControllableViewModel(_channel.Controllable); |
|
|
|
|
set |
|
|
|
|
{ |
|
|
|
|
if (value != null) |
|
|
|
|
_channel.MapControllable(value); |
|
|
|
|
_channel.MapControllable(value.Controllable); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public bool IsControllableMapped => Controllable != null; |
|
|
|
|
public bool IsPopupOpen { get; private set; } |
|
|
|
|
|
|
|
|
|
public ICommand SelectControllableCommand => ReactiveCommand.Create(SelectControllable); |
|
|
|
|
public ICommand SelectControllableCommand => ReactiveCommand.CreateFromTask(SelectControllable); |
|
|
|
|
|
|
|
|
|
private async Task SelectControllable() |
|
|
|
|
{ |
|
|
|
|
ControllableSelectionWindow controllableSelectionWindow = |
|
|
|
|
new() |
|
|
|
|
{ |
|
|
|
|
DataContext = new ControllableSelectionViewModel(_mainModel.Controllables) |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
private void SelectControllable() => IsPopupOpen = true; |
|
|
|
|
Controllable = await controllableSelectionWindow.ShowDialog<ControllableViewModel>(_mainWindow); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |