Device debugger - Redesigned window

Surface editor - Added option to disable color overlay
This commit is contained in:
Robert committed 2021-02-23 23:40:30 +01:00
1 parent 7f30950af1
commit b4ab8f6969
13 files changed
+465 -330

No files matched your search

@@ -201,6 +201,18 @@
</Path.Fill>
</Path>
<StackPanel ZIndex="1" VerticalAlignment="Bottom" HorizontalAlignment="Left" Margin="10" Cursor="Arrow">
<materialDesign:Card Padding="8">
<StackPanel Orientation="Horizontal">
<CheckBox Style="{StaticResource MaterialDesignCheckBox}"
IsChecked="{Binding ColorDevices}"
ToolTip="If selected, each device is completely lid up with a random color">
Show random device colors
</CheckBox>
</StackPanel>
</materialDesign:Card>
</StackPanel>
<StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Right" Margin="0, 0, 15, 15">
<Button Command="{s:Action AutoArrange}"
Style="{StaticResource MaterialDesignFloatingActionMiniButton}"
@@ -45,6 +45,7 @@ namespace Artemis.UI.Screens.SurfaceEditor
SelectionRectangle = new RectangleGeometry();
PanZoomViewModel = new PanZoomViewModel();
Cursor = null;
ColorDevices = true;
SurfaceDeviceViewModels = new BindableCollection<SurfaceDeviceViewModel>();
ListDeviceViewModels = new BindableCollection<ListDeviceViewModel>();
@@ -84,6 +85,12 @@ namespace Artemis.UI.Screens.SurfaceEditor
set => SetAndNotify(ref _cursor, value);
}
public bool ColorDevices
{
get => _colorDevices;
set => SetAndNotify(ref _colorDevices, value);
}
public void OpenHyperlink(object sender, RequestNavigateEventArgs e)
{
Core.Utilities.OpenUrl(e.Uri.AbsoluteUri);
@@ -111,9 +118,14 @@ namespace Artemis.UI.Screens.SurfaceEditor
private void CoreServiceOnFrameRendering(object sender, FrameRenderingEventArgs e)
{
if (!ColorDevices)
return;
foreach (ListDeviceViewModel listDeviceViewModel in ListDeviceViewModels)
foreach (ArtemisLed artemisLed in listDeviceViewModel.Device.Leds)
e.Canvas.DrawRect(artemisLed.AbsoluteRectangle, new SKPaint {Color = listDeviceViewModel.Color});
{
foreach (ArtemisLed artemisLed in listDeviceViewModel.Device.Leds)
e.Canvas.DrawRect(artemisLed.AbsoluteRectangle, new SKPaint {Color = listDeviceViewModel.Color});
}
}
#region Overrides of Screen
@@ -122,7 +134,7 @@ namespace Artemis.UI.Screens.SurfaceEditor
{
LoadWorkspaceSettings();
SurfaceDeviceViewModels.AddRange(_rgbService.EnabledDevices.OrderBy(d => d.ZIndex).Select(d => new SurfaceDeviceViewModel(d, _rgbService)));
ListDeviceViewModels.AddRange(_rgbService.EnabledDevices.OrderBy(d => d.ZIndex * -1).Select(d => new ListDeviceViewModel(d)));
ListDeviceViewModels.AddRange(_rgbService.EnabledDevices.OrderBy(d => d.ZIndex * -1).Select(d => new ListDeviceViewModel(d, this)));
List<ArtemisDevice> shuffledDevices = _rgbService.EnabledDevices.OrderBy(d => Guid.NewGuid()).ToList();
float amount = 360f / shuffledDevices.Count;
@@ -249,6 +261,7 @@ namespace Artemis.UI.Screens.SurfaceEditor
private MouseDragStatus _mouseDragStatus;
private Point _mouseDragStartPoint;
private bool _colorDevices;
// ReSharper disable once UnusedMember.Global - Called from view
public void EditorGridMouseClick(object sender, MouseButtonEventArgs e)
@@ -5,6 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Artemis.UI.Screens.SurfaceEditor.Visualization"
xmlns:shared="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
xmlns:s="https://github.com/canton7/Stylet"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
d:DataContext="{d:DesignInstance {x:Type local:ListDeviceViewModel}}">
@@ -22,7 +23,12 @@
<TextBlock Text="{Binding Device.RgbDevice.DeviceInfo.Model}" />
<TextBlock Text="{Binding Device.RgbDevice.DeviceInfo.Manufacturer}" Foreground="{DynamicResource MaterialDesignBodyLight}" />
</StackPanel>
<Ellipse Grid.Column="2" Width="20" Height="20" Stroke="{DynamicResource MaterialDesignBody}" StrokeThickness="1">
<Ellipse Grid.Column="2"
Width="20"
Height="20"
Stroke="{DynamicResource MaterialDesignBody}"
StrokeThickness="1"
Visibility="{Binding Parent.ColorDevices, Converter={x:Static s:BoolToVisibilityConverter.Instance}}">
<Ellipse.Fill>
<SolidColorBrush Color="{Binding Color, Converter={StaticResource SKColorToColorConverter}}" />
</Ellipse.Fill>
@@ -6,25 +6,28 @@ namespace Artemis.UI.Screens.SurfaceEditor.Visualization
{
public class ListDeviceViewModel : PropertyChangedBase
{
private bool _isSelected;
private SKColor _color;
public ArtemisDevice Device { get; }
private bool _isSelected;
public ListDeviceViewModel(ArtemisDevice device, SurfaceEditorViewModel surfaceEditorViewModel)
{
Device = device;
Parent = surfaceEditorViewModel;
}
public ArtemisDevice Device { get; }
public SurfaceEditorViewModel Parent { get; }
public bool IsSelected
{
get => _isSelected;
set => SetAndNotify(ref _isSelected, value);
set => SetAndNotify(ref _isSelected, value);
}
public SKColor Color
{
get => _color;
set => SetAndNotify(ref _color, value);
}
public ListDeviceViewModel(ArtemisDevice device)
{
Device = device;
}
}
}
}