mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 20:06:33 +00:00
UI - Removed Fody, begone arrogant devs!
This commit is contained in:
1 parent
8e01d1f63e
commit
2c2b0ca3e1
49 files changed
+1011
-232
No files matched your search
@@ -7,11 +7,17 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Dialogs
|
||||
{
|
||||
public class ProfileCreateViewModel : DialogViewModelBase
|
||||
{
|
||||
private string _profileName;
|
||||
|
||||
public ProfileCreateViewModel(IModelValidator<ProfileCreateViewModel> validator) : base(validator)
|
||||
{
|
||||
}
|
||||
|
||||
public string ProfileName { get; set; }
|
||||
public string ProfileName
|
||||
{
|
||||
get => _profileName;
|
||||
set => SetAndNotify(ref _profileName, value);
|
||||
}
|
||||
|
||||
public async Task Accept()
|
||||
{
|
||||
|
||||
@@ -7,6 +7,8 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Dialogs
|
||||
{
|
||||
public class RenameViewModel : DialogViewModelBase
|
||||
{
|
||||
private string _elementName;
|
||||
|
||||
public RenameViewModel(IModelValidator<RenameViewModel> validator, string subject, string currentName) : base(validator)
|
||||
{
|
||||
Subject = subject;
|
||||
@@ -14,7 +16,12 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Dialogs
|
||||
}
|
||||
|
||||
public string Subject { get; }
|
||||
public string ElementName { get; set; }
|
||||
|
||||
public string ElementName
|
||||
{
|
||||
get => _elementName;
|
||||
set => SetAndNotify(ref _elementName, value);
|
||||
}
|
||||
|
||||
public async Task Accept()
|
||||
{
|
||||
|
||||
+15
-2
@@ -7,15 +7,28 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Abstract
|
||||
{
|
||||
public abstract class LayerPropertyBaseViewModel : PropertyChangedBase, IDisposable
|
||||
{
|
||||
private bool _isExpanded;
|
||||
private List<LayerPropertyBaseViewModel> _children;
|
||||
|
||||
protected LayerPropertyBaseViewModel()
|
||||
{
|
||||
Children = new List<LayerPropertyBaseViewModel>();
|
||||
}
|
||||
|
||||
public virtual bool IsExpanded { get; set; }
|
||||
public abstract bool IsVisible { get; }
|
||||
|
||||
public List<LayerPropertyBaseViewModel> Children { get; set; }
|
||||
public virtual bool IsExpanded
|
||||
{
|
||||
get => _isExpanded;
|
||||
set => SetAndNotify(ref _isExpanded, value);
|
||||
}
|
||||
|
||||
public List<LayerPropertyBaseViewModel> Children
|
||||
{
|
||||
get => _children;
|
||||
set => SetAndNotify(ref _children, value);
|
||||
}
|
||||
|
||||
public abstract void Dispose();
|
||||
|
||||
public abstract List<BaseLayerPropertyKeyframe> GetKeyframes(bool expandedOnly);
|
||||
|
||||
+14
-4
@@ -13,8 +13,10 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.LayerEffects
|
||||
public class EffectsViewModel : PropertyChangedBase
|
||||
{
|
||||
private readonly ILayerService _layerService;
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private readonly IPluginService _pluginService;
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private BindableCollection<LayerEffectDescriptor> _layerEffectDescriptors;
|
||||
private LayerEffectDescriptor _selectedLayerEffectDescriptor;
|
||||
|
||||
public EffectsViewModel(LayerPropertiesViewModel layerPropertiesViewModel, IPluginService pluginService, ILayerService layerService, IProfileEditorService profileEditorService)
|
||||
{
|
||||
@@ -27,12 +29,20 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.LayerEffects
|
||||
}
|
||||
|
||||
public LayerPropertiesViewModel LayerPropertiesViewModel { get; }
|
||||
|
||||
public BindableCollection<LayerEffectDescriptor> LayerEffectDescriptors { get; set; }
|
||||
public bool HasLayerEffectDescriptors => LayerEffectDescriptors.Any();
|
||||
|
||||
public LayerEffectDescriptor SelectedLayerEffectDescriptor { get; set; }
|
||||
public BindableCollection<LayerEffectDescriptor> LayerEffectDescriptors
|
||||
{
|
||||
get => _layerEffectDescriptors;
|
||||
set => SetAndNotify(ref _layerEffectDescriptors, value);
|
||||
}
|
||||
|
||||
public LayerEffectDescriptor SelectedLayerEffectDescriptor
|
||||
{
|
||||
get => _selectedLayerEffectDescriptor;
|
||||
set => SetAndNotify(ref _selectedLayerEffectDescriptor, value);
|
||||
}
|
||||
|
||||
public void PopulateDescriptors()
|
||||
{
|
||||
var layerBrushProviders = _pluginService.GetPluginsOfType<LayerEffectProvider>();
|
||||
|
||||
+67
-11
@@ -27,6 +27,14 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
||||
{
|
||||
private readonly ILayerPropertyVmFactory _layerPropertyVmFactory;
|
||||
private LayerPropertyGroupViewModel _brushPropertyGroup;
|
||||
private bool _repeatAfterLastKeyframe;
|
||||
private int _propertyTreeIndex;
|
||||
private PropertiesProfileElement _selectedPropertiesElement;
|
||||
private BindableCollection<LayerPropertyGroupViewModel> _layerPropertyGroups;
|
||||
private TreeViewModel _treeViewModel;
|
||||
private EffectsViewModel _effectsViewModel;
|
||||
private TimelineViewModel _timelineViewModel;
|
||||
private bool _playing;
|
||||
|
||||
public LayerPropertiesViewModel(IProfileEditorService profileEditorService, ICoreService coreService, ISettingsService settingsService,
|
||||
ILayerPropertyVmFactory layerPropertyVmFactory)
|
||||
@@ -46,8 +54,18 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
||||
public ICoreService CoreService { get; }
|
||||
public ISettingsService SettingsService { get; }
|
||||
|
||||
public bool Playing { get; set; }
|
||||
public bool RepeatAfterLastKeyframe { get; set; }
|
||||
public bool Playing
|
||||
{
|
||||
get => _playing;
|
||||
set => SetAndNotify(ref _playing, value);
|
||||
}
|
||||
|
||||
public bool RepeatAfterLastKeyframe
|
||||
{
|
||||
get => _repeatAfterLastKeyframe;
|
||||
set => SetAndNotify(ref _repeatAfterLastKeyframe, value);
|
||||
}
|
||||
|
||||
public string FormattedCurrentTime => $"{Math.Floor(ProfileEditorService.CurrentTime.TotalSeconds):00}.{ProfileEditorService.CurrentTime.Milliseconds:000}";
|
||||
|
||||
public Thickness TimeCaretPosition
|
||||
@@ -56,17 +74,55 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
||||
set => ProfileEditorService.CurrentTime = TimeSpan.FromSeconds(value.Left / ProfileEditorService.PixelsPerSecond);
|
||||
}
|
||||
|
||||
public int PropertyTreeIndex { get; set; }
|
||||
public int PropertyTreeIndex
|
||||
{
|
||||
get => _propertyTreeIndex;
|
||||
set
|
||||
{
|
||||
if (!SetAndNotify(ref _propertyTreeIndex, value)) return;
|
||||
NotifyOfPropertyChange(nameof(PropertyTreeVisible));
|
||||
}
|
||||
}
|
||||
|
||||
public bool PropertyTreeVisible => PropertyTreeIndex == 0;
|
||||
|
||||
public PropertiesProfileElement SelectedPropertiesElement { get; set; }
|
||||
public PropertiesProfileElement SelectedPropertiesElement
|
||||
{
|
||||
get => _selectedPropertiesElement;
|
||||
set
|
||||
{
|
||||
if (!SetAndNotify(ref _selectedPropertiesElement, value)) return;
|
||||
NotifyOfPropertyChange(nameof(SelectedLayer));
|
||||
NotifyOfPropertyChange(nameof(SelectedFolder));
|
||||
}
|
||||
}
|
||||
|
||||
public Layer SelectedLayer => SelectedPropertiesElement as Layer;
|
||||
public Folder SelectedFolder => SelectedPropertiesElement as Folder;
|
||||
|
||||
public BindableCollection<LayerPropertyGroupViewModel> LayerPropertyGroups { get; set; }
|
||||
public TreeViewModel TreeViewModel { get; set; }
|
||||
public EffectsViewModel EffectsViewModel { get; set; }
|
||||
public TimelineViewModel TimelineViewModel { get; set; }
|
||||
public BindableCollection<LayerPropertyGroupViewModel> LayerPropertyGroups
|
||||
{
|
||||
get => _layerPropertyGroups;
|
||||
set => SetAndNotify(ref _layerPropertyGroups, value);
|
||||
}
|
||||
|
||||
public TreeViewModel TreeViewModel
|
||||
{
|
||||
get => _treeViewModel;
|
||||
set => SetAndNotify(ref _treeViewModel, value);
|
||||
}
|
||||
|
||||
public EffectsViewModel EffectsViewModel
|
||||
{
|
||||
get => _effectsViewModel;
|
||||
set => SetAndNotify(ref _effectsViewModel, value);
|
||||
}
|
||||
|
||||
public TimelineViewModel TimelineViewModel
|
||||
{
|
||||
get => _timelineViewModel;
|
||||
set => SetAndNotify(ref _timelineViewModel, value);
|
||||
}
|
||||
|
||||
protected override void OnInitialActivate()
|
||||
{
|
||||
@@ -116,8 +172,8 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
||||
|
||||
private void ProfileEditorServiceOnCurrentTimeChanged(object sender, EventArgs e)
|
||||
{
|
||||
NotifyOfPropertyChange(() => FormattedCurrentTime);
|
||||
NotifyOfPropertyChange(() => TimeCaretPosition);
|
||||
NotifyOfPropertyChange(nameof(FormattedCurrentTime));
|
||||
NotifyOfPropertyChange(nameof(TimeCaretPosition));
|
||||
}
|
||||
|
||||
private void ProfileEditorServiceOnPixelsPerSecondChanged(object sender, EventArgs e)
|
||||
@@ -261,7 +317,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
||||
var nonEffectProperties = LayerPropertyGroups.Where(l => l.GroupType != LayerEffectRoot).ToList();
|
||||
// Order the effects
|
||||
var effectProperties = LayerPropertyGroups.Where(l => l.GroupType == LayerEffectRoot).OrderBy(l => l.LayerPropertyGroup.LayerEffect.Order).ToList();
|
||||
|
||||
|
||||
// Put the non-effect properties in front
|
||||
for (var index = 0; index < nonEffectProperties.Count; index++)
|
||||
{
|
||||
|
||||
+23
-8
@@ -26,6 +26,9 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
||||
}
|
||||
|
||||
private readonly ILayerPropertyVmFactory _layerPropertyVmFactory;
|
||||
private ViewModelType _groupType;
|
||||
private TreePropertyGroupViewModel _treePropertyGroupViewModel;
|
||||
private TimelinePropertyGroupViewModel _timelinePropertyGroupViewModel;
|
||||
|
||||
public LayerPropertyGroupViewModel(LayerPropertyGroup layerPropertyGroup, PropertyGroupDescriptionAttribute propertyGroupDescription,
|
||||
IProfileEditorService profileEditorService, ILayerPropertyVmFactory layerPropertyVmFactory)
|
||||
@@ -44,22 +47,34 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
||||
DetermineType();
|
||||
}
|
||||
|
||||
public override bool IsVisible => !LayerPropertyGroup.IsHidden;
|
||||
public IProfileEditorService ProfileEditorService { get; }
|
||||
public LayerPropertyGroup LayerPropertyGroup { get; }
|
||||
public PropertyGroupDescriptionAttribute PropertyGroupDescription { get; }
|
||||
|
||||
public override bool IsExpanded
|
||||
{
|
||||
get => LayerPropertyGroup.ProfileElement.IsPropertyGroupExpanded(LayerPropertyGroup);
|
||||
set => LayerPropertyGroup.ProfileElement.SetPropertyGroupExpanded(LayerPropertyGroup, value);
|
||||
}
|
||||
|
||||
public override bool IsVisible => !LayerPropertyGroup.IsHidden;
|
||||
public ViewModelType GroupType { get; set; }
|
||||
public ViewModelType GroupType
|
||||
{
|
||||
get => _groupType;
|
||||
set => SetAndNotify(ref _groupType, value);
|
||||
}
|
||||
|
||||
public IProfileEditorService ProfileEditorService { get; }
|
||||
public TreePropertyGroupViewModel TreePropertyGroupViewModel
|
||||
{
|
||||
get => _treePropertyGroupViewModel;
|
||||
set => SetAndNotify(ref _treePropertyGroupViewModel, value);
|
||||
}
|
||||
|
||||
public LayerPropertyGroup LayerPropertyGroup { get; }
|
||||
public PropertyGroupDescriptionAttribute PropertyGroupDescription { get; }
|
||||
|
||||
public TreePropertyGroupViewModel TreePropertyGroupViewModel { get; set; }
|
||||
public TimelinePropertyGroupViewModel TimelinePropertyGroupViewModel { get; set; }
|
||||
public TimelinePropertyGroupViewModel TimelinePropertyGroupViewModel
|
||||
{
|
||||
get => _timelinePropertyGroupViewModel;
|
||||
set => SetAndNotify(ref _timelinePropertyGroupViewModel, value);
|
||||
}
|
||||
|
||||
public override List<BaseLayerPropertyKeyframe> GetKeyframes(bool expandedOnly)
|
||||
{
|
||||
|
||||
+28
-4
@@ -17,6 +17,9 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
||||
{
|
||||
public class LayerPropertyViewModel<T> : LayerPropertyViewModel
|
||||
{
|
||||
private TreePropertyViewModel<T> _treePropertyViewModel;
|
||||
private TimelinePropertyViewModel<T> _timelinePropertyViewModel;
|
||||
|
||||
public LayerPropertyViewModel(IProfileEditorService profileEditorService, LayerProperty<T> layerProperty) : base(profileEditorService, layerProperty)
|
||||
{
|
||||
LayerProperty = layerProperty;
|
||||
@@ -44,8 +47,17 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
||||
|
||||
public LayerProperty<T> LayerProperty { get; }
|
||||
|
||||
public TreePropertyViewModel<T> TreePropertyViewModel { get; set; }
|
||||
public TimelinePropertyViewModel<T> TimelinePropertyViewModel { get; set; }
|
||||
public TreePropertyViewModel<T> TreePropertyViewModel
|
||||
{
|
||||
get => _treePropertyViewModel;
|
||||
set => SetAndNotify(ref _treePropertyViewModel, value);
|
||||
}
|
||||
|
||||
public TimelinePropertyViewModel<T> TimelinePropertyViewModel
|
||||
{
|
||||
get => _timelinePropertyViewModel;
|
||||
set => SetAndNotify(ref _timelinePropertyViewModel, value);
|
||||
}
|
||||
|
||||
public override List<BaseLayerPropertyKeyframe> GetKeyframes(bool expandedOnly)
|
||||
{
|
||||
@@ -102,6 +114,9 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
||||
|
||||
public abstract class LayerPropertyViewModel : LayerPropertyBaseViewModel
|
||||
{
|
||||
private TreePropertyViewModel _treePropertyBaseViewModel;
|
||||
private TimelinePropertyViewModel _timelinePropertyBaseViewModel;
|
||||
|
||||
protected LayerPropertyViewModel(IProfileEditorService profileEditorService, BaseLayerProperty baseLayerProperty)
|
||||
{
|
||||
ProfileEditorService = profileEditorService;
|
||||
@@ -111,7 +126,16 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
||||
public IProfileEditorService ProfileEditorService { get; }
|
||||
public BaseLayerProperty BaseLayerProperty { get; }
|
||||
|
||||
public TreePropertyViewModel TreePropertyBaseViewModel { get; set; }
|
||||
public TimelinePropertyViewModel TimelinePropertyBaseViewModel { get; set; }
|
||||
public TreePropertyViewModel TreePropertyBaseViewModel
|
||||
{
|
||||
get => _treePropertyBaseViewModel;
|
||||
set => SetAndNotify(ref _treePropertyBaseViewModel, value);
|
||||
}
|
||||
|
||||
public TimelinePropertyViewModel TimelinePropertyBaseViewModel
|
||||
{
|
||||
get => _timelinePropertyBaseViewModel;
|
||||
set => SetAndNotify(ref _timelinePropertyBaseViewModel, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
+9
-14
@@ -18,12 +18,18 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
|
||||
EasingFunction = easingFunction;
|
||||
Description = easingFunction.Humanize();
|
||||
|
||||
CreateEasingPoints();
|
||||
EasingPoints = new PointCollection();
|
||||
for (var i = 1; i <= 10; i++)
|
||||
{
|
||||
var x = i;
|
||||
var y = Easings.Interpolate(i / 10.0, EasingFunction) * 10;
|
||||
EasingPoints.Add(new Point(x, y));
|
||||
}
|
||||
}
|
||||
|
||||
public Easings.Functions EasingFunction { get; }
|
||||
public PointCollection EasingPoints { get; set; }
|
||||
public string Description { get; set; }
|
||||
public PointCollection EasingPoints { get; }
|
||||
public string Description { get; }
|
||||
|
||||
public bool IsEasingModeSelected
|
||||
{
|
||||
@@ -35,16 +41,5 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
|
||||
_keyframeViewModel.SelectEasingMode(this);
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateEasingPoints()
|
||||
{
|
||||
EasingPoints = new PointCollection();
|
||||
for (var i = 1; i <= 10; i++)
|
||||
{
|
||||
var x = i;
|
||||
var y = Easings.Interpolate(i / 10.0, EasingFunction) * 10;
|
||||
EasingPoints.Add(new Point(x, y));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+26
-6
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using Artemis.Core.Models.Profile.LayerProperties;
|
||||
using Artemis.Core.Utilities;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
@@ -47,7 +46,11 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
|
||||
public abstract class TimelineKeyframeViewModel : PropertyChangedBase
|
||||
{
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private BindableCollection<TimelineEasingViewModel> _easingViewModels;
|
||||
private bool _isSelected;
|
||||
private int _pixelsPerSecond;
|
||||
private string _timestamp;
|
||||
private double _x;
|
||||
|
||||
protected TimelineKeyframeViewModel(IProfileEditorService profileEditorService, BaseLayerPropertyKeyframe baseLayerPropertyKeyframe)
|
||||
{
|
||||
@@ -57,13 +60,30 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
|
||||
}
|
||||
|
||||
public BaseLayerPropertyKeyframe BaseLayerPropertyKeyframe { get; }
|
||||
public BindableCollection<TimelineEasingViewModel> EasingViewModels { get; set; }
|
||||
|
||||
public bool IsSelected { get; set; }
|
||||
public double X { get; set; }
|
||||
public string Timestamp { get; set; }
|
||||
public BindableCollection<TimelineEasingViewModel> EasingViewModels
|
||||
{
|
||||
get => _easingViewModels;
|
||||
set => SetAndNotify(ref _easingViewModels, value);
|
||||
}
|
||||
|
||||
public UIElement ParentView { get; set; }
|
||||
public bool IsSelected
|
||||
{
|
||||
get => _isSelected;
|
||||
set => SetAndNotify(ref _isSelected, value);
|
||||
}
|
||||
|
||||
public double X
|
||||
{
|
||||
get => _x;
|
||||
set => SetAndNotify(ref _x, value);
|
||||
}
|
||||
|
||||
public string Timestamp
|
||||
{
|
||||
get => _timestamp;
|
||||
set => SetAndNotify(ref _timestamp, value);
|
||||
}
|
||||
|
||||
public void Update(int pixelsPerSecond)
|
||||
{
|
||||
|
||||
+8
-1
@@ -8,6 +8,8 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
|
||||
{
|
||||
public class TimelinePropertyGroupViewModel : PropertyChangedBase
|
||||
{
|
||||
private BindableCollection<double> _timelineKeyframeViewModels;
|
||||
|
||||
public TimelinePropertyGroupViewModel(LayerPropertyBaseViewModel layerPropertyBaseViewModel)
|
||||
{
|
||||
LayerPropertyGroupViewModel = (LayerPropertyGroupViewModel) layerPropertyBaseViewModel;
|
||||
@@ -19,7 +21,12 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
|
||||
}
|
||||
|
||||
public LayerPropertyGroupViewModel LayerPropertyGroupViewModel { get; }
|
||||
public BindableCollection<double> TimelineKeyframeViewModels { get; set; }
|
||||
|
||||
public BindableCollection<double> TimelineKeyframeViewModels
|
||||
{
|
||||
get => _timelineKeyframeViewModels;
|
||||
set => SetAndNotify(ref _timelineKeyframeViewModels, value);
|
||||
}
|
||||
|
||||
public void UpdateKeyframes()
|
||||
{
|
||||
|
||||
+8
-1
@@ -65,6 +65,8 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
|
||||
|
||||
public abstract class TimelinePropertyViewModel : PropertyChangedBase, IDisposable
|
||||
{
|
||||
private BindableCollection<TimelineKeyframeViewModel> _timelineKeyframeViewModels;
|
||||
|
||||
protected TimelinePropertyViewModel(LayerPropertyBaseViewModel layerPropertyBaseViewModel)
|
||||
{
|
||||
LayerPropertyBaseViewModel = layerPropertyBaseViewModel;
|
||||
@@ -72,7 +74,12 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
|
||||
}
|
||||
|
||||
public LayerPropertyBaseViewModel LayerPropertyBaseViewModel { get; }
|
||||
public BindableCollection<TimelineKeyframeViewModel> TimelineKeyframeViewModels { get; set; }
|
||||
|
||||
public BindableCollection<TimelineKeyframeViewModel> TimelineKeyframeViewModels
|
||||
{
|
||||
get => _timelineKeyframeViewModels;
|
||||
set => SetAndNotify(ref _timelineKeyframeViewModels, value);
|
||||
}
|
||||
|
||||
public abstract void Dispose();
|
||||
|
||||
|
||||
+22
-12
@@ -6,7 +6,6 @@ using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
using Artemis.Core.Models.Profile.LayerProperties;
|
||||
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Abstract;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
using Artemis.UI.Shared.Utilities;
|
||||
@@ -18,6 +17,8 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
|
||||
{
|
||||
private readonly LayerPropertiesViewModel _layerPropertiesViewModel;
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private RectangleGeometry _selectionRectangle;
|
||||
private double _width;
|
||||
|
||||
public TimelineViewModel(LayerPropertiesViewModel layerPropertiesViewModel, BindableCollection<LayerPropertyGroupViewModel> layerPropertyGroups,
|
||||
IProfileEditorService profileEditorService)
|
||||
@@ -32,8 +33,17 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
|
||||
|
||||
public BindableCollection<LayerPropertyGroupViewModel> LayerPropertyGroups { get; }
|
||||
|
||||
public double Width { get; set; }
|
||||
public RectangleGeometry SelectionRectangle { get; set; }
|
||||
public double Width
|
||||
{
|
||||
get => _width;
|
||||
set => SetAndNotify(ref _width, value);
|
||||
}
|
||||
|
||||
public RectangleGeometry SelectionRectangle
|
||||
{
|
||||
get => _selectionRectangle;
|
||||
set => SetAndNotify(ref _selectionRectangle, value);
|
||||
}
|
||||
|
||||
public void UpdateKeyframes()
|
||||
{
|
||||
@@ -60,7 +70,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
|
||||
if (viewModel == null)
|
||||
return;
|
||||
|
||||
((IInputElement)sender).CaptureMouse();
|
||||
((IInputElement) sender).CaptureMouse();
|
||||
if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift) && !viewModel.IsSelected)
|
||||
SelectKeyframe(viewModel, true, false);
|
||||
else if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
|
||||
@@ -76,7 +86,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
|
||||
_profileEditorService.UpdateSelectedProfileElement();
|
||||
ReleaseSelectedKeyframes();
|
||||
|
||||
((IInputElement)sender).ReleaseMouseCapture();
|
||||
((IInputElement) sender).ReleaseMouseCapture();
|
||||
}
|
||||
|
||||
public void KeyframeMouseMove(object sender, MouseEventArgs e)
|
||||
@@ -176,10 +186,10 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
|
||||
if (e.LeftButton == MouseButtonState.Released)
|
||||
return;
|
||||
|
||||
((IInputElement)sender).CaptureMouse();
|
||||
((IInputElement) sender).CaptureMouse();
|
||||
|
||||
SelectionRectangle.Rect = new Rect();
|
||||
_mouseDragStartPoint = e.GetPosition((IInputElement)sender);
|
||||
_mouseDragStartPoint = e.GetPosition((IInputElement) sender);
|
||||
_mouseDragging = true;
|
||||
e.Handled = true;
|
||||
}
|
||||
@@ -190,25 +200,25 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
|
||||
if (!_mouseDragging)
|
||||
return;
|
||||
|
||||
var position = e.GetPosition((IInputElement)sender);
|
||||
var position = e.GetPosition((IInputElement) sender);
|
||||
var selectedRect = new Rect(_mouseDragStartPoint, position);
|
||||
SelectionRectangle.Rect = selectedRect;
|
||||
|
||||
var keyframeViewModels = GetAllKeyframeViewModels();
|
||||
var selectedKeyframes = HitTestUtilities.GetHitViewModels<TimelineKeyframeViewModel>((Visual)sender, SelectionRectangle);
|
||||
var selectedKeyframes = HitTestUtilities.GetHitViewModels<TimelineKeyframeViewModel>((Visual) sender, SelectionRectangle);
|
||||
foreach (var keyframeViewModel in keyframeViewModels)
|
||||
keyframeViewModel.IsSelected = selectedKeyframes.Contains(keyframeViewModel);
|
||||
|
||||
_mouseDragging = false;
|
||||
e.Handled = true;
|
||||
((IInputElement)sender).ReleaseMouseCapture();
|
||||
((IInputElement) sender).ReleaseMouseCapture();
|
||||
}
|
||||
|
||||
public void TimelineCanvasMouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (_mouseDragging && e.LeftButton == MouseButtonState.Pressed)
|
||||
{
|
||||
var position = e.GetPosition((IInputElement)sender);
|
||||
var position = e.GetPosition((IInputElement) sender);
|
||||
var selectedRect = new Rect(_mouseDragStartPoint, position);
|
||||
SelectionRectangle.Rect = selectedRect;
|
||||
e.Handled = true;
|
||||
@@ -264,7 +274,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
|
||||
viewModels.AddRange(layerPropertyGroupViewModel.GetAllChildren());
|
||||
|
||||
var keyframes = viewModels.Where(vm => vm is LayerPropertyViewModel)
|
||||
.SelectMany(vm => ((LayerPropertyViewModel)vm).TimelinePropertyBaseViewModel.TimelineKeyframeViewModels)
|
||||
.SelectMany(vm => ((LayerPropertyViewModel) vm).TimelinePropertyBaseViewModel.TimelineKeyframeViewModels)
|
||||
.ToList();
|
||||
|
||||
return keyframes;
|
||||
|
||||
+8
-1
@@ -9,9 +9,11 @@ using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Tree
|
||||
{
|
||||
|
||||
public class TreePropertyViewModel<T> : TreePropertyViewModel
|
||||
{
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private PropertyInputViewModel<T> _propertyInputViewModel;
|
||||
|
||||
public TreePropertyViewModel(LayerPropertyBaseViewModel layerPropertyBaseViewModel, PropertyInputViewModel<T> propertyInputViewModel,
|
||||
IProfileEditorService profileEditorService) : base(layerPropertyBaseViewModel)
|
||||
@@ -22,7 +24,12 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Tree
|
||||
}
|
||||
|
||||
public LayerPropertyViewModel<T> LayerPropertyViewModel { get; }
|
||||
public PropertyInputViewModel<T> PropertyInputViewModel { get; set; }
|
||||
|
||||
public PropertyInputViewModel<T> PropertyInputViewModel
|
||||
{
|
||||
get => _propertyInputViewModel;
|
||||
set => SetAndNotify(ref _propertyInputViewModel, value);
|
||||
}
|
||||
|
||||
public bool KeyframesEnabled
|
||||
{
|
||||
|
||||
@@ -23,6 +23,11 @@ namespace Artemis.UI.Screens.Module.ProfileEditor
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private readonly IProfileService _profileService;
|
||||
private readonly ISettingsService _settingsService;
|
||||
private BindableCollection<Profile> _profiles;
|
||||
private PluginSetting<GridLength> _sidePanelsWidth;
|
||||
private PluginSetting<GridLength> _displayConditionsHeight;
|
||||
private PluginSetting<GridLength> _bottomPanelsHeight;
|
||||
private PluginSetting<GridLength> _elementPropertiesWidth;
|
||||
|
||||
public ProfileEditorViewModel(ProfileModule module,
|
||||
ICollection<ProfileEditorPanelViewModel> viewModels,
|
||||
@@ -54,12 +59,36 @@ namespace Artemis.UI.Screens.Module.ProfileEditor
|
||||
public LayerPropertiesViewModel LayerPropertiesViewModel { get; }
|
||||
public ProfileTreeViewModel ProfileTreeViewModel { get; }
|
||||
public ProfileViewModel ProfileViewModel { get; }
|
||||
public BindableCollection<Profile> Profiles { get; set; }
|
||||
|
||||
public PluginSetting<GridLength> SidePanelsWidth { get; set; }
|
||||
public PluginSetting<GridLength> DisplayConditionsHeight { get; set; }
|
||||
public PluginSetting<GridLength> BottomPanelsHeight { get; set; }
|
||||
public PluginSetting<GridLength> ElementPropertiesWidth { get; set; }
|
||||
public BindableCollection<Profile> Profiles
|
||||
{
|
||||
get => _profiles;
|
||||
set => SetAndNotify(ref _profiles, value);
|
||||
}
|
||||
|
||||
public PluginSetting<GridLength> SidePanelsWidth
|
||||
{
|
||||
get => _sidePanelsWidth;
|
||||
set => SetAndNotify(ref _sidePanelsWidth, value);
|
||||
}
|
||||
|
||||
public PluginSetting<GridLength> DisplayConditionsHeight
|
||||
{
|
||||
get => _displayConditionsHeight;
|
||||
set => SetAndNotify(ref _displayConditionsHeight, value);
|
||||
}
|
||||
|
||||
public PluginSetting<GridLength> BottomPanelsHeight
|
||||
{
|
||||
get => _bottomPanelsHeight;
|
||||
set => SetAndNotify(ref _bottomPanelsHeight, value);
|
||||
}
|
||||
|
||||
public PluginSetting<GridLength> ElementPropertiesWidth
|
||||
{
|
||||
get => _elementPropertiesWidth;
|
||||
set => SetAndNotify(ref _elementPropertiesWidth, value);
|
||||
}
|
||||
|
||||
public Profile SelectedProfile
|
||||
{
|
||||
@@ -165,6 +194,9 @@ namespace Artemis.UI.Screens.Module.ProfileEditor
|
||||
|
||||
if (_profileEditorService.SelectedProfile != profile)
|
||||
_profileEditorService.ChangeSelectedProfile(profile);
|
||||
|
||||
NotifyOfPropertyChange(nameof(SelectedProfile));
|
||||
NotifyOfPropertyChange(nameof(CanDeleteActiveProfile));
|
||||
}
|
||||
|
||||
private void ModuleOnActiveProfileChanged(object sender, EventArgs e)
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileTree
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private TreeItemViewModel _selectedTreeItem;
|
||||
private bool _updatingTree;
|
||||
private FolderViewModel _rootFolder;
|
||||
|
||||
public ProfileTreeViewModel(IProfileEditorService profileEditorService, IFolderVmFactory folderVmFactory)
|
||||
{
|
||||
@@ -26,7 +27,11 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileTree
|
||||
_profileEditorService.ProfileElementSelected += OnProfileElementSelected;
|
||||
}
|
||||
|
||||
public FolderViewModel RootFolder { get; set; }
|
||||
public FolderViewModel RootFolder
|
||||
{
|
||||
get => _rootFolder;
|
||||
set => SetAndNotify(ref _rootFolder, value);
|
||||
}
|
||||
|
||||
public TreeItemViewModel SelectedTreeItem
|
||||
{
|
||||
@@ -34,7 +39,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileTree
|
||||
set
|
||||
{
|
||||
if (_updatingTree) return;
|
||||
_selectedTreeItem = value;
|
||||
SetAndNotify(ref _selectedTreeItem, value);
|
||||
_profileEditorService.ChangeSelectedProfileElement(value?.ProfileElement);
|
||||
}
|
||||
}
|
||||
|
||||
+26
-10
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core.Models.Profile;
|
||||
@@ -20,6 +19,9 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileTree.TreeItem
|
||||
private readonly ILayerService _layerService;
|
||||
private readonly ILayerVmFactory _layerVmFactory;
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private BindableCollection<TreeItemViewModel> _children;
|
||||
private TreeItemViewModel _parent;
|
||||
private ProfileElement _profileElement;
|
||||
|
||||
protected TreeItemViewModel(TreeItemViewModel parent,
|
||||
ProfileElement profileElement,
|
||||
@@ -42,11 +44,31 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileTree.TreeItem
|
||||
UpdateProfileElements();
|
||||
}
|
||||
|
||||
public TreeItemViewModel Parent { get; set; }
|
||||
public ProfileElement ProfileElement { get; set; }
|
||||
public TreeItemViewModel Parent
|
||||
{
|
||||
get => _parent;
|
||||
set => SetAndNotify(ref _parent, value);
|
||||
}
|
||||
|
||||
public ProfileElement ProfileElement
|
||||
{
|
||||
get => _profileElement;
|
||||
set => SetAndNotify(ref _profileElement, value);
|
||||
}
|
||||
|
||||
public BindableCollection<TreeItemViewModel> Children
|
||||
{
|
||||
get => _children;
|
||||
set => SetAndNotify(ref _children, value);
|
||||
}
|
||||
|
||||
public abstract bool SupportsChildren { get; }
|
||||
public BindableCollection<TreeItemViewModel> Children { get; set; }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
public List<TreeItemViewModel> GetAllChildren()
|
||||
{
|
||||
@@ -214,11 +236,5 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileTree.TreeItem
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,20 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
{
|
||||
public abstract class CanvasViewModel : PropertyChangedBase, IDisposable
|
||||
{
|
||||
public double X { get; set; }
|
||||
public double Y { get; set; }
|
||||
private double _x;
|
||||
private double _y;
|
||||
|
||||
public double X
|
||||
{
|
||||
get => _x;
|
||||
set => SetAndNotify(ref _x, value);
|
||||
}
|
||||
|
||||
public double Y
|
||||
{
|
||||
get => _y;
|
||||
set => SetAndNotify(ref _y, value);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
|
||||
+21
-3
@@ -9,6 +9,10 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
{
|
||||
public class ProfileDeviceViewModel : CanvasViewModel
|
||||
{
|
||||
private ObservableCollection<ProfileLedViewModel> _leds;
|
||||
private ArtemisDevice _device;
|
||||
private bool _addedLeds;
|
||||
|
||||
public ProfileDeviceViewModel(ArtemisDevice device)
|
||||
{
|
||||
Device = device;
|
||||
@@ -17,9 +21,23 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
Task.Run(AddLedsAsync);
|
||||
}
|
||||
|
||||
public ObservableCollection<ProfileLedViewModel> Leds { get; set; }
|
||||
public ArtemisDevice Device { get; set; }
|
||||
public bool AddedLeds { get; private set; }
|
||||
public ObservableCollection<ProfileLedViewModel> Leds
|
||||
{
|
||||
get => _leds;
|
||||
set => SetAndNotify(ref _leds, value);
|
||||
}
|
||||
|
||||
public ArtemisDevice Device
|
||||
{
|
||||
get => _device;
|
||||
set => SetAndNotify(ref _device, value);
|
||||
}
|
||||
|
||||
public bool AddedLeds
|
||||
{
|
||||
get => _addedLeds;
|
||||
private set => SetAndNotify(ref _addedLeds, value);
|
||||
}
|
||||
|
||||
public new double X
|
||||
{
|
||||
|
||||
@@ -20,6 +20,12 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
{
|
||||
private readonly ILayerEditorService _layerEditorService;
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private Geometry _layerGeometry;
|
||||
private Geometry _opacityGeometry;
|
||||
private Geometry _shapeGeometry;
|
||||
private RenderTargetBitmap _layerGeometryBitmap;
|
||||
private Rect _viewportRectangle;
|
||||
private bool _isSelected;
|
||||
|
||||
public ProfileLayerViewModel(Layer layer, IProfileEditorService profileEditorService, ILayerEditorService layerEditorService)
|
||||
{
|
||||
@@ -36,13 +42,47 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
|
||||
public Layer Layer { get; }
|
||||
|
||||
public Geometry LayerGeometry { get; set; }
|
||||
public Geometry OpacityGeometry { get; set; }
|
||||
public Geometry ShapeGeometry { get; set; }
|
||||
public RenderTargetBitmap LayerGeometryBitmap { get; set; }
|
||||
public Rect ViewportRectangle { get; set; }
|
||||
public Geometry LayerGeometry
|
||||
{
|
||||
get => _layerGeometry;
|
||||
set => SetAndNotify(ref _layerGeometry, value);
|
||||
}
|
||||
|
||||
public Geometry OpacityGeometry
|
||||
{
|
||||
get => _opacityGeometry;
|
||||
set => SetAndNotify(ref _opacityGeometry, value);
|
||||
}
|
||||
|
||||
public Geometry ShapeGeometry
|
||||
{
|
||||
get => _shapeGeometry;
|
||||
set => SetAndNotify(ref _shapeGeometry, value);
|
||||
}
|
||||
|
||||
public RenderTargetBitmap LayerGeometryBitmap
|
||||
{
|
||||
get => _layerGeometryBitmap;
|
||||
set => SetAndNotify(ref _layerGeometryBitmap, value);
|
||||
}
|
||||
|
||||
public Rect ViewportRectangle
|
||||
{
|
||||
get => _viewportRectangle;
|
||||
set
|
||||
{
|
||||
if (!SetAndNotify(ref _viewportRectangle, value)) return;
|
||||
NotifyOfPropertyChange(nameof(LayerPosition));
|
||||
}
|
||||
}
|
||||
|
||||
public Thickness LayerPosition => new Thickness(ViewportRectangle.Left, ViewportRectangle.Top, 0, 0);
|
||||
public bool IsSelected { get; set; }
|
||||
|
||||
public bool IsSelected
|
||||
{
|
||||
get => _isSelected;
|
||||
set => SetAndNotify(ref _isSelected, value);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
@@ -56,7 +96,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
|
||||
private void Update()
|
||||
{
|
||||
IsSelected = _profileEditorService.SelectedProfileElement == Layer;
|
||||
|
||||
@@ -11,6 +11,12 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
{
|
||||
public class ProfileLedViewModel : PropertyChangedBase
|
||||
{
|
||||
private bool _isSelected;
|
||||
private bool _isDimmed;
|
||||
private Geometry _displayGeometry;
|
||||
private Geometry _strokeGeometry;
|
||||
private Color _displayColor;
|
||||
|
||||
public ProfileLedViewModel(ArtemisLed led)
|
||||
{
|
||||
Led = led;
|
||||
@@ -26,17 +32,40 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
|
||||
public ArtemisLed Led { get; }
|
||||
|
||||
public bool IsSelected { get; set; }
|
||||
public bool IsDimmed { get; set; }
|
||||
|
||||
public double X { get; }
|
||||
public double Y { get; }
|
||||
public double Width { get; }
|
||||
public double Height { get; }
|
||||
|
||||
public Geometry DisplayGeometry { get; private set; }
|
||||
public Geometry StrokeGeometry { get; private set; }
|
||||
public Color DisplayColor { get; private set; }
|
||||
public bool IsSelected
|
||||
{
|
||||
get => _isSelected;
|
||||
set => SetAndNotify(ref _isSelected, value);
|
||||
}
|
||||
|
||||
public bool IsDimmed
|
||||
{
|
||||
get => _isDimmed;
|
||||
set => SetAndNotify(ref _isDimmed, value);
|
||||
}
|
||||
|
||||
public Geometry DisplayGeometry
|
||||
{
|
||||
get => _displayGeometry;
|
||||
private set => SetAndNotify(ref _displayGeometry, value);
|
||||
}
|
||||
|
||||
public Geometry StrokeGeometry
|
||||
{
|
||||
get => _strokeGeometry;
|
||||
private set => SetAndNotify(ref _strokeGeometry, value);
|
||||
}
|
||||
|
||||
public Color DisplayColor
|
||||
{
|
||||
get => _displayColor;
|
||||
private set => SetAndNotify(ref _displayColor, value);
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
|
||||
@@ -8,14 +8,12 @@ using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Models.Surface;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.Core.Services.Storage.Interfaces;
|
||||
using Artemis.UI.Events;
|
||||
using Artemis.UI.Extensions;
|
||||
using Artemis.UI.Ninject.Factories;
|
||||
using Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools;
|
||||
using Artemis.UI.Screens.Shared;
|
||||
using Artemis.UI.Services.Interfaces;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
using Stylet;
|
||||
|
||||
@@ -23,30 +21,38 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
{
|
||||
public class ProfileViewModel : ProfileEditorPanelViewModel, IHandle<MainWindowFocusChangedEvent>, IHandle<MainWindowKeyEvent>
|
||||
{
|
||||
private readonly ILayerEditorService _layerEditorService;
|
||||
private readonly ILayerService _layerService;
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private readonly IProfileLayerVmFactory _profileLayerVmFactory;
|
||||
private readonly ISettingsService _settingsService;
|
||||
private readonly ISurfaceService _surfaceService;
|
||||
private readonly IVisualizationToolVmFactory _visualizationToolVmFactory;
|
||||
|
||||
private int _activeToolIndex;
|
||||
private VisualizationToolViewModel _activeToolViewModel;
|
||||
private bool _canApplyToLayer;
|
||||
private bool _canSelectEditTool;
|
||||
private BindableCollection<CanvasViewModel> _canvasViewModels;
|
||||
private BindableCollection<ArtemisDevice> _devices;
|
||||
private BindableCollection<ArtemisLed> _highlightedLeds;
|
||||
private PluginSetting<bool> _highlightSelectedLayer;
|
||||
private bool _isInitializing;
|
||||
private PluginSetting<bool> _onlyShowSelectedShape;
|
||||
private PanZoomViewModel _panZoomViewModel;
|
||||
private Layer _previousSelectedLayer;
|
||||
private int _previousTool;
|
||||
private BindableCollection<ArtemisLed> _selectedLeds;
|
||||
|
||||
public ProfileViewModel(IProfileEditorService profileEditorService,
|
||||
ILayerEditorService layerEditorService,
|
||||
ILayerService layerService,
|
||||
ISurfaceService surfaceService,
|
||||
ISettingsService settingsService,
|
||||
IEventAggregator eventAggregator,
|
||||
IVisualizationToolVmFactory visualizationToolVmFactory,
|
||||
IProfileLayerVmFactory profileLayerVmFactory)
|
||||
{
|
||||
_profileEditorService = profileEditorService;
|
||||
_layerEditorService = layerEditorService;
|
||||
_layerService = layerService;
|
||||
_surfaceService = surfaceService;
|
||||
_settingsService = settingsService;
|
||||
_visualizationToolVmFactory = visualizationToolVmFactory;
|
||||
_profileLayerVmFactory = profileLayerVmFactory;
|
||||
|
||||
Execute.OnUIThreadSync(() =>
|
||||
@@ -65,19 +71,59 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
eventAggregator.Subscribe(this);
|
||||
}
|
||||
|
||||
public bool IsInitializing
|
||||
{
|
||||
get => _isInitializing;
|
||||
private set => SetAndNotify(ref _isInitializing, value);
|
||||
}
|
||||
|
||||
public bool IsInitializing { get; private set; }
|
||||
public bool CanSelectEditTool { get; set; }
|
||||
public bool CanSelectEditTool
|
||||
{
|
||||
get => _canSelectEditTool;
|
||||
set => SetAndNotify(ref _canSelectEditTool, value);
|
||||
}
|
||||
|
||||
public PanZoomViewModel PanZoomViewModel { get; set; }
|
||||
public PanZoomViewModel PanZoomViewModel
|
||||
{
|
||||
get => _panZoomViewModel;
|
||||
set => SetAndNotify(ref _panZoomViewModel, value);
|
||||
}
|
||||
|
||||
public BindableCollection<CanvasViewModel> CanvasViewModels { get; set; }
|
||||
public BindableCollection<ArtemisDevice> Devices { get; set; }
|
||||
public BindableCollection<ArtemisLed> HighlightedLeds { get; set; }
|
||||
public BindableCollection<ArtemisLed> SelectedLeds { get; set; }
|
||||
public BindableCollection<CanvasViewModel> CanvasViewModels
|
||||
{
|
||||
get => _canvasViewModels;
|
||||
set => SetAndNotify(ref _canvasViewModels, value);
|
||||
}
|
||||
|
||||
public PluginSetting<bool> OnlyShowSelectedShape { get; set; }
|
||||
public PluginSetting<bool> HighlightSelectedLayer { get; set; }
|
||||
public BindableCollection<ArtemisDevice> Devices
|
||||
{
|
||||
get => _devices;
|
||||
set => SetAndNotify(ref _devices, value);
|
||||
}
|
||||
|
||||
public BindableCollection<ArtemisLed> HighlightedLeds
|
||||
{
|
||||
get => _highlightedLeds;
|
||||
set => SetAndNotify(ref _highlightedLeds, value);
|
||||
}
|
||||
|
||||
public BindableCollection<ArtemisLed> SelectedLeds
|
||||
{
|
||||
get => _selectedLeds;
|
||||
set => SetAndNotify(ref _selectedLeds, value);
|
||||
}
|
||||
|
||||
public PluginSetting<bool> OnlyShowSelectedShape
|
||||
{
|
||||
get => _onlyShowSelectedShape;
|
||||
set => SetAndNotify(ref _onlyShowSelectedShape, value);
|
||||
}
|
||||
|
||||
public PluginSetting<bool> HighlightSelectedLayer
|
||||
{
|
||||
get => _highlightSelectedLayer;
|
||||
set => SetAndNotify(ref _highlightSelectedLayer, value);
|
||||
}
|
||||
|
||||
public VisualizationToolViewModel ActiveToolViewModel
|
||||
{
|
||||
@@ -95,7 +141,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
}
|
||||
|
||||
// Set the new tool
|
||||
_activeToolViewModel = value;
|
||||
SetAndNotify(ref _activeToolViewModel, value);
|
||||
// Add the new tool to the canvas
|
||||
if (_activeToolViewModel != null)
|
||||
{
|
||||
@@ -113,15 +159,17 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
get => _activeToolIndex;
|
||||
set
|
||||
{
|
||||
if (_activeToolIndex != value)
|
||||
{
|
||||
_activeToolIndex = value;
|
||||
ActivateToolByIndex(value);
|
||||
NotifyOfPropertyChange(() => ActiveToolIndex);
|
||||
}
|
||||
if (!SetAndNotify(ref _activeToolIndex, value)) return;
|
||||
ActivateToolByIndex(value);
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanApplyToLayer
|
||||
{
|
||||
get => _canApplyToLayer;
|
||||
set => SetAndNotify(ref _canApplyToLayer, value);
|
||||
}
|
||||
|
||||
public List<ArtemisLed> GetLedsInRectangle(Rect selectedRect)
|
||||
{
|
||||
return Devices.SelectMany(d => d.Leds)
|
||||
@@ -156,7 +204,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
OnlyShowSelectedShape.Save();
|
||||
HighlightSelectedLayer.Save();
|
||||
|
||||
foreach (var canvasViewModel in CanvasViewModels)
|
||||
foreach (var canvasViewModel in CanvasViewModels)
|
||||
canvasViewModel.Dispose();
|
||||
CanvasViewModels.Clear();
|
||||
|
||||
@@ -230,16 +278,16 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
switch (value)
|
||||
{
|
||||
case 0:
|
||||
ActiveToolViewModel = new ViewpointMoveToolViewModel(this, _profileEditorService);
|
||||
ActiveToolViewModel = _visualizationToolVmFactory.ViewpointMoveToolViewModel(this);
|
||||
break;
|
||||
case 1:
|
||||
ActiveToolViewModel = new EditToolViewModel(this, _profileEditorService, _layerEditorService);
|
||||
ActiveToolViewModel = _visualizationToolVmFactory.EditToolViewModel(this);
|
||||
break;
|
||||
case 2:
|
||||
ActiveToolViewModel = new SelectionToolViewModel(this, _profileEditorService, _layerService);
|
||||
ActiveToolViewModel = _visualizationToolVmFactory.SelectionToolViewModel(this);
|
||||
break;
|
||||
case 3:
|
||||
ActiveToolViewModel = new SelectionRemoveToolViewModel(this, _profileEditorService);
|
||||
ActiveToolViewModel = _visualizationToolVmFactory.SelectionRemoveToolViewModel(this);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -282,8 +330,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
|
||||
#region Context menu actions
|
||||
|
||||
public bool CanApplyToLayer { get; set; }
|
||||
|
||||
public void CreateLayer()
|
||||
{
|
||||
}
|
||||
|
||||
+20
-3
@@ -18,6 +18,9 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
||||
private SKPoint _dragOffset;
|
||||
private SKPoint _dragStart;
|
||||
private SKPoint _topLeft;
|
||||
private SKPath _shapePath;
|
||||
private SKPoint _shapeAnchor;
|
||||
private RectangleGeometry _shapeGeometry;
|
||||
|
||||
public EditToolViewModel(ProfileViewModel profileViewModel, IProfileEditorService profileEditorService, ILayerEditorService layerEditorService)
|
||||
: base(profileViewModel, profileEditorService)
|
||||
@@ -32,9 +35,23 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
||||
profileEditorService.ProfilePreviewUpdated += (sender, args) => Update();
|
||||
}
|
||||
|
||||
public SKPath ShapePath { get; set; }
|
||||
public SKPoint ShapeAnchor { get; set; }
|
||||
public RectangleGeometry ShapeGeometry { get; set; }
|
||||
public SKPath ShapePath
|
||||
{
|
||||
get => _shapePath;
|
||||
set => SetAndNotify(ref _shapePath, value);
|
||||
}
|
||||
|
||||
public SKPoint ShapeAnchor
|
||||
{
|
||||
get => _shapeAnchor;
|
||||
set => SetAndNotify(ref _shapeAnchor, value);
|
||||
}
|
||||
|
||||
public RectangleGeometry ShapeGeometry
|
||||
{
|
||||
get => _shapeGeometry;
|
||||
set => SetAndNotify(ref _shapeGeometry, value);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
|
||||
+7
-1
@@ -10,6 +10,8 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
||||
{
|
||||
public class SelectionRemoveToolViewModel : VisualizationToolViewModel
|
||||
{
|
||||
private Rect _dragRectangle;
|
||||
|
||||
public SelectionRemoveToolViewModel(ProfileViewModel profileViewModel, IProfileEditorService profileEditorService) : base(profileViewModel, profileEditorService)
|
||||
{
|
||||
using (var stream = new MemoryStream(Resources.aero_pen_min))
|
||||
@@ -18,7 +20,11 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
||||
}
|
||||
}
|
||||
|
||||
public Rect DragRectangle { get; set; }
|
||||
public Rect DragRectangle
|
||||
{
|
||||
get => _dragRectangle;
|
||||
set => SetAndNotify(ref _dragRectangle, value);
|
||||
}
|
||||
|
||||
public override void MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
|
||||
+6
-1
@@ -12,6 +12,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
||||
public class SelectionToolViewModel : VisualizationToolViewModel
|
||||
{
|
||||
private readonly ILayerService _layerService;
|
||||
private Rect _dragRectangle;
|
||||
|
||||
public SelectionToolViewModel(ProfileViewModel profileViewModel, IProfileEditorService profileEditorService, ILayerService layerService)
|
||||
: base(profileViewModel, profileEditorService)
|
||||
@@ -23,7 +24,11 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
||||
}
|
||||
}
|
||||
|
||||
public Rect DragRectangle { get; set; }
|
||||
public Rect DragRectangle
|
||||
{
|
||||
get => _dragRectangle;
|
||||
set => SetAndNotify(ref _dragRectangle, value);
|
||||
}
|
||||
|
||||
public override void MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
|
||||
+22
-3
@@ -7,6 +7,10 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
||||
{
|
||||
public abstract class VisualizationToolViewModel : CanvasViewModel
|
||||
{
|
||||
private Cursor _cursor;
|
||||
private bool _isMouseDown;
|
||||
private Point _mouseDownStartPosition;
|
||||
|
||||
protected VisualizationToolViewModel(ProfileViewModel profileViewModel, IProfileEditorService profileEditorService)
|
||||
{
|
||||
// Not relevant for visualization tools as they overlay the entire canvas
|
||||
@@ -20,9 +24,24 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
||||
|
||||
public ProfileViewModel ProfileViewModel { get; }
|
||||
public IProfileEditorService ProfileEditorService { get; }
|
||||
public Cursor Cursor { get; protected set; }
|
||||
public bool IsMouseDown { get; protected set; }
|
||||
public Point MouseDownStartPosition { get; protected set; }
|
||||
|
||||
public Cursor Cursor
|
||||
{
|
||||
get => _cursor;
|
||||
protected set => SetAndNotify(ref _cursor, value);
|
||||
}
|
||||
|
||||
public bool IsMouseDown
|
||||
{
|
||||
get => _isMouseDown;
|
||||
protected set => SetAndNotify(ref _isMouseDown, value);
|
||||
}
|
||||
|
||||
public Point MouseDownStartPosition
|
||||
{
|
||||
get => _mouseDownStartPosition;
|
||||
protected set => SetAndNotify(ref _mouseDownStartPosition, value);
|
||||
}
|
||||
|
||||
public virtual void MouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user