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

UI - Don't apply layer brush VMs too early

UI - Create layer geometry on ui thread
This commit is contained in:
SpoinkyNL 2020-06-01 19:26:59 +02:00
parent cdb91021a2
commit eda57f6d32
2 changed files with 52 additions and 48 deletions

View File

@ -129,14 +129,14 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
);
LayerPropertyGroups.Add(new LayerPropertyGroupViewModel(ProfileEditorService, layer.General, (PropertyGroupDescriptionAttribute) generalAttribute));
LayerPropertyGroups.Add(new LayerPropertyGroupViewModel(ProfileEditorService, layer.Transform, (PropertyGroupDescriptionAttribute) transformAttribute));
ApplyLayerBrush();
}
else
SelectedLayer = null;
TreeViewModel = new TreeViewModel(this, LayerPropertyGroups);
TimelineViewModel = new TimelineViewModel(this, LayerPropertyGroups);
ApplyLayerBrush();
}
private void SelectedLayerOnLayerBrushUpdated(object sender, EventArgs e)
@ -146,6 +146,9 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
public void ApplyLayerBrush()
{
if (SelectedLayer == null)
return;
var hideRenderRelatedProperties = SelectedLayer.LayerBrush != null && SelectedLayer.LayerBrush.BrushType == LayerBrushType.RgbNet;
SelectedLayer.General.ShapeType.IsHidden = hideRenderRelatedProperties;
SelectedLayer.General.FillType.IsHidden = hideRenderRelatedProperties;

View File

@ -60,6 +60,8 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
}
private void CreateLayerGeometry()
{
Execute.OnUIThread(() =>
{
if (!Layer.Leds.Any())
{
@ -96,6 +98,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
group.Children.Add(geometry);
}
var layerGeometry = group.GetOutlinedPathGeometry();
var opacityGeometry = Geometry.Combine(Geometry.Empty, layerGeometry, GeometryCombineMode.Exclude, new TranslateTransform());
@ -103,8 +106,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
OpacityGeometry = opacityGeometry;
// Render the store as a bitmap
Execute.OnUIThread(() =>
{
var drawingImage = new DrawingImage(new GeometryDrawing(new SolidColorBrush(Colors.Black), null, LayerGeometry));
var image = new Image {Source = drawingImage};
var bitmap = new RenderTargetBitmap(
@ -119,7 +121,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
bitmap.Freeze();
LayerGeometryBitmap = bitmap;
});
}
private void CreateShapeGeometry()