mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
UI - Replaced tuples with custom classes for binding
As far as i know, it's not possible to have CompiledBindings with tuples, since tuple values are fields and not properties. This change allows for compiled bindings, and makes the intent behind the tuples clearer
This commit is contained in:
1 parent
59f9479d9a
commit
5429346396
9 files changed
+120
-45
No files matched your search
@@ -48,8 +48,8 @@
|
||||
AutoGenerateColumns="False"
|
||||
Margin="10">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Binding="{Binding [0].RgbLed.Id}" Header="Original LED ID" Width="*" />
|
||||
<DataGridTextColumn Binding="{Binding [1].RgbLed.Id}" Header="Remapped LED ID" Width="*" />
|
||||
<DataGridTextColumn Binding="{CompiledBinding Path=Original.RgbLed.Id}" Header="Original LED ID" Width="*" />
|
||||
<DataGridTextColumn Binding="{CompiledBinding Path=Replacement.RgbLed.Id}" Header="Remapped LED ID" Width="*" />
|
||||
|
||||
<DataGridTemplateColumn Width="Auto" IsReadOnly="True">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using System.Reactive.Disposables;
|
||||
@@ -31,8 +31,8 @@ public class InputMappingsTabViewModel : ActivatableViewModelBase
|
||||
|
||||
Device = device;
|
||||
DisplayName = "Input Mappings";
|
||||
InputMappings = new ObservableCollection<(ArtemisLed, ArtemisLed)>();
|
||||
DeleteMapping = ReactiveCommand.Create<(ArtemisLed, ArtemisLed)>(ExecuteDeleteMapping);
|
||||
InputMappings = new ObservableCollection<ArtemisInputMapping>();
|
||||
DeleteMapping = ReactiveCommand.Create<ArtemisInputMapping>(ExecuteDeleteMapping);
|
||||
|
||||
this.WhenActivated(d =>
|
||||
{
|
||||
@@ -48,7 +48,7 @@ public class InputMappingsTabViewModel : ActivatableViewModelBase
|
||||
});
|
||||
}
|
||||
|
||||
public ReactiveCommand<(ArtemisLed, ArtemisLed), Unit> DeleteMapping { get; }
|
||||
public ReactiveCommand<ArtemisInputMapping, Unit> DeleteMapping { get; }
|
||||
|
||||
public ArtemisDevice Device { get; }
|
||||
|
||||
@@ -58,11 +58,11 @@ public class InputMappingsTabViewModel : ActivatableViewModelBase
|
||||
set => RaiseAndSetIfChanged(ref _selectedLed, value);
|
||||
}
|
||||
|
||||
public ObservableCollection<(ArtemisLed, ArtemisLed)> InputMappings { get; }
|
||||
public ObservableCollection<ArtemisInputMapping> InputMappings { get; }
|
||||
|
||||
private void ExecuteDeleteMapping((ArtemisLed, ArtemisLed) inputMapping)
|
||||
private void ExecuteDeleteMapping(ArtemisInputMapping inputMapping)
|
||||
{
|
||||
Device.InputMappings.Remove(inputMapping.Item1);
|
||||
Device.InputMappings.Remove(inputMapping.Original);
|
||||
UpdateInputMappings();
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ public class InputMappingsTabViewModel : ActivatableViewModelBase
|
||||
if (InputMappings.Any())
|
||||
InputMappings.Clear();
|
||||
|
||||
foreach ((ArtemisLed, ArtemisLed) tuple in Device.InputMappings.Select(m => (m.Key, m.Value)))
|
||||
foreach (ArtemisInputMapping tuple in Device.InputMappings.Select(m => new ArtemisInputMapping(m.Key, m.Value)))
|
||||
InputMappings.Add(tuple);
|
||||
}
|
||||
|
||||
@@ -100,4 +100,29 @@ public class InputMappingsTabViewModel : ActivatableViewModelBase
|
||||
{
|
||||
SelectedLed = _selectedLeds.FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a pair of LEDs, the original and the replacement
|
||||
/// </summary>
|
||||
public class ArtemisInputMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="ArtemisInputMapping" /> class
|
||||
/// </summary>
|
||||
public ArtemisInputMapping(ArtemisLed original, ArtemisLed replacement)
|
||||
{
|
||||
Original = original;
|
||||
Replacement = replacement;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The original LED
|
||||
/// </summary>
|
||||
public ArtemisLed Original { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The replacement LED
|
||||
/// </summary>
|
||||
public ArtemisLed Replacement { get; set; }
|
||||
}
|
||||
@@ -15,7 +15,7 @@
|
||||
BorderBrush="{DynamicResource ButtonBorderBrush}"
|
||||
BorderThickness="0,0,0,1"
|
||||
Height="29">
|
||||
<Grid Margin="{Binding Converter={StaticResource PropertyTreeMarginConverter}}" ColumnDefinitions="Auto,*,Auto,Auto,Auto">
|
||||
<Grid Margin="{CompiledBinding Converter={StaticResource PropertyTreeMarginConverter}}" ColumnDefinitions="Auto,*,Auto,Auto,Auto">
|
||||
<ToggleButton Grid.Column="0"
|
||||
Classes="icon-button"
|
||||
ToolTip.Tip="Toggle key-framing"
|
||||
|
||||
@@ -10,7 +10,7 @@ public partial class InputPinView : PinView
|
||||
public InputPinView()
|
||||
{
|
||||
InitializeComponent();
|
||||
InitializePin(this.Get<Border>("PinPoint"));
|
||||
InitializePin(PinPoint);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ public partial class OutputPinView : PinView
|
||||
public OutputPinView()
|
||||
{
|
||||
InitializeComponent();
|
||||
InitializePin(this.Get<Border>("PinPoint"));
|
||||
InitializePin(PinPoint);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user