mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 20:06:33 +00:00
Project cleanup
This commit is contained in:
1 parent
73115898de
commit
6f95c609b6
51 files changed
+440
-490
No files matched your search
+12
-12
@@ -44,6 +44,18 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
? new Rect()
|
||||
: new Rect(X, Y, Device.RgbDevice.Size.Width, Device.RgbDevice.Size.Height);
|
||||
|
||||
/// <summary>
|
||||
/// Update the color of all LEDs if finished adding
|
||||
/// </summary>
|
||||
public void Update()
|
||||
{
|
||||
if (!AddedLeds)
|
||||
return;
|
||||
|
||||
foreach (var ledViewModel in Leds)
|
||||
ledViewModel.Update();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds LEDs in batches of 5 to avoid UI freezes
|
||||
/// </summary>
|
||||
@@ -62,17 +74,5 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
|
||||
AddedLeds = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the color of all LEDs if finished adding
|
||||
/// </summary>
|
||||
public void Update()
|
||||
{
|
||||
if (!AddedLeds)
|
||||
return;
|
||||
|
||||
foreach (var ledViewModel in Leds)
|
||||
ledViewModel.Update();
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
-10
@@ -30,7 +30,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
_profileEditorService.SelectedProfileElementUpdated += OnSelectedProfileElementUpdated;
|
||||
_profileEditorService.ProfilePreviewUpdated += ProfileEditorServiceOnProfilePreviewUpdated;
|
||||
}
|
||||
|
||||
|
||||
public Layer Layer { get; }
|
||||
|
||||
public Geometry LayerGeometry { get; set; }
|
||||
@@ -39,6 +39,14 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
public Rect ViewportRectangle { get; set; }
|
||||
public bool IsSelected { get; set; }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Layer.RenderPropertiesUpdated -= LayerOnRenderPropertiesUpdated;
|
||||
_profileEditorService.SelectedProfileElementChanged -= OnSelectedProfileElementChanged;
|
||||
_profileEditorService.SelectedProfileElementUpdated -= OnSelectedProfileElementUpdated;
|
||||
_profileEditorService.ProfilePreviewUpdated -= ProfileEditorServiceOnProfilePreviewUpdated;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
IsSelected = _profileEditorService.SelectedProfileElement == Layer;
|
||||
@@ -86,7 +94,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
|
||||
var layerGeometry = group.GetOutlinedPathGeometry();
|
||||
var opacityGeometry = Geometry.Combine(Geometry.Empty, layerGeometry, GeometryCombineMode.Exclude, new TranslateTransform());
|
||||
|
||||
|
||||
LayerGeometry = layerGeometry;
|
||||
OpacityGeometry = opacityGeometry;
|
||||
}
|
||||
@@ -171,14 +179,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Layer.RenderPropertiesUpdated -= LayerOnRenderPropertiesUpdated;
|
||||
_profileEditorService.SelectedProfileElementChanged -= OnSelectedProfileElementChanged;
|
||||
_profileEditorService.SelectedProfileElementUpdated -= OnSelectedProfileElementUpdated;
|
||||
_profileEditorService.ProfilePreviewUpdated -= ProfileEditorServiceOnProfilePreviewUpdated;
|
||||
}
|
||||
|
||||
#region Event handlers
|
||||
|
||||
private void LayerOnRenderPropertiesUpdated(object sender, EventArgs e)
|
||||
|
||||
@@ -38,6 +38,16 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
public Geometry StrokeGeometry { get; private set; }
|
||||
public Color DisplayColor { get; private set; }
|
||||
|
||||
public void Update()
|
||||
{
|
||||
var newColor = Led.RgbLed.Color.ToMediaColor();
|
||||
Execute.PostToUIThread(() =>
|
||||
{
|
||||
if (!DisplayColor.Equals(newColor))
|
||||
DisplayColor = newColor;
|
||||
});
|
||||
}
|
||||
|
||||
private void CreateLedGeometry()
|
||||
{
|
||||
switch (Led.RgbLed.Shape)
|
||||
@@ -105,15 +115,5 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
CreateRectangleGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
var newColor = Led.RgbLed.Color.ToMediaColor();
|
||||
Execute.PostToUIThread(() =>
|
||||
{
|
||||
if (!DisplayColor.Equals(newColor))
|
||||
DisplayColor = newColor;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -114,6 +114,34 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnActivate()
|
||||
{
|
||||
HighlightSelectedLayer = _settingsService.GetSetting("ProfileEditor.HighlightSelectedLayer", true);
|
||||
PauseRenderingOnFocusLoss = _settingsService.GetSetting("ProfileEditor.PauseRenderingOnFocusLoss", true);
|
||||
|
||||
HighlightSelectedLayer.SettingChanged += HighlightSelectedLayerOnSettingChanged;
|
||||
|
||||
_updateTrigger.Start();
|
||||
base.OnActivate();
|
||||
}
|
||||
|
||||
protected override void OnDeactivate()
|
||||
{
|
||||
HighlightSelectedLayer.Save();
|
||||
PauseRenderingOnFocusLoss.Save();
|
||||
|
||||
try
|
||||
{
|
||||
_updateTrigger.Stop();
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
// TODO: Remove when fixed in RGB.NET, or avoid double stopping
|
||||
}
|
||||
|
||||
base.OnDeactivate();
|
||||
}
|
||||
|
||||
private void CreateUpdateTrigger()
|
||||
{
|
||||
// Borrow RGB.NET's update trigger but limit the FPS
|
||||
@@ -217,34 +245,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnActivate()
|
||||
{
|
||||
HighlightSelectedLayer = _settingsService.GetSetting("ProfileEditor.HighlightSelectedLayer", true);
|
||||
PauseRenderingOnFocusLoss = _settingsService.GetSetting("ProfileEditor.PauseRenderingOnFocusLoss", true);
|
||||
|
||||
HighlightSelectedLayer.SettingChanged += HighlightSelectedLayerOnSettingChanged;
|
||||
|
||||
_updateTrigger.Start();
|
||||
base.OnActivate();
|
||||
}
|
||||
|
||||
protected override void OnDeactivate()
|
||||
{
|
||||
HighlightSelectedLayer.Save();
|
||||
PauseRenderingOnFocusLoss.Save();
|
||||
|
||||
try
|
||||
{
|
||||
_updateTrigger.Stop();
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
// TODO: Remove when fixed in RGB.NET, or avoid double stopping
|
||||
}
|
||||
|
||||
base.OnDeactivate();
|
||||
}
|
||||
|
||||
#region Buttons
|
||||
|
||||
private void ActivateToolByIndex(int value)
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Models.Profile.LayerProperties;
|
||||
using Artemis.UI.Events;
|
||||
using Artemis.UI.Services.Interfaces;
|
||||
using SkiaSharp;
|
||||
|
||||
+28
-28
@@ -56,6 +56,34 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.UserControls
|
||||
set => SetValue(ShapeGeometryProperty, value);
|
||||
}
|
||||
|
||||
public void UpdateDimensions()
|
||||
{
|
||||
if (Zoom == 0)
|
||||
return;
|
||||
|
||||
// Rotation controls
|
||||
UpdateRotateDimensions(RotateTopLeft);
|
||||
UpdateRotateDimensions(RotateTopRight);
|
||||
UpdateRotateDimensions(RotateBottomRight);
|
||||
UpdateRotateDimensions(RotateBottomLeft);
|
||||
|
||||
// Size controls
|
||||
UpdateResizeDimensions(ResizeTopCenter);
|
||||
UpdateResizeDimensions(ResizeRightCenter);
|
||||
UpdateResizeDimensions(ResizeBottomCenter);
|
||||
UpdateResizeDimensions(ResizeLeftCenter);
|
||||
UpdateResizeDimensions(ResizeTopLeft);
|
||||
UpdateResizeDimensions(ResizeTopRight);
|
||||
UpdateResizeDimensions(ResizeBottomRight);
|
||||
UpdateResizeDimensions(ResizeBottomLeft);
|
||||
|
||||
// Anchor point
|
||||
UpdateResizeDimensions(AnchorPoint);
|
||||
|
||||
// Layer outline
|
||||
LayerShapeOutline.StrokeThickness = Math.Max(2 / Zoom, 1);
|
||||
}
|
||||
|
||||
private static void ZoomChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var layerShapeControl = (LayerShapeControl) d;
|
||||
@@ -88,34 +116,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.UserControls
|
||||
layerShapeControl.UpdateShapeGeometry();
|
||||
}
|
||||
|
||||
public void UpdateDimensions()
|
||||
{
|
||||
if (Zoom == 0)
|
||||
return;
|
||||
|
||||
// Rotation controls
|
||||
UpdateRotateDimensions(RotateTopLeft);
|
||||
UpdateRotateDimensions(RotateTopRight);
|
||||
UpdateRotateDimensions(RotateBottomRight);
|
||||
UpdateRotateDimensions(RotateBottomLeft);
|
||||
|
||||
// Size controls
|
||||
UpdateResizeDimensions(ResizeTopCenter);
|
||||
UpdateResizeDimensions(ResizeRightCenter);
|
||||
UpdateResizeDimensions(ResizeBottomCenter);
|
||||
UpdateResizeDimensions(ResizeLeftCenter);
|
||||
UpdateResizeDimensions(ResizeTopLeft);
|
||||
UpdateResizeDimensions(ResizeTopRight);
|
||||
UpdateResizeDimensions(ResizeBottomRight);
|
||||
UpdateResizeDimensions(ResizeBottomLeft);
|
||||
|
||||
// Anchor point
|
||||
UpdateResizeDimensions(AnchorPoint);
|
||||
|
||||
// Layer outline
|
||||
LayerShapeOutline.StrokeThickness = Math.Max(2 / Zoom, 1);
|
||||
}
|
||||
|
||||
private void UpdateShapeGeometry()
|
||||
{
|
||||
LayerShapeOutline.Data = ShapeGeometry;
|
||||
|
||||
Reference in new issue
Block a user