1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Fixed a crash when minimizing

Test brush respects opacity setting
This commit is contained in:
Robert 2020-01-23 19:52:15 +01:00
parent 780abf0fcd
commit 4fc0dc12ab
5 changed files with 50 additions and 31 deletions

View File

@ -189,7 +189,7 @@ namespace Artemis.Core.Models.Profile
} }
var shader = SKShader.CreateSweepGradient(new SKPoint(LayerShape.RenderRectangle.MidX, LayerShape.RenderRectangle.MidY), testColors.ToArray()); var shader = SKShader.CreateSweepGradient(new SKPoint(LayerShape.RenderRectangle.MidX, LayerShape.RenderRectangle.MidY), testColors.ToArray());
canvas.DrawPath(LayerShape.RenderPath, new SKPaint {Shader = shader}); canvas.DrawPath(LayerShape.RenderPath, new SKPaint {Shader = shader, Color = new SKColor(0, 0, 0, (byte) (OpacityProperty.CurrentValue * 2.55f)) });
} }
LayerBrush?.Render(canvas); LayerBrush?.Render(canvas);

View File

@ -146,7 +146,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor
protected override void OnActivate() protected override void OnActivate()
{ {
LoadWorkspaceSettings(); LoadWorkspaceSettings();
Task.Run(() => LoadProfiles()); Task.Run(LoadProfiles);
base.OnActivate(); base.OnActivate();
} }
@ -184,15 +184,17 @@ namespace Artemis.UI.Screens.Module.ProfileEditor
profiles.Add(activeProfile); profiles.Add(activeProfile);
// Populate the UI collection // Populate the UI collection
Profiles.Clear(); Execute.PostToUIThread(() =>
Profiles.AddRange(profiles.OrderBy(p => p.Name)); {
Profiles.Clear();
Profiles.AddRange(profiles.OrderBy(p => p.Name));
SelectedProfile = activeProfile;
SelectedProfile = activeProfile; _profileEditorService.ChangeSelectedProfile(SelectedProfile);
if (!activeProfile.IsActivated)
_profileService.ActivateProfile(Module, activeProfile);
});
_profileEditorService.ChangeSelectedProfile(SelectedProfile);
if (!activeProfile.IsActivated)
_profileService.ActivateProfile(Module, activeProfile);
} }
} }
} }

View File

@ -28,76 +28,89 @@
Margin="{Binding ControlOffset}" Margin="{Binding ControlOffset}"
Canvas.Left="{Binding TopCenter.X}" Canvas.Left="{Binding TopCenter.X}"
Canvas.Top="{Binding TopCenter.Y}" Canvas.Top="{Binding TopCenter.Y}"
Fill="{DynamicResource SecondaryAccentBrush}" Fill="White"
Stroke="{DynamicResource SecondaryAccentBrush}"
StrokeThickness="0.5"
MouseDown="{s:Action ShapeEditMouseDown}" MouseUp="{s:Action ShapeEditMouseUp}" MouseMove="{s:Action TopCenterResize}" /> MouseDown="{s:Action ShapeEditMouseDown}" MouseUp="{s:Action ShapeEditMouseUp}" MouseMove="{s:Action TopCenterResize}" />
<Rectangle Width="{Binding ControlSize}" <Rectangle Width="{Binding ControlSize}"
Height="{Binding ControlSize}" Height="{Binding ControlSize}"
Margin="{Binding ControlOffset}" Margin="{Binding ControlOffset}"
Canvas.Left="{Binding RightCenter.X}" Canvas.Left="{Binding RightCenter.X}"
Canvas.Top="{Binding RightCenter.Y}" Canvas.Top="{Binding RightCenter.Y}"
Fill="{DynamicResource SecondaryAccentBrush}" Fill="White"
Stroke="{DynamicResource SecondaryAccentBrush}"
StrokeThickness="0.5"
MouseDown="{s:Action ShapeEditMouseDown}" MouseUp="{s:Action ShapeEditMouseUp}" MouseMove="{s:Action RightCenterResize}" /> MouseDown="{s:Action ShapeEditMouseDown}" MouseUp="{s:Action ShapeEditMouseUp}" MouseMove="{s:Action RightCenterResize}" />
<Rectangle Width="{Binding ControlSize}" <Rectangle Width="{Binding ControlSize}"
Height="{Binding ControlSize}" Height="{Binding ControlSize}"
Margin="{Binding ControlOffset}" Margin="{Binding ControlOffset}"
Canvas.Left="{Binding BottomCenter.X}" Canvas.Left="{Binding BottomCenter.X}"
Canvas.Top="{Binding BottomCenter.Y}" Canvas.Top="{Binding BottomCenter.Y}"
Fill="{DynamicResource SecondaryAccentBrush}" Fill="White"
Stroke="{DynamicResource SecondaryAccentBrush}"
StrokeThickness="0.5"
MouseDown="{s:Action ShapeEditMouseDown}" MouseUp="{s:Action ShapeEditMouseUp}" MouseMove="{s:Action BottomCenterResize}" /> MouseDown="{s:Action ShapeEditMouseDown}" MouseUp="{s:Action ShapeEditMouseUp}" MouseMove="{s:Action BottomCenterResize}" />
<Rectangle Width="{Binding ControlSize}" <Rectangle Width="{Binding ControlSize}"
Height="{Binding ControlSize}" Height="{Binding ControlSize}"
Margin="{Binding ControlOffset}" Margin="{Binding ControlOffset}"
Canvas.Left="{Binding LeftCenter.X}" Canvas.Left="{Binding LeftCenter.X}"
Canvas.Top="{Binding LeftCenter.Y}" Canvas.Top="{Binding LeftCenter.Y}"
Fill="{DynamicResource SecondaryAccentBrush}" Fill="White"
Stroke="{DynamicResource SecondaryAccentBrush}"
StrokeThickness="0.5"
MouseDown="{s:Action ShapeEditMouseDown}" MouseUp="{s:Action ShapeEditMouseUp}" MouseMove="{s:Action LeftCenterResize}" /> MouseDown="{s:Action ShapeEditMouseDown}" MouseUp="{s:Action ShapeEditMouseUp}" MouseMove="{s:Action LeftCenterResize}" />
<Rectangle Width="{Binding ControlSize}" <Rectangle Width="{Binding ControlSize}"
Height="{Binding ControlSize}" Height="{Binding ControlSize}"
Margin="{Binding ControlOffset}" Margin="{Binding ControlOffset}"
Canvas.Left="{Binding TopLeft.X}" Canvas.Left="{Binding TopLeft.X}"
Canvas.Top="{Binding TopLeft.Y}" Canvas.Top="{Binding TopLeft.Y}"
Fill="{DynamicResource SecondaryAccentBrush}" Fill="White"
Stroke="{DynamicResource SecondaryAccentBrush}"
StrokeThickness="0.5"
MouseDown="{s:Action ShapeEditMouseDown}" MouseUp="{s:Action ShapeEditMouseUp}" MouseMove="{s:Action TopLeftResize}" /> MouseDown="{s:Action ShapeEditMouseDown}" MouseUp="{s:Action ShapeEditMouseUp}" MouseMove="{s:Action TopLeftResize}" />
<Rectangle Width="{Binding ControlSize}" <Rectangle Width="{Binding ControlSize}"
Height="{Binding ControlSize}" Height="{Binding ControlSize}"
Margin="{Binding ControlOffset}" Margin="{Binding ControlOffset}"
Canvas.Left="{Binding TopRight.X}" Canvas.Left="{Binding TopRight.X}"
Canvas.Top="{Binding TopRight.Y}" Canvas.Top="{Binding TopRight.Y}"
Fill="{DynamicResource SecondaryAccentBrush}" Fill="White"
Stroke="{DynamicResource SecondaryAccentBrush}"
StrokeThickness="0.5"
MouseDown="{s:Action ShapeEditMouseDown}" MouseUp="{s:Action ShapeEditMouseUp}" MouseMove="{s:Action TopRightResize}" /> MouseDown="{s:Action ShapeEditMouseDown}" MouseUp="{s:Action ShapeEditMouseUp}" MouseMove="{s:Action TopRightResize}" />
<Rectangle Width="{Binding ControlSize}" <Rectangle Width="{Binding ControlSize}"
Height="{Binding ControlSize}" Height="{Binding ControlSize}"
Margin="{Binding ControlOffset}" Margin="{Binding ControlOffset}"
Canvas.Left="{Binding BottomRight.X}" Canvas.Left="{Binding BottomRight.X}"
Canvas.Top="{Binding BottomRight.Y}" Canvas.Top="{Binding BottomRight.Y}"
Fill="{DynamicResource SecondaryAccentBrush}" Fill="White"
Stroke="{DynamicResource SecondaryAccentBrush}"
StrokeThickness="0.5"
MouseDown="{s:Action ShapeEditMouseDown}" MouseUp="{s:Action ShapeEditMouseUp}" MouseMove="{s:Action BottomRightResize}" /> MouseDown="{s:Action ShapeEditMouseDown}" MouseUp="{s:Action ShapeEditMouseUp}" MouseMove="{s:Action BottomRightResize}" />
<Rectangle Width="{Binding ControlSize}" <Rectangle Width="{Binding ControlSize}"
Height="{Binding ControlSize}" Height="{Binding ControlSize}"
Margin="{Binding ControlOffset}" Margin="{Binding ControlOffset}"
Canvas.Left="{Binding BottomLeft.X}" Canvas.Left="{Binding BottomLeft.X}"
Canvas.Top="{Binding BottomLeft.Y}" Canvas.Top="{Binding BottomLeft.Y}"
Fill="{DynamicResource SecondaryAccentBrush}" Fill="White"
Stroke="{DynamicResource SecondaryAccentBrush}"
StrokeThickness="0.5"
MouseDown="{s:Action ShapeEditMouseDown}" MouseUp="{s:Action ShapeEditMouseUp}" MouseMove="{s:Action BottomLeftResize}" /> MouseDown="{s:Action ShapeEditMouseDown}" MouseUp="{s:Action ShapeEditMouseUp}" MouseMove="{s:Action BottomLeftResize}" />
<!-- Anchor point --> <!-- Anchor point -->
<materialDesign:PackIcon Kind="Crosshairs"
Width="8"
Height="8"
Foreground="{DynamicResource SecondaryAccentBrush}"
Canvas.Left="{Binding ShapeAnchor.X}"
Canvas.Top="{Binding ShapeAnchor.Y}"
Margin="-4,-4,0,0" />
<Ellipse MouseDown="{s:Action AnchorEditMouseDown}" <Ellipse MouseDown="{s:Action AnchorEditMouseDown}"
MouseUp="{s:Action ShapeEditMouseUp}" MouseUp="{s:Action ShapeEditMouseUp}"
MouseMove="{s:Action AnchorMove}" MouseMove="{s:Action AnchorMove}"
Width="8" Width="{Binding ControlSize}"
Height="8" Height="{Binding ControlSize}"
Fill="Transparent" Margin="{Binding ControlOffset}"
Fill="White"
Stroke="{DynamicResource SecondaryAccentBrush}"
StrokeThickness="0.5"
Canvas.Left="{Binding ShapeAnchor.X}" Canvas.Left="{Binding ShapeAnchor.X}"
Canvas.Top="{Binding ShapeAnchor.Y}" Canvas.Top="{Binding ShapeAnchor.Y}"
Margin="-4,-4,0,0" Cursor="SizeAll">
Cursor="SizeAll" /> </Ellipse>
</Canvas> </Canvas>
</UserControl> </UserControl>

View File

@ -32,6 +32,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
ProfileViewModel.PanZoomViewModel.PropertyChanged += (sender, args) => UpdateControls(); ProfileViewModel.PanZoomViewModel.PropertyChanged += (sender, args) => UpdateControls();
profileEditorService.SelectedProfileChanged += (sender, args) => Update(); profileEditorService.SelectedProfileChanged += (sender, args) => Update();
profileEditorService.SelectedProfileElementChanged += (sender, args) => Update();
profileEditorService.SelectedProfileElementUpdated += (sender, args) => Update(); profileEditorService.SelectedProfileElementUpdated += (sender, args) => Update();
profileEditorService.ProfilePreviewUpdated += (sender, args) => Update(); profileEditorService.ProfilePreviewUpdated += (sender, args) => Update();
} }
@ -57,7 +58,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
private void Update() private void Update()
{ {
if (!(ProfileEditorService.SelectedProfileElement is Layer layer) || layer.LayerShape == null) if (!(ProfileEditorService.SelectedProfileElement is Layer layer))
return; return;
ShapeRectangle = _layerEditorService.GetShapeRenderRect(layer.LayerShape).ToSKRect(); ShapeRectangle = _layerEditorService.GetShapeRenderRect(layer.LayerShape).ToSKRect();
@ -92,7 +93,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
{ {
Execute.PostToUIThread(() => Execute.PostToUIThread(() =>
{ {
ControlSize = Math.Max(8 / ProfileViewModel.PanZoomViewModel.Zoom, 4); ControlSize = Math.Max(10 / ProfileViewModel.PanZoomViewModel.Zoom, 4);
ControlOffset = new Thickness(ControlSize / 2 * -1, ControlSize / 2 * -1, 0, 0); ControlOffset = new Thickness(ControlSize / 2 * -1, ControlSize / 2 * -1, 0, 0);
OutlineThickness = Math.Max(2 / ProfileViewModel.PanZoomViewModel.Zoom, 1); OutlineThickness = Math.Max(2 / ProfileViewModel.PanZoomViewModel.Zoom, 1);
}); });

View File

@ -148,6 +148,9 @@ namespace Artemis.UI.Services
/// <inheritdoc /> /// <inheritdoc />
public Rect GetShapeRenderRect(LayerShape layerShape) public Rect GetShapeRenderRect(LayerShape layerShape)
{ {
if (layerShape == null)
return Rect.Empty;
// Adjust the render rectangle for the difference in render scale // Adjust the render rectangle for the difference in render scale
var renderScale = _settingsService.GetSetting("Core.RenderScale", 1.0).Value; var renderScale = _settingsService.GetSetting("Core.RenderScale", 1.0).Value;
return new Rect( return new Rect(