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

Code cleanup

This commit is contained in:
Robert 2020-01-14 19:18:24 +01:00
parent 0c245ba83d
commit ae330c3769
73 changed files with 372 additions and 364 deletions

View File

@ -6,7 +6,7 @@ namespace Artemis.Core.Extensions
{
public static int RoundToInt(this float number)
{
return (int)Math.Round(number, MidpointRounding.AwayFromZero);
return (int) Math.Round(number, MidpointRounding.AwayFromZero);
}
}
}

View File

@ -14,9 +14,7 @@ namespace Artemis.Core.JsonConverters
public override SKColor ReadJson(JsonReader reader, Type objectType, SKColor existingValue, bool hasExistingValue, JsonSerializer serializer)
{
if (reader.Value is string value && !string.IsNullOrWhiteSpace(value))
{
return SKColor.Parse(value);
}
return SKColor.Empty;
}

View File

@ -12,8 +12,8 @@ namespace Artemis.Core.Models.Profile.KeyframeEngines
protected override object GetInterpolatedValue()
{
var currentKeyframe = (Keyframe<SKSize>)CurrentKeyframe;
var nextKeyframe = (Keyframe<SKSize>)NextKeyframe;
var currentKeyframe = (Keyframe<SKSize>) CurrentKeyframe;
var nextKeyframe = (Keyframe<SKSize>) NextKeyframe;
var widthDiff = nextKeyframe.Value.Width - currentKeyframe.Value.Width;
var heightDiff = nextKeyframe.Value.Height - currentKeyframe.Value.Height;

View File

@ -328,7 +328,7 @@ namespace Artemis.Core.Models.Profile
var propertyEntity = LayerEntity.PropertyEntities.FirstOrDefault(p => p.Id == layerProperty.Id && p.ValueType == layerProperty.Type.Name);
// TODO: Catch serialization exceptions and log them
if (propertyEntity != null)
if (propertyEntity != null)
layerProperty.ApplyToProperty(propertyEntity);
_properties.Add(layerProperty.Id, layerProperty);
@ -354,7 +354,8 @@ namespace Artemis.Core.Models.Profile
private void CreateDefaultProperties()
{
var transformProperty = new LayerProperty<object>(this, null, "Core.Transform", "Transform", "The default properties collection every layer has, allows you to transform the shape.") {ExpandByDefault = true};
var transformProperty = new LayerProperty<object>(this, null, "Core.Transform", "Transform", "The default properties collection every layer has, allows you to transform the shape.")
{ExpandByDefault = true};
AnchorPointProperty = new LayerProperty<SKPoint>(this, transformProperty, "Core.AnchorPoint", "Anchor Point", "The point at which the shape is attached to its position.");
PositionProperty = new LayerProperty<SKPoint>(this, transformProperty, "Core.Position", "Position", "The position of the shape.");
SizeProperty = new LayerProperty<SKSize>(this, transformProperty, "Core.Size", "Size", "The size of the shape.") {InputAffix = "%"};

View File

@ -74,7 +74,7 @@ namespace Artemis.Core.Models.Profile.LayerProperties
public string InputAffix { get; set; }
/// <summary>
/// Gets or sets whether this property can use keyframes, True by default.
/// Gets or sets whether this property can use keyframes, True by default.
/// </summary>
public bool CanUseKeyframes { get; set; }

View File

@ -1,5 +1,4 @@
using System;
using System.Collections.ObjectModel;
using System.Collections.ObjectModel;
using System.Linq;
namespace Artemis.Core.Models.Profile.LayerProperties
@ -26,8 +25,8 @@ namespace Artemis.Core.Models.Profile.LayerProperties
{
get
{
var currentValue = base.GetCurrentValue();
return currentValue == null ? default : (T)currentValue;
var currentValue = GetCurrentValue();
return currentValue == null ? default : (T) currentValue;
}
}

View File

@ -43,7 +43,10 @@ namespace Artemis.Core.Models.Profile.LayerShapes
/// Updates Position and Size using the provided unscaled rectangle
/// </summary>
/// <param name="rect">An unscaled rectangle which is relative to the layer (1.0 being full width/height, 0.5 being half).</param>
/// <param name="time">An optional timespan to indicate where to set the properties, if null the properties' base values will be used.</param>
/// <param name="time">
/// An optional timespan to indicate where to set the properties, if null the properties' base values
/// will be used.
/// </param>
public void SetFromUnscaledRectangle(SKRect rect, TimeSpan? time)
{
if (!Layer.Leds.Any())

View File

@ -1,21 +1,18 @@
using System;
using System.Xml.Serialization;
using Newtonsoft.Json;
using Stylet;
namespace Artemis.Core.Plugins.LayerBrush
{
public abstract class LayerBrushSettings : PropertyChangedBase
{
private Action<Action> _propertyChangedDispatcher = Execute.DefaultPropertyChangedDispatcher;
/// <summary>
/// Gets or sets the dispatcher to use to dispatch PropertyChanged events. Defaults to Execute.DefaultPropertyChangedDispatcher
/// Gets or sets the dispatcher to use to dispatch PropertyChanged events. Defaults to
/// Execute.DefaultPropertyChangedDispatcher
/// </summary>
[System.Xml.Serialization.XmlIgnore]
[Newtonsoft.Json.JsonIgnore]
public override Action<Action> PropertyChangedDispatcher
{
get { return this._propertyChangedDispatcher; }
set { this._propertyChangedDispatcher = value; }
}
[XmlIgnore]
[JsonIgnore]
public override Action<Action> PropertyChangedDispatcher { get; set; } = Execute.DefaultPropertyChangedDispatcher;
}
}

View File

@ -26,7 +26,7 @@ namespace Artemis.Core.Plugins.Models
}
catch (JsonReaderException)
{
Value = default(T);
Value = default;
}
}

View File

@ -29,7 +29,7 @@ namespace Artemis.Core.Plugins.Models
/// <param name="name">The name of the setting</param>
/// <param name="defaultValue">The default value to use if the setting does not exist yet</param>
/// <returns></returns>
public PluginSetting<T> GetSetting<T>(string name, T defaultValue = default(T))
public PluginSetting<T> GetSetting<T>(string name, T defaultValue = default)
{
lock (_settingEntities)
{

View File

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using Artemis.Core.Extensions;
using Artemis.Core.Plugins.Models;
using RGB.NET.Core;

View File

@ -42,14 +42,6 @@ namespace Artemis.Core.Services
Task.Run(Initialize);
}
private void ConfigureJsonConvert()
{
JsonConvert.DefaultSettings = () => new JsonSerializerSettings
{
Converters = new List<JsonConverter> { new SKColorConverter() }
};
}
public void Dispose()
{
// Dispose services
@ -58,6 +50,14 @@ namespace Artemis.Core.Services
public bool IsInitialized { get; set; }
private void ConfigureJsonConvert()
{
JsonConvert.DefaultSettings = () => new JsonSerializerSettings
{
Converters = new List<JsonConverter> {new SKColorConverter()}
};
}
private async Task Initialize()
{
if (IsInitialized)

View File

@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Profile.KeyframeEngines;
using Artemis.Core.Models.Profile.LayerProperties;
@ -61,9 +60,7 @@ namespace Artemis.Core.Services
}
// If no settings found, provide a fresh instance of the settings type
else if (settingsType != null)
{
settingsInstance = Activator.CreateInstance(settingsType);
}
var arguments = new IParameter[]
{
@ -72,7 +69,7 @@ namespace Artemis.Core.Services
new ConstructorArgument("descriptor", brushDescriptor)
};
var layerElement = (LayerBrush) _kernel.Get(brushDescriptor.LayerBrushType, arguments);
layer.LayerBrush = (layerElement);
layer.LayerBrush = layerElement;
return layerElement;
}

View File

@ -16,7 +16,7 @@ namespace Artemis.Core.Services
_pluginSettings = new PluginSettings(pluginInfo, pluginSettingRepository);
}
public PluginSetting<T> GetSetting<T>(string name, T defaultValue = default(T))
public PluginSetting<T> GetSetting<T>(string name, T defaultValue = default)
{
return _pluginSettings.GetSetting(name, defaultValue);
}
@ -28,6 +28,6 @@ namespace Artemis.Core.Services
/// </summary>
public interface ISettingsService : IProtectedArtemisService
{
PluginSetting<T> GetSetting<T>(string name, T defaultValue = default(T));
PluginSetting<T> GetSetting<T>(string name, T defaultValue = default);
}
}

View File

@ -160,9 +160,7 @@ namespace Artemis.Core.Services.Storage
{
// Only instantiate engines for properties without an existing engine instance
foreach (var layerProperty in profile.GetAllLayers().SelectMany(l => l.Properties).Where(p => p.KeyframeEngine == null))
{
_layerService.InstantiateKeyframeEngine(layerProperty);
}
}
private void ActiveProfilesPopulateLeds(ArtemisSurface surface)

View File

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AppDomainToolkit" version="1.0.4.3" targetFramework="net461" />
<package id="Ben.Demystifier" version="0.1.4" targetFramework="net472" />

View File

@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
@ -33,4 +32,4 @@ using System.Runtime.InteropServices;
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -9,9 +9,9 @@ namespace Artemis.Plugins.LayerBrushes.Color
{
public class ColorBrush : LayerBrush
{
private SKShader _shader;
private List<SKColor> _testColors;
private SKPaint _paint;
private SKShader _shader;
private readonly List<SKColor> _testColors;
public ColorBrush(Layer layer, ColorBrushSettings settings, LayerBrushDescriptor descriptor) : base(layer, settings, descriptor)
{
@ -31,6 +31,8 @@ namespace Artemis.Plugins.LayerBrushes.Color
Settings.PropertyChanged += (sender, args) => CreateShader();
}
public new ColorBrushSettings Settings { get; }
private void CreateShader()
{
var center = new SKPoint(Layer.Rectangle.MidX, Layer.Rectangle.MidY);
@ -61,8 +63,6 @@ namespace Artemis.Plugins.LayerBrushes.Color
oldPaint?.Dispose();
}
public new ColorBrushSettings Settings { get; }
public override LayerBrushViewModel GetViewModel()
{
return new ColorBrushViewModel(this);

View File

@ -11,7 +11,7 @@ namespace Artemis.Plugins.LayerBrushes.Color
ColorBrush = element;
}
public new ColorBrush ColorBrush { get; }
public ColorBrush ColorBrush { get; }
public IEnumerable<ValueDescription> BrushTypes => EnumUtilities.GetAllValuesAndDescriptions(typeof(GradientType));
}
}

View File

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

View File

@ -1,5 +1,4 @@

using Artemis.Core.Plugins.LayerBrush;
using Artemis.Core.Plugins.LayerBrush;
using Artemis.Core.Plugins.Models;
namespace Artemis.Plugins.LayerBrushes.Noise

View File

@ -10,15 +10,6 @@ namespace Artemis.Plugins.LayerBrushes.Noise
private SKColor _color;
private float _xScale;
private float _yScale;
public NoiseBrushSettings()
{
// Color = new SKColor(0, 0, 0);
// BlendMode = SKBlendMode.Color;
// XScale = 0.5f;
// YScale = 0.5f;
// AnimationSpeed = 50f;
}
public SKColor Color
{

View File

@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
@ -33,4 +32,4 @@ using System.Runtime.InteropServices;
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

View File

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="SkiaSharp" version="1.68.1" targetFramework="net472" />
<package id="Stylet" version="1.3.0" targetFramework="net472" />

View File

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="QRCoder" version="1.3.5" targetFramework="net461" />
<package id="SkiaSharp" version="1.68.1" targetFramework="net472" />

View File

@ -2,7 +2,6 @@
using System.Runtime.CompilerServices;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Windows.Media;
@ -62,6 +61,8 @@ namespace Artemis.UI.Shared
set => SetValue(ColorOpacityProperty, value);
}
public event PropertyChangedEventHandler PropertyChanged;
private static void ColorPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var colorPicker = (ColorPicker) d;
@ -72,7 +73,7 @@ namespace Artemis.UI.Shared
colorPicker.SetCurrentValue(ColorOpacityProperty, ((Color) e.NewValue).A);
colorPicker.OnPropertyChanged(nameof(Color));
colorPicker._inCallback = false;
}
@ -109,8 +110,6 @@ namespace Artemis.UI.Shared
PopupOpen = !PopupOpen;
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));

View File

@ -7,7 +7,8 @@ namespace Artemis.UI.Shared.Converters
{
/// <inheritdoc />
/// <summary>
/// Converts <see cref="T:System.Windows.Media.Color" /> into a <see cref="T:System.Windows.Media.Color" /> with full opacity.
/// Converts <see cref="T:System.Windows.Media.Color" /> into a <see cref="T:System.Windows.Media.Color" /> with full
/// opacity.
/// </summary>
[ValueConversion(typeof(Color), typeof(string))]
internal class ColorToSolidColorConverter : IValueConverter

View File

@ -1,6 +1,4 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
@ -31,13 +29,13 @@ using System.Windows;
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly:ThemeInfo(
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
@ -52,4 +50,4 @@ using System.Windows;
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -1,4 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />

View File

@ -1,12 +1,10 @@
<UserControl x:Class="Artemis.UI.Shared.UserControl1"
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.Shared"
mc:Ignorable="d"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
</Grid>
</UserControl>
<Grid />
</UserControl>

View File

@ -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.Shared
{
/// <summary>
/// Interaction logic for UserControl1.xaml
/// Interaction logic for UserControl1.xaml
/// </summary>
public partial class UserControl1 : UserControl
{
@ -25,4 +12,4 @@ namespace Artemis.UI.Shared
InitializeComponent();
}
}
}
}

View File

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

View File

@ -63,8 +63,8 @@
<!-- Disable tab stop/focusable on all content controls -->
<Style TargetType="ContentControl">
<Setter Property="IsTabStop" Value="False"/>
<Setter Property="Focusable" Value="False"/>
<Setter Property="IsTabStop" Value="False" />
<Setter Property="Focusable" Value="False" />
</Style>
</ResourceDictionary>
</Application.Resources>

View File

@ -25,7 +25,7 @@ namespace Artemis.UI.Behaviors
private static void OnLoaded(object sender, RoutedEventArgs e)
{
var frameworkElement = (FrameworkElement)sender;
var frameworkElement = (FrameworkElement) sender;
frameworkElement.Loaded -= OnLoaded;
var window = Window.GetWindow(frameworkElement);

View File

@ -1,7 +1,6 @@
using System;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media.Animation;
using System.Windows.Threading;
using Artemis.Core.Ninject;
using Artemis.Core.Services.Interfaces;

View File

@ -4,13 +4,13 @@ namespace Artemis.UI.Events
{
public class MainWindowKeyEvent
{
public bool KeyDown { get; }
public KeyEventArgs EventArgs { get; }
public MainWindowKeyEvent(bool keyDown, KeyEventArgs eventArgs)
{
KeyDown = keyDown;
EventArgs = eventArgs;
}
public bool KeyDown { get; }
public KeyEventArgs EventArgs { get; }
}
}

View File

@ -1,15 +1,15 @@
<mde:MaterialWindow x:Class="Artemis.UI.Screens.GradientEditor.GradientEditorView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:gradientEditor="clr-namespace:Artemis.UI.Screens.GradientEditor"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:mde="clr-namespace:MaterialDesignExtensions.Controls;assembly=MaterialDesignExtensions"
mc:Ignorable="d"
Title="Gradient Editor"
Height="450" Width="800"
d:DataContext="{d:DesignInstance {x:Type gradientEditor:GradientEditorViewModel}}">
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:gradientEditor="clr-namespace:Artemis.UI.Screens.GradientEditor"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:mde="clr-namespace:MaterialDesignExtensions.Controls;assembly=MaterialDesignExtensions"
mc:Ignorable="d"
Title="Gradient Editor"
Height="450" Width="800"
d:DataContext="{d:DesignInstance {x:Type gradientEditor:GradientEditorViewModel}}">
<Grid>
<materialDesign:ColorPicker Color="{Binding CurrentColor}" />
</Grid>

View File

@ -10,15 +10,15 @@
d:DesignHeight="450" d:DesignWidth="800"
d:DataContext="{d:DesignInstance module:ModuleRootViewModel}">
<TabControl Margin="0 -1 0 0"
ItemsSource="{Binding Items}"
SelectedItem="{Binding ActiveItem}"
DisplayMemberPath="DisplayName"
<TabControl Margin="0 -1 0 0"
ItemsSource="{Binding Items}"
SelectedItem="{Binding ActiveItem}"
DisplayMemberPath="DisplayName"
Style="{StaticResource MaterialDesignTabControl}">
<TabControl.ContentTemplate>
<DataTemplate >
<TabControl.ContentTemplate>
<DataTemplate>
<materialDesign:TransitioningContent OpeningEffect="{materialDesign:TransitionEffect FadeIn}">
<ContentControl s:View.Model="{Binding}" TextElement.Foreground="{DynamicResource MaterialDesignBody}"/>
<ContentControl s:View.Model="{Binding}" TextElement.Foreground="{DynamicResource MaterialDesignBody}" />
</materialDesign:TransitioningContent>
</DataTemplate>
</TabControl.ContentTemplate>

View File

@ -14,7 +14,7 @@ namespace Artemis.UI.Screens.Module
{
DisplayName = module?.DisplayName;
Module = module;
_profileEditorViewModelFactory = profileEditorViewModelFactory;
Task.Run(AddTabsAsync);

View File

@ -14,11 +14,11 @@
d:DataContext="{d:DesignInstance local:LayerPropertiesViewModel}"
behaviors:InputBindingBehavior.PropagateInputBindingsToWindow="True">
<UserControl.InputBindings>
<KeyBinding Command="{s:Action Play}" Key="Space"></KeyBinding>
<KeyBinding Command="{s:Action PlayFromStart}" Modifiers="Shift" Key="Space"></KeyBinding>
<KeyBinding Command="{s:Action Play}" Key="Space" />
<KeyBinding Command="{s:Action PlayFromStart}" Modifiers="Shift" Key="Space" />
</UserControl.InputBindings>
<UserControl.Resources>
<s:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
<s:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
</UserControl.Resources>
<Grid x:Name="ContainerGrid">
<Grid.RowDefinitions>

View File

@ -1,5 +1,4 @@
using System.Windows.Controls;
using System.Windows.Input;
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
{
@ -17,13 +16,9 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
private void TimelineScrollChanged(object sender, ScrollChangedEventArgs e)
{
if (sender == TimelineHeaderScrollViewer)
{
TimelineRailsScrollViewer.ScrollToHorizontalOffset(e.HorizontalOffset);
}
else if (sender == TimelineRailsScrollViewer)
{
TimelineHeaderScrollViewer.ScrollToHorizontalOffset(e.HorizontalOffset);
}
}
}
}

View File

@ -15,7 +15,8 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
private readonly IProfileEditorService _profileEditorService;
private bool _keyframesEnabled;
public LayerPropertyViewModel(BaseLayerProperty layerProperty, LayerPropertyViewModel parent, ILayerPropertyViewModelFactory layerPropertyViewModelFactory, IKernel kernel, IProfileEditorService profileEditorService)
public LayerPropertyViewModel(BaseLayerProperty layerProperty, LayerPropertyViewModel parent, ILayerPropertyViewModelFactory layerPropertyViewModelFactory, IKernel kernel,
IProfileEditorService profileEditorService)
{
_kernel = kernel;
_profileEditorService = profileEditorService;

View File

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using Artemis.Core.Models.Profile.LayerProperties;
using Artemis.UI.Services.Interfaces;
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput

View File

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

View File

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using Artemis.Core.Models.Profile.LayerProperties;
using Artemis.UI.Services.Interfaces;
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput

View File

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Artemis.UI.Exceptions;
using Artemis.UI.Services.Interfaces;
using Stylet;

View File

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using Artemis.Core.Models.Profile.LayerProperties;
using Artemis.UI.Services.Interfaces;
using PropertyChanged;
using SkiaSharp;
@ -26,7 +25,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
[DependsOn(nameof(InputValue))]
public float Y
{
get => ((SKPoint?)InputValue)?.Y ?? 0;
get => ((SKPoint?) InputValue)?.Y ?? 0;
set => InputValue = new SKPoint(X, value);
}

View File

@ -16,7 +16,7 @@
materialDesign:ValidationAssist.UsePopup="True"
HorizontalAlignment="Left"
ToolTip="Height"
Text="{Binding Height}"/>
Text="{Binding Height}" />
<TextBlock Margin="5 0" VerticalAlignment="Bottom">,</TextBlock>
<TextBox Width="60"
Margin="0 2"

View File

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using Artemis.Core.Models.Profile.LayerProperties;
using Artemis.UI.Services.Interfaces;
using PropertyChanged;
using SkiaSharp;
@ -26,7 +25,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
[DependsOn(nameof(InputValue))]
public float Height
{
get => ((SKSize?)InputValue)?.Height ?? 0;
get => ((SKSize?) InputValue)?.Height ?? 0;
set => InputValue = new SKSize(Width, value);
}

View File

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using Artemis.UI.Services.Interfaces;
using Stylet;

View File

@ -74,7 +74,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
}
/// <summary>
/// Updates the time line's keyframes
/// Updates the time line's keyframes
/// </summary>
public void Update()
{

View File

@ -18,7 +18,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
EasingFunction = easingFunction;
Description = easingFunction.Humanize();
CreateGeometry();
}

View File

@ -21,8 +21,8 @@
</UserControl.Resources>
<UserControl.InputBindings>
<KeyBinding Command="{s:Action Undo}" Modifiers="Control" Key="Z"></KeyBinding>
<KeyBinding Command="{s:Action Redo}" Modifiers="Control" Key="Y"></KeyBinding>
<KeyBinding Command="{s:Action Undo}" Modifiers="Control" Key="Z" />
<KeyBinding Command="{s:Action Redo}" Modifiers="Control" Key="Y" />
</UserControl.InputBindings>
<Grid Margin="16">

View File

@ -14,8 +14,8 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileTree.TreeItem
public abstract class TreeItemViewModel : PropertyChangedBase
{
private readonly IDialogService _dialogService;
private readonly ILayerService _layerService;
private readonly IFolderViewModelFactory _folderViewModelFactory;
private readonly ILayerService _layerService;
private readonly ILayerViewModelFactory _layerViewModelFactory;
private readonly IProfileEditorService _profileEditorService;
@ -122,7 +122,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileTree.TreeItem
throw new ArtemisUIException("Cannot add a layer to a profile element of type " + ProfileElement.GetType().Name);
var layer = new Layer(ProfileElement.Profile, ProfileElement, "New layer");
foreach (var baseLayerProperty in layer.Properties)
foreach (var baseLayerProperty in layer.Properties)
_layerService.InstantiateKeyframeEngine(baseLayerProperty);
ProfileElement.AddChild(layer);
UpdateProfileElements();

View File

@ -1,7 +1,6 @@
using System;
using System.Linq;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Profile.LayerShapes;
@ -9,8 +8,6 @@ using Artemis.Core.Models.Surface;
using Artemis.UI.Extensions;
using Artemis.UI.Services.Interfaces;
using RGB.NET.Core;
using SkiaSharp;
using SkiaSharp.Views.WPF;
using Rectangle = Artemis.Core.Models.Profile.LayerShapes.Rectangle;
namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization

View File

@ -55,7 +55,7 @@
</ListBox.ItemsPanel>
<ListBoxItem ToolTip="Pan over different parts of the surface">
<materialDesign:PackIcon Kind="HandLeft" />
</ListBoxItem>
</ListBoxItem>
<ListBoxItem ToolTip="Edit shape in layer">
<materialDesign:PackIcon Kind="Edit" />
</ListBoxItem>
@ -171,7 +171,6 @@
</ItemsControl>
</Grid>
<StackPanel ZIndex="1" VerticalAlignment="Bottom" HorizontalAlignment="Left" Margin="10">
<materialDesign:Card Padding="8">

View File

@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using System.Windows;
using System.Windows.Input;

View File

@ -1,23 +1,21 @@
using System;
using System.Diagnostics.Eventing.Reader;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using Artemis.Core.Models.Profile;
using Artemis.UI.Services.Interfaces;
using SkiaSharp;
using SkiaSharp.Views.WPF;
namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
{
public class EditToolViewModel : VisualizationToolViewModel
{
private bool _isDragging;
private double _dragOffsetY;
private double _dragOffsetX;
private Point _dragStart;
private bool _draggingHorizontally;
private bool _draggingVertically;
private double _dragOffsetX;
private double _dragOffsetY;
private Point _dragStart;
private bool _isDragging;
public EditToolViewModel(ProfileViewModel profileViewModel, IProfileEditorService profileEditorService) : base(profileViewModel, profileEditorService)
{

View File

@ -1,5 +1,4 @@
using MaterialDesignThemes.Wpf;
using Stylet;
namespace Artemis.UI.Screens.News
{

View File

@ -1,6 +1,4 @@
using System;
using System.ComponentModel;
using System.Threading;
using System.ComponentModel;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
@ -31,6 +29,10 @@ namespace Artemis.UI.Screens
SidebarViewModel.PropertyChanged += SidebarViewModelOnPropertyChanged;
}
public SidebarViewModel SidebarViewModel { get; }
public bool IsSidebarVisible { get; set; }
public bool ActiveItemReady { get; set; }
private void SidebarViewModelOnPropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(SidebarViewModel.SelectedItem))
@ -48,10 +50,6 @@ namespace Artemis.UI.Screens
}
}
public SidebarViewModel SidebarViewModel { get; }
public bool IsSidebarVisible { get; set; }
public bool ActiveItemReady { get; set; }
private void ApplyWindowsTheme(ThemeWatcher.WindowsTheme windowsTheme)
{
var paletteHelper = new PaletteHelper();
@ -61,9 +59,9 @@ namespace Artemis.UI.Screens
var extensionsPaletteHelper = new MaterialDesignExtensions.Themes.PaletteHelper();
// That's nice, then don't use it in your own examples and provide a working alternative
#pragma warning disable 612
#pragma warning disable 612
extensionsPaletteHelper.SetLightDark(windowsTheme == ThemeWatcher.WindowsTheme.Dark);
#pragma warning restore 612
#pragma warning restore 612
}
public void WindowDeactivated()

View File

@ -78,7 +78,7 @@
</TextBlock>
</StackPanel>
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
<Button Style="{StaticResource MaterialDesignOutlinedButton}" Command="{s:Action ShowDebugger}" Width="150">
<Button Style="{StaticResource MaterialDesignOutlinedButton}" Command="{s:Action ShowDebugger}" Width="150">
SHOW DEBUGGER
</Button>
</StackPanel>
@ -101,7 +101,7 @@
</TextBlock>
</StackPanel>
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
<Button Style="{StaticResource MaterialDesignOutlinedButton}" Command="{s:Action ShowLogsFolder}" Width="150">
<Button Style="{StaticResource MaterialDesignOutlinedButton}" Command="{s:Action ShowLogsFolder}" Width="150">
SHOW LOGS
</Button>
</StackPanel>
@ -215,10 +215,10 @@
materialDesign:DataGridAssist.CellPadding="13 8 8 8"
materialDesign:DataGridAssist.ColumnHeaderPadding="8">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Type}" Header="Type" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding Name}" Header="Name" IsReadOnly="True" Width="*"/>
<DataGridTextColumn Binding="{Binding Description}" Header="Description" IsReadOnly="True" Width="*"/>
<DataGridTextColumn Binding="{Binding Version}" Header="Version" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding Type}" Header="Type" IsReadOnly="True" />
<DataGridTextColumn Binding="{Binding Name}" Header="Name" IsReadOnly="True" Width="*" />
<DataGridTextColumn Binding="{Binding Description}" Header="Description" IsReadOnly="True" Width="*" />
<DataGridTextColumn Binding="{Binding Version}" Header="Version" IsReadOnly="True" />
<DataGridCheckBoxColumn Header="Enabled"
Binding="{Binding IsEnabled}"
ElementStyle="{StaticResource MaterialDesignDataGridCheckBoxColumnStyle}"

View File

@ -22,9 +22,9 @@ namespace Artemis.UI.Screens.Settings
{
private readonly IDeviceSettingsViewModelFactory _deviceSettingsViewModelFactory;
private readonly IKernel _kernel;
private readonly IPluginService _pluginService;
private readonly ISettingsService _settingsService;
private readonly ISurfaceService _surfaceService;
private readonly IPluginService _pluginService;
private readonly IWindowManager _windowManager;
public SettingsViewModel(IKernel kernel,
@ -126,7 +126,7 @@ namespace Artemis.UI.Screens.Settings
{
_windowManager.ShowWindow(_kernel.Get<DebugViewModel>());
}
public void ShowLogsFolder()
{
Process.Start(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Logs"));

View File

@ -31,7 +31,7 @@ namespace Artemis.UI.Screens.Settings.Tabs.Devices
{
_deviceService.IdentifyDevice(Device);
}
public void ShowDeviceDebugger()
{
}

View File

@ -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.Sidebar
{
/// <summary>
/// Interaction logic for SidebarView.xaml
/// Interaction logic for SidebarView.xaml
/// </summary>
public partial class SidebarView : UserControl
{
@ -25,4 +12,4 @@ namespace Artemis.UI.Screens.Sidebar
InitializeComponent();
}
}
}
}

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using Artemis.Core.Events;
using Artemis.Core.Services.Interfaces;
@ -85,10 +86,10 @@ namespace Artemis.UI.Screens.Sidebar
return;
// Icon is provided as string to avoid having to reference MaterialDesignThemes
var parsedIcon = System.Enum.TryParse<PackIconKind>(module.DisplayIcon, true, out var iconEnum);
var parsedIcon = Enum.TryParse<PackIconKind>(module.DisplayIcon, true, out var iconEnum);
if (parsedIcon == false)
iconEnum = PackIconKind.QuestionMarkCircle;
var sidebarItem = new FirstLevelNavigationItem { Icon = iconEnum, Label = module.DisplayName };
var sidebarItem = new FirstLevelNavigationItem {Icon = iconEnum, Label = module.DisplayName};
SidebarItems.Add(sidebarItem);
SidebarItemObjects.Add(sidebarItem, module);
}
@ -117,7 +118,7 @@ namespace Artemis.UI.Screens.Sidebar
if (e.PluginInfo.Instance is Core.Plugins.Abstract.Module module)
RemoveModule(module);
}
#endregion
}
}

View File

@ -1,21 +1,21 @@
<controls:MaterialWindow x:Class="Artemis.UI.Screens.Splash.SplashView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:splash="clr-namespace:Artemis.UI.Screens.Splash"
xmlns:controls="clr-namespace:MaterialDesignExtensions.Controls;assembly=MaterialDesignExtensions"
xmlns:s="https://github.com/canton7/Stylet"
mc:Ignorable="d"
Title=" "
ResizeMode="NoResize"
BorderBackgroundBrush="{DynamicResource PrimaryHueMidBrush}"
Height="450"
Width="400"
WindowStartupLocation="CenterScreen"
FontFamily="pack://application:,,,/MaterialDesignThemes.Wpf;component/Resources/Roboto/#Roboto"
MouseDown="{s:Action MouseDown}"
d:DataContext="{d:DesignInstance splash:SplashViewModel}">
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:splash="clr-namespace:Artemis.UI.Screens.Splash"
xmlns:controls="clr-namespace:MaterialDesignExtensions.Controls;assembly=MaterialDesignExtensions"
xmlns:s="https://github.com/canton7/Stylet"
mc:Ignorable="d"
Title=" "
ResizeMode="NoResize"
BorderBackgroundBrush="{DynamicResource PrimaryHueMidBrush}"
Height="450"
Width="400"
WindowStartupLocation="CenterScreen"
FontFamily="pack://application:,,,/MaterialDesignThemes.Wpf;component/Resources/Roboto/#Roboto"
MouseDown="{s:Action MouseDown}"
d:DataContext="{d:DesignInstance splash:SplashViewModel}">
<Grid Background="{DynamicResource PrimaryHueMidBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="250" />

View File

@ -124,9 +124,7 @@ namespace Artemis.UI.Screens.SurfaceEditor
// Create VMs for missing devices
var viewModel = existing.FirstOrDefault(vm => vm.Device.RgbDevice == surfaceDeviceConfiguration.RgbDevice);
if (viewModel == null)
{
viewModel = new SurfaceDeviceViewModel(surfaceDeviceConfiguration);
}
// Update existing devices
else
viewModel.Device = surfaceDeviceConfiguration;
@ -199,6 +197,7 @@ namespace Artemis.UI.Screens.SurfaceEditor
var deviceViewModel = Devices[i];
deviceViewModel.Device.ZIndex = i + 1;
}
_surfaceService.UpdateSurfaceConfiguration(SelectedSurface, true);
}
@ -213,6 +212,7 @@ namespace Artemis.UI.Screens.SurfaceEditor
var deviceViewModel = Devices[i];
deviceViewModel.Device.ZIndex = i + 1;
}
_surfaceService.UpdateSurfaceConfiguration(SelectedSurface, true);
}
@ -224,6 +224,7 @@ namespace Artemis.UI.Screens.SurfaceEditor
var deviceViewModel = Devices[i];
deviceViewModel.Device.ZIndex = i + 1;
}
_surfaceService.UpdateSurfaceConfiguration(SelectedSurface, true);
}
@ -237,6 +238,7 @@ namespace Artemis.UI.Screens.SurfaceEditor
var deviceViewModel = Devices[i];
deviceViewModel.Device.ZIndex = i + 1;
}
_surfaceService.UpdateSurfaceConfiguration(SelectedSurface, true);
}

View File

@ -1,6 +1,5 @@
using System.Windows.Media;
using MaterialDesignThemes.Wpf;
using Stylet;
namespace Artemis.UI.Screens.Workshop
{
@ -15,7 +14,7 @@ namespace Artemis.UI.Screens.Workshop
public Color TestColor { get; set; }
public bool TestPopupOpen { get; set; }
public void UpdateValues()
{
TestPopupOpen = !TestPopupOpen;

View File

@ -47,7 +47,5 @@ namespace Artemis.UI.Services.Interfaces
/// Occurs when the profile preview has been updated
/// </summary>
event EventHandler ProfilePreviewUpdated;
}
}

View File

@ -9,11 +9,6 @@ namespace Artemis.UI.Utilities
{
public class ThemeWatcher
{
public ThemeWatcher()
{
WatchTheme();
}
public enum WindowsTheme
{
Light,
@ -24,6 +19,11 @@ namespace Artemis.UI.Utilities
private const string RegistryValueName = "AppsUseLightTheme";
public ThemeWatcher()
{
WatchTheme();
}
public void WatchTheme()
{
var currentUser = WindowsIdentity.GetCurrent();

View File

@ -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" />