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

Added a few property inputs

This commit is contained in:
SpoinkyNL 2020-01-07 22:47:40 +01:00
parent 592af6006b
commit e1a4a155b6
19 changed files with 282 additions and 26 deletions

View File

@ -296,10 +296,9 @@ namespace Artemis.Core.Models.Profile
var transformProperty = new LayerProperty(this, null, "Transform", "The default properties collection every layer has, allows you to transform the shape.", null);
AnchorPointProperty = new LayerProperty(this, transformProperty, "Anchor Point", "The point at which the shape is attached to its position.", typeof(SKPoint));
PositionProperty = new LayerProperty(this, transformProperty, "Position", "The position of the shape.", typeof(SKPoint));
ScaleProperty = new LayerProperty(this, transformProperty, "Scale", "The scale of the shape.", typeof(SKSize));
RotationProperty = new LayerProperty(this, transformProperty, "Rotation", "The rotation of the shape in degrees.", typeof(int));
OpacityProperty = new LayerProperty(this, transformProperty, "Opacity", "The opacity of the shape from 0 to 1.", typeof(float));
ScaleProperty = new LayerProperty(this, transformProperty, "Scale", "The scale of the shape.", typeof(SKSize)) { InputAffix = "%" };
RotationProperty = new LayerProperty(this, transformProperty, "Rotation", "The rotation of the shape in degrees.", typeof(int)) {InputAffix = "°" };
OpacityProperty = new LayerProperty(this, transformProperty, "Opacity", "The opacity of the shape.", typeof(float)) {InputAffix = "%"};
transformProperty.Children.Add(AnchorPointProperty);
transformProperty.Children.Add(PositionProperty);
transformProperty.Children.Add(ScaleProperty);

View File

@ -26,6 +26,8 @@ namespace Artemis.Core.Models.Profile
public string Name { get; set; }
public string Description { get; set; }
public string InputPrefix { get; set; }
public string InputAffix { get; set; }
public Type Type { get; set; }
public object BaseValue

View File

@ -162,6 +162,11 @@
</Compile>
<Compile Include="Screens\Module\ProfileEditor\LayerProperties\LayerPropertiesViewModel.cs" />
<Compile Include="Screens\Module\ProfileEditor\LayerProperties\LayerPropertyViewModel.cs" />
<Compile Include="Screens\Module\ProfileEditor\LayerProperties\PropertyTree\PropertyInput\FloatPropertyInputViewModel.cs" />
<Compile Include="Screens\Module\ProfileEditor\LayerProperties\PropertyTree\PropertyInput\IntPropertyInputViewModel.cs" />
<Compile Include="Screens\Module\ProfileEditor\LayerProperties\PropertyTree\PropertyInput\PropertyInputViewModel.cs" />
<Compile Include="Screens\Module\ProfileEditor\LayerProperties\PropertyTree\PropertyInput\SKPointPropertyInputViewModel.cs" />
<Compile Include="Screens\Module\ProfileEditor\LayerProperties\PropertyTree\PropertyInput\SKSizePropertyInputViewModel.cs" />
<Compile Include="Screens\Module\ProfileEditor\LayerProperties\PropertyTree\PropertyTreeChildViewModel.cs" />
<Compile Include="Screens\Module\ProfileEditor\LayerProperties\PropertyTree\PropertyTreeItemViewModel.cs" />
<Compile Include="Screens\Module\ProfileEditor\LayerProperties\PropertyTree\PropertyTreeParentViewModel.cs" />
@ -304,6 +309,22 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Screens\Module\ProfileEditor\LayerProperties\PropertyTree\PropertyInput\FloatPropertyInputView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Screens\Module\ProfileEditor\LayerProperties\PropertyTree\PropertyInput\IntPropertyInputView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Screens\Module\ProfileEditor\LayerProperties\PropertyTree\PropertyInput\SKPointPropertyInputView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Screens\Module\ProfileEditor\LayerProperties\PropertyTree\PropertyInput\SKSizePropertyInputView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Screens\Module\ProfileEditor\LayerProperties\PropertyTree\PropertyTreeChildView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@ -468,6 +489,7 @@
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<None Include="Resources\RobotoMono-Regular.ttf" />
</ItemGroup>
<ItemGroup>
<None Include="App.config">
@ -497,41 +519,46 @@
<Resource Include="logo-512.ico" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\aero_rotate_tl.cur" />
<Resource Include="Resources\aero_rotate_tl.cur" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\aero_rotate_tr.cur" />
<Resource Include="Resources\aero_rotate_tr.cur" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\aero_rotate_bl.cur" />
<Resource Include="Resources\aero_rotate_bl.cur" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\aero_rotate_br.cur" />
<Resource Include="Resources\aero_rotate_br.cur" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\aero_crosshair.cur" />
<Resource Include="Resources\aero_crosshair.cur" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\aero_crosshair_minus.cur" />
<Resource Include="Resources\aero_crosshair_minus.cur" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\aero_crosshair_plus.cur" />
<Resource Include="Resources\aero_crosshair_plus.cur" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\aero_pen_min.cur" />
<Resource Include="Resources\aero_pen_min.cur" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\aero_pen_plus.cur" />
<Resource Include="Resources\aero_pen_plus.cur" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\aero_fill.cur" />
<Resource Include="Resources\aero_fill.cur" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\aero_drag.cur" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<FluentValidationExcludedCultures Include="be;cs;cs-CZ;da;de;es;fa;fi;fr;ja;it;ko;mk;nl;pl;pt;ru;sv;tr;uk;zh-CN;zh-CHS;zh-CHT;uz-Latn-UZ">
<InProject>false</InProject>
</FluentValidationExcludedCultures>
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\aero_drag_ew.cur" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>

View File

@ -90,6 +90,26 @@ namespace Artemis.UI.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// </summary>
internal static byte[] aero_drag {
get {
object obj = ResourceManager.GetObject("aero_drag", resourceCulture);
return ((byte[])(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// </summary>
internal static byte[] aero_drag_ew {
get {
object obj = ResourceManager.GetObject("aero_drag_ew", resourceCulture);
return ((byte[])(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// </summary>
@ -179,5 +199,15 @@ namespace Artemis.UI.Properties {
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// </summary>
internal static byte[] RobotoMono_Regular {
get {
object obj = ResourceManager.GetObject("RobotoMono_Regular", resourceCulture);
return ((byte[])(obj));
}
}
}
}

View File

@ -127,6 +127,12 @@
<data name="aero_crosshair_plus" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\aero_crosshair_plus.cur;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="aero_drag" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\aero_drag.cur;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="aero_drag_ew" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\aero_drag_ew.cur;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="aero_fill" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\aero_fill.cur;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
@ -154,4 +160,7 @@
<data name="logo_512" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\logo-512.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="RobotoMono_Regular" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\RobotoMono-Regular.ttf;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
</root>

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@ -0,0 +1,21 @@
<UserControl x:Class="Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput.FloatPropertyInputView"
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:local="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
d:DataContext="{d:DesignInstance local:FloatPropertyInputViewModel}">
<StackPanel Orientation="Horizontal">
<TextBlock Margin="0 0 5 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputPrefix}" />
<TextBox Width="60"
Margin="0 2"
Padding="0 -1"
materialDesign:ValidationAssist.UsePopup="True"
HorizontalAlignment="Left"
Cursor="/Resources/aero_drag_ew.cur" />
<TextBlock Margin="5 0 0 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" />
</StackPanel>
</UserControl>

View File

@ -0,0 +1,16 @@
using Artemis.UI.Exceptions;
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput
{
public class FloatPropertyInputViewModel : PropertyInputViewModel
{
public FloatPropertyInputViewModel(LayerPropertyViewModel layerPropertyViewModel) : base(layerPropertyViewModel)
{
if (layerPropertyViewModel.LayerProperty.Type != typeof(float))
{
throw new ArtemisUIException("This input VM expects a layer property of type float, " +
$"not the provided type {layerPropertyViewModel.LayerProperty.Type.Name}");
}
}
}
}

View File

@ -0,0 +1,21 @@
<UserControl x:Class="Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput.IntPropertyInputView"
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:local="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
d:DataContext="{d:DesignInstance local:IntPropertyInputViewModel}">
<StackPanel Orientation="Horizontal">
<TextBlock Margin="0 0 5 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputPrefix}" />
<TextBox Width="60"
Margin="0 2"
Padding="0 -1"
materialDesign:ValidationAssist.UsePopup="True"
HorizontalAlignment="Left"
Cursor="/Resources/aero_drag_ew.cur" />
<TextBlock Margin="5 0 0 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" />
</StackPanel>
</UserControl>

View File

@ -0,0 +1,16 @@
using Artemis.UI.Exceptions;
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput
{
public class IntPropertyInputViewModel : PropertyInputViewModel
{
public IntPropertyInputViewModel(LayerPropertyViewModel layerPropertyViewModel) : base(layerPropertyViewModel)
{
if (layerPropertyViewModel.LayerProperty.Type != typeof(int))
{
throw new ArtemisUIException("This input VM expects a layer property of type int, " +
$"not the provided type {layerPropertyViewModel.LayerProperty.Type.Name}");
}
}
}
}

View File

@ -0,0 +1,14 @@
using Stylet;
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput
{
public abstract class PropertyInputViewModel : PropertyChangedBase
{
protected PropertyInputViewModel(LayerPropertyViewModel layerPropertyViewModel)
{
LayerPropertyViewModel = layerPropertyViewModel;
}
public LayerPropertyViewModel LayerPropertyViewModel { get; }
}
}

View File

@ -0,0 +1,30 @@
<UserControl x:Class="Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput.SKPointPropertyInputView"
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:local="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d"
d:DesignHeight="25" d:DesignWidth="800"
d:DataContext="{d:DesignInstance local:SKPointPropertyInputViewModel}">
<StackPanel Orientation="Horizontal">
<TextBlock Margin="0 0 5 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputPrefix}" />
<TextBox Width="60"
Margin="0 2"
Padding="0 -1"
materialDesign:ValidationAssist.UsePopup="True"
HorizontalAlignment="Left"
ToolTip="X-coordinate (horizontal)"
Cursor="/Resources/aero_drag_ew.cur" />
<TextBlock Margin="5 0" VerticalAlignment="Bottom">,</TextBlock>
<TextBox Width="60"
Margin="0 2"
Padding="0 -1"
materialDesign:ValidationAssist.UsePopup="True"
HorizontalAlignment="Left"
ToolTip="Y-coordinate (vertical)"
Cursor="/Resources/aero_drag_ew.cur" />
<TextBlock Margin="5 0 0 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" />
</StackPanel>
</UserControl>

View File

@ -0,0 +1,17 @@
using Artemis.UI.Exceptions;
using SkiaSharp;
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput
{
public class SKPointPropertyInputViewModel : PropertyInputViewModel
{
public SKPointPropertyInputViewModel(LayerPropertyViewModel layerPropertyViewModel) : base(layerPropertyViewModel)
{
if (layerPropertyViewModel.LayerProperty.Type != typeof(SKPoint))
{
throw new ArtemisUIException($"This input VM expects a layer property of type {nameof(SKPoint)}, " +
$"not the provided type {layerPropertyViewModel.LayerProperty.Type.Name}");
}
}
}
}

View File

@ -0,0 +1,30 @@
<UserControl x:Class="Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput.SKSizePropertyInputView"
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:local="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
d:DataContext="{d:DesignInstance local:SKSizePropertyInputViewModel}">
<StackPanel Orientation="Horizontal">
<TextBlock Margin="0 0 5 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputPrefix}" />
<TextBox Width="60"
Margin="0 2"
Padding="0 -1"
materialDesign:ValidationAssist.UsePopup="True"
HorizontalAlignment="Left"
ToolTip="Height"
Cursor="/Resources/aero_drag_ew.cur" />
<TextBlock Margin="5 0" VerticalAlignment="Bottom">,</TextBlock>
<TextBox Width="60"
Margin="0 2"
Padding="0 -1"
materialDesign:ValidationAssist.UsePopup="True"
HorizontalAlignment="Left"
ToolTip="Width"
Cursor="/Resources/aero_drag_ew.cur" />
<TextBlock Margin="5 0 0 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" />
</StackPanel>
</UserControl>

View File

@ -0,0 +1,17 @@
using Artemis.UI.Exceptions;
using SkiaSharp;
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput
{
public class SKSizePropertyInputViewModel : PropertyInputViewModel
{
public SKSizePropertyInputViewModel(LayerPropertyViewModel layerPropertyViewModel) : base(layerPropertyViewModel)
{
if (layerPropertyViewModel.LayerProperty.Type != typeof(SKSize))
{
throw new ArtemisUIException($"This input VM expects a layer property of type {nameof(SKSize)}, " +
$"not the provided type {layerPropertyViewModel.LayerProperty.Type.Name}");
}
}
}
}

View File

@ -5,6 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:s="https://github.com/canton7/Stylet"
mc:Ignorable="d"
d:DesignHeight="19"
d:DesignWidth="800"
@ -35,16 +36,8 @@
ToolTip="{Binding LayerPropertyViewModel.LayerProperty.Description}"
HorizontalAlignment="Left" />
<StackPanel Grid.Column="2" Margin="20 0" VerticalAlignment="Center">
<!-- Height is very limited so squeeze things together -->
<TextBox Width="100"
Margin="0 -1"
Padding="0 -1"
materialDesign:ValidationAssist.UsePopup="True"
HorizontalAlignment="Left"
ToolTip="Use a popup which can escape the bounds of the control where space is limited" />
</StackPanel>
<ContentControl Grid.Column="2" Margin="20 0" s:View.Model="{Binding PropertyInputViewModel}"/>
<Button Grid.Column="3"
Style="{StaticResource MaterialDesignOutlinedButton}"
Margin="0,1,0,1.2"

View File

@ -1,4 +1,7 @@
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput;
using SkiaSharp;
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree
{
public class PropertyTreeChildViewModel : PropertyTreeItemViewModel
{
@ -7,9 +10,20 @@
public PropertyTreeChildViewModel(LayerPropertyViewModel layerPropertyViewModel)
{
LayerPropertyViewModel = layerPropertyViewModel;
// TODO: Leverage DI for this and make it less shitty :))
if (LayerPropertyViewModel.LayerProperty.Type == typeof(SKPoint))
PropertyInputViewModel = new SKPointPropertyInputViewModel(LayerPropertyViewModel);
else if (LayerPropertyViewModel.LayerProperty.Type == typeof(SKSize))
PropertyInputViewModel = new SKSizePropertyInputViewModel(LayerPropertyViewModel);
else if (LayerPropertyViewModel.LayerProperty.Type == typeof(int))
PropertyInputViewModel = new IntPropertyInputViewModel(LayerPropertyViewModel);
else if (LayerPropertyViewModel.LayerProperty.Type == typeof(float))
PropertyInputViewModel = new FloatPropertyInputViewModel(LayerPropertyViewModel);
}
public LayerPropertyViewModel LayerPropertyViewModel { get; }
public PropertyInputViewModel PropertyInputViewModel { get; set; }
public bool KeyframesEnabled
{