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

UI - Removed Fody, begone arrogant devs!

This commit is contained in:
Robert 2020-06-30 20:41:46 +02:00
parent 8e01d1f63e
commit 2c2b0ca3e1
49 changed files with 1011 additions and 232 deletions

View File

@ -89,6 +89,9 @@ namespace Artemis.Core.Services.Storage
public void ActivateProfile(ProfileModule module, Profile profile)
{
if (module.ActiveProfile == profile)
return;
module.ChangeActiveProfile(profile, _surfaceService.ActiveSurface);
if (profile != null)
{

View File

@ -128,10 +128,6 @@
<ItemGroup>
<PackageReference Include="Castle.Core" Version="4.4.1" />
<PackageReference Include="FluentValidation" Version="8.6.2" />
<PackageReference Include="Fody" Version="6.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="gong-wpf-dragdrop" Version="2.2.0" />
<PackageReference Include="Hardcodet.NotifyIcon.Wpf.NetCore" Version="1.0.11" />
<PackageReference Include="Humanizer.Core" Version="2.8.26" />
@ -141,7 +137,6 @@
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.19" />
<PackageReference Include="Ninject" Version="3.3.4" />
<PackageReference Include="Ninject.Extensions.Conventions" Version="3.3.0" />
<PackageReference Include="PropertyChanged.Fody" Version="3.2.8" />
<PackageReference Include="Serilog" Version="2.9.0" />
<PackageReference Include="SkiaSharp.Views.WPF" Version="1.68.3" />
<PackageReference Include="Stylet" Version="1.3.2" />

View File

@ -9,6 +9,10 @@ namespace Artemis.UI.DataModelVisualization
{
public class DataModelListViewModel : DataModelVisualizationViewModel
{
private BindableCollection<DataModelVisualizationViewModel> _children;
private IList _list;
private string _count;
public DataModelListViewModel(PropertyInfo propertyInfo, DataModelPropertyAttribute propertyDescription, DataModelVisualizationViewModel parent)
{
PropertyInfo = propertyInfo;
@ -17,9 +21,23 @@ namespace Artemis.UI.DataModelVisualization
Children = new BindableCollection<DataModelVisualizationViewModel>();
}
public BindableCollection<DataModelVisualizationViewModel> Children { get; set; }
public IList List { get; set; }
public string Count { get; set; }
public BindableCollection<DataModelVisualizationViewModel> Children
{
get => _children;
set => SetAndNotify(ref _children, value);
}
public IList List
{
get => _list;
set => SetAndNotify(ref _list, value);
}
public string Count
{
get => _count;
set => SetAndNotify(ref _count, value);
}
public override void Update()
{

View File

@ -7,6 +7,8 @@ namespace Artemis.UI.DataModelVisualization
{
public class DataModelViewModel : DataModelVisualizationViewModel
{
private BindableCollection<DataModelVisualizationViewModel> _children;
public DataModelViewModel()
{
Children = new BindableCollection<DataModelVisualizationViewModel>();
@ -23,7 +25,11 @@ namespace Artemis.UI.DataModelVisualization
PopulateProperties();
}
public BindableCollection<DataModelVisualizationViewModel> Children { get; set; }
public BindableCollection<DataModelVisualizationViewModel> Children
{
get => _children;
set => SetAndNotify(ref _children, value);
}
public void PopulateProperties()
{

View File

@ -10,15 +10,55 @@ namespace Artemis.UI.DataModelVisualization
{
public abstract class DataModelVisualizationViewModel : PropertyChangedBase
{
public DataModelPropertyAttribute PropertyDescription { get; protected set; }
public PropertyInfo PropertyInfo { get; protected set; }
public Type PropertyType { get; set; }
private DataModelPropertyAttribute _propertyDescription;
private PropertyInfo _propertyInfo;
private Type _propertyType;
private DataModelVisualizationViewModel _parent;
private object _model;
private bool _isListProperty;
private string _listDescription;
public DataModelVisualizationViewModel Parent { get; protected set; }
public object Model { get; set; }
public DataModelPropertyAttribute PropertyDescription
{
get => _propertyDescription;
protected set => SetAndNotify(ref _propertyDescription, value);
}
public bool IsListProperty { get; set; }
public string ListDescription { get; set; }
public PropertyInfo PropertyInfo
{
get => _propertyInfo;
protected set => SetAndNotify(ref _propertyInfo, value);
}
public Type PropertyType
{
get => _propertyType;
set => SetAndNotify(ref _propertyType, value);
}
public DataModelVisualizationViewModel Parent
{
get => _parent;
protected set => SetAndNotify(ref _parent, value);
}
public object Model
{
get => _model;
set => SetAndNotify(ref _model, value);
}
public bool IsListProperty
{
get => _isListProperty;
set => SetAndNotify(ref _isListProperty, value);
}
public string ListDescription
{
get => _listDescription;
set => SetAndNotify(ref _listDescription, value);
}
public abstract void Update();

View File

@ -11,6 +11,7 @@ using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline;
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Tree;
using Artemis.UI.Screens.Module.ProfileEditor.ProfileTree.TreeItem;
using Artemis.UI.Screens.Module.ProfileEditor.Visualization;
using Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools;
using Artemis.UI.Screens.Settings.Debug;
using Artemis.UI.Screens.Settings.Tabs.Devices;
using Artemis.UI.Screens.Settings.Tabs.Plugins;
@ -63,6 +64,14 @@ namespace Artemis.UI.Ninject.Factories
ProfileLayerViewModel Create(Layer layer);
}
public interface IVisualizationToolVmFactory : IVmFactory
{
ViewpointMoveToolViewModel ViewpointMoveToolViewModel(ProfileViewModel profileViewModel);
EditToolViewModel EditToolViewModel(ProfileViewModel profileViewModel);
SelectionToolViewModel SelectionToolViewModel(ProfileViewModel profileViewModel);
SelectionRemoveToolViewModel SelectionRemoveToolViewModel(ProfileViewModel profileViewModel);
}
public interface ILayerPropertyVmFactory : IVmFactory
{
LayerPropertyGroupViewModel LayerPropertyGroupViewModel(LayerPropertyGroup layerPropertyGroup, PropertyGroupDescriptionAttribute propertyGroupDescription);

View File

@ -15,6 +15,7 @@ namespace Artemis.UI.PropertyInput
{
private readonly ILayerService _layerService;
private readonly IPluginService _pluginService;
private List<LayerBrushDescriptor> _descriptors;
public BrushPropertyInputViewModel(LayerProperty<LayerBrushReference> layerProperty, IProfileEditorService profileEditorService,
ILayerService layerService, IPluginService pluginService) : base(layerProperty, profileEditorService)
@ -27,7 +28,11 @@ namespace Artemis.UI.PropertyInput
UpdateEnumValues();
}
public List<LayerBrushDescriptor> Descriptors { get; set; }
public List<LayerBrushDescriptor> Descriptors
{
get => _descriptors;
set => SetAndNotify(ref _descriptors, value);
}
public LayerBrushDescriptor SelectedDescriptor
{

View File

@ -18,14 +18,12 @@ namespace Artemis.UI.PropertyInput
}
// Since SKSize is immutable we need to create properties that replace the SKSize entirely
// [DependsOn(nameof(InputValue))]
public float Width
{
get => InputValue.Width;
set => InputValue = new SKSize(value, Height);
}
// [DependsOn(nameof(InputValue))]
public float Height
{
get => InputValue.Height;

View File

@ -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()
{

View File

@ -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()
{

View File

@ -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);

View File

@ -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>();

View File

@ -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++)
{

View File

@ -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)
{

View File

@ -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);
}
}
}

View File

@ -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));
}
}
}
}

View File

@ -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)
{

View File

@ -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()
{

View File

@ -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();

View File

@ -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;

View File

@ -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
{

View File

@ -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)

View File

@ -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);
}
}

View File

@ -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);
}
}
}

View File

@ -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)
{

View File

@ -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
{

View File

@ -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;

View File

@ -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()
{

View File

@ -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()
{
}

View File

@ -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()
{

View File

@ -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)
{

View File

@ -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)
{

View File

@ -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)
{

View File

@ -24,11 +24,13 @@ namespace Artemis.UI.Screens
private readonly ICoreService _coreService;
private readonly IDebugService _debugService;
private readonly IEventAggregator _eventAggregator;
private readonly ISettingsService _settingsService;
private readonly ThemeWatcher _themeWatcher;
private readonly Timer _titleUpdateTimer;
private readonly PluginSetting<WindowSize> _windowSize;
private bool _lostFocus;
private bool _isSidebarVisible;
private bool _activeItemReady;
private string _windowTitle;
public RootViewModel(IEventAggregator eventAggregator, SidebarViewModel sidebarViewModel, ISettingsService settingsService, ICoreService coreService,
IDebugService debugService, ISnackbarMessageQueue snackbarMessageQueue)
@ -36,7 +38,6 @@ namespace Artemis.UI.Screens
SidebarViewModel = sidebarViewModel;
MainMessageQueue = snackbarMessageQueue;
_eventAggregator = eventAggregator;
_settingsService = settingsService;
_coreService = coreService;
_debugService = debugService;
@ -55,10 +56,25 @@ namespace Artemis.UI.Screens
}
public SidebarViewModel SidebarViewModel { get; }
public ISnackbarMessageQueue MainMessageQueue { get; set; }
public bool IsSidebarVisible { get; set; }
public bool ActiveItemReady { get; set; }
public string WindowTitle { get; set; }
public ISnackbarMessageQueue MainMessageQueue { get; }
public bool IsSidebarVisible
{
get => _isSidebarVisible;
set => SetAndNotify(ref _isSidebarVisible, value);
}
public bool ActiveItemReady
{
get => _activeItemReady;
set => SetAndNotify(ref _activeItemReady, value);
}
public string WindowTitle
{
get => _windowTitle;
set => SetAndNotify(ref _windowTitle, value);
}
public void WindowDeactivated()
{

View File

@ -14,6 +14,7 @@ namespace Artemis.UI.Screens.Settings.Debug
{
private readonly IDeviceService _deviceService;
private readonly IDialogService _dialogService;
private ArtemisLed _selectedLed;
public DeviceDebugViewModel(ArtemisDevice device, IDeviceService deviceService, IDialogService dialogService)
{
@ -22,11 +23,18 @@ namespace Artemis.UI.Screens.Settings.Debug
Device = device;
}
// [DependsOn(nameof(SelectedLed))]
public List<ArtemisLed> SelectedLeds => SelectedLed != null ? new List<ArtemisLed> {SelectedLed} : null;
public ArtemisDevice Device { get; }
public ArtemisLed SelectedLed { get; set; }
public ArtemisLed SelectedLed
{
get => _selectedLed;
set
{
if (!SetAndNotify(ref _selectedLed, value)) return;
NotifyOfPropertyChange(nameof(SelectedLeds));
}
}
public bool CanOpenImageDirectory => Device.RgbDevice.DeviceInfo.Image != null;

View File

@ -16,6 +16,9 @@ namespace Artemis.UI.Screens.Settings.Debug.Tabs
private readonly Timer _updateTimer;
private bool _isModuleFilterEnabled;
private Core.Plugins.Abstract.Module _selectedModule;
private DataModelViewModel _mainDataModel;
private string _propertySearch;
private List<Core.Plugins.Abstract.Module> _modules;
public DataModelDebugViewModel(IDataModelVisualizationService dataModelVisualizationService, IPluginService pluginService)
{
@ -27,17 +30,30 @@ namespace Artemis.UI.Screens.Settings.Debug.Tabs
DisplayName = "Data model";
}
public DataModelViewModel MainDataModel { get; set; }
public DataModelViewModel MainDataModel
{
get => _mainDataModel;
set => SetAndNotify(ref _mainDataModel, value);
}
public string PropertySearch { get; set; }
public List<Core.Plugins.Abstract.Module> Modules { get; set; }
public string PropertySearch
{
get => _propertySearch;
set => SetAndNotify(ref _propertySearch, value);
}
public List<Core.Plugins.Abstract.Module> Modules
{
get => _modules;
set => SetAndNotify(ref _modules, value);
}
public Core.Plugins.Abstract.Module SelectedModule
{
get => _selectedModule;
set
{
_selectedModule = value;
if (!SetAndNotify(ref _selectedModule, value)) return;
GetDataModel();
}
}
@ -47,8 +63,8 @@ namespace Artemis.UI.Screens.Settings.Debug.Tabs
get => _isModuleFilterEnabled;
set
{
_isModuleFilterEnabled = value;
SetAndNotify(ref _isModuleFilterEnabled, value);
if (!IsModuleFilterEnabled)
SelectedModule = null;
else
@ -75,8 +91,8 @@ namespace Artemis.UI.Screens.Settings.Debug.Tabs
private void GetDataModel()
{
MainDataModel = SelectedModule != null
? _dataModelVisualizationService.GetPluginDataModelVisualization(SelectedModule)
MainDataModel = SelectedModule != null
? _dataModelVisualizationService.GetPluginDataModelVisualization(SelectedModule)
: _dataModelVisualizationService.GetMainDataModelVisualization();
}

View File

@ -4,7 +4,6 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using Artemis.Core.Events;
using Artemis.Core.Services.Interfaces;
using Artemis.Core.Services.Storage.Interfaces;
using SkiaSharp;
using SkiaSharp.Views.WPF;
using Stylet;
@ -14,20 +13,26 @@ namespace Artemis.UI.Screens.Settings.Debug.Tabs
public class RenderDebugViewModel : Screen
{
private readonly ICoreService _coreService;
private readonly IRgbService _rgbService;
private readonly ISurfaceService _surfaceService;
private double _currentFps;
private ImageSource _currentFrame;
public RenderDebugViewModel(ICoreService coreService, IRgbService rgbService, ISurfaceService surfaceService)
public RenderDebugViewModel(ICoreService coreService)
{
_coreService = coreService;
_rgbService = rgbService;
_surfaceService = surfaceService;
DisplayName = "Rendering";
}
public ImageSource CurrentFrame { get; set; }
public double CurrentFps { get; set; }
public ImageSource CurrentFrame
{
get => _currentFrame;
set => SetAndNotify(ref _currentFrame, value);
}
public double CurrentFps
{
get => _currentFps;
set => SetAndNotify(ref _currentFps, value);
}
protected override void OnActivate()
{
@ -47,7 +52,7 @@ namespace Artemis.UI.Screens.Settings.Debug.Tabs
{
Execute.PostToUIThread(() =>
{
if (e.BitmapBrush?.Bitmap == null)
if (e.BitmapBrush?.Bitmap == null || e.BitmapBrush.Bitmap.Pixels.Length == 0)
return;
if (!(CurrentFrame is WriteableBitmap writeableBitmap))

View File

@ -29,6 +29,11 @@ namespace Artemis.UI.Screens.Settings
private readonly ISettingsService _settingsService;
private readonly IPluginSettingsVmFactory _pluginSettingsVmFactory;
private readonly ISurfaceService _surfaceService;
private List<Tuple<string, int>> _targetFrameRates;
private List<Tuple<string, double>> _renderScales;
private List<int> _sampleSizes;
private BindableCollection<DeviceSettingsViewModel> _deviceSettingsViewModels;
private BindableCollection<PluginSettingsViewModel> _plugins;
public SettingsViewModel(ISurfaceService surfaceService, IPluginService pluginService, IDialogService dialogService, IDebugService debugService,
ISettingsService settingsService, IPluginSettingsVmFactory pluginSettingsVmFactory, IDeviceSettingsVmFactory deviceSettingsVmFactory)
@ -60,15 +65,39 @@ namespace Artemis.UI.Screens.Settings
SampleSizes = new List<int> {1, 9};
}
public List<Tuple<string, int>> TargetFrameRates { get; set; }
public List<Tuple<string, double>> RenderScales { get; set; }
public List<Tuple<string, int>> TargetFrameRates
{
get => _targetFrameRates;
set => SetAndNotify(ref _targetFrameRates, value);
}
public List<Tuple<string, double>> RenderScales
{
get => _renderScales;
set => SetAndNotify(ref _renderScales, value);
}
public List<int> SampleSizes
{
get => _sampleSizes;
set => SetAndNotify(ref _sampleSizes, value);
}
public BindableCollection<DeviceSettingsViewModel> DeviceSettingsViewModels
{
get => _deviceSettingsViewModels;
set => SetAndNotify(ref _deviceSettingsViewModels, value);
}
public BindableCollection<PluginSettingsViewModel> Plugins
{
get => _plugins;
set => SetAndNotify(ref _plugins, value);
}
public IEnumerable<ValueDescription> LogLevels { get; }
public IEnumerable<ValueDescription> ColorSchemes { get; }
public List<int> SampleSizes { get; set; }
public BindableCollection<DeviceSettingsViewModel> DeviceSettingsViewModels { get; set; }
public BindableCollection<PluginSettingsViewModel> Plugins { get; set; }
public bool StartWithWindows
{
get => _settingsService.GetSetting("UI.AutoRun", false).Value;

View File

@ -10,14 +10,15 @@ using Stylet;
namespace Artemis.UI.Screens.Settings.Tabs.Devices
{
public class DeviceSettingsViewModel
public class DeviceSettingsViewModel : PropertyChangedBase
{
private readonly IDeviceService _deviceService;
private readonly IDialogService _dialogService;
private readonly IWindowManager _windowManager;
private readonly IDeviceDebugVmFactory _deviceDebugVmFactory;
private bool _isDeviceEnabled;
public DeviceSettingsViewModel(ArtemisDevice device, IDeviceService deviceService, IDialogService dialogService,
public DeviceSettingsViewModel(ArtemisDevice device, IDeviceService deviceService, IDialogService dialogService,
IWindowManager windowManager, IDeviceDebugVmFactory deviceDebugVmFactory)
{
_deviceService = deviceService;
@ -29,15 +30,22 @@ namespace Artemis.UI.Screens.Settings.Tabs.Devices
Type = Device.RgbDevice.DeviceInfo.DeviceType.ToString().Humanize();
Name = Device.RgbDevice.DeviceInfo.Model;
Manufacturer = Device.RgbDevice.DeviceInfo.Manufacturer;
// TODO: Implement this bad boy
IsDeviceEnabled = true;
}
public ArtemisDevice Device { get; }
public string Type { get; set; }
public string Name { get; set; }
public string Manufacturer { get; set; }
public bool IsDeviceEnabled { get; set; }
public string Type { get; }
public string Name { get; }
public string Manufacturer { get; }
public bool IsDeviceEnabled
{
get => _isDeviceEnabled;
set => SetAndNotify(ref _isDeviceEnabled, value);
}
public void IdentifyDevice()
{

View File

@ -17,6 +17,9 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
private readonly IPluginService _pluginService;
private readonly ISnackbarMessageQueue _snackbarMessageQueue;
private readonly IWindowManager _windowManager;
private Plugin _plugin;
private PluginInfo _pluginInfo;
private bool _enabling;
public PluginSettingsViewModel(Plugin plugin, IWindowManager windowManager, IDialogService dialogService, IPluginService pluginService,
ISnackbarMessageQueue snackbarMessageQueue)
@ -30,9 +33,24 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
_snackbarMessageQueue = snackbarMessageQueue;
}
public Plugin Plugin { get; set; }
public PluginInfo PluginInfo { get; set; }
public bool Enabling { get; set; }
public Plugin Plugin
{
get => _plugin;
set => SetAndNotify(ref _plugin, value);
}
public PluginInfo PluginInfo
{
get => _pluginInfo;
set => SetAndNotify(ref _pluginInfo, value);
}
public bool Enabling
{
get => _enabling;
set => SetAndNotify(ref _enabling, value);
}
public PackIconKind Icon => GetIconKind();
public string Type => Plugin.GetType().BaseType?.Name ?? Plugin.GetType().Name;
public bool CanOpenSettings => IsEnabled && Plugin.HasConfigurationViewModel;

View File

@ -12,8 +12,29 @@ namespace Artemis.UI.Screens.Shared
{
public class PanZoomViewModel : PropertyChangedBase
{
public Point? LastPanPosition { get; set; }
public double Zoom { get; set; } = 1;
private Point? _lastPanPosition;
private double _zoom = 1;
private double _panX;
private double _panY;
private double _canvasWidth;
private double _canvasHeight;
private bool _limitToZero;
public Point? LastPanPosition
{
get => _lastPanPosition;
set => SetAndNotify(ref _lastPanPosition, value);
}
public double Zoom
{
get => _zoom;
set
{
if (!SetAndNotify(ref _zoom, value)) return;
NotifyOfPropertyChange(nameof(ZoomPercentage));
}
}
public double ZoomPercentage
{
@ -21,11 +42,43 @@ namespace Artemis.UI.Screens.Shared
set => SetZoomFromPercentage(value);
}
public double PanX { get; set; }
public double PanY { get; set; }
public double CanvasWidth { get; set; }
public double CanvasHeight { get; set; }
public bool LimitToZero { get; set; }
public double PanX
{
get => _panX;
set
{
if (!SetAndNotify(ref _panX, value)) return;
NotifyOfPropertyChange(nameof(BackgroundViewport));
}
}
public double PanY
{
get => _panY;
set
{
if (!SetAndNotify(ref _panY, value)) return;
NotifyOfPropertyChange(nameof(BackgroundViewport));
}
}
public double CanvasWidth
{
get => _canvasWidth;
set => SetAndNotify(ref _canvasWidth, value);
}
public double CanvasHeight
{
get => _canvasHeight;
set => SetAndNotify(ref _canvasHeight, value);
}
public bool LimitToZero
{
get => _limitToZero;
set => SetAndNotify(ref _limitToZero, value);
}
public Rect BackgroundViewport => new Rect(PanX, PanY, 20, 20);

View File

@ -24,6 +24,9 @@ namespace Artemis.UI.Screens.Sidebar
private readonly IKernel _kernel;
private readonly IModuleVmFactory _moduleVmFactory;
private readonly IPluginService _pluginService;
private BindableCollection<INavigationItem> _sidebarItems;
private Dictionary<INavigationItem, Core.Plugins.Abstract.Module> _sidebarModules;
private IScreen _selectedItem;
public SidebarViewModel(IKernel kernel, IEventAggregator eventAggregator, IModuleVmFactory moduleVmFactory, IPluginService pluginService)
{
@ -41,9 +44,23 @@ namespace Artemis.UI.Screens.Sidebar
eventAggregator.Subscribe(this);
}
public BindableCollection<INavigationItem> SidebarItems { get; set; }
public Dictionary<INavigationItem, Core.Plugins.Abstract.Module> SidebarModules { get; set; }
public IScreen SelectedItem { get; set; }
public BindableCollection<INavigationItem> SidebarItems
{
get => _sidebarItems;
set => SetAndNotify(ref _sidebarItems, value);
}
public Dictionary<INavigationItem, Core.Plugins.Abstract.Module> SidebarModules
{
get => _sidebarModules;
set => SetAndNotify(ref _sidebarModules, value);
}
public IScreen SelectedItem
{
get => _selectedItem;
set => SetAndNotify(ref _selectedItem, value);
}
public void SetupSidebar()
{

View File

@ -11,6 +11,7 @@ namespace Artemis.UI.Screens.Splash
{
private readonly ICoreService _coreService;
private readonly IPluginService _pluginService;
private string _status;
public SplashViewModel(ICoreService coreService, IPluginService pluginService)
{
@ -19,7 +20,11 @@ namespace Artemis.UI.Screens.Splash
Status = "Initializing Core";
}
public string Status { get; set; }
public string Status
{
get => _status;
set => SetAndNotify(ref _status, value);
}
// ReSharper disable once UnusedMember.Global - Called from view
public void MouseDown(object sender, MouseButtonEventArgs e)

View File

@ -6,11 +6,17 @@ namespace Artemis.UI.Screens.SurfaceEditor.Dialogs
{
public class SurfaceCreateViewModel : DialogViewModelBase
{
private string _surfaceName;
public SurfaceCreateViewModel(IModelValidator<SurfaceCreateViewModel> validator) : base(validator)
{
}
public string SurfaceName { get; set; }
public string SurfaceName
{
get => _surfaceName;
set => SetAndNotify(ref _surfaceName, value);
}
public async Task Accept()
{

View File

@ -9,6 +9,11 @@ namespace Artemis.UI.Screens.SurfaceEditor.Dialogs
public class SurfaceDeviceConfigViewModel : DialogViewModelBase
{
private readonly ICoreService _coreService;
private string _title;
private int _x;
private int _y;
private double _scale;
private int _rotation;
public SurfaceDeviceConfigViewModel(SurfaceDeviceViewModel surfaceDeviceViewModel, ICoreService coreService, IModelValidator<SurfaceDeviceConfigViewModel> validator)
: base(validator)
@ -24,12 +29,36 @@ namespace Artemis.UI.Screens.SurfaceEditor.Dialogs
}
public SurfaceDeviceViewModel SurfaceDeviceViewModel { get; }
public string Title { get; set; }
public int X { get; set; }
public int Y { get; set; }
public double Scale { get; set; }
public int Rotation { get; set; }
public string Title
{
get => _title;
set => SetAndNotify(ref _title, value);
}
public int X
{
get => _x;
set => SetAndNotify(ref _x, value);
}
public int Y
{
get => _y;
set => SetAndNotify(ref _y, value);
}
public double Scale
{
get => _scale;
set => SetAndNotify(ref _scale, value);
}
public int Rotation
{
get => _rotation;
set => SetAndNotify(ref _rotation, value);
}
public async Task Accept()
{

View File

@ -27,6 +27,13 @@ namespace Artemis.UI.Screens.SurfaceEditor
private readonly IRgbService _rgbService;
private readonly ISettingsService _settingsService;
private readonly ISurfaceService _surfaceService;
private ArtemisSurface _selectedSurface;
private ObservableCollection<SurfaceDeviceViewModel> _devices;
private ObservableCollection<ArtemisSurface> _surfaceConfigurations;
private RectangleGeometry _selectionRectangle;
private PanZoomViewModel _panZoomViewModel;
private PluginSetting<GridLength> _surfaceListWidth;
private Cursor _cursor;
public SurfaceEditorViewModel(IRgbService rgbService, ISurfaceService surfaceService, IDialogService dialogService, ISettingsService settingsService,
IDeviceService deviceService)
@ -46,12 +53,41 @@ namespace Artemis.UI.Screens.SurfaceEditor
_deviceService = deviceService;
}
public ObservableCollection<SurfaceDeviceViewModel> Devices { get; set; }
public ObservableCollection<ArtemisSurface> SurfaceConfigurations { get; set; }
public RectangleGeometry SelectionRectangle { get; set; }
public PanZoomViewModel PanZoomViewModel { get; set; }
public PluginSetting<GridLength> SurfaceListWidth { get; set; }
public Cursor Cursor { get; set; }
public ObservableCollection<SurfaceDeviceViewModel> Devices
{
get => _devices;
set => SetAndNotify(ref _devices, value);
}
public ObservableCollection<ArtemisSurface> SurfaceConfigurations
{
get => _surfaceConfigurations;
set => SetAndNotify(ref _surfaceConfigurations, value);
}
public RectangleGeometry SelectionRectangle
{
get => _selectionRectangle;
set => SetAndNotify(ref _selectionRectangle, value);
}
public PanZoomViewModel PanZoomViewModel
{
get => _panZoomViewModel;
set => SetAndNotify(ref _panZoomViewModel, value);
}
public PluginSetting<GridLength> SurfaceListWidth
{
get => _surfaceListWidth;
set => SetAndNotify(ref _surfaceListWidth, value);
}
public Cursor Cursor
{
get => _cursor;
set => SetAndNotify(ref _cursor, value);
}
public ArtemisSurface SelectedSurface
{
@ -61,7 +97,7 @@ namespace Artemis.UI.Screens.SurfaceEditor
if (value == null)
return;
_selectedSurface = value;
SetAndNotify(ref _selectedSurface, value);
ApplySelectedSurfaceConfiguration();
}
}
@ -260,7 +296,6 @@ namespace Artemis.UI.Screens.SurfaceEditor
private MouseDragStatus _mouseDragStatus;
private Point _mouseDragStartPoint;
private ArtemisSurface _selectedSurface;
// ReSharper disable once UnusedMember.Global - Called from view
public void EditorGridMouseClick(object sender, MouseButtonEventArgs e)

View File

@ -10,15 +10,36 @@ namespace Artemis.UI.Screens.SurfaceEditor.Visualization
{
private double _dragOffsetX;
private double _dragOffsetY;
private ArtemisDevice _device;
private SelectionStatus _selectionStatus;
private Cursor _cursor;
public SurfaceDeviceViewModel(ArtemisDevice device)
{
Device = device;
}
public ArtemisDevice Device { get; set; }
public SelectionStatus SelectionStatus { get; set; }
public Cursor Cursor { get; set; }
public ArtemisDevice Device
{
get => _device;
set
{
if (SetAndNotify(ref _device, value)) return;
NotifyOfPropertyChange(nameof(DeviceRectangle));
}
}
public SelectionStatus SelectionStatus
{
get => _selectionStatus;
set => SetAndNotify(ref _selectionStatus, value);
}
public Cursor Cursor
{
get => _cursor;
set => SetAndNotify(ref _cursor, value);
}
public Rect DeviceRectangle => Device.RgbDevice == null
? new Rect()

View File

@ -17,6 +17,7 @@ namespace Artemis.UI.Screens
private readonly IWindowManager _windowManager;
private bool _setGradientPickerService;
private SplashViewModel _splashViewModel;
private bool _canShowRootViewModel;
public TrayViewModel(IKernel kernel, IWindowManager windowManager, IEventAggregator eventAggregator, ICoreService coreService, ISettingsService settingsService)
{
@ -34,7 +35,11 @@ namespace Artemis.UI.Screens
}
}
public bool CanShowRootViewModel { get; set; }
public bool CanShowRootViewModel
{
get => _canShowRootViewModel;
set => SetAndNotify(ref _canShowRootViewModel, value);
}
public void TrayBringToForeground()
{

View File

@ -4,13 +4,25 @@ namespace Artemis.UI.Screens.Workshop
{
public class WorkshopViewModel : MainScreenViewModel
{
private Color _testColor;
private bool _testPopupOpen;
public WorkshopViewModel()
{
DisplayName = "Workshop";
}
public Color TestColor { get; set; }
public bool TestPopupOpen { get; set; }
public Color TestColor
{
get => _testColor;
set => SetAndNotify(ref _testColor, value);
}
public bool TestPopupOpen
{
get => _testPopupOpen;
set => SetAndNotify(ref _testPopupOpen, value);
}
public void UpdateValues()
{