mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Added shape properties
This commit is contained in:
parent
2c60a42315
commit
12d5fd39a0
@ -211,7 +211,6 @@
|
||||
<Compile Include="Services\Storage\Interfaces\ISurfaceService.cs" />
|
||||
<Compile Include="Services\Storage\SurfaceService.cs" />
|
||||
<Compile Include="Utilities\Easings.cs" />
|
||||
<Compile Include="Utilities\EnumUtilities.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
|
||||
@ -50,13 +50,19 @@ namespace Artemis.Core.Models.Profile
|
||||
_properties = new Dictionary<string, BaseLayerProperty>();
|
||||
|
||||
CreateDefaultProperties();
|
||||
CreateShapeType();
|
||||
|
||||
switch (layerEntity.ShapeType)
|
||||
ShapeTypeProperty.ValueChanged += (sender, args) => CreateShapeType();
|
||||
}
|
||||
|
||||
private void CreateShapeType()
|
||||
{
|
||||
switch (ShapeTypeProperty.CurrentValue)
|
||||
{
|
||||
case ShapeEntityType.Ellipse:
|
||||
case LayerShapeType.Ellipse:
|
||||
LayerShape = new Ellipse(this);
|
||||
break;
|
||||
case ShapeEntityType.Rectangle:
|
||||
case LayerShapeType.Rectangle:
|
||||
LayerShape = new Rectangle(this);
|
||||
break;
|
||||
default:
|
||||
@ -111,6 +117,12 @@ namespace Artemis.Core.Models.Profile
|
||||
/// </summary>
|
||||
public ReadOnlyCollection<BaseLayerProperty> Properties => _properties.Values.ToList().AsReadOnly();
|
||||
|
||||
public LayerProperty<LayerShapeType> ShapeTypeProperty { get; set; }
|
||||
|
||||
public LayerProperty<LayerFillType> FillTypeProperty { get; set; }
|
||||
|
||||
public LayerProperty<SKBlendMode> BlendModeProperty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The anchor point property of this layer, also found in <see cref="Properties" />
|
||||
/// </summary>
|
||||
@ -124,7 +136,7 @@ namespace Artemis.Core.Models.Profile
|
||||
/// <summary>
|
||||
/// The size property of this layer, also found in <see cref="Properties" />
|
||||
/// </summary>
|
||||
public LayerProperty<SKSize> SizeProperty { get; private set; }
|
||||
public LayerProperty<SKSize> ScaleProperty { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The rotation property of this layer range 0 - 360, also found in <see cref="Properties" />
|
||||
@ -162,41 +174,48 @@ namespace Artemis.Core.Models.Profile
|
||||
canvas.Save();
|
||||
canvas.ClipPath(Path);
|
||||
|
||||
// Apply transformations
|
||||
var sizeProperty = SizeProperty.CurrentValue;
|
||||
var rotationProperty = RotationProperty.CurrentValue;
|
||||
|
||||
var anchorPosition = GetLayerAnchorPosition();
|
||||
var anchorProperty = AnchorPointProperty.CurrentValue;
|
||||
|
||||
// Translation originates from the unscaled center of the layer and is tied to the anchor
|
||||
var x = anchorPosition.X - Bounds.MidX - anchorProperty.X * Bounds.Width;
|
||||
var y = anchorPosition.Y - Bounds.MidY - anchorProperty.Y * Bounds.Height;
|
||||
|
||||
// Rotation is always applied on the canvas
|
||||
canvas.RotateDegrees(rotationProperty, anchorPosition.X, anchorPosition.Y);
|
||||
// canvas.Scale(sizeProperty.Width, sizeProperty.Height, anchorPosition.X, anchorPosition.Y);
|
||||
// Once the other transformations are done it is save to translate
|
||||
// canvas.Translate(x, y);
|
||||
|
||||
// Placeholder
|
||||
if (LayerShape?.Path != null)
|
||||
using (var paint = new SKPaint())
|
||||
{
|
||||
var testColors = new List<SKColor>();
|
||||
for (var i = 0; i < 9; i++)
|
||||
paint.BlendMode = BlendModeProperty.CurrentValue;
|
||||
paint.Color = new SKColor(0, 0, 0, (byte) (OpacityProperty.CurrentValue * 2.55f));
|
||||
|
||||
// Apply transformations
|
||||
var sizeProperty = ScaleProperty.CurrentValue;
|
||||
var rotationProperty = RotationProperty.CurrentValue;
|
||||
|
||||
var anchorPosition = GetLayerAnchorPosition();
|
||||
var anchorProperty = AnchorPointProperty.CurrentValue;
|
||||
|
||||
// Translation originates from the unscaled center of the layer and is tied to the anchor
|
||||
var x = anchorPosition.X - Bounds.MidX - anchorProperty.X * Bounds.Width;
|
||||
var y = anchorPosition.Y - Bounds.MidY - anchorProperty.Y * Bounds.Height;
|
||||
|
||||
// Rotation is always applied on the canvas
|
||||
canvas.RotateDegrees(rotationProperty, anchorPosition.X, anchorPosition.Y);
|
||||
// canvas.Scale(sizeProperty.Width, sizeProperty.Height, anchorPosition.X, anchorPosition.Y);
|
||||
// Once the other transformations are done it is save to translate
|
||||
// canvas.Translate(x, y);
|
||||
|
||||
// Placeholder
|
||||
if (LayerShape?.Path != null)
|
||||
{
|
||||
if (i != 8)
|
||||
testColors.Add(SKColor.FromHsv(i * 32, 100, 100));
|
||||
else
|
||||
testColors.Add(SKColor.FromHsv(0, 100, 100));
|
||||
var testColors = new List<SKColor>();
|
||||
for (var i = 0; i < 9; i++)
|
||||
{
|
||||
if (i != 8)
|
||||
testColors.Add(SKColor.FromHsv(i * 32, 100, 100));
|
||||
else
|
||||
testColors.Add(SKColor.FromHsv(0, 100, 100));
|
||||
}
|
||||
|
||||
var path = new SKPath(LayerShape.Path);
|
||||
path.Transform(SKMatrix.MakeTranslation(x, y));
|
||||
path.Transform(SKMatrix.MakeScale(sizeProperty.Width / 100f, sizeProperty.Height / 100f, anchorPosition.X, anchorPosition.Y));
|
||||
|
||||
|
||||
paint.Shader = SKShader.CreateSweepGradient(new SKPoint(path.Bounds.MidX, path.Bounds.MidY), testColors.ToArray());
|
||||
canvas.DrawPath(path, paint);
|
||||
}
|
||||
|
||||
var path = new SKPath(LayerShape.Path);
|
||||
path.Transform(SKMatrix.MakeTranslation(x, y));
|
||||
path.Transform(SKMatrix.MakeScale(sizeProperty.Width, sizeProperty.Height, anchorPosition.X, anchorPosition.Y));
|
||||
|
||||
var shader = SKShader.CreateSweepGradient(new SKPoint(path.Bounds.MidX, path.Bounds.MidY), testColors.ToArray());
|
||||
canvas.DrawPath(path, new SKPaint {Shader = shader, Color = new SKColor(0, 0, 0, (byte) (OpacityProperty.CurrentValue * 2.55f))});
|
||||
}
|
||||
|
||||
LayerBrush?.Render(canvas);
|
||||
@ -253,9 +272,6 @@ namespace Artemis.Core.Models.Profile
|
||||
Configuration = JsonConvert.SerializeObject(LayerBrush.Settings)
|
||||
};
|
||||
}
|
||||
|
||||
// Shape
|
||||
LayerShape?.ApplyToEntity();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -397,22 +413,43 @@ 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};
|
||||
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 = "%"};
|
||||
RotationProperty = new LayerProperty<float>(this, transformProperty, "Core.Rotation", "Rotation", "The rotation of the shape in degrees.") {InputAffix = "°"};
|
||||
OpacityProperty = new LayerProperty<float>(this, transformProperty, "Core.Opacity", "Opacity", "The opacity of the shape.") {InputAffix = "%"};
|
||||
transformProperty.Children.Add(AnchorPointProperty);
|
||||
transformProperty.Children.Add(PositionProperty);
|
||||
transformProperty.Children.Add(SizeProperty);
|
||||
transformProperty.Children.Add(RotationProperty);
|
||||
transformProperty.Children.Add(OpacityProperty);
|
||||
var shape = new LayerProperty<object>(this, null, "Core.Shape", "Shape", "A collection of basic shape properties.");
|
||||
ShapeTypeProperty = new LayerProperty<LayerShapeType>(this, shape, "Core.ShapeType", "Shape type", "The type of shape to draw in this layer.") {CanUseKeyframes = false};
|
||||
FillTypeProperty = new LayerProperty<LayerFillType>(this, shape, "Core.FillType", "Fill type", "How to make the shape adjust to scale changes.") {CanUseKeyframes = false};
|
||||
BlendModeProperty = new LayerProperty<SKBlendMode>(this, shape, "Core.BlendMode", "Blend mode", "How to blend this layer into the resulting image.") {CanUseKeyframes = false};
|
||||
shape.Children.Add(ShapeTypeProperty);
|
||||
shape.Children.Add(FillTypeProperty);
|
||||
shape.Children.Add(BlendModeProperty);
|
||||
|
||||
AddLayerProperty(transformProperty);
|
||||
foreach (var transformPropertyChild in transformProperty.Children)
|
||||
AddLayerProperty(transformPropertyChild);
|
||||
var transform = new LayerProperty<object>(this, null, "Core.Transform", "Transform", "A collection of transformation properties.") {ExpandByDefault = true};
|
||||
AnchorPointProperty = new LayerProperty<SKPoint>(this, transform, "Core.AnchorPoint", "Anchor Point", "The point at which the shape is attached to its position.");
|
||||
PositionProperty = new LayerProperty<SKPoint>(this, transform, "Core.Position", "Position", "The position of the shape.");
|
||||
ScaleProperty = new LayerProperty<SKSize>(this, transform, "Core.Scale", "Scale", "The scale of the shape.") {InputAffix = "%"};
|
||||
RotationProperty = new LayerProperty<float>(this, transform, "Core.Rotation", "Rotation", "The rotation of the shape in degrees.") {InputAffix = "°"};
|
||||
OpacityProperty = new LayerProperty<float>(this, transform, "Core.Opacity", "Opacity", "The opacity of the shape.") {InputAffix = "%"};
|
||||
transform.Children.Add(AnchorPointProperty);
|
||||
transform.Children.Add(PositionProperty);
|
||||
transform.Children.Add(ScaleProperty);
|
||||
transform.Children.Add(RotationProperty);
|
||||
|
||||
// Set default values
|
||||
ShapeTypeProperty.Value = LayerShapeType.Rectangle;
|
||||
FillTypeProperty.Value = LayerFillType.Stretch;
|
||||
BlendModeProperty.Value = SKBlendMode.SrcOver;
|
||||
|
||||
ScaleProperty.Value = new SKSize(100, 100);
|
||||
OpacityProperty.Value = 100;
|
||||
|
||||
|
||||
transform.Children.Add(OpacityProperty);
|
||||
|
||||
AddLayerProperty(shape);
|
||||
foreach (var shapeProperty in shape.Children)
|
||||
AddLayerProperty(shapeProperty);
|
||||
|
||||
AddLayerProperty(transform);
|
||||
foreach (var transformProperty in transform.Children)
|
||||
AddLayerProperty(transformProperty);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -434,4 +471,17 @@ namespace Artemis.Core.Models.Profile
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public enum LayerShapeType
|
||||
{
|
||||
Ellipse,
|
||||
Rectangle
|
||||
}
|
||||
|
||||
public enum LayerFillType
|
||||
{
|
||||
Stretch,
|
||||
Clip,
|
||||
Tile
|
||||
}
|
||||
}
|
||||
@ -182,7 +182,9 @@ namespace Artemis.Core.Models.Profile.LayerProperties
|
||||
/// </summary>
|
||||
public void ClearKeyframes()
|
||||
{
|
||||
BaseValue = KeyframeEngine.GetCurrentValue();
|
||||
if (KeyframeEngine != null)
|
||||
BaseValue = KeyframeEngine.GetCurrentValue();
|
||||
|
||||
BaseKeyframes.Clear();
|
||||
}
|
||||
|
||||
@ -265,6 +267,9 @@ namespace Artemis.Core.Models.Profile.LayerProperties
|
||||
|
||||
#region Events
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when this property's value was changed outside regular keyframe updates
|
||||
/// </summary>
|
||||
public event EventHandler<EventArgs> ValueChanged;
|
||||
|
||||
protected virtual void OnValueChanged()
|
||||
|
||||
@ -15,10 +15,5 @@ namespace Artemis.Core.Models.Profile.LayerShapes
|
||||
path.AddOval(Layer.Bounds);
|
||||
Path = path;
|
||||
}
|
||||
|
||||
public override void ApplyToEntity()
|
||||
{
|
||||
Layer.LayerEntity.ShapeType = ShapeEntityType.Ellipse;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -20,7 +20,5 @@ namespace Artemis.Core.Models.Profile.LayerShapes
|
||||
public SKPath Path { get; protected set; }
|
||||
|
||||
public abstract void CalculateRenderProperties();
|
||||
|
||||
public abstract void ApplyToEntity();
|
||||
}
|
||||
}
|
||||
@ -15,10 +15,5 @@ namespace Artemis.Core.Models.Profile.LayerShapes
|
||||
path.AddRect(Layer.Bounds);
|
||||
Path = path;
|
||||
}
|
||||
|
||||
public override void ApplyToEntity()
|
||||
{
|
||||
Layer.LayerEntity.ShapeType = ShapeEntityType.Rectangle;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -12,7 +12,7 @@
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
<ShouldIncludeNativeSkiaSharp>false</ShouldIncludeNativeSkiaSharp>
|
||||
<ShouldIncludeNativeSkiaSharp>false</ShouldIncludeNativeSkiaSharp>
|
||||
<TargetFrameworkProfile />
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
@ -102,6 +102,10 @@
|
||||
<Name>Artemis.Core</Name>
|
||||
<Private>False</Private>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Artemis.UI.Shared\Artemis.UI.Shared.csproj">
|
||||
<Project>{adb357e6-151d-4d0d-87cb-68fd0bc29812}</Project>
|
||||
<Name>Artemis.UI.Shared</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Core.Plugins.LayerBrush;
|
||||
using Artemis.Core.Utilities;
|
||||
using Artemis.UI.Shared.Utilities;
|
||||
|
||||
namespace Artemis.Plugins.LayerBrushes.Color
|
||||
{
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Core.Plugins.LayerBrush;
|
||||
using Artemis.Core.Utilities;
|
||||
using Artemis.UI.Shared.Utilities;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Plugins.LayerBrushes.Noise
|
||||
|
||||
@ -23,7 +23,6 @@ namespace Artemis.Storage.Entities.Profile
|
||||
public List<PropertyEntity> PropertyEntities { get; set; }
|
||||
public List<ProfileConditionEntity> Condition { get; set; }
|
||||
|
||||
public ShapeEntityType ShapeType { get; set; }
|
||||
public BrushEntity BrushEntity { get; set; }
|
||||
|
||||
[BsonRef("ProfileEntity")]
|
||||
@ -31,10 +30,4 @@ namespace Artemis.Storage.Entities.Profile
|
||||
|
||||
public Guid ProfileId { get; set; }
|
||||
}
|
||||
|
||||
public enum ShapeEntityType
|
||||
{
|
||||
Ellipse,
|
||||
Rectangle
|
||||
}
|
||||
}
|
||||
@ -13,7 +13,7 @@
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Deterministic>true</Deterministic>
|
||||
<ShouldIncludeNativeSkiaSharp>false</ShouldIncludeNativeSkiaSharp>
|
||||
<ShouldIncludeNativeSkiaSharp>false</ShouldIncludeNativeSkiaSharp>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
@ -38,6 +38,9 @@
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Humanizer, Version=2.7.0.0, Culture=neutral, PublicKeyToken=979442b78dfc278e, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Humanizer.Core.2.7.9\lib\netstandard2.0\Humanizer.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MaterialDesignColors, Version=1.2.0.325, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MaterialDesignColors.1.2.0\lib\net45\MaterialDesignColors.dll</HintPath>
|
||||
</Reference>
|
||||
@ -76,6 +79,7 @@
|
||||
<Reference Include="PresentationFramework" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Utilities\EnumUtilities.cs" />
|
||||
<Page Include="ColorPicker.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
||||
@ -3,8 +3,9 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using Humanizer;
|
||||
|
||||
namespace Artemis.Core.Utilities
|
||||
namespace Artemis.UI.Shared.Utilities
|
||||
{
|
||||
public static class EnumUtilities
|
||||
{
|
||||
@ -25,7 +26,7 @@ namespace Artemis.Core.Utilities
|
||||
if (!t.IsEnum)
|
||||
throw new ArgumentException($"{nameof(t)} must be an enum type");
|
||||
|
||||
return Enum.GetValues(t).Cast<Enum>().Select(e => new ValueDescription {Value = e, Description = e.Description()}).ToList();
|
||||
return Enum.GetValues(t).Cast<Enum>().Select(e => new ValueDescription {Value = e, Description = e.Humanize()}).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<packages>
|
||||
<package id="Humanizer.Core" version="2.7.9" targetFramework="net472" />
|
||||
<package id="MaterialDesignColors" version="1.2.0" targetFramework="net472" />
|
||||
<package id="MaterialDesignThemes" version="2.6.0" targetFramework="net472" />
|
||||
<package id="SkiaSharp" version="1.68.1" targetFramework="net472" />
|
||||
|
||||
@ -52,8 +52,8 @@
|
||||
<Reference Include="GongSolutions.WPF.DragDrop, Version=2.0.0.0, Culture=neutral, PublicKeyToken=91f1945125b7a587, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\gong-wpf-dragdrop.2.1.0\lib\net47\GongSolutions.WPF.DragDrop.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Humanizer, Version=2.6.0.0, Culture=neutral, PublicKeyToken=979442b78dfc278e, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Humanizer.Core.2.6.2\lib\netstandard2.0\Humanizer.dll</HintPath>
|
||||
<Reference Include="Humanizer, Version=2.7.0.0, Culture=neutral, PublicKeyToken=979442b78dfc278e, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Humanizer.Core.2.7.9\lib\netstandard2.0\Humanizer.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MaterialDesignColors, Version=1.2.2.920, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MaterialDesignColors.1.2.2\lib\net45\MaterialDesignColors.dll</HintPath>
|
||||
@ -169,6 +169,10 @@
|
||||
</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\EnumPropertyInputView.xaml.cs">
|
||||
<DependentUpon>EnumPropertyInputView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Screens\Module\ProfileEditor\LayerProperties\PropertyTree\PropertyInput\EnumPropertyInputViewModel.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" />
|
||||
@ -298,6 +302,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Screens\Module\ProfileEditor\LayerProperties\PropertyTree\PropertyInput\EnumPropertyInputView.xaml">
|
||||
<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>
|
||||
|
||||
@ -19,6 +19,43 @@
|
||||
</UserControl.InputBindings>
|
||||
<UserControl.Resources>
|
||||
<s:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
|
||||
<Style x:Key="SVStyle" TargetType="{x:Type ScrollViewer}">
|
||||
<Setter Property="OverridesDefaultStyle" Value="True" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ScrollViewer}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<ScrollContentPresenter Grid.ColumnSpan="2" Grid.RowSpan="2" />
|
||||
<ScrollBar Name="PART_VerticalScrollBar"
|
||||
HorizontalAlignment="Right"
|
||||
Opacity="0.5"
|
||||
Grid.Column="1"
|
||||
Value="{TemplateBinding VerticalOffset}"
|
||||
Maximum="{TemplateBinding ScrollableHeight}"
|
||||
ViewportSize="{TemplateBinding ViewportHeight}"
|
||||
Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" />
|
||||
<ScrollBar Name="PART_HorizontalScrollBar"
|
||||
VerticalAlignment="Bottom"
|
||||
Orientation="Horizontal"
|
||||
Opacity="0.5"
|
||||
Grid.Row="1"
|
||||
Value="{TemplateBinding HorizontalOffset}"
|
||||
Maximum="{TemplateBinding ScrollableWidth}"
|
||||
ViewportSize="{TemplateBinding ViewportWidth}"
|
||||
Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" />
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
<Grid x:Name="ContainerGrid">
|
||||
<Grid.RowDefinitions>
|
||||
@ -74,7 +111,11 @@
|
||||
</DockPanel>
|
||||
|
||||
<!-- Properties tree -->
|
||||
<ScrollViewer Grid.Row="1" x:Name="PropertyTreeScrollViewer" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
|
||||
<ScrollViewer x:Name="PropertyTreeScrollViewer"
|
||||
Grid.Row="1"
|
||||
HorizontalScrollBarVisibility="Hidden"
|
||||
VerticalScrollBarVisibility="Hidden"
|
||||
ScrollChanged="TimelineScrollChanged">
|
||||
<Border BorderThickness="0,0,1,0" BorderBrush="{DynamicResource MaterialDesignDivider}">
|
||||
<ContentControl s:View.Model="{Binding PropertyTree}" />
|
||||
</Border>
|
||||
@ -113,7 +154,12 @@
|
||||
</ScrollViewer>
|
||||
|
||||
<!-- Timeline rails -->
|
||||
<ScrollViewer Grid.Row="1" x:Name="TimelineRailsScrollViewer" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Hidden" ScrollChanged="TimelineScrollChanged">
|
||||
<ScrollViewer x:Name="TimelineRailsScrollViewer"
|
||||
Grid.Row="1"
|
||||
Style="{StaticResource SVStyle}"
|
||||
HorizontalScrollBarVisibility="Auto"
|
||||
VerticalScrollBarVisibility="Auto"
|
||||
ScrollChanged="TimelineScrollChanged">
|
||||
<Grid>
|
||||
<Canvas ZIndex="1"
|
||||
Margin="{Binding TimeCaretPosition}"
|
||||
@ -125,7 +171,6 @@
|
||||
</Canvas>
|
||||
<ContentControl x:Name="PropertyTimeLine" s:View.Model="{Binding PropertyTimeline}" />
|
||||
</Grid>
|
||||
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
|
||||
|
||||
@ -17,8 +17,13 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
||||
{
|
||||
if (sender == TimelineHeaderScrollViewer)
|
||||
TimelineRailsScrollViewer.ScrollToHorizontalOffset(e.HorizontalOffset);
|
||||
else if (sender == PropertyTreeScrollViewer)
|
||||
TimelineRailsScrollViewer.ScrollToVerticalOffset(e.VerticalOffset);
|
||||
else if (sender == TimelineRailsScrollViewer)
|
||||
{
|
||||
TimelineHeaderScrollViewer.ScrollToHorizontalOffset(e.HorizontalOffset);
|
||||
PropertyTreeScrollViewer.ScrollToVerticalOffset(e.VerticalOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Artemis.Core.Models.Profile.LayerProperties;
|
||||
using Artemis.UI.Ninject.Factories;
|
||||
@ -58,14 +59,19 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
||||
|
||||
// Force the keyframe engine to update, the new keyframe is the current keyframe
|
||||
LayerProperty.IsUsingKeyframes = _keyframesEnabled;
|
||||
LayerProperty.KeyframeEngine.Update(0);
|
||||
LayerProperty.KeyframeEngine?.Update(0);
|
||||
|
||||
_profileEditorService.UpdateSelectedProfileElement();
|
||||
}
|
||||
|
||||
public PropertyInputViewModel GetPropertyInputViewModel()
|
||||
{
|
||||
var match = _kernel.Get<List<PropertyInputViewModel>>().FirstOrDefault(p => p.CompatibleTypes.Contains(LayerProperty.Type));
|
||||
// If the type is an enum type, search for Enum instead.
|
||||
var type = LayerProperty.Type;
|
||||
if (type.IsEnum)
|
||||
type = typeof(Enum);
|
||||
|
||||
var match = _kernel.Get<List<PropertyInputViewModel>>().FirstOrDefault(p => p.CompatibleTypes.Contains(type));
|
||||
if (match == null)
|
||||
return null;
|
||||
|
||||
|
||||
@ -0,0 +1,34 @@
|
||||
<UserControl x:Class="Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput.EnumPropertyInputView"
|
||||
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"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance local:EnumPropertyInputViewModel}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Margin="0 0 5 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputPrefix}" />
|
||||
<ComboBox Width="132"
|
||||
Margin="0 2"
|
||||
Padding="0 -1"
|
||||
Height="15"
|
||||
materialDesign:ValidationAssist.UsePopup="True"
|
||||
HorizontalAlignment="Left"
|
||||
ItemsSource="{Binding Path=EnumValues}"
|
||||
SelectedValuePath="Value"
|
||||
DisplayMemberPath="Description"
|
||||
SelectedValue="{Binding Path=EnumInputValue}"
|
||||
RequestBringIntoView="{s:Action OnRequestBringIntoView}"
|
||||
materialDesign:ComboBoxAssist.ClassicMode="True">
|
||||
<ComboBox.ItemContainerStyle>
|
||||
<Style TargetType="ComboBoxItem" BasedOn="{StaticResource MaterialDesignComboBoxItemStyle}">
|
||||
<EventSetter Event="RequestBringIntoView" Handler="OnRequestBringIntoView"/>
|
||||
</Style>
|
||||
</ComboBox.ItemContainerStyle>
|
||||
</ComboBox>
|
||||
<TextBlock Margin="5 0 0 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" />
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
@ -0,0 +1,33 @@
|
||||
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;
|
||||
|
||||
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for EnumPropertyInputView.xaml
|
||||
/// </summary>
|
||||
public partial class EnumPropertyInputView : UserControl
|
||||
{
|
||||
public EnumPropertyInputView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void OnRequestBringIntoView(object sender, RequestBringIntoViewEventArgs e)
|
||||
{
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Artemis.UI.Services.Interfaces;
|
||||
using Artemis.UI.Shared.Utilities;
|
||||
|
||||
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput
|
||||
{
|
||||
public class EnumPropertyInputViewModel : PropertyInputViewModel
|
||||
{
|
||||
public EnumPropertyInputViewModel(IProfileEditorService profileEditorService) : base(profileEditorService)
|
||||
{
|
||||
}
|
||||
|
||||
public IEnumerable<ValueDescription> EnumValues { get; private set; }
|
||||
|
||||
public sealed override List<Type> CompatibleTypes { get; } = new List<Type> {typeof(Enum)};
|
||||
|
||||
public object EnumInputValue
|
||||
{
|
||||
get => InputValue ?? Enum.GetValues(LayerPropertyViewModel.LayerProperty.Type).Cast<object>().First();
|
||||
set => InputValue = value;
|
||||
}
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
EnumValues = EnumUtilities.GetAllValuesAndDescriptions(LayerPropertyViewModel.LayerProperty.Type);
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
NotifyOfPropertyChange(() => EnumInputValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5,6 +5,7 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance local:FloatPropertyInputViewModel}">
|
||||
@ -15,7 +16,8 @@
|
||||
Padding="0 -1"
|
||||
materialDesign:ValidationAssist.UsePopup="True"
|
||||
HorizontalAlignment="Left"
|
||||
Text="{Binding FloatInputValue}" />
|
||||
Text="{Binding FloatInputValue}"
|
||||
RequestBringIntoView="{s:Action OnRequestBringIntoView}"/>
|
||||
<TextBlock Margin="5 0 0 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" />
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
@ -5,6 +5,7 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance local:IntPropertyInputViewModel}">
|
||||
@ -15,7 +16,8 @@
|
||||
Padding="0 -1"
|
||||
materialDesign:ValidationAssist.UsePopup="True"
|
||||
HorizontalAlignment="Left"
|
||||
Text="{Binding IntInputValue}" />
|
||||
Text="{Binding IntInputValue}"
|
||||
RequestBringIntoView="{s:Action OnRequestBringIntoView}"/>
|
||||
<TextBlock Margin="5 0 0 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" />
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using Artemis.UI.Exceptions;
|
||||
using Artemis.UI.Services.Interfaces;
|
||||
using Stylet;
|
||||
@ -28,16 +29,31 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
|
||||
|
||||
public void Initialize(LayerPropertyViewModel layerPropertyViewModel)
|
||||
{
|
||||
var type = layerPropertyViewModel.LayerProperty.Type;
|
||||
if (type.IsEnum)
|
||||
type = typeof(Enum);
|
||||
if (Initialized)
|
||||
throw new ArtemisUIException("Cannot initialize the same property input VM twice");
|
||||
if (!CompatibleTypes.Contains(layerPropertyViewModel.LayerProperty.Type))
|
||||
throw new ArtemisUIException($"This input VM does not support the provided type {layerPropertyViewModel.LayerProperty.Type.Name}");
|
||||
if (!CompatibleTypes.Contains(type))
|
||||
throw new ArtemisUIException($"This input VM does not support the provided type {type.Name}");
|
||||
|
||||
LayerPropertyViewModel = layerPropertyViewModel;
|
||||
layerPropertyViewModel.LayerProperty.ValueChanged += (sender, args) => Update();
|
||||
Update();
|
||||
|
||||
Initialized = true;
|
||||
|
||||
OnInitialized();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called by the view, prevents scrolling into view when scrubbing through the timeline
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
public void OnRequestBringIntoView(object sender, RequestBringIntoViewEventArgs e)
|
||||
{
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void UpdateInputValue(object value)
|
||||
@ -49,6 +65,10 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
|
||||
ProfileEditorService.UpdateSelectedProfileElement();
|
||||
}
|
||||
|
||||
protected virtual void OnInitialized()
|
||||
{
|
||||
}
|
||||
|
||||
public abstract void Update();
|
||||
}
|
||||
}
|
||||
@ -5,6 +5,7 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="25" d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance local:SKPointPropertyInputViewModel}">
|
||||
@ -16,7 +17,8 @@
|
||||
materialDesign:ValidationAssist.UsePopup="True"
|
||||
HorizontalAlignment="Left"
|
||||
ToolTip="X-coordinate (horizontal)"
|
||||
Text="{Binding X}" />
|
||||
Text="{Binding X}"
|
||||
RequestBringIntoView="{s:Action OnRequestBringIntoView}"/>
|
||||
<TextBlock Margin="5 0" VerticalAlignment="Bottom">,</TextBlock>
|
||||
<TextBox Width="60"
|
||||
Margin="0 2"
|
||||
@ -24,7 +26,8 @@
|
||||
materialDesign:ValidationAssist.UsePopup="True"
|
||||
HorizontalAlignment="Left"
|
||||
ToolTip="Y-coordinate (vertical)"
|
||||
Text="{Binding Y}" />
|
||||
Text="{Binding Y}"
|
||||
RequestBringIntoView="{s:Action OnRequestBringIntoView}"/>
|
||||
<TextBlock Margin="5 0 0 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" />
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
@ -5,6 +5,7 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance local:SKSizePropertyInputViewModel}">
|
||||
@ -16,7 +17,8 @@
|
||||
materialDesign:ValidationAssist.UsePopup="True"
|
||||
HorizontalAlignment="Left"
|
||||
ToolTip="Height"
|
||||
Text="{Binding Height}" />
|
||||
Text="{Binding Height}"
|
||||
RequestBringIntoView="{s:Action OnRequestBringIntoView}"/>
|
||||
<TextBlock Margin="5 0" VerticalAlignment="Bottom">,</TextBlock>
|
||||
<TextBox Width="60"
|
||||
Margin="0 2"
|
||||
@ -24,7 +26,8 @@
|
||||
materialDesign:ValidationAssist.UsePopup="True"
|
||||
HorizontalAlignment="Left"
|
||||
ToolTip="Width"
|
||||
Text="{Binding Width}" />
|
||||
Text="{Binding Width}"
|
||||
RequestBringIntoView="{s:Action OnRequestBringIntoView}"/>
|
||||
<TextBlock Margin="5 0 0 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" />
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
@ -23,6 +23,7 @@
|
||||
Width="18"
|
||||
Height="18"
|
||||
IsChecked="{Binding LayerPropertyViewModel.KeyframesEnabled}"
|
||||
IsEnabled="{Binding LayerPropertyViewModel.LayerProperty.CanUseKeyframes}"
|
||||
VerticalAlignment="Center" Padding="-25">
|
||||
<materialDesign:PackIcon Kind="Stopwatch" Height="13" Width="13" />
|
||||
</ToggleButton>
|
||||
|
||||
@ -82,6 +82,7 @@
|
||||
<TreeView ItemsSource="{Binding PropertyTreeItemViewModels}"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
Background="{DynamicResource MaterialDesignToolBarBackground}"
|
||||
PreviewMouseWheel="{s:Action PropertyTreePreviewMouseWheel}"
|
||||
Margin="0 -1">
|
||||
<TreeView.ItemContainerStyle>
|
||||
<Style TargetType="TreeViewItem" BasedOn="{StaticResource PropertyTreeStyle}">
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using Artemis.UI.Services.Interfaces;
|
||||
using Stylet;
|
||||
|
||||
@ -49,5 +52,20 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree
|
||||
foreach (var viewModel in PropertyTreeItemViewModels)
|
||||
viewModel.Update(forceUpdate);
|
||||
}
|
||||
|
||||
public void PropertyTreePreviewMouseWheel(object sender, MouseWheelEventArgs e)
|
||||
{
|
||||
if (e.Handled || !(sender is TreeView))
|
||||
return;
|
||||
|
||||
e.Handled = true;
|
||||
var eventArg = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta)
|
||||
{
|
||||
RoutedEvent = UIElement.MouseWheelEvent,
|
||||
Source = sender
|
||||
};
|
||||
var parent = ((Control) sender).Parent as UIElement;
|
||||
parent?.RaiseEvent(eventArg);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -120,7 +120,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
||||
|
||||
// The path starts at 0,0 so there's no simple way to get the position relative to the top-left of the path
|
||||
_dragStart = GetRelativePosition(sender, e.MouseEventArgs).ToSKPoint();
|
||||
_dragStartScale = layer.SizeProperty.CurrentValue;
|
||||
_dragStartScale = layer.ScaleProperty.CurrentValue;
|
||||
|
||||
// Store the original position and do a test to figure out the mouse offset
|
||||
var originalPosition = layer.PositionProperty.CurrentValue;
|
||||
@ -169,25 +169,25 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
||||
break;
|
||||
case ShapeControlPoint.TopCenter:
|
||||
height = VerticalResize(layer, position, ResizeOrigin.Top);
|
||||
width = layer.SizeProperty.CurrentValue.Width;
|
||||
width = layer.ScaleProperty.CurrentValue.Width;
|
||||
break;
|
||||
case ShapeControlPoint.RightCenter:
|
||||
width = HorizontalResize(layer, position, ResizeOrigin.Right);
|
||||
height = layer.SizeProperty.CurrentValue.Height;
|
||||
height = layer.ScaleProperty.CurrentValue.Height;
|
||||
break;
|
||||
case ShapeControlPoint.BottomCenter:
|
||||
width = layer.SizeProperty.CurrentValue.Width;
|
||||
width = layer.ScaleProperty.CurrentValue.Width;
|
||||
height = VerticalResize(layer, position, ResizeOrigin.Bottom);
|
||||
break;
|
||||
case ShapeControlPoint.LeftCenter:
|
||||
width = HorizontalResize(layer, position, ResizeOrigin.Left);
|
||||
height = layer.SizeProperty.CurrentValue.Height;
|
||||
height = layer.ScaleProperty.CurrentValue.Height;
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
layer.SizeProperty.SetCurrentValue(new SKSize(width, height), ProfileEditorService.CurrentTime);
|
||||
layer.ScaleProperty.SetCurrentValue(new SKSize(width, height), ProfileEditorService.CurrentTime);
|
||||
ProfileEditorService.UpdateProfilePreview();
|
||||
}
|
||||
|
||||
@ -206,9 +206,9 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
||||
var anchorOffset = anchorDistance / shapePath.Bounds.Width;
|
||||
|
||||
var pixelsToAdd = (position - dragStart).X / anchorOffset;
|
||||
var scaleToAdd = scalePerPixel * pixelsToAdd;
|
||||
var scaleToAdd = scalePerPixel * pixelsToAdd * 100f;
|
||||
|
||||
return Math.Max(0.001f, _dragStartScale.Width + scaleToAdd);
|
||||
return (float) Math.Round(Math.Max(0, _dragStartScale.Width + scaleToAdd), 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
|
||||
private float VerticalResize(Layer layer, SKPoint position, ResizeOrigin origin)
|
||||
@ -226,9 +226,9 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
||||
var anchorOffset = anchorDistance / shapePath.Bounds.Height;
|
||||
|
||||
var pixelsToAdd = (position - dragStart).Y / anchorOffset;
|
||||
var scaleToAdd = scalePerPixel * pixelsToAdd;
|
||||
var scaleToAdd = scalePerPixel * pixelsToAdd * 100f;
|
||||
|
||||
return Math.Max(0.001f, _dragStartScale.Height + scaleToAdd);
|
||||
return (float) Math.Round(Math.Max(0, _dragStartScale.Height + scaleToAdd), 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -250,7 +250,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
||||
{
|
||||
// The path starts at 0,0 so there's no simple way to get the position relative to the top-left of the path
|
||||
_dragStart = GetRelativePosition(sender, e.MouseEventArgs).ToSKPoint();
|
||||
_dragStartScale = layer.SizeProperty.CurrentValue;
|
||||
_dragStartScale = layer.ScaleProperty.CurrentValue;
|
||||
|
||||
// Store the original position and do a test to figure out the mouse offset
|
||||
var originalPosition = layer.PositionProperty.CurrentValue;
|
||||
@ -378,7 +378,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
||||
counterRotatePath.AddPoly(skPoints, false);
|
||||
counterRotatePath.Transform(SKMatrix.MakeRotationDegrees(layer.RotationProperty.CurrentValue * -1, pivot.X, pivot.Y));
|
||||
if (includeScale)
|
||||
counterRotatePath.Transform(SKMatrix.MakeScale(1f / layer.SizeProperty.CurrentValue.Width, 1f / layer.SizeProperty.CurrentValue.Height));
|
||||
counterRotatePath.Transform(SKMatrix.MakeScale(1f / (layer.ScaleProperty.CurrentValue.Width / 100f), 1f / (layer.ScaleProperty.CurrentValue.Height / 100f)));
|
||||
|
||||
return counterRotatePath.Points;
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ namespace Artemis.UI.Services
|
||||
|
||||
var transformGroup = new TransformGroup();
|
||||
transformGroup.Children.Add(new TranslateTransform(x, y));
|
||||
transformGroup.Children.Add(new ScaleTransform(layer.SizeProperty.CurrentValue.Width, layer.SizeProperty.CurrentValue.Height, anchorPosition.X, anchorPosition.Y));
|
||||
transformGroup.Children.Add(new ScaleTransform(layer.ScaleProperty.CurrentValue.Width / 100f, layer.ScaleProperty.CurrentValue.Height / 100f, anchorPosition.X, anchorPosition.Y));
|
||||
transformGroup.Children.Add(new RotateTransform(layer.RotationProperty.CurrentValue, anchorPosition.X, anchorPosition.Y));
|
||||
|
||||
return transformGroup;
|
||||
@ -89,7 +89,7 @@ namespace Artemis.UI.Services
|
||||
if (includeTranslation)
|
||||
path.Transform(SKMatrix.MakeTranslation(x, y));
|
||||
if (includeScale)
|
||||
path.Transform(SKMatrix.MakeScale(layer.SizeProperty.CurrentValue.Width, layer.SizeProperty.CurrentValue.Height, anchorPosition.X, anchorPosition.Y));
|
||||
path.Transform(SKMatrix.MakeScale(layer.ScaleProperty.CurrentValue.Width / 100f, layer.ScaleProperty.CurrentValue.Height / 100f, anchorPosition.X, anchorPosition.Y));
|
||||
if (includeRotation)
|
||||
path.Transform(SKMatrix.MakeRotationDegrees(layer.RotationProperty.CurrentValue, anchorPosition.X, anchorPosition.Y));
|
||||
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
<?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" />
|
||||
<package id="Fody" version="6.0.5" targetFramework="net472" developmentDependency="true" />
|
||||
<package id="gong-wpf-dragdrop" version="2.1.0" targetFramework="net472" />
|
||||
<package id="Humanizer.Core" version="2.6.2" targetFramework="net461" />
|
||||
<package id="Humanizer.Core" version="2.7.9" targetFramework="net472" />
|
||||
<package id="MaterialDesignColors" version="1.2.2" targetFramework="net472" />
|
||||
<package id="MaterialDesignExtensions" version="3.0.0-a03" targetFramework="net472" />
|
||||
<package id="MaterialDesignThemes" version="3.0.1" targetFramework="net472" />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user