Project cleanup

This commit is contained in:
Robert committed 2020-02-13 15:17:58 +01:00
1 parent f5e95e43be
commit 3aa9a632ea
51 files changed
+440 -490

No files matched your search

@@ -20,10 +20,10 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
public class LayerPropertiesViewModel : ProfileEditorPanelViewModel
{
private readonly ICoreService _coreService;
private readonly List<LayerPropertyViewModel> _layerPropertyViewModels;
private readonly ILayerPropertyVmFactory _layerPropertyVmFactory;
private readonly IProfileEditorService _profileEditorService;
private readonly ISettingsService _settingsService;
private readonly List<LayerPropertyViewModel> _layerPropertyViewModels;
public LayerPropertiesViewModel(IProfileEditorService profileEditorService,
ICoreService coreService,
@@ -71,18 +71,18 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
public PropertyTreeViewModel PropertyTree { get; set; }
public PropertyTimelineViewModel PropertyTimeline { get; set; }
private void ProfileEditorServiceOnCurrentTimeChanged(object sender, EventArgs e)
{
NotifyOfPropertyChange(() => FormattedCurrentTime);
NotifyOfPropertyChange(() => TimeCaretPosition);
}
protected override void OnDeactivate()
{
Pause();
base.OnDeactivate();
}
private void ProfileEditorServiceOnCurrentTimeChanged(object sender, EventArgs e)
{
NotifyOfPropertyChange(() => FormattedCurrentTime);
NotifyOfPropertyChange(() => TimeCaretPosition);
}
#region View model managament
private void PopulateProperties(ProfileElement profileElement, ProfileElement previousProfileElement)
@@ -92,6 +92,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
previousLayer.LayerPropertyRegistered -= LayerOnPropertyRegistered;
previousLayer.LayerPropertyRemoved -= LayerOnPropertyRemoved;
}
if (profileElement is Layer layer)
{
// Create VMs for missing properties
@@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using Artemis.Core.Models.Profile.LayerProperties;
using Artemis.UI.Ninject.Factories;
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput;
using Artemis.UI.Services.Interfaces;
using Ninject;
@@ -47,21 +46,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
}
}
private void UpdateKeyframes()
{
// Either create a new first keyframe or clear all the keyframes
if (_keyframesEnabled)
LayerProperty.CreateNewKeyframe(_profileEditorService.CurrentTime, LayerProperty.GetCurrentValue());
else
LayerProperty.ClearKeyframes();
// Force the keyframe engine to update, the new keyframe is the current keyframe
LayerProperty.IsUsingKeyframes = _keyframesEnabled;
LayerProperty.KeyframeEngine?.Update(0);
_profileEditorService.UpdateSelectedProfileElement();
}
public PropertyInputViewModel GetPropertyInputViewModel()
{
// If the type is an enum type, search for Enum instead.
@@ -76,5 +60,20 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
match.Initialize(this);
return match;
}
private void UpdateKeyframes()
{
// Either create a new first keyframe or clear all the keyframes
if (_keyframesEnabled)
LayerProperty.CreateNewKeyframe(_profileEditorService.CurrentTime, LayerProperty.GetCurrentValue());
else
LayerProperty.ClearKeyframes();
// Force the keyframe engine to update, the new keyframe is the current keyframe
LayerProperty.IsUsingKeyframes = _keyframesEnabled;
LayerProperty.KeyframeEngine?.Update(0);
_profileEditorService.UpdateSelectedProfileElement();
}
}
}
@@ -1,12 +1,12 @@
<UserControl x:Class="Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput.BrushPropertyInputView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:s="https://github.com/canton7/Stylet"
mc:Ignorable="d"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<StackPanel Orientation="Horizontal">
<TextBlock Margin="0 0 5 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputPrefix}" />
@@ -19,10 +19,9 @@
ItemsSource="{Binding Path=EnumValues}"
SelectedValuePath="Value"
DisplayMemberPath="Description"
SelectedValue="{Binding Path=BrushInputValue}"
SelectedValue="{Binding Path=BrushInputValue}"
RequestBringIntoView="{s:Action OnRequestBringIntoView}"
materialDesign:ComboBoxAssist.ClassicMode="True">
</ComboBox>
materialDesign:ComboBoxAssist.ClassicMode="True" />
<TextBlock Margin="5 0 0 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" />
</StackPanel>
</UserControl>
</UserControl>
@@ -1,22 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Controls;
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput
{
/// <summary>
/// Interaction logic for BrushPropertyInputView.xaml
/// Interaction logic for BrushPropertyInputView.xaml
/// </summary>
public partial class BrushPropertyInputView : UserControl
{
@@ -25,4 +12,4 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
InitializeComponent();
}
}
}
}
@@ -38,12 +38,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
}
}
protected override void OnInitialized()
{
UpdateEnumValues();
base.OnInitialized();
}
public void UpdateEnumValues()
{
var layerBrushProviders = _pluginService.GetPluginsOfType<LayerBrushProvider>();
@@ -64,5 +58,11 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
{
NotifyOfPropertyChange(() => BrushInputValue);
}
protected override void OnInitialized()
{
UpdateEnumValues();
base.OnInitialized();
}
}
}
@@ -20,10 +20,9 @@
ItemsSource="{Binding Path=EnumValues}"
SelectedValuePath="Value"
DisplayMemberPath="Description"
SelectedValue="{Binding Path=EnumInputValue}"
SelectedValue="{Binding Path=EnumInputValue}"
RequestBringIntoView="{s:Action OnRequestBringIntoView}"
materialDesign:ComboBoxAssist.ClassicMode="True">
</ComboBox>
materialDesign:ComboBoxAssist.ClassicMode="True" />
<TextBlock Margin="5 0 0 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" />
</StackPanel>
</UserControl>
@@ -1,22 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Controls;
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput
{
/// <summary>
/// Interaction logic for EnumPropertyInputView.xaml
/// Interaction logic for EnumPropertyInputView.xaml
/// </summary>
public partial class EnumPropertyInputView : UserControl
{
@@ -25,4 +12,4 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
InitializeComponent();
}
}
}
}
@@ -22,14 +22,14 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
set => InputValue = value;
}
protected override void OnInitialized()
{
EnumValues = EnumUtilities.GetAllValuesAndDescriptions(LayerPropertyViewModel.LayerProperty.Type);
}
public override void Update()
{
NotifyOfPropertyChange(() => EnumInputValue);
}
protected override void OnInitialized()
{
EnumValues = EnumUtilities.GetAllValuesAndDescriptions(LayerPropertyViewModel.LayerProperty.Type);
}
}
}
@@ -17,7 +17,7 @@
materialDesign:ValidationAssist.UsePopup="True"
HorizontalAlignment="Left"
Text="{Binding FloatInputValue}"
RequestBringIntoView="{s:Action OnRequestBringIntoView}"/>
RequestBringIntoView="{s:Action OnRequestBringIntoView}" />
<TextBlock Margin="5 0 0 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" />
</StackPanel>
</UserControl>
@@ -16,8 +16,8 @@
Padding="0 -1"
materialDesign:ValidationAssist.UsePopup="True"
HorizontalAlignment="Left"
Text="{Binding IntInputValue}"
RequestBringIntoView="{s:Action OnRequestBringIntoView}"/>
Text="{Binding IntInputValue}"
RequestBringIntoView="{s:Action OnRequestBringIntoView}" />
<TextBlock Margin="5 0 0 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" />
</StackPanel>
</UserControl>
@@ -47,7 +47,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
}
/// <summary>
/// Called by the view, prevents scrolling into view when scrubbing through the timeline
/// Called by the view, prevents scrolling into view when scrubbing through the timeline
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
@@ -56,6 +56,12 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
e.Handled = true;
}
public abstract void Update();
protected virtual void OnInitialized()
{
}
private void UpdateInputValue(object value)
{
LayerPropertyViewModel.LayerProperty.SetCurrentValue(value, ProfileEditorService.CurrentTime);
@@ -64,11 +70,5 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
ProfileEditorService.UpdateSelectedProfileElement();
}
protected virtual void OnInitialized()
{
}
public abstract void Update();
}
}
@@ -1,22 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Controls;
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput
{
/// <summary>
/// Interaction logic for SKColorPropertyInputView.xaml
/// Interaction logic for SKColorPropertyInputView.xaml
/// </summary>
public partial class SKColorPropertyInputView : UserControl
{
@@ -25,4 +12,4 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
InitializeComponent();
}
}
}
}
@@ -18,7 +18,7 @@
HorizontalAlignment="Left"
ToolTip="X-coordinate (horizontal)"
Text="{Binding X}"
RequestBringIntoView="{s:Action OnRequestBringIntoView}"/>
RequestBringIntoView="{s:Action OnRequestBringIntoView}" />
<TextBlock Margin="5 0" VerticalAlignment="Bottom">,</TextBlock>
<TextBox Width="60"
Margin="0 2"
@@ -26,8 +26,8 @@
materialDesign:ValidationAssist.UsePopup="True"
HorizontalAlignment="Left"
ToolTip="Y-coordinate (vertical)"
Text="{Binding Y}"
RequestBringIntoView="{s:Action OnRequestBringIntoView}"/>
Text="{Binding Y}"
RequestBringIntoView="{s:Action OnRequestBringIntoView}" />
<TextBlock Margin="5 0 0 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" />
</StackPanel>
</UserControl>
@@ -18,7 +18,7 @@
HorizontalAlignment="Left"
ToolTip="Height"
Text="{Binding Height}"
RequestBringIntoView="{s:Action OnRequestBringIntoView}"/>
RequestBringIntoView="{s:Action OnRequestBringIntoView}" />
<TextBlock Margin="5 0" VerticalAlignment="Bottom">,</TextBlock>
<TextBox Width="60"
Margin="0 2"
@@ -27,7 +27,7 @@
HorizontalAlignment="Left"
ToolTip="Width"
Text="{Binding Width}"
RequestBringIntoView="{s:Action OnRequestBringIntoView}"/>
RequestBringIntoView="{s:Action OnRequestBringIntoView}" />
<TextBlock Margin="5 0 0 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" />
</StackPanel>
</UserControl>
@@ -4,13 +4,13 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree
{
public abstract class PropertyTreeItemViewModel : PropertyChangedBase
{
public LayerPropertyViewModel LayerPropertyViewModel { get; }
protected PropertyTreeItemViewModel(LayerPropertyViewModel layerPropertyViewModel)
{
LayerPropertyViewModel = layerPropertyViewModel;
}
public LayerPropertyViewModel LayerPropertyViewModel { get; }
/// <summary>
/// Updates the tree item's input if it is visible and has keyframes enabled
/// </summary>
@@ -18,16 +18,15 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree
public abstract void Update(bool forceUpdate);
/// <summary>
/// Removes the layer property recursively
/// Removes the layer property recursively
/// </summary>
/// <param name="layerPropertyViewModel"></param>
public abstract void RemoveLayerProperty(LayerPropertyViewModel layerPropertyViewModel);
/// <summary>
/// Adds the layer property recursively
/// Adds the layer property recursively
/// </summary>
/// <param name="layerPropertyViewModel"></param>
public abstract void AddLayerProperty(LayerPropertyViewModel layerPropertyViewModel);
}
}
@@ -1,5 +1,4 @@
using System.Linq;
using Artemis.Core.Events;
using Stylet;
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Artemis.Core.Models.Profile.LayerProperties;
using Artemis.UI.Ninject.Factories;
using Artemis.UI.Services.Interfaces;
using Stylet;
@@ -70,13 +69,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
PropertyTrackViewModels.Remove(vm);
}
private void CreateViewModels(LayerPropertyViewModel property)
{
PropertyTrackViewModels.Add(_propertyTrackVmFactory.Create(this, property));
foreach (var child in property.Children)
CreateViewModels(child);
}
public void UpdateKeyframePositions()
{
foreach (var viewModel in PropertyTrackViewModels)
@@ -95,5 +87,12 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
UpdateEndTime();
}
private void CreateViewModels(LayerPropertyViewModel property)
{
PropertyTrackViewModels.Add(_propertyTrackVmFactory.Create(this, property));
foreach (var child in property.Children)
CreateViewModels(child);
}
}
}
@@ -1,5 +1,4 @@
using System.Linq;
using Artemis.Core.Events;
using Artemis.UI.Ninject.Factories;
using Stylet;
@@ -9,7 +8,8 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
{
private readonly IPropertyTrackKeyframeVmFactory _propertyTrackKeyframeVmFactory;
public PropertyTrackViewModel(PropertyTimelineViewModel propertyTimelineViewModel, LayerPropertyViewModel layerPropertyViewModel, IPropertyTrackKeyframeVmFactory propertyTrackKeyframeVmFactory)
public PropertyTrackViewModel(PropertyTimelineViewModel propertyTimelineViewModel, LayerPropertyViewModel layerPropertyViewModel,
IPropertyTrackKeyframeVmFactory propertyTrackKeyframeVmFactory)
{
_propertyTrackKeyframeVmFactory = propertyTrackKeyframeVmFactory;
PropertyTimelineViewModel = propertyTimelineViewModel;
@@ -71,22 +71,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor
public bool CanDeleteActiveProfile => SelectedProfile != null && Profiles.Count > 1;
private void ChangeSelectedProfile(Profile profile)
{
if (profile == Module.ActiveProfile)
return;
var oldProfile = Module.ActiveProfile;
_profileService.ActivateProfile(Module, profile);
if (oldProfile != null)
_profileService.UpdateProfile(oldProfile, false);
if (profile != null)
_profileService.UpdateProfile(profile, false);
_profileEditorService.ChangeSelectedProfile(profile);
}
public Profile CreateProfile(string name)
{
var profile = _profileService.CreateProfile(Module, name);
@@ -135,14 +119,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor
_profileEditorService.RedoUpdateProfile(Module);
}
private void ModuleOnActiveProfileChanged(object sender, EventArgs e)
{
if (SelectedProfile == Module.ActiveProfile)
return;
SelectedProfile = Profiles.FirstOrDefault(p => p == Module.ActiveProfile);
}
protected override void OnActivate()
{
LoadWorkspaceSettings();
@@ -158,6 +134,30 @@ namespace Artemis.UI.Screens.Module.ProfileEditor
base.OnDeactivate();
}
private void ChangeSelectedProfile(Profile profile)
{
if (profile == Module.ActiveProfile)
return;
var oldProfile = Module.ActiveProfile;
_profileService.ActivateProfile(Module, profile);
if (oldProfile != null)
_profileService.UpdateProfile(oldProfile, false);
if (profile != null)
_profileService.UpdateProfile(profile, false);
_profileEditorService.ChangeSelectedProfile(profile);
}
private void ModuleOnActiveProfileChanged(object sender, EventArgs e)
{
if (SelectedProfile == Module.ActiveProfile)
return;
SelectedProfile = Profiles.FirstOrDefault(p => p == Module.ActiveProfile);
}
private void LoadWorkspaceSettings()
{
SidePanelsWidth = _settingsService.GetSetting("ProfileEditor.SidePanelsWidth", new GridLength(385));
@@ -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();
}
}
}
@@ -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;
@@ -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;