Signitifantly reduced build size

Updated project folder names
Show only selected layer in visualization
Added rectangle support
This commit is contained in:
Robert committed 2019-12-18 13:05:46 +01:00
1 parent b74a1b2871
commit 04bc8f013a
52 files changed
+373 -633

No files matched your search

@@ -6,7 +6,29 @@
xmlns:local="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.Visualization"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Canvas>
<UserControl.Resources>
<Style TargetType="{x:Type Canvas}" x:Key="SelectedStyle">
<Style.Triggers>
<DataTrigger Binding="{Binding IsSelected}" Value="False">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="(Canvas.Opacity)" To="0" Duration="0:0:0.25" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="(Canvas.Opacity)" To="1" Duration="0:0:0.25" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.ExitActions>
</DataTrigger>
</Style.Triggers>
</Style>
</UserControl.Resources>
<Canvas Style="{StaticResource SelectedStyle}">
<!-- The part of the layer's shape that falls outside the layer -->
<Path Data="{Binding ShapeGeometry, Mode=OneWay}" >
<Path.Fill>
@@ -6,20 +6,24 @@ using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Profile.LayerShapes;
using Artemis.Core.Models.Surface;
using Artemis.UI.Extensions;
using Artemis.UI.Services.Interfaces;
using RGB.NET.Core;
using SkiaSharp.Views.WPF;
using Rectangle = Artemis.Core.Models.Profile.LayerShapes.Rectangle;
namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
{
public class ProfileLayerViewModel : CanvasViewModel
{
public ProfileLayerViewModel(Layer layer)
private readonly IProfileEditorService _profileEditorService;
public ProfileLayerViewModel(Layer layer, IProfileEditorService profileEditorService)
{
_profileEditorService = profileEditorService;
Layer = layer;
Update();
Layer.RenderPropertiesUpdated += LayerOnRenderPropertiesUpdated;
_profileEditorService.SelectedProfileElementChanged += OnSelectedProfileElementChanged;
}
public Layer Layer { get; }
@@ -28,9 +32,11 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
public Geometry OpacityGeometry { get; set; }
public Geometry ShapeGeometry { get; set; }
public Rect ViewportRectangle { get; set; }
public bool IsSelected { get; set; }
private void Update()
{
IsSelected = _profileEditorService.SelectedProfileElement == Layer;
CreateLayerGeometry();
CreateShapeGeometry();
CreateViewportRectangle();
@@ -118,8 +124,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
ViewportRectangle = Rect.Empty;
return;
}
var x = Layer.Leds.Min(l => l.RgbLed.AbsoluteLedRectangle.Location.X);
var y = Layer.Leds.Min(l => l.RgbLed.AbsoluteLedRectangle.Location.Y);
var width = Layer.Leds.Max(l => l.RgbLed.AbsoluteLedRectangle.Location.X + l.RgbLed.AbsoluteLedRectangle.Size.Width) - x;
@@ -176,6 +181,11 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
Update();
}
private void OnSelectedProfileElementChanged(object sender, EventArgs e)
{
IsSelected = _profileEditorService.SelectedProfileElement == Layer;
}
public void Dispose()
{
Layer.RenderPropertiesUpdated -= LayerOnRenderPropertiesUpdated;
@@ -11,6 +11,7 @@ using Artemis.Core.Plugins.Models;
using Artemis.Core.Services;
using Artemis.Core.Services.Storage.Interfaces;
using Artemis.UI.Events;
using Artemis.UI.Ninject.Factories;
using Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools;
using Artemis.UI.Screens.Shared;
using Artemis.UI.Services.Interfaces;
@@ -23,17 +24,23 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
{
private readonly IProfileEditorService _profileEditorService;
private readonly ISettingsService _settingsService;
private readonly IProfileLayerViewModelFactory _profileLayerViewModelFactory;
private readonly ISurfaceService _surfaceService;
private int _activeToolIndex;
private VisualizationToolViewModel _activeToolViewModel;
private int _previousTool;
private TimerUpdateTrigger _updateTrigger;
public ProfileViewModel(IProfileEditorService profileEditorService, ISurfaceService surfaceService, ISettingsService settingsService, IEventAggregator eventAggregator)
public ProfileViewModel(IProfileEditorService profileEditorService,
ISurfaceService surfaceService,
ISettingsService settingsService,
IEventAggregator eventAggregator,
IProfileLayerViewModelFactory profileLayerViewModelFactory)
{
_profileEditorService = profileEditorService;
_surfaceService = surfaceService;
_settingsService = settingsService;
_profileLayerViewModelFactory = profileLayerViewModelFactory;
Execute.OnUIThreadSync(() =>
{
@@ -133,7 +140,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
foreach (var layer in layers)
{
if (layerViewModels.All(vm => vm.Layer != layer))
CanvasViewModels.Add(new ProfileLayerViewModel(layer));
CanvasViewModels.Add(_profileLayerViewModelFactory.Create(layer));
}
// Remove layers that no longer exist
@@ -45,8 +45,11 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
if (ProfileEditorService.SelectedProfileElement is Layer layer)
{
// Ensure the shape is an ellipse, we're all about ellipses up here
if (!(layer.LayerShape is Ellipse))
layer.LayerShape = new Ellipse(layer);
// Apply the drag rectangle
layer.LayerShape.SetFromUnscaledRectangle(DragRectangle.ToSKRect());
ProfileEditorService.UpdateSelectedProfileElement();
}
@@ -25,15 +25,16 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
// Find out if the click is inside a layer and if so, fill it
var position = e.GetPosition((IInputElement) sender);
var panZoomVm = ProfileViewModel.PanZoomViewModel;
var layer = ProfileEditorService.SelectedProfile
.GetAllLayers()
.FirstOrDefault(l => l.Leds.Any(
led => panZoomVm.TransformContainingRect(led.RgbLed.AbsoluteLedRectangle).Contains(position))
);
if (layer != null)
layer.LayerShape = new Fill(layer);
if (layer == null)
return;
layer.LayerShape = new Fill(layer);
ProfileEditorService.UpdateSelectedProfileElement();
}
}
}
@@ -1,8 +1,11 @@
using System.IO;
using System.Windows;
using System.Windows.Input;
using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Profile.LayerShapes;
using Artemis.UI.Properties;
using Artemis.UI.Services.Interfaces;
using SkiaSharp.Views.WPF;
namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
{
@@ -34,6 +37,22 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
DragRectangle = GetSquareRectBetweenPoints(MouseDownStartPosition, position);
}
public override void MouseUp(object sender, MouseButtonEventArgs e)
{
base.MouseUp(sender, e);
if (ProfileEditorService.SelectedProfileElement is Layer layer)
{
// Ensure the shape is a rectangle
if (!(layer.LayerShape is Rectangle))
layer.LayerShape = new Rectangle(layer);
// Apply the drag rectangle
layer.LayerShape.SetFromUnscaledRectangle(DragRectangle.ToSKRect());
ProfileEditorService.UpdateSelectedProfileElement();
}
}
public override void KeyUp(KeyEventArgs e)
{
base.KeyUp(e);
+3
View File
@@ -60,7 +60,10 @@ namespace Artemis.UI.Screens
paletteHelper.SetTheme(theme);
var extensionsPaletteHelper = new MaterialDesignExtensions.Themes.PaletteHelper();
// That's nice, then don't use it in your own examples and provide a working alternative
#pragma warning disable 612
extensionsPaletteHelper.SetLightDark(windowsTheme == ThemeWatcher.WindowsTheme.Dark);
#pragma warning restore 612
}
public void WindowDeactivated()
@@ -41,7 +41,7 @@ namespace Artemis.UI.Screens.SurfaceEditor.Dialogs
Session.Close(true);
}
public async Task Cancel()
public void Cancel()
{
Session.Close(false);
}