mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Project cleanup
This commit is contained in:
parent
73115898de
commit
6f95c609b6
@ -77,6 +77,11 @@ namespace Artemis.Core.Models.Profile
|
||||
return layer;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"[Folder] {nameof(Name)}: {Name}, {nameof(Order)}: {Order}";
|
||||
}
|
||||
|
||||
internal override void ApplyToEntity()
|
||||
{
|
||||
FolderEntity.Id = EntityId;
|
||||
@ -89,10 +94,5 @@ namespace Artemis.Core.Models.Profile
|
||||
|
||||
// TODO: conditions
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"[Folder] {nameof(Name)}: {Name}, {nameof(Order)}: {Order}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -11,9 +11,6 @@ using Artemis.Core.Models.Surface;
|
||||
using Artemis.Core.Plugins.LayerBrush;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Storage.Entities.Profile;
|
||||
using Newtonsoft.Json;
|
||||
using Ninject;
|
||||
using Ninject.Parameters;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Core.Models.Profile
|
||||
@ -147,6 +144,11 @@ namespace Artemis.Core.Models.Profile
|
||||
/// </summary>
|
||||
public LayerBrush LayerBrush { get; internal set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"[Layer] {nameof(Name)}: {Name}, {nameof(Order)}: {Order}";
|
||||
}
|
||||
|
||||
#region Storage
|
||||
|
||||
internal override void ApplyToEntity()
|
||||
@ -178,6 +180,35 @@ namespace Artemis.Core.Models.Profile
|
||||
|
||||
#endregion
|
||||
|
||||
#region Shape management
|
||||
|
||||
private void ApplyShapeType()
|
||||
{
|
||||
switch (ShapeTypeProperty.CurrentValue)
|
||||
{
|
||||
case LayerShapeType.Ellipse:
|
||||
LayerShape = new Ellipse(this);
|
||||
break;
|
||||
case LayerShapeType.Rectangle:
|
||||
LayerShape = new Rectangle(this);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void OnLayerPropertyRegistered(LayerPropertyEventArgs e)
|
||||
{
|
||||
LayerPropertyRegistered?.Invoke(this, e);
|
||||
}
|
||||
|
||||
private void OnLayerPropertyRemoved(LayerPropertyEventArgs e)
|
||||
{
|
||||
LayerPropertyRemoved?.Invoke(this, e);
|
||||
}
|
||||
|
||||
#region Rendering
|
||||
|
||||
public override void Update(double deltaTime)
|
||||
@ -277,7 +308,7 @@ namespace Artemis.Core.Models.Profile
|
||||
renderPath.AddRect(Path.Bounds);
|
||||
LayerBrush?.Render(canvas, renderPath, paint);
|
||||
}
|
||||
|
||||
|
||||
internal void CalculateRenderProperties()
|
||||
{
|
||||
if (!Leds.Any())
|
||||
@ -378,25 +409,6 @@ namespace Artemis.Core.Models.Profile
|
||||
|
||||
#endregion
|
||||
|
||||
#region Shape management
|
||||
|
||||
private void ApplyShapeType()
|
||||
{
|
||||
switch (ShapeTypeProperty.CurrentValue)
|
||||
{
|
||||
case LayerShapeType.Ellipse:
|
||||
LayerShape = new Ellipse(this);
|
||||
break;
|
||||
case LayerShapeType.Rectangle:
|
||||
LayerShape = new Rectangle(this);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
@ -534,21 +546,6 @@ namespace Artemis.Core.Models.Profile
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"[Layer] {nameof(Name)}: {Name}, {nameof(Order)}: {Order}";
|
||||
}
|
||||
|
||||
private void OnLayerPropertyRegistered(LayerPropertyEventArgs e)
|
||||
{
|
||||
LayerPropertyRegistered?.Invoke(this, e);
|
||||
}
|
||||
|
||||
private void OnLayerPropertyRemoved(LayerPropertyEventArgs e)
|
||||
{
|
||||
LayerPropertyRemoved?.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
public enum LayerShapeType
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using Artemis.Storage.Entities.Profile;
|
||||
using SkiaSharp;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Core.Models.Profile.LayerShapes
|
||||
{
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using Artemis.Storage.Entities.Profile;
|
||||
using SkiaSharp;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Core.Models.Profile.LayerShapes
|
||||
{
|
||||
|
||||
@ -74,6 +74,27 @@ namespace Artemis.Core.Models.Profile
|
||||
return (Folder) Children.Single();
|
||||
}
|
||||
|
||||
public void ApplyToProfile()
|
||||
{
|
||||
Name = ProfileEntity.Name;
|
||||
|
||||
lock (_children)
|
||||
{
|
||||
_children.Clear();
|
||||
// Populate the profile starting at the root, the rest is populated recursively
|
||||
var rootFolder = ProfileEntity.Folders.FirstOrDefault(f => f.ParentId == new Guid());
|
||||
if (rootFolder == null)
|
||||
AddChild(new Folder(this, null, "Root folder"));
|
||||
else
|
||||
AddChild(new Folder(this, null, rootFolder));
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"[Profile] {nameof(Name)}: {Name}, {nameof(IsActivated)}: {IsActivated}, {nameof(PluginInfo)}: {PluginInfo}";
|
||||
}
|
||||
|
||||
internal override void ApplyToEntity()
|
||||
{
|
||||
ProfileEntity.Id = EntityId;
|
||||
@ -91,22 +112,6 @@ namespace Artemis.Core.Models.Profile
|
||||
ProfileEntity.Layers.AddRange(GetAllLayers().Select(f => f.LayerEntity));
|
||||
}
|
||||
|
||||
public void ApplyToProfile()
|
||||
{
|
||||
Name = ProfileEntity.Name;
|
||||
|
||||
lock (_children)
|
||||
{
|
||||
_children.Clear();
|
||||
// Populate the profile starting at the root, the rest is populated recursively
|
||||
var rootFolder = ProfileEntity.Folders.FirstOrDefault(f => f.ParentId == new Guid());
|
||||
if (rootFolder == null)
|
||||
AddChild(new Folder(this, null, "Root folder"));
|
||||
else
|
||||
AddChild(new Folder(this, null, rootFolder));
|
||||
}
|
||||
}
|
||||
|
||||
internal void Activate(ArtemisSurface surface)
|
||||
{
|
||||
lock (this)
|
||||
@ -137,11 +142,6 @@ namespace Artemis.Core.Models.Profile
|
||||
layer.PopulateLeds(surface);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"[Profile] {nameof(Name)}: {Name}, {nameof(IsActivated)}: {IsActivated}, {nameof(PluginInfo)}: {PluginInfo}";
|
||||
}
|
||||
|
||||
#region Events
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -46,11 +46,6 @@ namespace Artemis.Core.Models.Profile
|
||||
/// </summary>
|
||||
public abstract void Render(double deltaTime, SKCanvas canvas);
|
||||
|
||||
/// <summary>
|
||||
/// Applies the profile element's properties to the underlying storage entity
|
||||
/// </summary>
|
||||
internal abstract void ApplyToEntity();
|
||||
|
||||
public List<Folder> GetAllFolders()
|
||||
{
|
||||
var folders = new List<Folder>();
|
||||
@ -131,5 +126,10 @@ namespace Artemis.Core.Models.Profile
|
||||
child.Parent = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Applies the profile element's properties to the underlying storage entity
|
||||
/// </summary>
|
||||
internal abstract void ApplyToEntity();
|
||||
}
|
||||
}
|
||||
@ -76,6 +76,18 @@ namespace Artemis.Core.Models.Surface
|
||||
set => DeviceEntity.ZIndex = value;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"[{RgbDevice.DeviceInfo.DeviceType}] {RgbDevice.DeviceInfo.DeviceName} - {X}.{Y}.{ZIndex}";
|
||||
}
|
||||
|
||||
public event EventHandler DeviceUpdated;
|
||||
|
||||
protected virtual void OnDeviceUpdated()
|
||||
{
|
||||
DeviceUpdated?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
internal void ApplyToEntity()
|
||||
{
|
||||
// Other properties are computed
|
||||
@ -113,17 +125,5 @@ namespace Artemis.Core.Models.Surface
|
||||
|
||||
RenderPath = path;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"[{RgbDevice.DeviceInfo.DeviceType}] {RgbDevice.DeviceInfo.DeviceName} - {X}.{Y}.{ZIndex}";
|
||||
}
|
||||
|
||||
public event EventHandler DeviceUpdated;
|
||||
|
||||
protected virtual void OnDeviceUpdated()
|
||||
{
|
||||
DeviceUpdated?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -48,6 +48,15 @@ namespace Artemis.Core.Models.Surface
|
||||
internal SurfaceEntity SurfaceEntity { get; set; }
|
||||
internal Guid EntityId { get; set; }
|
||||
|
||||
public void UpdateScale(double value)
|
||||
{
|
||||
Scale = value;
|
||||
foreach (var device in Devices)
|
||||
device.CalculateRenderProperties();
|
||||
|
||||
OnScaleChanged();
|
||||
}
|
||||
|
||||
internal void ApplyToEntity()
|
||||
{
|
||||
SurfaceEntity.Id = EntityId;
|
||||
@ -62,15 +71,6 @@ namespace Artemis.Core.Models.Surface
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateScale(double value)
|
||||
{
|
||||
Scale = value;
|
||||
foreach (var device in Devices)
|
||||
device.CalculateRenderProperties();
|
||||
|
||||
OnScaleChanged();
|
||||
}
|
||||
|
||||
#region Events
|
||||
|
||||
public event EventHandler<EventArgs> ScaleChanged;
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Models.Profile.LayerProperties;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using SkiaSharp;
|
||||
|
||||
|
||||
@ -78,14 +78,14 @@ namespace Artemis.Core.Plugins.Models
|
||||
|
||||
public event EventHandler<EventArgs> SettingChanged;
|
||||
|
||||
protected virtual void OnSettingChanged()
|
||||
{
|
||||
SettingChanged?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{nameof(Name)}: {Name}, {nameof(Value)}: {Value}, {nameof(HasChanged)}: {HasChanged}";
|
||||
}
|
||||
|
||||
protected virtual void OnSettingChanged()
|
||||
{
|
||||
SettingChanged?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -55,6 +55,16 @@ namespace Artemis.Core.Services
|
||||
|
||||
public bool IsInitialized { get; set; }
|
||||
|
||||
protected virtual void OnFrameRendering(FrameRenderingEventArgs e)
|
||||
{
|
||||
FrameRendering?.Invoke(this, e);
|
||||
}
|
||||
|
||||
protected virtual void OnFrameRendered(FrameRenderedEventArgs e)
|
||||
{
|
||||
FrameRendered?.Invoke(this, e);
|
||||
}
|
||||
|
||||
private void ConfigureJsonConvert()
|
||||
{
|
||||
JsonConvert.DefaultSettings = () => new JsonSerializerSettings
|
||||
@ -136,16 +146,6 @@ namespace Artemis.Core.Services
|
||||
OnFrameRendered(new FrameRenderedEventArgs(_rgbService.BitmapBrush, _rgbService.Surface));
|
||||
}
|
||||
|
||||
protected virtual void OnFrameRendering(FrameRenderingEventArgs e)
|
||||
{
|
||||
FrameRendering?.Invoke(this, e);
|
||||
}
|
||||
|
||||
protected virtual void OnFrameRendered(FrameRenderedEventArgs e)
|
||||
{
|
||||
FrameRendered?.Invoke(this, e);
|
||||
}
|
||||
|
||||
#region Events
|
||||
|
||||
public event EventHandler Initialized;
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.Storage.Repositories.Interfaces;
|
||||
|
||||
|
||||
@ -38,6 +38,24 @@ namespace Artemis.Plugins.LayerBrushes.Color
|
||||
public LayerProperty<SKColor> ColorProperty { get; set; }
|
||||
public LayerProperty<GradientType> GradientTypeProperty { get; set; }
|
||||
|
||||
public override void Update(double deltaTime)
|
||||
{
|
||||
// Only recreate the shader if the color changed
|
||||
if (_color != ColorProperty.CurrentValue)
|
||||
{
|
||||
_color = ColorProperty.CurrentValue;
|
||||
CreateShader();
|
||||
}
|
||||
|
||||
base.Update(deltaTime);
|
||||
}
|
||||
|
||||
public override void Render(SKCanvas canvas, SKPath path, SKPaint paint)
|
||||
{
|
||||
paint.Shader = _shader;
|
||||
canvas.DrawPath(path, paint);
|
||||
}
|
||||
|
||||
private void CreateShader()
|
||||
{
|
||||
var center = new SKPoint(Layer.Bounds.MidX, Layer.Bounds.MidY);
|
||||
@ -67,24 +85,6 @@ namespace Artemis.Plugins.LayerBrushes.Color
|
||||
oldShader?.Dispose();
|
||||
oldPaint?.Dispose();
|
||||
}
|
||||
|
||||
public override void Update(double deltaTime)
|
||||
{
|
||||
// Only recreate the shader if the color changed
|
||||
if (_color != ColorProperty.CurrentValue)
|
||||
{
|
||||
_color = ColorProperty.CurrentValue;
|
||||
CreateShader();
|
||||
}
|
||||
|
||||
base.Update(deltaTime);
|
||||
}
|
||||
|
||||
public override void Render(SKCanvas canvas, SKPath path, SKPaint paint)
|
||||
{
|
||||
paint.Shader = _shader;
|
||||
canvas.DrawPath(path, paint);
|
||||
}
|
||||
}
|
||||
|
||||
public enum GradientType
|
||||
|
||||
@ -23,7 +23,7 @@ namespace Artemis.Plugins.LayerBrushes.Noise
|
||||
_z = Rand.Next(0, 4096);
|
||||
_noise = new OpenSimplexNoise(Rand.Next(0, 4096));
|
||||
}
|
||||
|
||||
|
||||
public LayerProperty<SKColor> MainColorProperty { get; set; }
|
||||
public LayerProperty<SKSize> ScaleProperty { get; set; }
|
||||
public LayerProperty<float> AnimationSpeedProperty { get; set; }
|
||||
|
||||
@ -268,13 +268,6 @@ namespace Artemis.Plugins.LayerBrushes.Noise.Utilities
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static int FastFloor(double x)
|
||||
{
|
||||
var xi = (int) x;
|
||||
return x < xi ? xi - 1 : xi;
|
||||
}
|
||||
|
||||
public double Evaluate(double x, double y)
|
||||
{
|
||||
var stretchOffset = (x + y) * STRETCH_2D;
|
||||
@ -454,6 +447,13 @@ namespace Artemis.Plugins.LayerBrushes.Noise.Utilities
|
||||
return value * NORM_4D;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static int FastFloor(double x)
|
||||
{
|
||||
var xi = (int) x;
|
||||
return x < xi ? xi - 1 : xi;
|
||||
}
|
||||
|
||||
private class Contribution2
|
||||
{
|
||||
public readonly double dx;
|
||||
|
||||
@ -101,9 +101,9 @@
|
||||
HorizontalAlignment="Stretch" />
|
||||
|
||||
<Border Width="15"
|
||||
Height="15"
|
||||
Height="15"
|
||||
CornerRadius="15"
|
||||
Margin="0,0,0,2"
|
||||
Margin="0,0,0,2"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Right"
|
||||
Background="{StaticResource Checkerboard}">
|
||||
|
||||
@ -63,6 +63,11 @@ namespace Artemis.UI.Shared
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
private static void ColorPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var colorPicker = (ColorPicker) d;
|
||||
@ -109,10 +114,5 @@ namespace Artemis.UI.Shared
|
||||
{
|
||||
PopupOpen = !PopupOpen;
|
||||
}
|
||||
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<packages>
|
||||
<package id="Humanizer.Core" version="2.7.9" targetFramework="net472" />
|
||||
<package id="MaterialDesignColors" version="1.2.0" targetFramework="net472" />
|
||||
|
||||
@ -56,6 +56,31 @@ namespace Artemis.UI.Behaviors
|
||||
set => SetValue(ExpandSelectedProperty, value);
|
||||
}
|
||||
|
||||
protected override void OnAttached()
|
||||
{
|
||||
base.OnAttached();
|
||||
|
||||
AssociatedObject.SelectedItemChanged += OnTreeViewSelectedItemChanged;
|
||||
((INotifyCollectionChanged) AssociatedObject.Items).CollectionChanged += OnTreeViewItemsChanged;
|
||||
|
||||
UpdateTreeViewItemStyle();
|
||||
_modelHandled = true;
|
||||
UpdateAllTreeViewItems();
|
||||
_modelHandled = false;
|
||||
}
|
||||
|
||||
protected override void OnDetaching()
|
||||
{
|
||||
base.OnDetaching();
|
||||
|
||||
if (AssociatedObject != null)
|
||||
{
|
||||
AssociatedObject.ItemContainerStyle?.Setters?.Remove(_treeViewItemEventSetter);
|
||||
AssociatedObject.SelectedItemChanged -= OnTreeViewSelectedItemChanged;
|
||||
((INotifyCollectionChanged) AssociatedObject.Items).CollectionChanged -= OnTreeViewItemsChanged;
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnSelectedItemChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
|
||||
{
|
||||
var behavior = (TreeViewSelectionBehavior) sender;
|
||||
@ -145,30 +170,5 @@ namespace Artemis.UI.Behaviors
|
||||
{
|
||||
UpdateTreeViewItem((TreeViewItem) sender, false);
|
||||
}
|
||||
|
||||
protected override void OnAttached()
|
||||
{
|
||||
base.OnAttached();
|
||||
|
||||
AssociatedObject.SelectedItemChanged += OnTreeViewSelectedItemChanged;
|
||||
((INotifyCollectionChanged) AssociatedObject.Items).CollectionChanged += OnTreeViewItemsChanged;
|
||||
|
||||
UpdateTreeViewItemStyle();
|
||||
_modelHandled = true;
|
||||
UpdateAllTreeViewItems();
|
||||
_modelHandled = false;
|
||||
}
|
||||
|
||||
protected override void OnDetaching()
|
||||
{
|
||||
base.OnDetaching();
|
||||
|
||||
if (AssociatedObject != null)
|
||||
{
|
||||
AssociatedObject.ItemContainerStyle?.Setters?.Remove(_treeViewItemEventSetter);
|
||||
AssociatedObject.SelectedItemChanged -= OnTreeViewSelectedItemChanged;
|
||||
((INotifyCollectionChanged) AssociatedObject.Items).CollectionChanged -= OnTreeViewItemsChanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -64,15 +64,6 @@ namespace Artemis.UI
|
||||
});
|
||||
}
|
||||
|
||||
private void ShowMainWindow(IWindowManager windowManager, SplashViewModel splashViewModel)
|
||||
{
|
||||
Execute.OnUIThread(() =>
|
||||
{
|
||||
windowManager.ShowWindow(RootViewModel);
|
||||
splashViewModel.RequestClose();
|
||||
});
|
||||
}
|
||||
|
||||
protected override void ConfigureIoC(IKernel kernel)
|
||||
{
|
||||
kernel.Settings.InjectNonPublic = true;
|
||||
@ -91,5 +82,14 @@ namespace Artemis.UI
|
||||
|
||||
base.OnUnhandledException(e);
|
||||
}
|
||||
|
||||
private void ShowMainWindow(IWindowManager windowManager, SplashViewModel splashViewModel)
|
||||
{
|
||||
Execute.OnUIThread(() =>
|
||||
{
|
||||
windowManager.ShowWindow(RootViewModel);
|
||||
splashViewModel.RequestClose();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -20,10 +20,10 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
||||
public class LayerPropertiesViewModel : ProfileEditorPanelViewModel
|
||||
{
|
||||
private readonly ICoreService _coreService;
|
||||
private readonly List<LayerPropertyViewModel> _layerPropertyViewModels;
|
||||
private readonly ILayerPropertyVmFactory _layerPropertyVmFactory;
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private readonly ISettingsService _settingsService;
|
||||
private readonly List<LayerPropertyViewModel> _layerPropertyViewModels;
|
||||
|
||||
public LayerPropertiesViewModel(IProfileEditorService profileEditorService,
|
||||
ICoreService coreService,
|
||||
@ -71,18 +71,18 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
||||
public PropertyTreeViewModel PropertyTree { get; set; }
|
||||
public PropertyTimelineViewModel PropertyTimeline { get; set; }
|
||||
|
||||
private void ProfileEditorServiceOnCurrentTimeChanged(object sender, EventArgs e)
|
||||
{
|
||||
NotifyOfPropertyChange(() => FormattedCurrentTime);
|
||||
NotifyOfPropertyChange(() => TimeCaretPosition);
|
||||
}
|
||||
|
||||
protected override void OnDeactivate()
|
||||
{
|
||||
Pause();
|
||||
base.OnDeactivate();
|
||||
}
|
||||
|
||||
private void ProfileEditorServiceOnCurrentTimeChanged(object sender, EventArgs e)
|
||||
{
|
||||
NotifyOfPropertyChange(() => FormattedCurrentTime);
|
||||
NotifyOfPropertyChange(() => TimeCaretPosition);
|
||||
}
|
||||
|
||||
#region View model managament
|
||||
|
||||
private void PopulateProperties(ProfileElement profileElement, ProfileElement previousProfileElement)
|
||||
@ -92,6 +92,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
||||
previousLayer.LayerPropertyRegistered -= LayerOnPropertyRegistered;
|
||||
previousLayer.LayerPropertyRemoved -= LayerOnPropertyRemoved;
|
||||
}
|
||||
|
||||
if (profileElement is Layer layer)
|
||||
{
|
||||
// Create VMs for missing properties
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Artemis.Core.Models.Profile.LayerProperties;
|
||||
using Artemis.UI.Ninject.Factories;
|
||||
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput;
|
||||
using Artemis.UI.Services.Interfaces;
|
||||
using Ninject;
|
||||
@ -47,21 +46,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateKeyframes()
|
||||
{
|
||||
// Either create a new first keyframe or clear all the keyframes
|
||||
if (_keyframesEnabled)
|
||||
LayerProperty.CreateNewKeyframe(_profileEditorService.CurrentTime, LayerProperty.GetCurrentValue());
|
||||
else
|
||||
LayerProperty.ClearKeyframes();
|
||||
|
||||
// Force the keyframe engine to update, the new keyframe is the current keyframe
|
||||
LayerProperty.IsUsingKeyframes = _keyframesEnabled;
|
||||
LayerProperty.KeyframeEngine?.Update(0);
|
||||
|
||||
_profileEditorService.UpdateSelectedProfileElement();
|
||||
}
|
||||
|
||||
public PropertyInputViewModel GetPropertyInputViewModel()
|
||||
{
|
||||
// If the type is an enum type, search for Enum instead.
|
||||
@ -76,5 +60,20 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
||||
match.Initialize(this);
|
||||
return match;
|
||||
}
|
||||
|
||||
private void UpdateKeyframes()
|
||||
{
|
||||
// Either create a new first keyframe or clear all the keyframes
|
||||
if (_keyframesEnabled)
|
||||
LayerProperty.CreateNewKeyframe(_profileEditorService.CurrentTime, LayerProperty.GetCurrentValue());
|
||||
else
|
||||
LayerProperty.ClearKeyframes();
|
||||
|
||||
// Force the keyframe engine to update, the new keyframe is the current keyframe
|
||||
LayerProperty.IsUsingKeyframes = _keyframesEnabled;
|
||||
LayerProperty.KeyframeEngine?.Update(0);
|
||||
|
||||
_profileEditorService.UpdateSelectedProfileElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,12 +1,12 @@
|
||||
<UserControl x:Class="Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput.BrushPropertyInputView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
mc:Ignorable="d"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Margin="0 0 5 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputPrefix}" />
|
||||
@ -19,10 +19,9 @@
|
||||
ItemsSource="{Binding Path=EnumValues}"
|
||||
SelectedValuePath="Value"
|
||||
DisplayMemberPath="Description"
|
||||
SelectedValue="{Binding Path=BrushInputValue}"
|
||||
SelectedValue="{Binding Path=BrushInputValue}"
|
||||
RequestBringIntoView="{s:Action OnRequestBringIntoView}"
|
||||
materialDesign:ComboBoxAssist.ClassicMode="True">
|
||||
</ComboBox>
|
||||
materialDesign:ComboBoxAssist.ClassicMode="True" />
|
||||
<TextBlock Margin="5 0 0 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" />
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
</UserControl>
|
||||
@ -1,22 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for BrushPropertyInputView.xaml
|
||||
/// Interaction logic for BrushPropertyInputView.xaml
|
||||
/// </summary>
|
||||
public partial class BrushPropertyInputView : UserControl
|
||||
{
|
||||
@ -25,4 +12,4 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -38,12 +38,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
UpdateEnumValues();
|
||||
base.OnInitialized();
|
||||
}
|
||||
|
||||
public void UpdateEnumValues()
|
||||
{
|
||||
var layerBrushProviders = _pluginService.GetPluginsOfType<LayerBrushProvider>();
|
||||
@ -64,5 +58,11 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
|
||||
{
|
||||
NotifyOfPropertyChange(() => BrushInputValue);
|
||||
}
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
UpdateEnumValues();
|
||||
base.OnInitialized();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -20,10 +20,9 @@
|
||||
ItemsSource="{Binding Path=EnumValues}"
|
||||
SelectedValuePath="Value"
|
||||
DisplayMemberPath="Description"
|
||||
SelectedValue="{Binding Path=EnumInputValue}"
|
||||
SelectedValue="{Binding Path=EnumInputValue}"
|
||||
RequestBringIntoView="{s:Action OnRequestBringIntoView}"
|
||||
materialDesign:ComboBoxAssist.ClassicMode="True">
|
||||
</ComboBox>
|
||||
materialDesign:ComboBoxAssist.ClassicMode="True" />
|
||||
<TextBlock Margin="5 0 0 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" />
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
@ -1,22 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for EnumPropertyInputView.xaml
|
||||
/// Interaction logic for EnumPropertyInputView.xaml
|
||||
/// </summary>
|
||||
public partial class EnumPropertyInputView : UserControl
|
||||
{
|
||||
@ -25,4 +12,4 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -22,14 +22,14 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
|
||||
set => InputValue = value;
|
||||
}
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
EnumValues = EnumUtilities.GetAllValuesAndDescriptions(LayerPropertyViewModel.LayerProperty.Type);
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
NotifyOfPropertyChange(() => EnumInputValue);
|
||||
}
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
EnumValues = EnumUtilities.GetAllValuesAndDescriptions(LayerPropertyViewModel.LayerProperty.Type);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -17,7 +17,7 @@
|
||||
materialDesign:ValidationAssist.UsePopup="True"
|
||||
HorizontalAlignment="Left"
|
||||
Text="{Binding FloatInputValue}"
|
||||
RequestBringIntoView="{s:Action OnRequestBringIntoView}"/>
|
||||
RequestBringIntoView="{s:Action OnRequestBringIntoView}" />
|
||||
<TextBlock Margin="5 0 0 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" />
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
@ -16,8 +16,8 @@
|
||||
Padding="0 -1"
|
||||
materialDesign:ValidationAssist.UsePopup="True"
|
||||
HorizontalAlignment="Left"
|
||||
Text="{Binding IntInputValue}"
|
||||
RequestBringIntoView="{s:Action OnRequestBringIntoView}"/>
|
||||
Text="{Binding IntInputValue}"
|
||||
RequestBringIntoView="{s:Action OnRequestBringIntoView}" />
|
||||
<TextBlock Margin="5 0 0 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" />
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
@ -47,7 +47,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called by the view, prevents scrolling into view when scrubbing through the timeline
|
||||
/// Called by the view, prevents scrolling into view when scrubbing through the timeline
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
@ -56,6 +56,12 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
public abstract void Update();
|
||||
|
||||
protected virtual void OnInitialized()
|
||||
{
|
||||
}
|
||||
|
||||
private void UpdateInputValue(object value)
|
||||
{
|
||||
LayerPropertyViewModel.LayerProperty.SetCurrentValue(value, ProfileEditorService.CurrentTime);
|
||||
@ -64,11 +70,5 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
|
||||
|
||||
ProfileEditorService.UpdateSelectedProfileElement();
|
||||
}
|
||||
|
||||
protected virtual void OnInitialized()
|
||||
{
|
||||
}
|
||||
|
||||
public abstract void Update();
|
||||
}
|
||||
}
|
||||
@ -1,22 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for SKColorPropertyInputView.xaml
|
||||
/// Interaction logic for SKColorPropertyInputView.xaml
|
||||
/// </summary>
|
||||
public partial class SKColorPropertyInputView : UserControl
|
||||
{
|
||||
@ -25,4 +12,4 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -18,7 +18,7 @@
|
||||
HorizontalAlignment="Left"
|
||||
ToolTip="X-coordinate (horizontal)"
|
||||
Text="{Binding X}"
|
||||
RequestBringIntoView="{s:Action OnRequestBringIntoView}"/>
|
||||
RequestBringIntoView="{s:Action OnRequestBringIntoView}" />
|
||||
<TextBlock Margin="5 0" VerticalAlignment="Bottom">,</TextBlock>
|
||||
<TextBox Width="60"
|
||||
Margin="0 2"
|
||||
@ -26,8 +26,8 @@
|
||||
materialDesign:ValidationAssist.UsePopup="True"
|
||||
HorizontalAlignment="Left"
|
||||
ToolTip="Y-coordinate (vertical)"
|
||||
Text="{Binding Y}"
|
||||
RequestBringIntoView="{s:Action OnRequestBringIntoView}"/>
|
||||
Text="{Binding Y}"
|
||||
RequestBringIntoView="{s:Action OnRequestBringIntoView}" />
|
||||
<TextBlock Margin="5 0 0 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" />
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
@ -18,7 +18,7 @@
|
||||
HorizontalAlignment="Left"
|
||||
ToolTip="Height"
|
||||
Text="{Binding Height}"
|
||||
RequestBringIntoView="{s:Action OnRequestBringIntoView}"/>
|
||||
RequestBringIntoView="{s:Action OnRequestBringIntoView}" />
|
||||
<TextBlock Margin="5 0" VerticalAlignment="Bottom">,</TextBlock>
|
||||
<TextBox Width="60"
|
||||
Margin="0 2"
|
||||
@ -27,7 +27,7 @@
|
||||
HorizontalAlignment="Left"
|
||||
ToolTip="Width"
|
||||
Text="{Binding Width}"
|
||||
RequestBringIntoView="{s:Action OnRequestBringIntoView}"/>
|
||||
RequestBringIntoView="{s:Action OnRequestBringIntoView}" />
|
||||
<TextBlock Margin="5 0 0 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" />
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
@ -4,13 +4,13 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree
|
||||
{
|
||||
public abstract class PropertyTreeItemViewModel : PropertyChangedBase
|
||||
{
|
||||
public LayerPropertyViewModel LayerPropertyViewModel { get; }
|
||||
|
||||
protected PropertyTreeItemViewModel(LayerPropertyViewModel layerPropertyViewModel)
|
||||
{
|
||||
LayerPropertyViewModel = layerPropertyViewModel;
|
||||
}
|
||||
|
||||
public LayerPropertyViewModel LayerPropertyViewModel { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Updates the tree item's input if it is visible and has keyframes enabled
|
||||
/// </summary>
|
||||
@ -18,16 +18,15 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree
|
||||
public abstract void Update(bool forceUpdate);
|
||||
|
||||
/// <summary>
|
||||
/// Removes the layer property recursively
|
||||
/// Removes the layer property recursively
|
||||
/// </summary>
|
||||
/// <param name="layerPropertyViewModel"></param>
|
||||
public abstract void RemoveLayerProperty(LayerPropertyViewModel layerPropertyViewModel);
|
||||
|
||||
/// <summary>
|
||||
/// Adds the layer property recursively
|
||||
/// Adds the layer property recursively
|
||||
/// </summary>
|
||||
/// <param name="layerPropertyViewModel"></param>
|
||||
public abstract void AddLayerProperty(LayerPropertyViewModel layerPropertyViewModel);
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,4 @@
|
||||
using System.Linq;
|
||||
using Artemis.Core.Events;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Artemis.Core.Models.Profile.LayerProperties;
|
||||
using Artemis.UI.Ninject.Factories;
|
||||
using Artemis.UI.Services.Interfaces;
|
||||
using Stylet;
|
||||
@ -70,13 +69,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
|
||||
PropertyTrackViewModels.Remove(vm);
|
||||
}
|
||||
|
||||
private void CreateViewModels(LayerPropertyViewModel property)
|
||||
{
|
||||
PropertyTrackViewModels.Add(_propertyTrackVmFactory.Create(this, property));
|
||||
foreach (var child in property.Children)
|
||||
CreateViewModels(child);
|
||||
}
|
||||
|
||||
public void UpdateKeyframePositions()
|
||||
{
|
||||
foreach (var viewModel in PropertyTrackViewModels)
|
||||
@ -95,5 +87,12 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
|
||||
|
||||
UpdateEndTime();
|
||||
}
|
||||
|
||||
private void CreateViewModels(LayerPropertyViewModel property)
|
||||
{
|
||||
PropertyTrackViewModels.Add(_propertyTrackVmFactory.Create(this, property));
|
||||
foreach (var child in property.Children)
|
||||
CreateViewModels(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,4 @@
|
||||
using System.Linq;
|
||||
using Artemis.Core.Events;
|
||||
using Artemis.UI.Ninject.Factories;
|
||||
using Stylet;
|
||||
|
||||
@ -9,7 +8,8 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
|
||||
{
|
||||
private readonly IPropertyTrackKeyframeVmFactory _propertyTrackKeyframeVmFactory;
|
||||
|
||||
public PropertyTrackViewModel(PropertyTimelineViewModel propertyTimelineViewModel, LayerPropertyViewModel layerPropertyViewModel, IPropertyTrackKeyframeVmFactory propertyTrackKeyframeVmFactory)
|
||||
public PropertyTrackViewModel(PropertyTimelineViewModel propertyTimelineViewModel, LayerPropertyViewModel layerPropertyViewModel,
|
||||
IPropertyTrackKeyframeVmFactory propertyTrackKeyframeVmFactory)
|
||||
{
|
||||
_propertyTrackKeyframeVmFactory = propertyTrackKeyframeVmFactory;
|
||||
PropertyTimelineViewModel = propertyTimelineViewModel;
|
||||
|
||||
@ -71,22 +71,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor
|
||||
|
||||
public bool CanDeleteActiveProfile => SelectedProfile != null && Profiles.Count > 1;
|
||||
|
||||
private void ChangeSelectedProfile(Profile profile)
|
||||
{
|
||||
if (profile == Module.ActiveProfile)
|
||||
return;
|
||||
|
||||
var oldProfile = Module.ActiveProfile;
|
||||
_profileService.ActivateProfile(Module, profile);
|
||||
|
||||
if (oldProfile != null)
|
||||
_profileService.UpdateProfile(oldProfile, false);
|
||||
if (profile != null)
|
||||
_profileService.UpdateProfile(profile, false);
|
||||
|
||||
_profileEditorService.ChangeSelectedProfile(profile);
|
||||
}
|
||||
|
||||
public Profile CreateProfile(string name)
|
||||
{
|
||||
var profile = _profileService.CreateProfile(Module, name);
|
||||
@ -135,14 +119,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor
|
||||
_profileEditorService.RedoUpdateProfile(Module);
|
||||
}
|
||||
|
||||
private void ModuleOnActiveProfileChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (SelectedProfile == Module.ActiveProfile)
|
||||
return;
|
||||
|
||||
SelectedProfile = Profiles.FirstOrDefault(p => p == Module.ActiveProfile);
|
||||
}
|
||||
|
||||
protected override void OnActivate()
|
||||
{
|
||||
LoadWorkspaceSettings();
|
||||
@ -158,6 +134,30 @@ namespace Artemis.UI.Screens.Module.ProfileEditor
|
||||
base.OnDeactivate();
|
||||
}
|
||||
|
||||
private void ChangeSelectedProfile(Profile profile)
|
||||
{
|
||||
if (profile == Module.ActiveProfile)
|
||||
return;
|
||||
|
||||
var oldProfile = Module.ActiveProfile;
|
||||
_profileService.ActivateProfile(Module, profile);
|
||||
|
||||
if (oldProfile != null)
|
||||
_profileService.UpdateProfile(oldProfile, false);
|
||||
if (profile != null)
|
||||
_profileService.UpdateProfile(profile, false);
|
||||
|
||||
_profileEditorService.ChangeSelectedProfile(profile);
|
||||
}
|
||||
|
||||
private void ModuleOnActiveProfileChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (SelectedProfile == Module.ActiveProfile)
|
||||
return;
|
||||
|
||||
SelectedProfile = Profiles.FirstOrDefault(p => p == Module.ActiveProfile);
|
||||
}
|
||||
|
||||
private void LoadWorkspaceSettings()
|
||||
{
|
||||
SidePanelsWidth = _settingsService.GetSetting("ProfileEditor.SidePanelsWidth", new GridLength(385));
|
||||
|
||||
@ -44,6 +44,18 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
? new Rect()
|
||||
: new Rect(X, Y, Device.RgbDevice.Size.Width, Device.RgbDevice.Size.Height);
|
||||
|
||||
/// <summary>
|
||||
/// Update the color of all LEDs if finished adding
|
||||
/// </summary>
|
||||
public void Update()
|
||||
{
|
||||
if (!AddedLeds)
|
||||
return;
|
||||
|
||||
foreach (var ledViewModel in Leds)
|
||||
ledViewModel.Update();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds LEDs in batches of 5 to avoid UI freezes
|
||||
/// </summary>
|
||||
@ -62,17 +74,5 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
|
||||
AddedLeds = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the color of all LEDs if finished adding
|
||||
/// </summary>
|
||||
public void Update()
|
||||
{
|
||||
if (!AddedLeds)
|
||||
return;
|
||||
|
||||
foreach (var ledViewModel in Leds)
|
||||
ledViewModel.Update();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -30,7 +30,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
_profileEditorService.SelectedProfileElementUpdated += OnSelectedProfileElementUpdated;
|
||||
_profileEditorService.ProfilePreviewUpdated += ProfileEditorServiceOnProfilePreviewUpdated;
|
||||
}
|
||||
|
||||
|
||||
public Layer Layer { get; }
|
||||
|
||||
public Geometry LayerGeometry { get; set; }
|
||||
@ -39,6 +39,14 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
public Rect ViewportRectangle { get; set; }
|
||||
public bool IsSelected { get; set; }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Layer.RenderPropertiesUpdated -= LayerOnRenderPropertiesUpdated;
|
||||
_profileEditorService.SelectedProfileElementChanged -= OnSelectedProfileElementChanged;
|
||||
_profileEditorService.SelectedProfileElementUpdated -= OnSelectedProfileElementUpdated;
|
||||
_profileEditorService.ProfilePreviewUpdated -= ProfileEditorServiceOnProfilePreviewUpdated;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
IsSelected = _profileEditorService.SelectedProfileElement == Layer;
|
||||
@ -86,7 +94,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
|
||||
var layerGeometry = group.GetOutlinedPathGeometry();
|
||||
var opacityGeometry = Geometry.Combine(Geometry.Empty, layerGeometry, GeometryCombineMode.Exclude, new TranslateTransform());
|
||||
|
||||
|
||||
LayerGeometry = layerGeometry;
|
||||
OpacityGeometry = opacityGeometry;
|
||||
}
|
||||
@ -171,14 +179,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Layer.RenderPropertiesUpdated -= LayerOnRenderPropertiesUpdated;
|
||||
_profileEditorService.SelectedProfileElementChanged -= OnSelectedProfileElementChanged;
|
||||
_profileEditorService.SelectedProfileElementUpdated -= OnSelectedProfileElementUpdated;
|
||||
_profileEditorService.ProfilePreviewUpdated -= ProfileEditorServiceOnProfilePreviewUpdated;
|
||||
}
|
||||
|
||||
#region Event handlers
|
||||
|
||||
private void LayerOnRenderPropertiesUpdated(object sender, EventArgs e)
|
||||
|
||||
@ -38,6 +38,16 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
public Geometry StrokeGeometry { get; private set; }
|
||||
public Color DisplayColor { get; private set; }
|
||||
|
||||
public void Update()
|
||||
{
|
||||
var newColor = Led.RgbLed.Color.ToMediaColor();
|
||||
Execute.PostToUIThread(() =>
|
||||
{
|
||||
if (!DisplayColor.Equals(newColor))
|
||||
DisplayColor = newColor;
|
||||
});
|
||||
}
|
||||
|
||||
private void CreateLedGeometry()
|
||||
{
|
||||
switch (Led.RgbLed.Shape)
|
||||
@ -105,15 +115,5 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
CreateRectangleGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
var newColor = Led.RgbLed.Color.ToMediaColor();
|
||||
Execute.PostToUIThread(() =>
|
||||
{
|
||||
if (!DisplayColor.Equals(newColor))
|
||||
DisplayColor = newColor;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -114,6 +114,34 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnActivate()
|
||||
{
|
||||
HighlightSelectedLayer = _settingsService.GetSetting("ProfileEditor.HighlightSelectedLayer", true);
|
||||
PauseRenderingOnFocusLoss = _settingsService.GetSetting("ProfileEditor.PauseRenderingOnFocusLoss", true);
|
||||
|
||||
HighlightSelectedLayer.SettingChanged += HighlightSelectedLayerOnSettingChanged;
|
||||
|
||||
_updateTrigger.Start();
|
||||
base.OnActivate();
|
||||
}
|
||||
|
||||
protected override void OnDeactivate()
|
||||
{
|
||||
HighlightSelectedLayer.Save();
|
||||
PauseRenderingOnFocusLoss.Save();
|
||||
|
||||
try
|
||||
{
|
||||
_updateTrigger.Stop();
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
// TODO: Remove when fixed in RGB.NET, or avoid double stopping
|
||||
}
|
||||
|
||||
base.OnDeactivate();
|
||||
}
|
||||
|
||||
private void CreateUpdateTrigger()
|
||||
{
|
||||
// Borrow RGB.NET's update trigger but limit the FPS
|
||||
@ -217,34 +245,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnActivate()
|
||||
{
|
||||
HighlightSelectedLayer = _settingsService.GetSetting("ProfileEditor.HighlightSelectedLayer", true);
|
||||
PauseRenderingOnFocusLoss = _settingsService.GetSetting("ProfileEditor.PauseRenderingOnFocusLoss", true);
|
||||
|
||||
HighlightSelectedLayer.SettingChanged += HighlightSelectedLayerOnSettingChanged;
|
||||
|
||||
_updateTrigger.Start();
|
||||
base.OnActivate();
|
||||
}
|
||||
|
||||
protected override void OnDeactivate()
|
||||
{
|
||||
HighlightSelectedLayer.Save();
|
||||
PauseRenderingOnFocusLoss.Save();
|
||||
|
||||
try
|
||||
{
|
||||
_updateTrigger.Stop();
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
// TODO: Remove when fixed in RGB.NET, or avoid double stopping
|
||||
}
|
||||
|
||||
base.OnDeactivate();
|
||||
}
|
||||
|
||||
#region Buttons
|
||||
|
||||
private void ActivateToolByIndex(int value)
|
||||
|
||||
@ -3,7 +3,6 @@ using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Models.Profile.LayerProperties;
|
||||
using Artemis.UI.Events;
|
||||
using Artemis.UI.Services.Interfaces;
|
||||
using SkiaSharp;
|
||||
|
||||
@ -56,6 +56,34 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.UserControls
|
||||
set => SetValue(ShapeGeometryProperty, value);
|
||||
}
|
||||
|
||||
public void UpdateDimensions()
|
||||
{
|
||||
if (Zoom == 0)
|
||||
return;
|
||||
|
||||
// Rotation controls
|
||||
UpdateRotateDimensions(RotateTopLeft);
|
||||
UpdateRotateDimensions(RotateTopRight);
|
||||
UpdateRotateDimensions(RotateBottomRight);
|
||||
UpdateRotateDimensions(RotateBottomLeft);
|
||||
|
||||
// Size controls
|
||||
UpdateResizeDimensions(ResizeTopCenter);
|
||||
UpdateResizeDimensions(ResizeRightCenter);
|
||||
UpdateResizeDimensions(ResizeBottomCenter);
|
||||
UpdateResizeDimensions(ResizeLeftCenter);
|
||||
UpdateResizeDimensions(ResizeTopLeft);
|
||||
UpdateResizeDimensions(ResizeTopRight);
|
||||
UpdateResizeDimensions(ResizeBottomRight);
|
||||
UpdateResizeDimensions(ResizeBottomLeft);
|
||||
|
||||
// Anchor point
|
||||
UpdateResizeDimensions(AnchorPoint);
|
||||
|
||||
// Layer outline
|
||||
LayerShapeOutline.StrokeThickness = Math.Max(2 / Zoom, 1);
|
||||
}
|
||||
|
||||
private static void ZoomChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var layerShapeControl = (LayerShapeControl) d;
|
||||
@ -88,34 +116,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.UserControls
|
||||
layerShapeControl.UpdateShapeGeometry();
|
||||
}
|
||||
|
||||
public void UpdateDimensions()
|
||||
{
|
||||
if (Zoom == 0)
|
||||
return;
|
||||
|
||||
// Rotation controls
|
||||
UpdateRotateDimensions(RotateTopLeft);
|
||||
UpdateRotateDimensions(RotateTopRight);
|
||||
UpdateRotateDimensions(RotateBottomRight);
|
||||
UpdateRotateDimensions(RotateBottomLeft);
|
||||
|
||||
// Size controls
|
||||
UpdateResizeDimensions(ResizeTopCenter);
|
||||
UpdateResizeDimensions(ResizeRightCenter);
|
||||
UpdateResizeDimensions(ResizeBottomCenter);
|
||||
UpdateResizeDimensions(ResizeLeftCenter);
|
||||
UpdateResizeDimensions(ResizeTopLeft);
|
||||
UpdateResizeDimensions(ResizeTopRight);
|
||||
UpdateResizeDimensions(ResizeBottomRight);
|
||||
UpdateResizeDimensions(ResizeBottomLeft);
|
||||
|
||||
// Anchor point
|
||||
UpdateResizeDimensions(AnchorPoint);
|
||||
|
||||
// Layer outline
|
||||
LayerShapeOutline.StrokeThickness = Math.Max(2 / Zoom, 1);
|
||||
}
|
||||
|
||||
private void UpdateShapeGeometry()
|
||||
{
|
||||
LayerShapeOutline.Data = ShapeGeometry;
|
||||
|
||||
@ -33,6 +33,35 @@ namespace Artemis.UI.Screens
|
||||
public bool IsSidebarVisible { get; set; }
|
||||
public bool ActiveItemReady { get; set; }
|
||||
|
||||
public void WindowDeactivated()
|
||||
{
|
||||
var windowState = ((Window) View).WindowState;
|
||||
if (windowState == WindowState.Minimized)
|
||||
return;
|
||||
|
||||
_lostFocus = true;
|
||||
_eventAggregator.Publish(new MainWindowFocusChangedEvent(false));
|
||||
}
|
||||
|
||||
public void WindowActivated()
|
||||
{
|
||||
if (!_lostFocus)
|
||||
return;
|
||||
|
||||
_lostFocus = false;
|
||||
_eventAggregator.Publish(new MainWindowFocusChangedEvent(true));
|
||||
}
|
||||
|
||||
public void WindowKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
_eventAggregator.Publish(new MainWindowKeyEvent(true, e));
|
||||
}
|
||||
|
||||
public void WindowKeyUp(object sender, KeyEventArgs e)
|
||||
{
|
||||
_eventAggregator.Publish(new MainWindowKeyEvent(false, e));
|
||||
}
|
||||
|
||||
private void SidebarViewModelOnPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == nameof(SidebarViewModel.SelectedItem))
|
||||
@ -63,34 +92,5 @@ namespace Artemis.UI.Screens
|
||||
extensionsPaletteHelper.SetLightDark(windowsTheme == ThemeWatcher.WindowsTheme.Dark);
|
||||
#pragma warning restore 612
|
||||
}
|
||||
|
||||
public void WindowDeactivated()
|
||||
{
|
||||
var windowState = ((Window) View).WindowState;
|
||||
if (windowState == WindowState.Minimized)
|
||||
return;
|
||||
|
||||
_lostFocus = true;
|
||||
_eventAggregator.Publish(new MainWindowFocusChangedEvent(false));
|
||||
}
|
||||
|
||||
public void WindowActivated()
|
||||
{
|
||||
if (!_lostFocus)
|
||||
return;
|
||||
|
||||
_lostFocus = false;
|
||||
_eventAggregator.Publish(new MainWindowFocusChangedEvent(true));
|
||||
}
|
||||
|
||||
public void WindowKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
_eventAggregator.Publish(new MainWindowKeyEvent(true, e));
|
||||
}
|
||||
|
||||
public void WindowKeyUp(object sender, KeyEventArgs e)
|
||||
{
|
||||
_eventAggregator.Publish(new MainWindowKeyEvent(false, e));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -36,6 +36,20 @@ namespace Artemis.UI.Screens.Settings.Debug
|
||||
GC.WaitForPendingFinalizers();
|
||||
}
|
||||
|
||||
protected override void OnActivate()
|
||||
{
|
||||
_coreService.FrameRendered += CoreServiceOnFrameRendered;
|
||||
_coreService.FrameRendering += CoreServiceOnFrameRendering;
|
||||
base.OnActivate();
|
||||
}
|
||||
|
||||
protected override void OnDeactivate()
|
||||
{
|
||||
_coreService.FrameRendered -= CoreServiceOnFrameRendered;
|
||||
_coreService.FrameRendering -= CoreServiceOnFrameRendering;
|
||||
base.OnDeactivate();
|
||||
}
|
||||
|
||||
private void CoreServiceOnFrameRendered(object sender, FrameRenderedEventArgs e)
|
||||
{
|
||||
Execute.PostToUIThread(() =>
|
||||
@ -75,19 +89,5 @@ namespace Artemis.UI.Screens.Settings.Debug
|
||||
{
|
||||
CurrentFps = Math.Round(1.0 / e.DeltaTime, 2);
|
||||
}
|
||||
|
||||
protected override void OnActivate()
|
||||
{
|
||||
_coreService.FrameRendered += CoreServiceOnFrameRendered;
|
||||
_coreService.FrameRendering += CoreServiceOnFrameRendering;
|
||||
base.OnActivate();
|
||||
}
|
||||
|
||||
protected override void OnDeactivate()
|
||||
{
|
||||
_coreService.FrameRendered -= CoreServiceOnFrameRendered;
|
||||
_coreService.FrameRendering -= CoreServiceOnFrameRendering;
|
||||
base.OnDeactivate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -108,20 +108,6 @@ namespace Artemis.UI.Screens.Settings
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnActivate()
|
||||
{
|
||||
DeviceSettingsViewModels.Clear();
|
||||
foreach (var device in _surfaceService.ActiveSurface.Devices)
|
||||
DeviceSettingsViewModels.Add(_deviceSettingsVmFactory.Create(device));
|
||||
|
||||
// TODO: GetPluginsOfType isn't ideal here as it doesn't include disabled plugins
|
||||
Plugins.Clear();
|
||||
foreach (var plugin in _pluginService.GetPluginsOfType<Plugin>())
|
||||
Plugins.Add(new PluginSettingsViewModel(plugin));
|
||||
|
||||
base.OnActivate();
|
||||
}
|
||||
|
||||
public void ShowDebugger()
|
||||
{
|
||||
_windowManager.ShowWindow(_kernel.Get<DebugViewModel>());
|
||||
@ -136,5 +122,19 @@ namespace Artemis.UI.Screens.Settings
|
||||
{
|
||||
Process.Start(Constants.DataFolder);
|
||||
}
|
||||
|
||||
protected override void OnActivate()
|
||||
{
|
||||
DeviceSettingsViewModels.Clear();
|
||||
foreach (var device in _surfaceService.ActiveSurface.Devices)
|
||||
DeviceSettingsViewModels.Add(_deviceSettingsVmFactory.Create(device));
|
||||
|
||||
// TODO: GetPluginsOfType isn't ideal here as it doesn't include disabled plugins
|
||||
Plugins.Clear();
|
||||
foreach (var plugin in _pluginService.GetPluginsOfType<Plugin>())
|
||||
Plugins.Add(new PluginSettingsViewModel(plugin));
|
||||
|
||||
base.OnActivate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -21,11 +21,6 @@ namespace Artemis.UI.Screens.SurfaceEditor.Visualization
|
||||
public double Width { get; set; }
|
||||
public double Height { get; set; }
|
||||
|
||||
private void OnLedOnPropertyChanged(object sender, PropertyChangedEventArgs args)
|
||||
{
|
||||
if (args.PropertyName == "Location" || args.PropertyName == "ActualSize") ApplyLedToViewModel();
|
||||
}
|
||||
|
||||
public void ApplyLedToViewModel()
|
||||
{
|
||||
// Don't want ActualLocation here since rotation is done in XAML
|
||||
@ -34,5 +29,10 @@ namespace Artemis.UI.Screens.SurfaceEditor.Visualization
|
||||
Width = Led.ActualSize.Width;
|
||||
Height = Led.ActualSize.Height;
|
||||
}
|
||||
|
||||
private void OnLedOnPropertyChanged(object sender, PropertyChangedEventArgs args)
|
||||
{
|
||||
if (args.PropertyName == "Location" || args.PropertyName == "ActualSize") ApplyLedToViewModel();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -13,6 +13,19 @@ namespace Artemis.UI.Stylet
|
||||
|
||||
protected virtual object RootViewModel => _rootViewModel ?? (_rootViewModel = GetInstance(typeof(TRootViewModel)));
|
||||
|
||||
public override object GetInstance(Type type)
|
||||
{
|
||||
return Kernel.Get(type);
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
ScreenExtensions.TryDispose(_rootViewModel);
|
||||
if (Kernel != null)
|
||||
Kernel.Dispose();
|
||||
}
|
||||
|
||||
protected override void ConfigureBootstrapper()
|
||||
{
|
||||
Kernel = new StandardKernel();
|
||||
@ -49,21 +62,8 @@ namespace Artemis.UI.Stylet
|
||||
{
|
||||
}
|
||||
|
||||
public override object GetInstance(Type type)
|
||||
{
|
||||
return Kernel.Get(type);
|
||||
}
|
||||
|
||||
protected override void Launch()
|
||||
{
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
ScreenExtensions.TryDispose(_rootViewModel);
|
||||
if (Kernel != null)
|
||||
Kernel.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<packages>
|
||||
<package id="Castle.Core" version="4.4.0" targetFramework="net461" />
|
||||
<package id="FluentValidation" version="8.5.0" targetFramework="net472" />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user