mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Surface editor - Contain devices to the max texture size
Surface editor - Show a bounding box indicating the max texture size
This commit is contained in:
parent
aace06b6cc
commit
dfdc28760e
@ -1,7 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Artemis.Core.DeviceProviders;
|
using Artemis.Core.DeviceProviders;
|
||||||
|
|||||||
@ -63,9 +63,8 @@
|
|||||||
<Border BorderBrush="{DynamicResource MaterialDesignDivider}" BorderThickness="0 0 0 1" Margin="0 10" />
|
<Border BorderBrush="{DynamicResource MaterialDesignDivider}" BorderThickness="0 0 0 1" Margin="0 10" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<materialDesign:Card materialDesign:ShadowAssist.ShadowDepth="Depth1" Grid.Row="1" Grid.Column="0"
|
<materialDesign:Card materialDesign:ShadowAssist.ShadowDepth="Depth1" Grid.Row="1" Grid.Column="0" VerticalAlignment="Stretch" Margin="0,0,5,0">
|
||||||
VerticalAlignment="Stretch" Margin="0,0,5,0">
|
<Grid ClipToBounds="False"
|
||||||
<Grid ClipToBounds="True"
|
|
||||||
Focusable="True"
|
Focusable="True"
|
||||||
FocusVisualStyle="{StaticResource FocusVisual}"
|
FocusVisualStyle="{StaticResource FocusVisual}"
|
||||||
KeyUp="{s:Action EditorGridKeyUp}"
|
KeyUp="{s:Action EditorGridKeyUp}"
|
||||||
@ -188,8 +187,16 @@
|
|||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ItemsControl.ItemTemplate>
|
</ItemsControl.ItemTemplate>
|
||||||
</ItemsControl>
|
</ItemsControl>
|
||||||
|
<Canvas>
|
||||||
|
<Rectangle ClipToBounds="False"
|
||||||
|
Width="{Binding MaxTextureSize}"
|
||||||
|
Height="{Binding MaxTextureSize}"
|
||||||
|
Stroke="{DynamicResource SecondaryHueMidBrush}"
|
||||||
|
StrokeThickness="{Binding MaxTextureSizeIndicatorThickness}"
|
||||||
|
StrokeDashArray="2 2" />
|
||||||
|
</Canvas>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<!-- Multi-selection rectangle -->
|
<!-- Multi-selection rectangle -->
|
||||||
<Path Data="{Binding SelectionRectangle}" Opacity="0"
|
<Path Data="{Binding SelectionRectangle}" Opacity="0"
|
||||||
Stroke="{DynamicResource PrimaryHueLightBrush}"
|
Stroke="{DynamicResource PrimaryHueLightBrush}"
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
@ -106,6 +107,9 @@ namespace Artemis.UI.Screens.SurfaceEditor
|
|||||||
set => SetAndNotify(ref _colorFirstLedOnly, value);
|
set => SetAndNotify(ref _colorFirstLedOnly, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double MaxTextureSize => 4096 / _settingsService.GetSetting("Core.RenderScale", 0.5).Value;
|
||||||
|
public double MaxTextureSizeIndicatorThickness => 2 / PanZoomViewModel.Zoom;
|
||||||
|
|
||||||
public void OpenHyperlink(object sender, RequestNavigateEventArgs e)
|
public void OpenHyperlink(object sender, RequestNavigateEventArgs e)
|
||||||
{
|
{
|
||||||
Core.Utilities.OpenUrl(e.Uri.AbsoluteUri);
|
Core.Utilities.OpenUrl(e.Uri.AbsoluteUri);
|
||||||
@ -155,7 +159,7 @@ namespace Artemis.UI.Screens.SurfaceEditor
|
|||||||
protected override void OnInitialActivate()
|
protected override void OnInitialActivate()
|
||||||
{
|
{
|
||||||
LoadWorkspaceSettings();
|
LoadWorkspaceSettings();
|
||||||
SurfaceDeviceViewModels.AddRange(_rgbService.EnabledDevices.OrderBy(d => d.ZIndex).Select(d => new SurfaceDeviceViewModel(d, _rgbService)));
|
SurfaceDeviceViewModels.AddRange(_rgbService.EnabledDevices.OrderBy(d => d.ZIndex).Select(d => new SurfaceDeviceViewModel(d, _rgbService, _settingsService)));
|
||||||
ListDeviceViewModels.AddRange(_rgbService.EnabledDevices.OrderBy(d => d.ZIndex * -1).Select(d => new ListDeviceViewModel(d, this)));
|
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();
|
List<ArtemisDevice> shuffledDevices = _rgbService.EnabledDevices.OrderBy(d => Guid.NewGuid()).ToList();
|
||||||
@ -168,7 +172,7 @@ namespace Artemis.UI.Screens.SurfaceEditor
|
|||||||
}
|
}
|
||||||
|
|
||||||
_coreService.FrameRendering += CoreServiceOnFrameRendering;
|
_coreService.FrameRendering += CoreServiceOnFrameRendering;
|
||||||
|
PanZoomViewModel.PropertyChanged += PanZoomViewModelOnPropertyChanged;
|
||||||
base.OnInitialActivate();
|
base.OnInitialActivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,10 +183,17 @@ namespace Artemis.UI.Screens.SurfaceEditor
|
|||||||
ListDeviceViewModels.Clear();
|
ListDeviceViewModels.Clear();
|
||||||
|
|
||||||
_coreService.FrameRendering -= CoreServiceOnFrameRendering;
|
_coreService.FrameRendering -= CoreServiceOnFrameRendering;
|
||||||
|
PanZoomViewModel.PropertyChanged -= PanZoomViewModelOnPropertyChanged;
|
||||||
|
|
||||||
base.OnClose();
|
base.OnClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void PanZoomViewModelOnPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.PropertyName == nameof(PanZoomViewModel.Zoom))
|
||||||
|
NotifyOfPropertyChange(nameof(MaxTextureSizeIndicatorThickness));
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Context menu actions
|
#region Context menu actions
|
||||||
|
|||||||
@ -14,15 +14,17 @@ namespace Artemis.UI.Screens.SurfaceEditor.Visualization
|
|||||||
public class SurfaceDeviceViewModel : PropertyChangedBase
|
public class SurfaceDeviceViewModel : PropertyChangedBase
|
||||||
{
|
{
|
||||||
private readonly IRgbService _rgbService;
|
private readonly IRgbService _rgbService;
|
||||||
|
private readonly ISettingsService _settingsService;
|
||||||
private Cursor _cursor;
|
private Cursor _cursor;
|
||||||
private double _dragOffsetX;
|
private double _dragOffsetX;
|
||||||
private double _dragOffsetY;
|
private double _dragOffsetY;
|
||||||
private SelectionStatus _selectionStatus;
|
private SelectionStatus _selectionStatus;
|
||||||
|
|
||||||
public SurfaceDeviceViewModel(ArtemisDevice device, IRgbService rgbService)
|
public SurfaceDeviceViewModel(ArtemisDevice device, IRgbService rgbService, ISettingsService settingsService)
|
||||||
{
|
{
|
||||||
Device = device;
|
Device = device;
|
||||||
_rgbService = rgbService;
|
_rgbService = rgbService;
|
||||||
|
_settingsService = settingsService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArtemisDevice Device { get; }
|
public ArtemisDevice Device { get; }
|
||||||
@ -101,6 +103,10 @@ namespace Artemis.UI.Screens.SurfaceEditor.Visualization
|
|||||||
if (x < 0 || y < 0)
|
if (x < 0 || y < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
double maxTextureSize = 4096 / _settingsService.GetSetting("Core.RenderScale", 0.5).Value;
|
||||||
|
if (x + Device.Rectangle.Width > maxTextureSize || y + Device.Rectangle.Height > maxTextureSize)
|
||||||
|
return false;
|
||||||
|
|
||||||
List<SKRect> own = Device.Leds
|
List<SKRect> own = Device.Leds
|
||||||
.Select(l => SKRect.Create(l.Rectangle.Left + x, l.Rectangle.Top + y, l.Rectangle.Width, l.Rectangle.Height))
|
.Select(l => SKRect.Create(l.Rectangle.Left + x, l.Rectangle.Top + y, l.Rectangle.Width, l.Rectangle.Height))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user