- add channel number

master
Simon G 5 years ago
parent b8d68a5bc0
commit 8f90b394a7
  1. 8
      Lib.Audio/Channel.cs
  2. 2
      Lib.Audio/Factories/IChannelFactory.cs
  3. 4
      Mystify/App.axaml.cs
  4. 36
      Mystify/ViewModels/MainWindowViewModel.cs
  5. 20
      Mystify/Views/MainWindow.axaml

@ -13,11 +13,15 @@ namespace Lib.Audio
{ {
public class Channel : IChannel public class Channel : IChannel
{ {
public Channel(IDeviceButtonConfiguration buttonConfiguration, private readonly uint _channelNumber;
public Channel(uint channelNumber,
IDeviceButtonConfiguration buttonConfiguration,
IFaderFactory faderFactory, IFaderFactory faderFactory,
IKnobFactory knobFactory, IKnobFactory knobFactory,
IButtonFactory buttonFactory) IButtonFactory buttonFactory)
{ {
_channelNumber = channelNumber;
Fader = faderFactory.Create(); Fader = faderFactory.Create();
Knob = knobFactory.Create(); Knob = knobFactory.Create();
Buttons = InitializeButtons(buttonConfiguration, buttonFactory); Buttons = InitializeButtons(buttonConfiguration, buttonFactory);
@ -43,5 +47,7 @@ namespace Lib.Audio
} }
private void OnFaderPositionChanged(object? sender, float position) => Controllable?.SetVolume(position); private void OnFaderPositionChanged(object? sender, float position) => Controllable?.SetVolume(position);
public override string ToString() => $"Channel {_channelNumber}";
} }
} }

@ -8,6 +8,6 @@ namespace Lib.Audio.Factories
{ {
public interface IChannelFactory public interface IChannelFactory
{ {
IChannel Create(IDeviceButtonConfiguration deviceButtonConfiguration); IChannel Create(uint channelNumber, IDeviceButtonConfiguration deviceButtonConfiguration);
} }
} }

@ -7,6 +7,7 @@ using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
using Lib.Audio.Factories;
using Lib.NotifyIcon; using Lib.NotifyIcon;
using LightweightIocContainer.Interfaces; using LightweightIocContainer.Interfaces;
using Mystify.ViewModels; using Mystify.ViewModels;
@ -30,9 +31,10 @@ namespace Mystify
Bootstrapper bootstrapper = new(); Bootstrapper bootstrapper = new();
_kernel = bootstrapper.BootstrapKernel(); _kernel = bootstrapper.BootstrapKernel();
//FixMe
_mainWindow = new MainWindow _mainWindow = new MainWindow
{ {
DataContext = new MainWindowViewModel() DataContext = new MainWindowViewModel(_kernel.Resolve<IDeviceFactory>(), _kernel.Resolve<IControllableCollectorFactory>())
}; };
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktopStyleApplicationLifetime) if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktopStyleApplicationLifetime)

@ -2,10 +2,46 @@
// Created: 2021-04-06 // Created: 2021-04-06
// Copyright(c) 2021 SimonG. All Rights Reserved. // Copyright(c) 2021 SimonG. All Rights Reserved.
using System;
using System.Collections.Generic;
using System.Windows.Input;
using Lib.Audio.Factories;
using Lib.Audio.Interfaces;
using ReactiveUI;
namespace Mystify.ViewModels namespace Mystify.ViewModels
{ {
public class MainWindowViewModel : ViewModelBase public class MainWindowViewModel : ViewModelBase
{ {
public MainWindowViewModel()
{
if (!IsInDesignMode)
throw new InvalidOperationException("Constructor is for design time usage only.");
Channels = new List<IChannel>();
Controllables = new List<IControllable>();
}
public MainWindowViewModel(IDeviceFactory deviceFactory, IControllableCollectorFactory controllableCollectorFactory)
{
IDevice device = deviceFactory.Create();
IControllableCollector controllableCollector = controllableCollectorFactory.Create();
Channels = device.Channels;
Controllables = controllableCollector.Controllables;
}
public List<IChannel> Channels { get; }
public List<IControllable> Controllables { get; }
public IChannel? SelectedChannel { get; set; }
public IControllable? SelectedControllable { get; set; }
public ICommand AllocateControllableCommand =>
ReactiveCommand.Create(() =>
{
if (SelectedControllable != null)
SelectedChannel?.AllocateControllable(SelectedControllable);
});
} }
} }

@ -7,12 +7,28 @@
x:Class="Mystify.Views.MainWindow" x:Class="Mystify.Views.MainWindow"
Icon="/Resources/TestIcon.ico" Icon="/Resources/TestIcon.ico"
Title="Mystify" Title="Mystify"
Background="#FFFFFFFF"> Background="#FF3F3F3F"
Foreground="#FFF0F0F0">
<Design.DataContext> <Design.DataContext>
<vm:MainWindowViewModel/> <vm:MainWindowViewModel/>
</Design.DataContext> </Design.DataContext>
<TextBlock Text=""/> <StackPanel>
<StackPanel Orientation="Horizontal" Margin="10">
<TextBlock Text="Select Channel:" Margin="12"/>
<ComboBox Items="{Binding Channels}"
SelectedItem="{Binding SelectedChannel}"
Margin="5"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="10">
<TextBlock Text="Select Controllable:" Margin="12"/>
<ComboBox Items="{Binding Controllables}"
SelectedItem="{Binding SelectedControllable}"
Margin="5"/>
</StackPanel>
<Button Margin="15" Content="Allocate selected Controllable" Command="{Binding AllocateControllableCommand}"/>
</StackPanel>
</Window> </Window>

Loading…
Cancel
Save