1
0
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:
Robert 2020-02-05 23:48:36 +01:00
parent 2c60a42315
commit 12d5fd39a0
31 changed files with 373 additions and 114 deletions

View File

@ -211,7 +211,6 @@
<Compile Include="Services\Storage\Interfaces\ISurfaceService.cs" /> <Compile Include="Services\Storage\Interfaces\ISurfaceService.cs" />
<Compile Include="Services\Storage\SurfaceService.cs" /> <Compile Include="Services\Storage\SurfaceService.cs" />
<Compile Include="Utilities\Easings.cs" /> <Compile Include="Utilities\Easings.cs" />
<Compile Include="Utilities\EnumUtilities.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="app.config" /> <None Include="app.config" />

View File

@ -50,13 +50,19 @@ namespace Artemis.Core.Models.Profile
_properties = new Dictionary<string, BaseLayerProperty>(); _properties = new Dictionary<string, BaseLayerProperty>();
CreateDefaultProperties(); CreateDefaultProperties();
CreateShapeType();
switch (layerEntity.ShapeType) ShapeTypeProperty.ValueChanged += (sender, args) => CreateShapeType();
}
private void CreateShapeType()
{ {
case ShapeEntityType.Ellipse: switch (ShapeTypeProperty.CurrentValue)
{
case LayerShapeType.Ellipse:
LayerShape = new Ellipse(this); LayerShape = new Ellipse(this);
break; break;
case ShapeEntityType.Rectangle: case LayerShapeType.Rectangle:
LayerShape = new Rectangle(this); LayerShape = new Rectangle(this);
break; break;
default: default:
@ -111,6 +117,12 @@ namespace Artemis.Core.Models.Profile
/// </summary> /// </summary>
public ReadOnlyCollection<BaseLayerProperty> Properties => _properties.Values.ToList().AsReadOnly(); 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> /// <summary>
/// The anchor point property of this layer, also found in <see cref="Properties" /> /// The anchor point property of this layer, also found in <see cref="Properties" />
/// </summary> /// </summary>
@ -124,7 +136,7 @@ namespace Artemis.Core.Models.Profile
/// <summary> /// <summary>
/// The size property of this layer, also found in <see cref="Properties" /> /// The size property of this layer, also found in <see cref="Properties" />
/// </summary> /// </summary>
public LayerProperty<SKSize> SizeProperty { get; private set; } public LayerProperty<SKSize> ScaleProperty { get; private set; }
/// <summary> /// <summary>
/// The rotation property of this layer range 0 - 360, also found in <see cref="Properties" /> /// The rotation property of this layer range 0 - 360, also found in <see cref="Properties" />
@ -162,8 +174,13 @@ namespace Artemis.Core.Models.Profile
canvas.Save(); canvas.Save();
canvas.ClipPath(Path); canvas.ClipPath(Path);
using (var paint = new SKPaint())
{
paint.BlendMode = BlendModeProperty.CurrentValue;
paint.Color = new SKColor(0, 0, 0, (byte) (OpacityProperty.CurrentValue * 2.55f));
// Apply transformations // Apply transformations
var sizeProperty = SizeProperty.CurrentValue; var sizeProperty = ScaleProperty.CurrentValue;
var rotationProperty = RotationProperty.CurrentValue; var rotationProperty = RotationProperty.CurrentValue;
var anchorPosition = GetLayerAnchorPosition(); var anchorPosition = GetLayerAnchorPosition();
@ -193,10 +210,12 @@ namespace Artemis.Core.Models.Profile
var path = new SKPath(LayerShape.Path); var path = new SKPath(LayerShape.Path);
path.Transform(SKMatrix.MakeTranslation(x, y)); path.Transform(SKMatrix.MakeTranslation(x, y));
path.Transform(SKMatrix.MakeScale(sizeProperty.Width, sizeProperty.Height, anchorPosition.X, anchorPosition.Y)); path.Transform(SKMatrix.MakeScale(sizeProperty.Width / 100f, sizeProperty.Height / 100f, 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))}); paint.Shader = SKShader.CreateSweepGradient(new SKPoint(path.Bounds.MidX, path.Bounds.MidY), testColors.ToArray());
canvas.DrawPath(path, paint);
}
} }
LayerBrush?.Render(canvas); LayerBrush?.Render(canvas);
@ -253,9 +272,6 @@ namespace Artemis.Core.Models.Profile
Configuration = JsonConvert.SerializeObject(LayerBrush.Settings) Configuration = JsonConvert.SerializeObject(LayerBrush.Settings)
}; };
} }
// Shape
LayerShape?.ApplyToEntity();
} }
/// <summary> /// <summary>
@ -397,22 +413,43 @@ namespace Artemis.Core.Models.Profile
private void CreateDefaultProperties() 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.") var shape = new LayerProperty<object>(this, null, "Core.Shape", "Shape", "A collection of basic shape properties.");
{ExpandByDefault = true}; ShapeTypeProperty = new LayerProperty<LayerShapeType>(this, shape, "Core.ShapeType", "Shape type", "The type of shape to draw in this layer.") {CanUseKeyframes = false};
AnchorPointProperty = new LayerProperty<SKPoint>(this, transformProperty, "Core.AnchorPoint", "Anchor Point", "The point at which the shape is attached to its position."); FillTypeProperty = new LayerProperty<LayerFillType>(this, shape, "Core.FillType", "Fill type", "How to make the shape adjust to scale changes.") {CanUseKeyframes = false};
PositionProperty = new LayerProperty<SKPoint>(this, transformProperty, "Core.Position", "Position", "The position of the shape."); BlendModeProperty = new LayerProperty<SKBlendMode>(this, shape, "Core.BlendMode", "Blend mode", "How to blend this layer into the resulting image.") {CanUseKeyframes = false};
SizeProperty = new LayerProperty<SKSize>(this, transformProperty, "Core.Size", "Size", "The size of the shape.") {InputAffix = "%"}; shape.Children.Add(ShapeTypeProperty);
RotationProperty = new LayerProperty<float>(this, transformProperty, "Core.Rotation", "Rotation", "The rotation of the shape in degrees.") {InputAffix = "°"}; shape.Children.Add(FillTypeProperty);
OpacityProperty = new LayerProperty<float>(this, transformProperty, "Core.Opacity", "Opacity", "The opacity of the shape.") {InputAffix = "%"}; shape.Children.Add(BlendModeProperty);
transformProperty.Children.Add(AnchorPointProperty);
transformProperty.Children.Add(PositionProperty);
transformProperty.Children.Add(SizeProperty);
transformProperty.Children.Add(RotationProperty);
transformProperty.Children.Add(OpacityProperty);
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); AddLayerProperty(transformProperty);
foreach (var transformPropertyChild in transformProperty.Children)
AddLayerProperty(transformPropertyChild);
} }
#endregion #endregion
@ -434,4 +471,17 @@ namespace Artemis.Core.Models.Profile
#endregion #endregion
} }
public enum LayerShapeType
{
Ellipse,
Rectangle
}
public enum LayerFillType
{
Stretch,
Clip,
Tile
}
} }

View File

@ -182,7 +182,9 @@ namespace Artemis.Core.Models.Profile.LayerProperties
/// </summary> /// </summary>
public void ClearKeyframes() public void ClearKeyframes()
{ {
if (KeyframeEngine != null)
BaseValue = KeyframeEngine.GetCurrentValue(); BaseValue = KeyframeEngine.GetCurrentValue();
BaseKeyframes.Clear(); BaseKeyframes.Clear();
} }
@ -265,6 +267,9 @@ namespace Artemis.Core.Models.Profile.LayerProperties
#region Events #region Events
/// <summary>
/// Occurs when this property's value was changed outside regular keyframe updates
/// </summary>
public event EventHandler<EventArgs> ValueChanged; public event EventHandler<EventArgs> ValueChanged;
protected virtual void OnValueChanged() protected virtual void OnValueChanged()

View File

@ -15,10 +15,5 @@ namespace Artemis.Core.Models.Profile.LayerShapes
path.AddOval(Layer.Bounds); path.AddOval(Layer.Bounds);
Path = path; Path = path;
} }
public override void ApplyToEntity()
{
Layer.LayerEntity.ShapeType = ShapeEntityType.Ellipse;
}
} }
} }

View File

@ -20,7 +20,5 @@ namespace Artemis.Core.Models.Profile.LayerShapes
public SKPath Path { get; protected set; } public SKPath Path { get; protected set; }
public abstract void CalculateRenderProperties(); public abstract void CalculateRenderProperties();
public abstract void ApplyToEntity();
} }
} }

View File

@ -15,10 +15,5 @@ namespace Artemis.Core.Models.Profile.LayerShapes
path.AddRect(Layer.Bounds); path.AddRect(Layer.Bounds);
Path = path; Path = path;
} }
public override void ApplyToEntity()
{
Layer.LayerEntity.ShapeType = ShapeEntityType.Rectangle;
}
} }
} }

View File

@ -102,6 +102,10 @@
<Name>Artemis.Core</Name> <Name>Artemis.Core</Name>
<Private>False</Private> <Private>False</Private>
</ProjectReference> </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>
<ItemGroup> <ItemGroup>
<None Include="app.config" /> <None Include="app.config" />

View File

@ -1,6 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using Artemis.Core.Plugins.LayerBrush; using Artemis.Core.Plugins.LayerBrush;
using Artemis.Core.Utilities; using Artemis.UI.Shared.Utilities;
namespace Artemis.Plugins.LayerBrushes.Color namespace Artemis.Plugins.LayerBrushes.Color
{ {

View File

@ -1,6 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using Artemis.Core.Plugins.LayerBrush; using Artemis.Core.Plugins.LayerBrush;
using Artemis.Core.Utilities; using Artemis.UI.Shared.Utilities;
using SkiaSharp; using SkiaSharp;
namespace Artemis.Plugins.LayerBrushes.Noise namespace Artemis.Plugins.LayerBrushes.Noise

View File

@ -23,7 +23,6 @@ namespace Artemis.Storage.Entities.Profile
public List<PropertyEntity> PropertyEntities { get; set; } public List<PropertyEntity> PropertyEntities { get; set; }
public List<ProfileConditionEntity> Condition { get; set; } public List<ProfileConditionEntity> Condition { get; set; }
public ShapeEntityType ShapeType { get; set; }
public BrushEntity BrushEntity { get; set; } public BrushEntity BrushEntity { get; set; }
[BsonRef("ProfileEntity")] [BsonRef("ProfileEntity")]
@ -31,10 +30,4 @@ namespace Artemis.Storage.Entities.Profile
public Guid ProfileId { get; set; } public Guid ProfileId { get; set; }
} }
public enum ShapeEntityType
{
Ellipse,
Rectangle
}
} }

View File

@ -38,6 +38,9 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <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"> <Reference Include="MaterialDesignColors, Version=1.2.0.325, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MaterialDesignColors.1.2.0\lib\net45\MaterialDesignColors.dll</HintPath> <HintPath>..\packages\MaterialDesignColors.1.2.0\lib\net45\MaterialDesignColors.dll</HintPath>
</Reference> </Reference>
@ -76,6 +79,7 @@
<Reference Include="PresentationFramework" /> <Reference Include="PresentationFramework" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Utilities\EnumUtilities.cs" />
<Page Include="ColorPicker.xaml"> <Page Include="ColorPicker.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>

View File

@ -3,8 +3,9 @@ using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using Humanizer;
namespace Artemis.Core.Utilities namespace Artemis.UI.Shared.Utilities
{ {
public static class EnumUtilities public static class EnumUtilities
{ {
@ -25,7 +26,7 @@ namespace Artemis.Core.Utilities
if (!t.IsEnum) if (!t.IsEnum)
throw new ArgumentException($"{nameof(t)} must be an enum type"); 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();
} }
} }

View File

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

View File

@ -52,8 +52,8 @@
<Reference Include="GongSolutions.WPF.DragDrop, Version=2.0.0.0, Culture=neutral, PublicKeyToken=91f1945125b7a587, processorArchitecture=MSIL"> <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> <HintPath>..\packages\gong-wpf-dragdrop.2.1.0\lib\net47\GongSolutions.WPF.DragDrop.dll</HintPath>
</Reference> </Reference>
<Reference Include="Humanizer, Version=2.6.0.0, Culture=neutral, PublicKeyToken=979442b78dfc278e, processorArchitecture=MSIL"> <Reference Include="Humanizer, Version=2.7.0.0, Culture=neutral, PublicKeyToken=979442b78dfc278e, processorArchitecture=MSIL">
<HintPath>..\packages\Humanizer.Core.2.6.2\lib\netstandard2.0\Humanizer.dll</HintPath> <HintPath>..\packages\Humanizer.Core.2.7.9\lib\netstandard2.0\Humanizer.dll</HintPath>
</Reference> </Reference>
<Reference Include="MaterialDesignColors, Version=1.2.2.920, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="MaterialDesignColors, Version=1.2.2.920, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MaterialDesignColors.1.2.2\lib\net45\MaterialDesignColors.dll</HintPath> <HintPath>..\packages\MaterialDesignColors.1.2.2\lib\net45\MaterialDesignColors.dll</HintPath>
@ -169,6 +169,10 @@
</Compile> </Compile>
<Compile Include="Screens\Module\ProfileEditor\LayerProperties\LayerPropertiesViewModel.cs" /> <Compile Include="Screens\Module\ProfileEditor\LayerProperties\LayerPropertiesViewModel.cs" />
<Compile Include="Screens\Module\ProfileEditor\LayerProperties\LayerPropertyViewModel.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\FloatPropertyInputViewModel.cs" />
<Compile Include="Screens\Module\ProfileEditor\LayerProperties\PropertyTree\PropertyInput\IntPropertyInputViewModel.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\PropertyInputViewModel.cs" />
@ -298,6 +302,10 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </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"> <Page Include="Screens\Module\ProfileEditor\LayerProperties\PropertyTree\PropertyInput\FloatPropertyInputView.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>

View File

@ -19,6 +19,43 @@
</UserControl.InputBindings> </UserControl.InputBindings>
<UserControl.Resources> <UserControl.Resources>
<s:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" /> <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> </UserControl.Resources>
<Grid x:Name="ContainerGrid"> <Grid x:Name="ContainerGrid">
<Grid.RowDefinitions> <Grid.RowDefinitions>
@ -74,7 +111,11 @@
</DockPanel> </DockPanel>
<!-- Properties tree --> <!-- 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}"> <Border BorderThickness="0,0,1,0" BorderBrush="{DynamicResource MaterialDesignDivider}">
<ContentControl s:View.Model="{Binding PropertyTree}" /> <ContentControl s:View.Model="{Binding PropertyTree}" />
</Border> </Border>
@ -113,7 +154,12 @@
</ScrollViewer> </ScrollViewer>
<!-- Timeline rails --> <!-- 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> <Grid>
<Canvas ZIndex="1" <Canvas ZIndex="1"
Margin="{Binding TimeCaretPosition}" Margin="{Binding TimeCaretPosition}"
@ -125,7 +171,6 @@
</Canvas> </Canvas>
<ContentControl x:Name="PropertyTimeLine" s:View.Model="{Binding PropertyTimeline}" /> <ContentControl x:Name="PropertyTimeLine" s:View.Model="{Binding PropertyTimeline}" />
</Grid> </Grid>
</ScrollViewer> </ScrollViewer>
</Grid> </Grid>

View File

@ -17,8 +17,13 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
{ {
if (sender == TimelineHeaderScrollViewer) if (sender == TimelineHeaderScrollViewer)
TimelineRailsScrollViewer.ScrollToHorizontalOffset(e.HorizontalOffset); TimelineRailsScrollViewer.ScrollToHorizontalOffset(e.HorizontalOffset);
else if (sender == PropertyTreeScrollViewer)
TimelineRailsScrollViewer.ScrollToVerticalOffset(e.VerticalOffset);
else if (sender == TimelineRailsScrollViewer) else if (sender == TimelineRailsScrollViewer)
{
TimelineHeaderScrollViewer.ScrollToHorizontalOffset(e.HorizontalOffset); TimelineHeaderScrollViewer.ScrollToHorizontalOffset(e.HorizontalOffset);
PropertyTreeScrollViewer.ScrollToVerticalOffset(e.VerticalOffset);
}
} }
} }
} }

View File

@ -1,4 +1,5 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using Artemis.Core.Models.Profile.LayerProperties; using Artemis.Core.Models.Profile.LayerProperties;
using Artemis.UI.Ninject.Factories; using Artemis.UI.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 // Force the keyframe engine to update, the new keyframe is the current keyframe
LayerProperty.IsUsingKeyframes = _keyframesEnabled; LayerProperty.IsUsingKeyframes = _keyframesEnabled;
LayerProperty.KeyframeEngine.Update(0); LayerProperty.KeyframeEngine?.Update(0);
_profileEditorService.UpdateSelectedProfileElement(); _profileEditorService.UpdateSelectedProfileElement();
} }
public PropertyInputViewModel GetPropertyInputViewModel() 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) if (match == null)
return null; return null;

View File

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

View File

@ -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;
}
}
}

View File

@ -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);
}
}
}

View File

@ -5,6 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput" xmlns:local="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:s="https://github.com/canton7/Stylet"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800" d:DesignHeight="450" d:DesignWidth="800"
d:DataContext="{d:DesignInstance local:FloatPropertyInputViewModel}"> d:DataContext="{d:DesignInstance local:FloatPropertyInputViewModel}">
@ -15,7 +16,8 @@
Padding="0 -1" Padding="0 -1"
materialDesign:ValidationAssist.UsePopup="True" materialDesign:ValidationAssist.UsePopup="True"
HorizontalAlignment="Left" 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}" /> <TextBlock Margin="5 0 0 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" />
</StackPanel> </StackPanel>
</UserControl> </UserControl>

View File

@ -5,6 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput" xmlns:local="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:s="https://github.com/canton7/Stylet"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800" d:DesignHeight="450" d:DesignWidth="800"
d:DataContext="{d:DesignInstance local:IntPropertyInputViewModel}"> d:DataContext="{d:DesignInstance local:IntPropertyInputViewModel}">
@ -15,7 +16,8 @@
Padding="0 -1" Padding="0 -1"
materialDesign:ValidationAssist.UsePopup="True" materialDesign:ValidationAssist.UsePopup="True"
HorizontalAlignment="Left" 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}" /> <TextBlock Margin="5 0 0 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" />
</StackPanel> </StackPanel>
</UserControl> </UserControl>

View File

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows;
using Artemis.UI.Exceptions; using Artemis.UI.Exceptions;
using Artemis.UI.Services.Interfaces; using Artemis.UI.Services.Interfaces;
using Stylet; using Stylet;
@ -28,16 +29,31 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
public void Initialize(LayerPropertyViewModel layerPropertyViewModel) public void Initialize(LayerPropertyViewModel layerPropertyViewModel)
{ {
var type = layerPropertyViewModel.LayerProperty.Type;
if (type.IsEnum)
type = typeof(Enum);
if (Initialized) if (Initialized)
throw new ArtemisUIException("Cannot initialize the same property input VM twice"); throw new ArtemisUIException("Cannot initialize the same property input VM twice");
if (!CompatibleTypes.Contains(layerPropertyViewModel.LayerProperty.Type)) if (!CompatibleTypes.Contains(type))
throw new ArtemisUIException($"This input VM does not support the provided type {layerPropertyViewModel.LayerProperty.Type.Name}"); throw new ArtemisUIException($"This input VM does not support the provided type {type.Name}");
LayerPropertyViewModel = layerPropertyViewModel; LayerPropertyViewModel = layerPropertyViewModel;
layerPropertyViewModel.LayerProperty.ValueChanged += (sender, args) => Update(); layerPropertyViewModel.LayerProperty.ValueChanged += (sender, args) => Update();
Update(); Update();
Initialized = true; 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) private void UpdateInputValue(object value)
@ -49,6 +65,10 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
ProfileEditorService.UpdateSelectedProfileElement(); ProfileEditorService.UpdateSelectedProfileElement();
} }
protected virtual void OnInitialized()
{
}
public abstract void Update(); public abstract void Update();
} }
} }

View File

@ -5,6 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput" xmlns:local="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:s="https://github.com/canton7/Stylet"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="25" d:DesignWidth="800" d:DesignHeight="25" d:DesignWidth="800"
d:DataContext="{d:DesignInstance local:SKPointPropertyInputViewModel}"> d:DataContext="{d:DesignInstance local:SKPointPropertyInputViewModel}">
@ -16,7 +17,8 @@
materialDesign:ValidationAssist.UsePopup="True" materialDesign:ValidationAssist.UsePopup="True"
HorizontalAlignment="Left" HorizontalAlignment="Left"
ToolTip="X-coordinate (horizontal)" ToolTip="X-coordinate (horizontal)"
Text="{Binding X}" /> Text="{Binding X}"
RequestBringIntoView="{s:Action OnRequestBringIntoView}"/>
<TextBlock Margin="5 0" VerticalAlignment="Bottom">,</TextBlock> <TextBlock Margin="5 0" VerticalAlignment="Bottom">,</TextBlock>
<TextBox Width="60" <TextBox Width="60"
Margin="0 2" Margin="0 2"
@ -24,7 +26,8 @@
materialDesign:ValidationAssist.UsePopup="True" materialDesign:ValidationAssist.UsePopup="True"
HorizontalAlignment="Left" HorizontalAlignment="Left"
ToolTip="Y-coordinate (vertical)" 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}" /> <TextBlock Margin="5 0 0 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" />
</StackPanel> </StackPanel>
</UserControl> </UserControl>

View File

@ -5,6 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput" xmlns:local="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:s="https://github.com/canton7/Stylet"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800" d:DesignHeight="450" d:DesignWidth="800"
d:DataContext="{d:DesignInstance local:SKSizePropertyInputViewModel}"> d:DataContext="{d:DesignInstance local:SKSizePropertyInputViewModel}">
@ -16,7 +17,8 @@
materialDesign:ValidationAssist.UsePopup="True" materialDesign:ValidationAssist.UsePopup="True"
HorizontalAlignment="Left" HorizontalAlignment="Left"
ToolTip="Height" ToolTip="Height"
Text="{Binding Height}" /> Text="{Binding Height}"
RequestBringIntoView="{s:Action OnRequestBringIntoView}"/>
<TextBlock Margin="5 0" VerticalAlignment="Bottom">,</TextBlock> <TextBlock Margin="5 0" VerticalAlignment="Bottom">,</TextBlock>
<TextBox Width="60" <TextBox Width="60"
Margin="0 2" Margin="0 2"
@ -24,7 +26,8 @@
materialDesign:ValidationAssist.UsePopup="True" materialDesign:ValidationAssist.UsePopup="True"
HorizontalAlignment="Left" HorizontalAlignment="Left"
ToolTip="Width" 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}" /> <TextBlock Margin="5 0 0 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" />
</StackPanel> </StackPanel>
</UserControl> </UserControl>

View File

@ -23,6 +23,7 @@
Width="18" Width="18"
Height="18" Height="18"
IsChecked="{Binding LayerPropertyViewModel.KeyframesEnabled}" IsChecked="{Binding LayerPropertyViewModel.KeyframesEnabled}"
IsEnabled="{Binding LayerPropertyViewModel.LayerProperty.CanUseKeyframes}"
VerticalAlignment="Center" Padding="-25"> VerticalAlignment="Center" Padding="-25">
<materialDesign:PackIcon Kind="Stopwatch" Height="13" Width="13" /> <materialDesign:PackIcon Kind="Stopwatch" Height="13" Width="13" />
</ToggleButton> </ToggleButton>

View File

@ -82,6 +82,7 @@
<TreeView ItemsSource="{Binding PropertyTreeItemViewModels}" <TreeView ItemsSource="{Binding PropertyTreeItemViewModels}"
HorizontalContentAlignment="Stretch" HorizontalContentAlignment="Stretch"
Background="{DynamicResource MaterialDesignToolBarBackground}" Background="{DynamicResource MaterialDesignToolBarBackground}"
PreviewMouseWheel="{s:Action PropertyTreePreviewMouseWheel}"
Margin="0 -1"> Margin="0 -1">
<TreeView.ItemContainerStyle> <TreeView.ItemContainerStyle>
<Style TargetType="TreeViewItem" BasedOn="{StaticResource PropertyTreeStyle}"> <Style TargetType="TreeViewItem" BasedOn="{StaticResource PropertyTreeStyle}">

View File

@ -1,5 +1,8 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using Artemis.UI.Services.Interfaces; using Artemis.UI.Services.Interfaces;
using Stylet; using Stylet;
@ -49,5 +52,20 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree
foreach (var viewModel in PropertyTreeItemViewModels) foreach (var viewModel in PropertyTreeItemViewModels)
viewModel.Update(forceUpdate); 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);
}
} }
} }

View File

@ -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 // 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(); _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 // Store the original position and do a test to figure out the mouse offset
var originalPosition = layer.PositionProperty.CurrentValue; var originalPosition = layer.PositionProperty.CurrentValue;
@ -169,25 +169,25 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
break; break;
case ShapeControlPoint.TopCenter: case ShapeControlPoint.TopCenter:
height = VerticalResize(layer, position, ResizeOrigin.Top); height = VerticalResize(layer, position, ResizeOrigin.Top);
width = layer.SizeProperty.CurrentValue.Width; width = layer.ScaleProperty.CurrentValue.Width;
break; break;
case ShapeControlPoint.RightCenter: case ShapeControlPoint.RightCenter:
width = HorizontalResize(layer, position, ResizeOrigin.Right); width = HorizontalResize(layer, position, ResizeOrigin.Right);
height = layer.SizeProperty.CurrentValue.Height; height = layer.ScaleProperty.CurrentValue.Height;
break; break;
case ShapeControlPoint.BottomCenter: case ShapeControlPoint.BottomCenter:
width = layer.SizeProperty.CurrentValue.Width; width = layer.ScaleProperty.CurrentValue.Width;
height = VerticalResize(layer, position, ResizeOrigin.Bottom); height = VerticalResize(layer, position, ResizeOrigin.Bottom);
break; break;
case ShapeControlPoint.LeftCenter: case ShapeControlPoint.LeftCenter:
width = HorizontalResize(layer, position, ResizeOrigin.Left); width = HorizontalResize(layer, position, ResizeOrigin.Left);
height = layer.SizeProperty.CurrentValue.Height; height = layer.ScaleProperty.CurrentValue.Height;
break; break;
default: default:
throw new ArgumentOutOfRangeException(); throw new ArgumentOutOfRangeException();
} }
layer.SizeProperty.SetCurrentValue(new SKSize(width, height), ProfileEditorService.CurrentTime); layer.ScaleProperty.SetCurrentValue(new SKSize(width, height), ProfileEditorService.CurrentTime);
ProfileEditorService.UpdateProfilePreview(); ProfileEditorService.UpdateProfilePreview();
} }
@ -206,9 +206,9 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
var anchorOffset = anchorDistance / shapePath.Bounds.Width; var anchorOffset = anchorDistance / shapePath.Bounds.Width;
var pixelsToAdd = (position - dragStart).X / anchorOffset; 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) 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 anchorOffset = anchorDistance / shapePath.Bounds.Height;
var pixelsToAdd = (position - dragStart).Y / anchorOffset; 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 #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 // 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(); _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 // Store the original position and do a test to figure out the mouse offset
var originalPosition = layer.PositionProperty.CurrentValue; var originalPosition = layer.PositionProperty.CurrentValue;
@ -378,7 +378,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
counterRotatePath.AddPoly(skPoints, false); counterRotatePath.AddPoly(skPoints, false);
counterRotatePath.Transform(SKMatrix.MakeRotationDegrees(layer.RotationProperty.CurrentValue * -1, pivot.X, pivot.Y)); counterRotatePath.Transform(SKMatrix.MakeRotationDegrees(layer.RotationProperty.CurrentValue * -1, pivot.X, pivot.Y));
if (includeScale) 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; return counterRotatePath.Points;
} }

View File

@ -65,7 +65,7 @@ namespace Artemis.UI.Services
var transformGroup = new TransformGroup(); var transformGroup = new TransformGroup();
transformGroup.Children.Add(new TranslateTransform(x, y)); 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)); transformGroup.Children.Add(new RotateTransform(layer.RotationProperty.CurrentValue, anchorPosition.X, anchorPosition.Y));
return transformGroup; return transformGroup;
@ -89,7 +89,7 @@ namespace Artemis.UI.Services
if (includeTranslation) if (includeTranslation)
path.Transform(SKMatrix.MakeTranslation(x, y)); path.Transform(SKMatrix.MakeTranslation(x, y));
if (includeScale) 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) if (includeRotation)
path.Transform(SKMatrix.MakeRotationDegrees(layer.RotationProperty.CurrentValue, anchorPosition.X, anchorPosition.Y)); path.Transform(SKMatrix.MakeRotationDegrees(layer.RotationProperty.CurrentValue, anchorPosition.X, anchorPosition.Y));

View File

@ -1,11 +1,10 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Castle.Core" version="4.4.0" targetFramework="net461" /> <package id="Castle.Core" version="4.4.0" targetFramework="net461" />
<package id="FluentValidation" version="8.5.0" targetFramework="net472" /> <package id="FluentValidation" version="8.5.0" targetFramework="net472" />
<package id="Fody" version="6.0.5" targetFramework="net472" developmentDependency="true" /> <package id="Fody" version="6.0.5" targetFramework="net472" developmentDependency="true" />
<package id="gong-wpf-dragdrop" version="2.1.0" targetFramework="net472" /> <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="MaterialDesignColors" version="1.2.2" targetFramework="net472" />
<package id="MaterialDesignExtensions" version="3.0.0-a03" targetFramework="net472" /> <package id="MaterialDesignExtensions" version="3.0.0-a03" targetFramework="net472" />
<package id="MaterialDesignThemes" version="3.0.1" targetFramework="net472" /> <package id="MaterialDesignThemes" version="3.0.1" targetFramework="net472" />