1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-31 09:43:46 +00:00

Project cleanup

This commit is contained in:
Robert 2020-02-13 19:38:43 +01:00
parent 73115898de
commit 6f95c609b6
51 changed files with 440 additions and 490 deletions

View File

@ -77,6 +77,11 @@ namespace Artemis.Core.Models.Profile
return layer; return layer;
} }
public override string ToString()
{
return $"[Folder] {nameof(Name)}: {Name}, {nameof(Order)}: {Order}";
}
internal override void ApplyToEntity() internal override void ApplyToEntity()
{ {
FolderEntity.Id = EntityId; FolderEntity.Id = EntityId;
@ -89,10 +94,5 @@ namespace Artemis.Core.Models.Profile
// TODO: conditions // TODO: conditions
} }
public override string ToString()
{
return $"[Folder] {nameof(Name)}: {Name}, {nameof(Order)}: {Order}";
}
} }
} }

View File

@ -11,9 +11,6 @@ using Artemis.Core.Models.Surface;
using Artemis.Core.Plugins.LayerBrush; using Artemis.Core.Plugins.LayerBrush;
using Artemis.Core.Plugins.Models; using Artemis.Core.Plugins.Models;
using Artemis.Storage.Entities.Profile; using Artemis.Storage.Entities.Profile;
using Newtonsoft.Json;
using Ninject;
using Ninject.Parameters;
using SkiaSharp; using SkiaSharp;
namespace Artemis.Core.Models.Profile namespace Artemis.Core.Models.Profile
@ -147,6 +144,11 @@ namespace Artemis.Core.Models.Profile
/// </summary> /// </summary>
public LayerBrush LayerBrush { get; internal set; } public LayerBrush LayerBrush { get; internal set; }
public override string ToString()
{
return $"[Layer] {nameof(Name)}: {Name}, {nameof(Order)}: {Order}";
}
#region Storage #region Storage
internal override void ApplyToEntity() internal override void ApplyToEntity()
@ -178,6 +180,35 @@ namespace Artemis.Core.Models.Profile
#endregion #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 #region Rendering
public override void Update(double deltaTime) public override void Update(double deltaTime)
@ -378,25 +409,6 @@ namespace Artemis.Core.Models.Profile
#endregion #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 #region Properties
/// <summary> /// <summary>
@ -534,21 +546,6 @@ namespace Artemis.Core.Models.Profile
} }
#endregion #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 public enum LayerShapeType

View File

@ -1,5 +1,4 @@
using Artemis.Storage.Entities.Profile; using SkiaSharp;
using SkiaSharp;
namespace Artemis.Core.Models.Profile.LayerShapes namespace Artemis.Core.Models.Profile.LayerShapes
{ {

View File

@ -1,5 +1,4 @@
using Artemis.Storage.Entities.Profile; using SkiaSharp;
using SkiaSharp;
namespace Artemis.Core.Models.Profile.LayerShapes namespace Artemis.Core.Models.Profile.LayerShapes
{ {

View File

@ -74,6 +74,27 @@ namespace Artemis.Core.Models.Profile
return (Folder) Children.Single(); 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() internal override void ApplyToEntity()
{ {
ProfileEntity.Id = EntityId; ProfileEntity.Id = EntityId;
@ -91,22 +112,6 @@ namespace Artemis.Core.Models.Profile
ProfileEntity.Layers.AddRange(GetAllLayers().Select(f => f.LayerEntity)); 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) internal void Activate(ArtemisSurface surface)
{ {
lock (this) lock (this)
@ -137,11 +142,6 @@ namespace Artemis.Core.Models.Profile
layer.PopulateLeds(surface); layer.PopulateLeds(surface);
} }
public override string ToString()
{
return $"[Profile] {nameof(Name)}: {Name}, {nameof(IsActivated)}: {IsActivated}, {nameof(PluginInfo)}: {PluginInfo}";
}
#region Events #region Events
/// <summary> /// <summary>

View File

@ -46,11 +46,6 @@ namespace Artemis.Core.Models.Profile
/// </summary> /// </summary>
public abstract void Render(double deltaTime, SKCanvas canvas); 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() public List<Folder> GetAllFolders()
{ {
var folders = new List<Folder>(); var folders = new List<Folder>();
@ -131,5 +126,10 @@ namespace Artemis.Core.Models.Profile
child.Parent = null; child.Parent = null;
} }
} }
/// <summary>
/// Applies the profile element's properties to the underlying storage entity
/// </summary>
internal abstract void ApplyToEntity();
} }
} }

View File

@ -76,6 +76,18 @@ namespace Artemis.Core.Models.Surface
set => DeviceEntity.ZIndex = value; 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() internal void ApplyToEntity()
{ {
// Other properties are computed // Other properties are computed
@ -113,17 +125,5 @@ namespace Artemis.Core.Models.Surface
RenderPath = path; 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);
}
} }
} }

View File

@ -48,6 +48,15 @@ namespace Artemis.Core.Models.Surface
internal SurfaceEntity SurfaceEntity { get; set; } internal SurfaceEntity SurfaceEntity { get; set; }
internal Guid EntityId { 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() internal void ApplyToEntity()
{ {
SurfaceEntity.Id = EntityId; 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 #region Events
public event EventHandler<EventArgs> ScaleChanged; public event EventHandler<EventArgs> ScaleChanged;

View File

@ -1,7 +1,6 @@
using System; using System;
using Artemis.Core.Models.Profile; using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Profile.LayerProperties; using Artemis.Core.Models.Profile.LayerProperties;
using Artemis.Core.Services;
using Artemis.Core.Services.Interfaces; using Artemis.Core.Services.Interfaces;
using SkiaSharp; using SkiaSharp;

View File

@ -78,14 +78,14 @@ namespace Artemis.Core.Plugins.Models
public event EventHandler<EventArgs> SettingChanged; public event EventHandler<EventArgs> SettingChanged;
protected virtual void OnSettingChanged()
{
SettingChanged?.Invoke(this, EventArgs.Empty);
}
public override string ToString() public override string ToString()
{ {
return $"{nameof(Name)}: {Name}, {nameof(Value)}: {Value}, {nameof(HasChanged)}: {HasChanged}"; return $"{nameof(Name)}: {Name}, {nameof(Value)}: {Value}, {nameof(HasChanged)}: {HasChanged}";
} }
protected virtual void OnSettingChanged()
{
SettingChanged?.Invoke(this, EventArgs.Empty);
}
} }
} }

View File

@ -55,6 +55,16 @@ namespace Artemis.Core.Services
public bool IsInitialized { get; set; } 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() private void ConfigureJsonConvert()
{ {
JsonConvert.DefaultSettings = () => new JsonSerializerSettings JsonConvert.DefaultSettings = () => new JsonSerializerSettings
@ -136,16 +146,6 @@ namespace Artemis.Core.Services
OnFrameRendered(new FrameRenderedEventArgs(_rgbService.BitmapBrush, _rgbService.Surface)); 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 #region Events
public event EventHandler Initialized; public event EventHandler Initialized;

View File

@ -1,5 +1,4 @@
using System; using Artemis.Core.Plugins.Models;
using Artemis.Core.Plugins.Models;
using Artemis.Core.Services.Interfaces; using Artemis.Core.Services.Interfaces;
using Artemis.Storage.Repositories.Interfaces; using Artemis.Storage.Repositories.Interfaces;

View File

@ -38,6 +38,24 @@ namespace Artemis.Plugins.LayerBrushes.Color
public LayerProperty<SKColor> ColorProperty { get; set; } public LayerProperty<SKColor> ColorProperty { get; set; }
public LayerProperty<GradientType> GradientTypeProperty { 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() private void CreateShader()
{ {
var center = new SKPoint(Layer.Bounds.MidX, Layer.Bounds.MidY); var center = new SKPoint(Layer.Bounds.MidX, Layer.Bounds.MidY);
@ -67,24 +85,6 @@ namespace Artemis.Plugins.LayerBrushes.Color
oldShader?.Dispose(); oldShader?.Dispose();
oldPaint?.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 public enum GradientType

View File

@ -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) public double Evaluate(double x, double y)
{ {
var stretchOffset = (x + y) * STRETCH_2D; var stretchOffset = (x + y) * STRETCH_2D;
@ -454,6 +447,13 @@ namespace Artemis.Plugins.LayerBrushes.Noise.Utilities
return value * NORM_4D; 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 private class Contribution2
{ {
public readonly double dx; public readonly double dx;

View File

@ -63,6 +63,11 @@ namespace Artemis.UI.Shared
public event PropertyChangedEventHandler PropertyChanged; 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) private static void ColorPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
{ {
var colorPicker = (ColorPicker) d; var colorPicker = (ColorPicker) d;
@ -109,10 +114,5 @@ namespace Artemis.UI.Shared
{ {
PopupOpen = !PopupOpen; PopupOpen = !PopupOpen;
} }
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
} }
} }

View File

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Humanizer.Core" version="2.7.9" targetFramework="net472" /> <package id="Humanizer.Core" version="2.7.9" targetFramework="net472" />
<package id="MaterialDesignColors" version="1.2.0" targetFramework="net472" /> <package id="MaterialDesignColors" version="1.2.0" targetFramework="net472" />

View File

@ -56,6 +56,31 @@ namespace Artemis.UI.Behaviors
set => SetValue(ExpandSelectedProperty, value); 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) private static void OnSelectedItemChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
{ {
var behavior = (TreeViewSelectionBehavior) sender; var behavior = (TreeViewSelectionBehavior) sender;
@ -145,30 +170,5 @@ namespace Artemis.UI.Behaviors
{ {
UpdateTreeViewItem((TreeViewItem) sender, false); 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;
}
}
} }
} }

View File

@ -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) protected override void ConfigureIoC(IKernel kernel)
{ {
kernel.Settings.InjectNonPublic = true; kernel.Settings.InjectNonPublic = true;
@ -91,5 +82,14 @@ namespace Artemis.UI
base.OnUnhandledException(e); base.OnUnhandledException(e);
} }
private void ShowMainWindow(IWindowManager windowManager, SplashViewModel splashViewModel)
{
Execute.OnUIThread(() =>
{
windowManager.ShowWindow(RootViewModel);
splashViewModel.RequestClose();
});
}
} }
} }

View File

@ -20,10 +20,10 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
public class LayerPropertiesViewModel : ProfileEditorPanelViewModel public class LayerPropertiesViewModel : ProfileEditorPanelViewModel
{ {
private readonly ICoreService _coreService; private readonly ICoreService _coreService;
private readonly List<LayerPropertyViewModel> _layerPropertyViewModels;
private readonly ILayerPropertyVmFactory _layerPropertyVmFactory; private readonly ILayerPropertyVmFactory _layerPropertyVmFactory;
private readonly IProfileEditorService _profileEditorService; private readonly IProfileEditorService _profileEditorService;
private readonly ISettingsService _settingsService; private readonly ISettingsService _settingsService;
private readonly List<LayerPropertyViewModel> _layerPropertyViewModels;
public LayerPropertiesViewModel(IProfileEditorService profileEditorService, public LayerPropertiesViewModel(IProfileEditorService profileEditorService,
ICoreService coreService, ICoreService coreService,
@ -71,18 +71,18 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
public PropertyTreeViewModel PropertyTree { get; set; } public PropertyTreeViewModel PropertyTree { get; set; }
public PropertyTimelineViewModel PropertyTimeline { get; set; } public PropertyTimelineViewModel PropertyTimeline { get; set; }
private void ProfileEditorServiceOnCurrentTimeChanged(object sender, EventArgs e)
{
NotifyOfPropertyChange(() => FormattedCurrentTime);
NotifyOfPropertyChange(() => TimeCaretPosition);
}
protected override void OnDeactivate() protected override void OnDeactivate()
{ {
Pause(); Pause();
base.OnDeactivate(); base.OnDeactivate();
} }
private void ProfileEditorServiceOnCurrentTimeChanged(object sender, EventArgs e)
{
NotifyOfPropertyChange(() => FormattedCurrentTime);
NotifyOfPropertyChange(() => TimeCaretPosition);
}
#region View model managament #region View model managament
private void PopulateProperties(ProfileElement profileElement, ProfileElement previousProfileElement) private void PopulateProperties(ProfileElement profileElement, ProfileElement previousProfileElement)
@ -92,6 +92,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
previousLayer.LayerPropertyRegistered -= LayerOnPropertyRegistered; previousLayer.LayerPropertyRegistered -= LayerOnPropertyRegistered;
previousLayer.LayerPropertyRemoved -= LayerOnPropertyRemoved; previousLayer.LayerPropertyRemoved -= LayerOnPropertyRemoved;
} }
if (profileElement is Layer layer) if (profileElement is Layer layer)
{ {
// Create VMs for missing properties // Create VMs for missing properties

View File

@ -2,7 +2,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Artemis.Core.Models.Profile.LayerProperties; using Artemis.Core.Models.Profile.LayerProperties;
using Artemis.UI.Ninject.Factories;
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput; using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput;
using Artemis.UI.Services.Interfaces; using Artemis.UI.Services.Interfaces;
using Ninject; 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() public PropertyInputViewModel GetPropertyInputViewModel()
{ {
// If the type is an enum type, search for Enum instead. // 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); match.Initialize(this);
return match; 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();
}
} }
} }

View File

@ -21,8 +21,7 @@
DisplayMemberPath="Description" DisplayMemberPath="Description"
SelectedValue="{Binding Path=BrushInputValue}" SelectedValue="{Binding Path=BrushInputValue}"
RequestBringIntoView="{s:Action OnRequestBringIntoView}" RequestBringIntoView="{s:Action OnRequestBringIntoView}"
materialDesign:ComboBoxAssist.ClassicMode="True"> materialDesign:ComboBoxAssist.ClassicMode="True" />
</ComboBox>
<TextBlock Margin="5 0 0 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" /> <TextBlock Margin="5 0 0 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" />
</StackPanel> </StackPanel>
</UserControl> </UserControl>

View File

@ -1,22 +1,9 @@
using System; using System.Windows.Controls;
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;
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput
{ {
/// <summary> /// <summary>
/// Interaction logic for BrushPropertyInputView.xaml /// Interaction logic for BrushPropertyInputView.xaml
/// </summary> /// </summary>
public partial class BrushPropertyInputView : UserControl public partial class BrushPropertyInputView : UserControl
{ {

View File

@ -38,12 +38,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
} }
} }
protected override void OnInitialized()
{
UpdateEnumValues();
base.OnInitialized();
}
public void UpdateEnumValues() public void UpdateEnumValues()
{ {
var layerBrushProviders = _pluginService.GetPluginsOfType<LayerBrushProvider>(); var layerBrushProviders = _pluginService.GetPluginsOfType<LayerBrushProvider>();
@ -64,5 +58,11 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
{ {
NotifyOfPropertyChange(() => BrushInputValue); NotifyOfPropertyChange(() => BrushInputValue);
} }
protected override void OnInitialized()
{
UpdateEnumValues();
base.OnInitialized();
}
} }
} }

View File

@ -22,8 +22,7 @@
DisplayMemberPath="Description" DisplayMemberPath="Description"
SelectedValue="{Binding Path=EnumInputValue}" SelectedValue="{Binding Path=EnumInputValue}"
RequestBringIntoView="{s:Action OnRequestBringIntoView}" RequestBringIntoView="{s:Action OnRequestBringIntoView}"
materialDesign:ComboBoxAssist.ClassicMode="True"> materialDesign:ComboBoxAssist.ClassicMode="True" />
</ComboBox>
<TextBlock Margin="5 0 0 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" /> <TextBlock Margin="5 0 0 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" />
</StackPanel> </StackPanel>
</UserControl> </UserControl>

View File

@ -1,22 +1,9 @@
using System; using System.Windows.Controls;
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;
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput
{ {
/// <summary> /// <summary>
/// Interaction logic for EnumPropertyInputView.xaml /// Interaction logic for EnumPropertyInputView.xaml
/// </summary> /// </summary>
public partial class EnumPropertyInputView : UserControl public partial class EnumPropertyInputView : UserControl
{ {

View File

@ -22,14 +22,14 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
set => InputValue = value; set => InputValue = value;
} }
protected override void OnInitialized()
{
EnumValues = EnumUtilities.GetAllValuesAndDescriptions(LayerPropertyViewModel.LayerProperty.Type);
}
public override void Update() public override void Update()
{ {
NotifyOfPropertyChange(() => EnumInputValue); NotifyOfPropertyChange(() => EnumInputValue);
} }
protected override void OnInitialized()
{
EnumValues = EnumUtilities.GetAllValuesAndDescriptions(LayerPropertyViewModel.LayerProperty.Type);
}
} }
} }

View File

@ -17,7 +17,7 @@
materialDesign:ValidationAssist.UsePopup="True" materialDesign:ValidationAssist.UsePopup="True"
HorizontalAlignment="Left" HorizontalAlignment="Left"
Text="{Binding FloatInputValue}" 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}" /> <TextBlock Margin="5 0 0 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" />
</StackPanel> </StackPanel>
</UserControl> </UserControl>

View File

@ -17,7 +17,7 @@
materialDesign:ValidationAssist.UsePopup="True" materialDesign:ValidationAssist.UsePopup="True"
HorizontalAlignment="Left" HorizontalAlignment="Left"
Text="{Binding IntInputValue}" Text="{Binding IntInputValue}"
RequestBringIntoView="{s:Action OnRequestBringIntoView}"/> RequestBringIntoView="{s:Action OnRequestBringIntoView}" />
<TextBlock Margin="5 0 0 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" /> <TextBlock Margin="5 0 0 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" />
</StackPanel> </StackPanel>
</UserControl> </UserControl>

View File

@ -47,7 +47,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
} }
/// <summary> /// <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> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
@ -56,6 +56,12 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
e.Handled = true; e.Handled = true;
} }
public abstract void Update();
protected virtual void OnInitialized()
{
}
private void UpdateInputValue(object value) private void UpdateInputValue(object value)
{ {
LayerPropertyViewModel.LayerProperty.SetCurrentValue(value, ProfileEditorService.CurrentTime); LayerPropertyViewModel.LayerProperty.SetCurrentValue(value, ProfileEditorService.CurrentTime);
@ -64,11 +70,5 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
ProfileEditorService.UpdateSelectedProfileElement(); ProfileEditorService.UpdateSelectedProfileElement();
} }
protected virtual void OnInitialized()
{
}
public abstract void Update();
} }
} }

View File

@ -1,22 +1,9 @@
using System; using System.Windows.Controls;
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;
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput
{ {
/// <summary> /// <summary>
/// Interaction logic for SKColorPropertyInputView.xaml /// Interaction logic for SKColorPropertyInputView.xaml
/// </summary> /// </summary>
public partial class SKColorPropertyInputView : UserControl public partial class SKColorPropertyInputView : UserControl
{ {

View File

@ -18,7 +18,7 @@
HorizontalAlignment="Left" HorizontalAlignment="Left"
ToolTip="X-coordinate (horizontal)" ToolTip="X-coordinate (horizontal)"
Text="{Binding X}" Text="{Binding X}"
RequestBringIntoView="{s:Action OnRequestBringIntoView}"/> RequestBringIntoView="{s:Action OnRequestBringIntoView}" />
<TextBlock Margin="5 0" VerticalAlignment="Bottom">,</TextBlock> <TextBlock Margin="5 0" VerticalAlignment="Bottom">,</TextBlock>
<TextBox Width="60" <TextBox Width="60"
Margin="0 2" Margin="0 2"
@ -27,7 +27,7 @@
HorizontalAlignment="Left" HorizontalAlignment="Left"
ToolTip="Y-coordinate (vertical)" ToolTip="Y-coordinate (vertical)"
Text="{Binding Y}" Text="{Binding Y}"
RequestBringIntoView="{s:Action OnRequestBringIntoView}"/> RequestBringIntoView="{s:Action OnRequestBringIntoView}" />
<TextBlock Margin="5 0 0 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" /> <TextBlock Margin="5 0 0 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" />
</StackPanel> </StackPanel>
</UserControl> </UserControl>

View File

@ -18,7 +18,7 @@
HorizontalAlignment="Left" HorizontalAlignment="Left"
ToolTip="Height" ToolTip="Height"
Text="{Binding Height}" Text="{Binding Height}"
RequestBringIntoView="{s:Action OnRequestBringIntoView}"/> RequestBringIntoView="{s:Action OnRequestBringIntoView}" />
<TextBlock Margin="5 0" VerticalAlignment="Bottom">,</TextBlock> <TextBlock Margin="5 0" VerticalAlignment="Bottom">,</TextBlock>
<TextBox Width="60" <TextBox Width="60"
Margin="0 2" Margin="0 2"
@ -27,7 +27,7 @@
HorizontalAlignment="Left" HorizontalAlignment="Left"
ToolTip="Width" ToolTip="Width"
Text="{Binding 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}" /> <TextBlock Margin="5 0 0 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" />
</StackPanel> </StackPanel>
</UserControl> </UserControl>

View File

@ -4,13 +4,13 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree
{ {
public abstract class PropertyTreeItemViewModel : PropertyChangedBase public abstract class PropertyTreeItemViewModel : PropertyChangedBase
{ {
public LayerPropertyViewModel LayerPropertyViewModel { get; }
protected PropertyTreeItemViewModel(LayerPropertyViewModel layerPropertyViewModel) protected PropertyTreeItemViewModel(LayerPropertyViewModel layerPropertyViewModel)
{ {
LayerPropertyViewModel = layerPropertyViewModel; LayerPropertyViewModel = layerPropertyViewModel;
} }
public LayerPropertyViewModel LayerPropertyViewModel { get; }
/// <summary> /// <summary>
/// Updates the tree item's input if it is visible and has keyframes enabled /// Updates the tree item's input if it is visible and has keyframes enabled
/// </summary> /// </summary>
@ -18,16 +18,15 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree
public abstract void Update(bool forceUpdate); public abstract void Update(bool forceUpdate);
/// <summary> /// <summary>
/// Removes the layer property recursively /// Removes the layer property recursively
/// </summary> /// </summary>
/// <param name="layerPropertyViewModel"></param> /// <param name="layerPropertyViewModel"></param>
public abstract void RemoveLayerProperty(LayerPropertyViewModel layerPropertyViewModel); public abstract void RemoveLayerProperty(LayerPropertyViewModel layerPropertyViewModel);
/// <summary> /// <summary>
/// Adds the layer property recursively /// Adds the layer property recursively
/// </summary> /// </summary>
/// <param name="layerPropertyViewModel"></param> /// <param name="layerPropertyViewModel"></param>
public abstract void AddLayerProperty(LayerPropertyViewModel layerPropertyViewModel); public abstract void AddLayerProperty(LayerPropertyViewModel layerPropertyViewModel);
} }
} }

View File

@ -1,5 +1,4 @@
using System.Linq; using System.Linq;
using Artemis.Core.Events;
using Stylet; using Stylet;
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree

View File

@ -1,7 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Artemis.Core.Models.Profile.LayerProperties;
using Artemis.UI.Ninject.Factories; using Artemis.UI.Ninject.Factories;
using Artemis.UI.Services.Interfaces; using Artemis.UI.Services.Interfaces;
using Stylet; using Stylet;
@ -70,13 +69,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
PropertyTrackViewModels.Remove(vm); 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() public void UpdateKeyframePositions()
{ {
foreach (var viewModel in PropertyTrackViewModels) foreach (var viewModel in PropertyTrackViewModels)
@ -95,5 +87,12 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
UpdateEndTime(); UpdateEndTime();
} }
private void CreateViewModels(LayerPropertyViewModel property)
{
PropertyTrackViewModels.Add(_propertyTrackVmFactory.Create(this, property));
foreach (var child in property.Children)
CreateViewModels(child);
}
} }
} }

View File

@ -1,5 +1,4 @@
using System.Linq; using System.Linq;
using Artemis.Core.Events;
using Artemis.UI.Ninject.Factories; using Artemis.UI.Ninject.Factories;
using Stylet; using Stylet;
@ -9,7 +8,8 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
{ {
private readonly IPropertyTrackKeyframeVmFactory _propertyTrackKeyframeVmFactory; private readonly IPropertyTrackKeyframeVmFactory _propertyTrackKeyframeVmFactory;
public PropertyTrackViewModel(PropertyTimelineViewModel propertyTimelineViewModel, LayerPropertyViewModel layerPropertyViewModel, IPropertyTrackKeyframeVmFactory propertyTrackKeyframeVmFactory) public PropertyTrackViewModel(PropertyTimelineViewModel propertyTimelineViewModel, LayerPropertyViewModel layerPropertyViewModel,
IPropertyTrackKeyframeVmFactory propertyTrackKeyframeVmFactory)
{ {
_propertyTrackKeyframeVmFactory = propertyTrackKeyframeVmFactory; _propertyTrackKeyframeVmFactory = propertyTrackKeyframeVmFactory;
PropertyTimelineViewModel = propertyTimelineViewModel; PropertyTimelineViewModel = propertyTimelineViewModel;

View File

@ -71,22 +71,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor
public bool CanDeleteActiveProfile => SelectedProfile != null && Profiles.Count > 1; 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) public Profile CreateProfile(string name)
{ {
var profile = _profileService.CreateProfile(Module, name); var profile = _profileService.CreateProfile(Module, name);
@ -135,14 +119,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor
_profileEditorService.RedoUpdateProfile(Module); _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() protected override void OnActivate()
{ {
LoadWorkspaceSettings(); LoadWorkspaceSettings();
@ -158,6 +134,30 @@ namespace Artemis.UI.Screens.Module.ProfileEditor
base.OnDeactivate(); 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() private void LoadWorkspaceSettings()
{ {
SidePanelsWidth = _settingsService.GetSetting("ProfileEditor.SidePanelsWidth", new GridLength(385)); SidePanelsWidth = _settingsService.GetSetting("ProfileEditor.SidePanelsWidth", new GridLength(385));

View File

@ -44,6 +44,18 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
? new Rect() ? new Rect()
: new Rect(X, Y, Device.RgbDevice.Size.Width, Device.RgbDevice.Size.Height); : 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> /// <summary>
/// Adds LEDs in batches of 5 to avoid UI freezes /// Adds LEDs in batches of 5 to avoid UI freezes
/// </summary> /// </summary>
@ -62,17 +74,5 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
AddedLeds = true; 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();
}
} }
} }

View File

@ -39,6 +39,14 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
public Rect ViewportRectangle { get; set; } public Rect ViewportRectangle { get; set; }
public bool IsSelected { 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() private void Update()
{ {
IsSelected = _profileEditorService.SelectedProfileElement == Layer; IsSelected = _profileEditorService.SelectedProfileElement == Layer;
@ -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 #region Event handlers
private void LayerOnRenderPropertiesUpdated(object sender, EventArgs e) private void LayerOnRenderPropertiesUpdated(object sender, EventArgs e)

View File

@ -38,6 +38,16 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
public Geometry StrokeGeometry { get; private set; } public Geometry StrokeGeometry { get; private set; }
public Color DisplayColor { 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() private void CreateLedGeometry()
{ {
switch (Led.RgbLed.Shape) switch (Led.RgbLed.Shape)
@ -105,15 +115,5 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
CreateRectangleGeometry(); CreateRectangleGeometry();
} }
} }
public void Update()
{
var newColor = Led.RgbLed.Color.ToMediaColor();
Execute.PostToUIThread(() =>
{
if (!DisplayColor.Equals(newColor))
DisplayColor = newColor;
});
}
} }
} }

View File

@ -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() private void CreateUpdateTrigger()
{ {
// Borrow RGB.NET's update trigger but limit the FPS // 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 #region Buttons
private void ActivateToolByIndex(int value) private void ActivateToolByIndex(int value)

View File

@ -3,7 +3,6 @@ using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using Artemis.Core.Models.Profile; using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Profile.LayerProperties;
using Artemis.UI.Events; using Artemis.UI.Events;
using Artemis.UI.Services.Interfaces; using Artemis.UI.Services.Interfaces;
using SkiaSharp; using SkiaSharp;

View File

@ -56,6 +56,34 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.UserControls
set => SetValue(ShapeGeometryProperty, value); 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) private static void ZoomChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{ {
var layerShapeControl = (LayerShapeControl) d; var layerShapeControl = (LayerShapeControl) d;
@ -88,34 +116,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.UserControls
layerShapeControl.UpdateShapeGeometry(); 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() private void UpdateShapeGeometry()
{ {
LayerShapeOutline.Data = ShapeGeometry; LayerShapeOutline.Data = ShapeGeometry;

View File

@ -33,6 +33,35 @@ namespace Artemis.UI.Screens
public bool IsSidebarVisible { get; set; } public bool IsSidebarVisible { get; set; }
public bool ActiveItemReady { 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) private void SidebarViewModelOnPropertyChanged(object sender, PropertyChangedEventArgs e)
{ {
if (e.PropertyName == nameof(SidebarViewModel.SelectedItem)) if (e.PropertyName == nameof(SidebarViewModel.SelectedItem))
@ -63,34 +92,5 @@ namespace Artemis.UI.Screens
extensionsPaletteHelper.SetLightDark(windowsTheme == ThemeWatcher.WindowsTheme.Dark); extensionsPaletteHelper.SetLightDark(windowsTheme == ThemeWatcher.WindowsTheme.Dark);
#pragma warning restore 612 #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));
}
} }
} }

View File

@ -36,6 +36,20 @@ namespace Artemis.UI.Screens.Settings.Debug
GC.WaitForPendingFinalizers(); 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) private void CoreServiceOnFrameRendered(object sender, FrameRenderedEventArgs e)
{ {
Execute.PostToUIThread(() => Execute.PostToUIThread(() =>
@ -75,19 +89,5 @@ namespace Artemis.UI.Screens.Settings.Debug
{ {
CurrentFps = Math.Round(1.0 / e.DeltaTime, 2); 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();
}
} }
} }

View File

@ -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() public void ShowDebugger()
{ {
_windowManager.ShowWindow(_kernel.Get<DebugViewModel>()); _windowManager.ShowWindow(_kernel.Get<DebugViewModel>());
@ -136,5 +122,19 @@ namespace Artemis.UI.Screens.Settings
{ {
Process.Start(Constants.DataFolder); 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();
}
} }
} }

View File

@ -21,11 +21,6 @@ namespace Artemis.UI.Screens.SurfaceEditor.Visualization
public double Width { get; set; } public double Width { get; set; }
public double Height { 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() public void ApplyLedToViewModel()
{ {
// Don't want ActualLocation here since rotation is done in XAML // 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; Width = Led.ActualSize.Width;
Height = Led.ActualSize.Height; Height = Led.ActualSize.Height;
} }
private void OnLedOnPropertyChanged(object sender, PropertyChangedEventArgs args)
{
if (args.PropertyName == "Location" || args.PropertyName == "ActualSize") ApplyLedToViewModel();
}
} }
} }

View File

@ -13,6 +13,19 @@ namespace Artemis.UI.Stylet
protected virtual object RootViewModel => _rootViewModel ?? (_rootViewModel = GetInstance(typeof(TRootViewModel))); 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() protected override void ConfigureBootstrapper()
{ {
Kernel = new StandardKernel(); 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() protected override void Launch()
{ {
} }
public override void Dispose()
{
base.Dispose();
ScreenExtensions.TryDispose(_rootViewModel);
if (Kernel != null)
Kernel.Dispose();
}
} }
} }

View File

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Castle.Core" version="4.4.0" targetFramework="net461" /> <package id="Castle.Core" version="4.4.0" targetFramework="net461" />
<package id="FluentValidation" version="8.5.0" targetFramework="net472" /> <package id="FluentValidation" version="8.5.0" targetFramework="net472" />