UI - Restructured resources directory

UI - Fixed a few memory leaks
This commit is contained in:
Robert committed 2020-02-24 16:31:35 +01:00
1 parent f704e66296
commit 757ac68ea2
41 files changed
+215 -123

No files matched your search

@@ -9,6 +9,7 @@ using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Profile.LayerProperties;
using Artemis.Core.Services;
using Artemis.Core.Services.Interfaces;
using Artemis.UI.Events;
using Artemis.UI.Ninject.Factories;
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree;
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline;
@@ -43,8 +44,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
PropertyTimeline = propertyTimelineVmFactory.Create(this);
PopulateProperties(_profileEditorService.SelectedProfileElement, null);
_profileEditorService.ProfileElementSelected += (sender, args) => PopulateProperties(args.ProfileElement, args.PreviousProfileElement);
_profileEditorService.CurrentTimeChanged += ProfileEditorServiceOnCurrentTimeChanged;
}
public bool Playing { get; set; }
@@ -70,11 +69,36 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
public PropertyTreeViewModel PropertyTree { get; set; }
public PropertyTimelineViewModel PropertyTimeline { get; set; }
protected override void OnInitialActivate()
{
_profileEditorService.ProfileElementSelected += ProfileEditorServiceOnProfileElementSelected;
_profileEditorService.CurrentTimeChanged += ProfileEditorServiceOnCurrentTimeChanged;
base.OnInitialActivate();
}
protected override void OnClose()
{
_profileEditorService.ProfileElementSelected -= ProfileEditorServiceOnProfileElementSelected;
_profileEditorService.CurrentTimeChanged -= ProfileEditorServiceOnCurrentTimeChanged;
PropertyTree?.Dispose();
PropertyTimeline?.Dispose();
PropertyTree = null;
PropertyTimeline = null;
base.OnClose();
}
protected override void OnDeactivate()
{
Pause();
base.OnDeactivate();
}
private void ProfileEditorServiceOnProfileElementSelected(object? sender, ProfileElementEventArgs e)
{
PopulateProperties(e.ProfileElement, e.PreviousProfileElement);
}
private void ProfileEditorServiceOnCurrentTimeChanged(object sender, EventArgs e)
{
@@ -1,13 +1,15 @@
using System.Linq;
using System;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using Artemis.UI.Events;
using Artemis.UI.Services.Interfaces;
using Stylet;
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree
{
public class PropertyTreeViewModel : PropertyChangedBase
public class PropertyTreeViewModel : PropertyChangedBase, IDisposable
{
private readonly IProfileEditorService _profileEditorService;
@@ -18,13 +20,19 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree
LayerPropertiesViewModel = layerPropertiesViewModel;
PropertyTreeItemViewModels = new BindableCollection<PropertyTreeItemViewModel>();
_profileEditorService.CurrentTimeChanged += (sender, args) => Update(false);
_profileEditorService.SelectedProfileElementUpdated += (sender, args) => Update(true);
_profileEditorService.CurrentTimeChanged += OnCurrentTimeChanged;
_profileEditorService.SelectedProfileElementUpdated += OnSelectedProfileElementUpdated;
}
public LayerPropertiesViewModel LayerPropertiesViewModel { get; }
public BindableCollection<PropertyTreeItemViewModel> PropertyTreeItemViewModels { get; set; }
public void Dispose()
{
_profileEditorService.CurrentTimeChanged -= OnCurrentTimeChanged;
_profileEditorService.SelectedProfileElementUpdated -= OnSelectedProfileElementUpdated;
}
public void AddLayerProperty(LayerPropertyViewModel layerPropertyViewModel)
{
// Add as a root VM
@@ -76,5 +84,15 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree
var parent = ((Control) sender).Parent as UIElement;
parent?.RaiseEvent(eventArg);
}
private void OnCurrentTimeChanged(object? sender, EventArgs e)
{
Update(false);
}
private void OnSelectedProfileElementUpdated(object? sender, ProfileElementEventArgs e)
{
Update(true);
}
}
}
@@ -4,7 +4,7 @@ using System.Linq;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Shapes;
using Artemis.UI.Events;
using Artemis.UI.Ninject.Factories;
using Artemis.UI.Services.Interfaces;
using Artemis.UI.Utilities;
@@ -12,7 +12,7 @@ using Stylet;
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
{
public class PropertyTimelineViewModel : PropertyChangedBase
public class PropertyTimelineViewModel : PropertyChangedBase, IDisposable
{
private readonly IProfileEditorService _profileEditorService;
private readonly IPropertyTrackVmFactory _propertyTrackVmFactory;
@@ -27,8 +27,8 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
LayerPropertiesViewModel = layerPropertiesViewModel;
PropertyTrackViewModels = new BindableCollection<PropertyTrackViewModel>();
_profileEditorService.SelectedProfileElementUpdated += (sender, args) => Update();
LayerPropertiesViewModel.PixelsPerSecondChanged += (sender, args) => UpdateKeyframePositions();
_profileEditorService.SelectedProfileElementUpdated += OnSelectedProfileElementUpdated;
LayerPropertiesViewModel.PixelsPerSecondChanged += OnPixelsPerSecondChanged;
Execute.PostToUIThread(() => SelectionRectangle = new RectangleGeometry());
}
@@ -39,6 +39,12 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
public BindableCollection<PropertyTrackViewModel> PropertyTrackViewModels { get; set; }
public RectangleGeometry SelectionRectangle { get; set; }
public void Dispose()
{
_profileEditorService.SelectedProfileElementUpdated -= OnSelectedProfileElementUpdated;
LayerPropertiesViewModel.PixelsPerSecondChanged -= OnPixelsPerSecondChanged;
}
public void UpdateEndTime()
{
// End time is the last keyframe + 10 sec
@@ -96,6 +102,16 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
UpdateEndTime();
}
private void OnSelectedProfileElementUpdated(object? sender, ProfileElementEventArgs e)
{
Update();
}
private void OnPixelsPerSecondChanged(object? sender, EventArgs e)
{
UpdateKeyframePositions();
}
private void CreateViewModels(LayerPropertyViewModel property)
{
PropertyTrackViewModels.Add(_propertyTrackVmFactory.Create(this, property));
@@ -47,8 +47,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor
Profiles = new BindableCollection<Profile>();
Items.AddRange(viewModels);
module.ActiveProfileChanged += ModuleOnActiveProfileChanged;
}
public ProfileModule Module { get; }
@@ -124,6 +122,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor
{
LoadWorkspaceSettings();
_profileEditorService.StopRegularRender();
Module.ActiveProfileChanged += ModuleOnActiveProfileChanged;
Task.Run(LoadProfiles);
base.OnInitialActivate();
}
@@ -132,6 +131,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor
{
SaveWorkspaceSettings();
_profileEditorService.ResumeRegularRender();
Module.ActiveProfileChanged -= ModuleOnActiveProfileChanged;
base.OnClose();
}
@@ -52,14 +52,11 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
PanZoomViewModel = new PanZoomViewModel {LimitToZero = false};
});
ApplySurfaceConfiguration(surfaceService.ActiveSurface);
ApplySurfaceConfiguration(_surfaceService.ActiveSurface);
ApplyActiveProfile();
CreateUpdateTrigger();
ActivateToolByIndex(0);
_profileEditorService.ProfileSelected += OnProfileSelected;
_profileEditorService.ProfileElementSelected += OnProfileElementSelected;
_profileEditorService.SelectedProfileElementUpdated += OnSelectedProfileElementUpdated;
eventAggregator.Subscribe(this);
}
@@ -120,6 +117,10 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
PauseRenderingOnFocusLoss = _settingsService.GetSetting("ProfileEditor.PauseRenderingOnFocusLoss", true);
HighlightSelectedLayer.SettingChanged += HighlightSelectedLayerOnSettingChanged;
_surfaceService.ActiveSurfaceConfigurationSelected += OnActiveSurfaceConfigurationSelected;
_profileEditorService.ProfileSelected += OnProfileSelected;
_profileEditorService.ProfileElementSelected += OnProfileElementSelected;
_profileEditorService.SelectedProfileElementUpdated += OnSelectedProfileElementUpdated;
_updateTrigger.Start();
base.OnInitialActivate();
@@ -127,6 +128,12 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
protected override void OnClose()
{
HighlightSelectedLayer.SettingChanged -= HighlightSelectedLayerOnSettingChanged;
_surfaceService.ActiveSurfaceConfigurationSelected -= OnActiveSurfaceConfigurationSelected;
_profileEditorService.ProfileSelected -= OnProfileSelected;
_profileEditorService.ProfileElementSelected -= OnProfileElementSelected;
_profileEditorService.SelectedProfileElementUpdated -= OnSelectedProfileElementUpdated;
HighlightSelectedLayer.Save();
PauseRenderingOnFocusLoss.Save();
@@ -150,8 +157,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
var targetFps = Math.Min(targetFpsSetting.Value, editorTargetFpsSetting.Value);
_updateTrigger = new TimerUpdateTrigger {UpdateFrequency = 1.0 / targetFps};
_updateTrigger.Update += UpdateLeds;
_surfaceService.ActiveSurfaceConfigurationSelected += OnActiveSurfaceConfigurationSelected;
}
private void OnActiveSurfaceConfigurationSelected(object sender, SurfaceConfigurationEventArgs e)
@@ -9,25 +9,25 @@
<!-- Render these first so that they are always behind the actual shape -->
<Ellipse x:Name="RotateTopLeft"
Fill="Transparent"
Cursor="/Resources/aero_rotate.cur"
Cursor="/Resources/Cursors/aero_rotate.cur"
MouseDown="RotationOnMouseDown"
MouseUp="RotationOnMouseUp"
MouseMove="RotationOnMouseMove" />
<Ellipse x:Name="RotateTopRight"
Fill="Transparent"
Cursor="/Resources/aero_rotate.cur"
Cursor="/Resources/Cursors/aero_rotate.cur"
MouseDown="RotationOnMouseDown"
MouseUp="RotationOnMouseUp"
MouseMove="RotationOnMouseMove" />
<Ellipse x:Name="RotateBottomRight"
Fill="Transparent"
Cursor="/Resources/aero_rotate.cur"
Cursor="/Resources/Cursors/aero_rotate.cur"
MouseDown="RotationOnMouseDown"
MouseUp="RotationOnMouseUp"
MouseMove="RotationOnMouseMove" />
<Ellipse x:Name="RotateBottomLeft"
Fill="Transparent"
Cursor="/Resources/aero_rotate.cur"
Cursor="/Resources/Cursors/aero_rotate.cur"
MouseDown="RotationOnMouseDown"
MouseUp="RotationOnMouseUp"
MouseMove="RotationOnMouseMove" />
@@ -38,7 +38,7 @@
Stroke="{DynamicResource PrimaryHueMidBrush}"
StrokeThickness="{Binding OutlineThickness}"
StrokeDashArray="2 2"
Cursor="/Resources/aero_drag.cur"
Cursor="/Resources/Cursors/aero_drag.cur"
MouseDown="MoveOnMouseDown"
MouseUp="MoveOnMouseUp"
MouseMove="MoveOnMouseMove" />