mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-31 09:43:46 +00:00
Added undo/redo to profile editor
Added shape anchor point display and movement
This commit is contained in:
parent
7ddf816ca5
commit
0c245ba83d
@ -290,7 +290,7 @@ namespace Artemis.Core.Models.Profile
|
|||||||
Path = path;
|
Path = path;
|
||||||
// This is called here so that the shape's render properties are up to date when other code
|
// This is called here so that the shape's render properties are up to date when other code
|
||||||
// responds to OnRenderPropertiesUpdated
|
// responds to OnRenderPropertiesUpdated
|
||||||
LayerShape?.CalculateRenderProperties(PositionProperty.GetCurrentValue(), SizeProperty.GetCurrentValue());
|
LayerShape?.CalculateRenderProperties(PositionProperty.CurrentValue, SizeProperty.CurrentValue);
|
||||||
|
|
||||||
OnRenderPropertiesUpdated();
|
OnRenderPropertiesUpdated();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,7 +27,7 @@ namespace Artemis.Core.Models.Profile.LayerProperties
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected BaseLayerProperty BaseProperty { get; }
|
protected BaseLayerProperty BaseProperty { get; }
|
||||||
protected internal object BaseValue { get; set; }
|
public object BaseValue { get; internal set; }
|
||||||
public Easings.Functions EasingFunction { get; set; }
|
public Easings.Functions EasingFunction { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -101,10 +101,10 @@ namespace Artemis.Core.Models.Profile.LayerProperties
|
|||||||
|
|
||||||
protected List<BaseKeyframe> BaseKeyframes { get; set; }
|
protected List<BaseKeyframe> BaseKeyframes { get; set; }
|
||||||
|
|
||||||
protected internal object BaseValue
|
public object BaseValue
|
||||||
{
|
{
|
||||||
get => _baseValue;
|
get => _baseValue;
|
||||||
set
|
internal set
|
||||||
{
|
{
|
||||||
if (value != null && value.GetType() != Type)
|
if (value != null && value.GetType() != Type)
|
||||||
throw new ArtemisCoreException($"Cannot set value of type {value.GetType()} on property {this}, expected type is {Type}.");
|
throw new ArtemisCoreException($"Cannot set value of type {value.GetType()} on property {this}, expected type is {Type}.");
|
||||||
@ -164,13 +164,13 @@ namespace Artemis.Core.Models.Profile.LayerProperties
|
|||||||
/// Creates a new keyframe for this base property without knowing the type
|
/// Creates a new keyframe for this base property without knowing the type
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public BaseKeyframe CreateNewKeyframe(TimeSpan position)
|
public BaseKeyframe CreateNewKeyframe(TimeSpan position, object value)
|
||||||
{
|
{
|
||||||
// Create a strongly typed keyframe or else it cannot be cast later on
|
// Create a strongly typed keyframe or else it cannot be cast later on
|
||||||
var keyframeType = typeof(Keyframe<>);
|
var keyframeType = typeof(Keyframe<>);
|
||||||
var keyframe = (BaseKeyframe) Activator.CreateInstance(keyframeType.MakeGenericType(Type), Layer, this);
|
var keyframe = (BaseKeyframe) Activator.CreateInstance(keyframeType.MakeGenericType(Type), Layer, this);
|
||||||
keyframe.Position = position;
|
keyframe.Position = position;
|
||||||
keyframe.BaseValue = BaseValue;
|
keyframe.BaseValue = value;
|
||||||
BaseKeyframes.Add(keyframe);
|
BaseKeyframes.Add(keyframe);
|
||||||
SortKeyframes();
|
SortKeyframes();
|
||||||
|
|
||||||
@ -186,6 +186,17 @@ namespace Artemis.Core.Models.Profile.LayerProperties
|
|||||||
BaseKeyframes.Clear();
|
BaseKeyframes.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the current value using the regular value or if present, keyframes
|
||||||
|
/// </summary>
|
||||||
|
public object GetCurrentValue()
|
||||||
|
{
|
||||||
|
if (KeyframeEngine == null || !UntypedKeyframes.Any())
|
||||||
|
return BaseValue;
|
||||||
|
|
||||||
|
return KeyframeEngine.GetCurrentValue();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the current value using the regular value or keyframes.
|
/// Gets the current value using the regular value or keyframes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -207,12 +218,32 @@ namespace Artemis.Core.Models.Profile.LayerProperties
|
|||||||
var currentKeyframe = UntypedKeyframes.FirstOrDefault(k => k.Position == time.Value);
|
var currentKeyframe = UntypedKeyframes.FirstOrDefault(k => k.Position == time.Value);
|
||||||
// Create a new keyframe if none found
|
// Create a new keyframe if none found
|
||||||
if (currentKeyframe == null)
|
if (currentKeyframe == null)
|
||||||
currentKeyframe = CreateNewKeyframe(time.Value);
|
currentKeyframe = CreateNewKeyframe(time.Value, value);
|
||||||
|
|
||||||
currentKeyframe.BaseValue = value;
|
currentKeyframe.BaseValue = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds a keyframe to the property.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="keyframe">The keyframe to remove</param>
|
||||||
|
public void AddKeyframe(BaseKeyframe keyframe)
|
||||||
|
{
|
||||||
|
BaseKeyframes.Add(keyframe);
|
||||||
|
SortKeyframes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes a keyframe from the property.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="keyframe">The keyframe to remove</param>
|
||||||
|
public void RemoveKeyframe(BaseKeyframe keyframe)
|
||||||
|
{
|
||||||
|
BaseKeyframes.Remove(keyframe);
|
||||||
|
SortKeyframes();
|
||||||
|
}
|
||||||
|
|
||||||
internal void SortKeyframes()
|
internal void SortKeyframes()
|
||||||
{
|
{
|
||||||
BaseKeyframes = BaseKeyframes.OrderBy(k => k.Position).ToList();
|
BaseKeyframes = BaseKeyframes.OrderBy(k => k.Position).ToList();
|
||||||
|
|||||||
@ -22,7 +22,14 @@ namespace Artemis.Core.Models.Profile.LayerProperties
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the value of the property with keyframes applied
|
/// Gets the value of the property with keyframes applied
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public T CurrentValue => KeyframeEngine != null ? (T) KeyframeEngine.GetCurrentValue() : Value;
|
public T CurrentValue
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var currentValue = base.GetCurrentValue();
|
||||||
|
return currentValue == null ? default : (T)currentValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a list of keyframes defining different values of the property in time, this list contains the strongly typed
|
/// Gets a list of keyframes defining different values of the property in time, this list contains the strongly typed
|
||||||
@ -36,8 +43,7 @@ namespace Artemis.Core.Models.Profile.LayerProperties
|
|||||||
/// <param name="keyframe">The keyframe to remove</param>
|
/// <param name="keyframe">The keyframe to remove</param>
|
||||||
public void AddKeyframe(Keyframe<T> keyframe)
|
public void AddKeyframe(Keyframe<T> keyframe)
|
||||||
{
|
{
|
||||||
BaseKeyframes.Add(keyframe);
|
base.AddKeyframe(keyframe);
|
||||||
SortKeyframes();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -46,20 +52,7 @@ namespace Artemis.Core.Models.Profile.LayerProperties
|
|||||||
/// <param name="keyframe">The keyframe to remove</param>
|
/// <param name="keyframe">The keyframe to remove</param>
|
||||||
public void RemoveKeyframe(Keyframe<T> keyframe)
|
public void RemoveKeyframe(Keyframe<T> keyframe)
|
||||||
{
|
{
|
||||||
BaseKeyframes.Remove(keyframe);
|
base.RemoveKeyframe(keyframe);
|
||||||
SortKeyframes();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the current value using the regular value or if present, keyframes
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public T GetCurrentValue()
|
|
||||||
{
|
|
||||||
if (KeyframeEngine == null || !Keyframes.Any())
|
|
||||||
return Value;
|
|
||||||
|
|
||||||
return (T) KeyframeEngine.GetCurrentValue();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -81,5 +81,42 @@ namespace Artemis.Core.Models.Profile.LayerShapes
|
|||||||
(float) (height * Layer.SizeProperty.CurrentValue.Height)
|
(float) (height * Layer.SizeProperty.CurrentValue.Height)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetFromUnscaledAnchor(SKPoint anchor, TimeSpan? time)
|
||||||
|
{
|
||||||
|
if (!Layer.Leds.Any())
|
||||||
|
{
|
||||||
|
Layer.PositionProperty.SetCurrentValue(SKPoint.Empty, time);
|
||||||
|
Layer.SizeProperty.SetCurrentValue(SKSize.Empty, time);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var x = Layer.Leds.Min(l => l.RgbLed.AbsoluteLedRectangle.Location.X);
|
||||||
|
var y = Layer.Leds.Min(l => l.RgbLed.AbsoluteLedRectangle.Location.Y);
|
||||||
|
var width = Layer.Leds.Max(l => l.RgbLed.AbsoluteLedRectangle.Location.X + l.RgbLed.AbsoluteLedRectangle.Size.Width) - x;
|
||||||
|
var height = Layer.Leds.Max(l => l.RgbLed.AbsoluteLedRectangle.Location.Y + l.RgbLed.AbsoluteLedRectangle.Size.Height) - y;
|
||||||
|
|
||||||
|
Layer.AnchorPointProperty.SetCurrentValue(new SKPoint(
|
||||||
|
(float) (100f / width * (anchor.X - x - Layer.PositionProperty.CurrentValue.X)) / 100f,
|
||||||
|
(float) (100f / height * (anchor.Y - y - Layer.PositionProperty.CurrentValue.Y)) / 100f
|
||||||
|
), time);
|
||||||
|
CalculateRenderProperties(Layer.PositionProperty.CurrentValue, Layer.SizeProperty.CurrentValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SKPoint GetUnscaledAnchor()
|
||||||
|
{
|
||||||
|
if (!Layer.Leds.Any())
|
||||||
|
return SKPoint.Empty;
|
||||||
|
|
||||||
|
var x = Layer.Leds.Min(l => l.RgbLed.AbsoluteLedRectangle.Location.X);
|
||||||
|
var y = Layer.Leds.Min(l => l.RgbLed.AbsoluteLedRectangle.Location.Y);
|
||||||
|
var width = Layer.Leds.Max(l => l.RgbLed.AbsoluteLedRectangle.Location.X + l.RgbLed.AbsoluteLedRectangle.Size.Width) - x;
|
||||||
|
var height = Layer.Leds.Max(l => l.RgbLed.AbsoluteLedRectangle.Location.Y + l.RgbLed.AbsoluteLedRectangle.Size.Height) - y;
|
||||||
|
|
||||||
|
return new SKPoint(
|
||||||
|
(float) (x + width * (Layer.AnchorPointProperty.CurrentValue.X + Layer.PositionProperty.CurrentValue.X)),
|
||||||
|
(float) (y + height * (Layer.AnchorPointProperty.CurrentValue.Y + Layer.PositionProperty.CurrentValue.Y))
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Artemis.Core.Exceptions;
|
using Artemis.Core.Exceptions;
|
||||||
using Artemis.Core.Models.Surface;
|
using Artemis.Core.Models.Surface;
|
||||||
@ -17,6 +18,8 @@ namespace Artemis.Core.Models.Profile
|
|||||||
|
|
||||||
PluginInfo = pluginInfo;
|
PluginInfo = pluginInfo;
|
||||||
Name = name;
|
Name = name;
|
||||||
|
UndoStack = new Stack<string>();
|
||||||
|
RedoStack = new Stack<string>();
|
||||||
|
|
||||||
AddChild(new Folder(this, null, "Root folder"));
|
AddChild(new Folder(this, null, "Root folder"));
|
||||||
ApplyToEntity();
|
ApplyToEntity();
|
||||||
@ -28,14 +31,10 @@ namespace Artemis.Core.Models.Profile
|
|||||||
EntityId = profileEntity.Id;
|
EntityId = profileEntity.Id;
|
||||||
|
|
||||||
PluginInfo = pluginInfo;
|
PluginInfo = pluginInfo;
|
||||||
Name = profileEntity.Name;
|
UndoStack = new Stack<string>();
|
||||||
|
RedoStack = new Stack<string>();
|
||||||
|
|
||||||
// Populate the profile starting at the root, the rest is populated recursively
|
ApplyToProfile();
|
||||||
var rootFolder = profileEntity.Folders.FirstOrDefault(f => f.ParentId == new Guid());
|
|
||||||
if (rootFolder == null)
|
|
||||||
AddChild(new Folder(this, null, "Root folder"));
|
|
||||||
else
|
|
||||||
AddChild(new Folder(this, null, rootFolder));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PluginInfo PluginInfo { get; }
|
public PluginInfo PluginInfo { get; }
|
||||||
@ -43,6 +42,9 @@ namespace Artemis.Core.Models.Profile
|
|||||||
|
|
||||||
internal ProfileEntity ProfileEntity { get; set; }
|
internal ProfileEntity ProfileEntity { get; set; }
|
||||||
|
|
||||||
|
internal Stack<string> UndoStack { get; set; }
|
||||||
|
internal Stack<string> RedoStack { get; set; }
|
||||||
|
|
||||||
public override void Update(double deltaTime)
|
public override void Update(double deltaTime)
|
||||||
{
|
{
|
||||||
lock (this)
|
lock (this)
|
||||||
@ -89,6 +91,22 @@ namespace Artemis.Core.Models.Profile
|
|||||||
ProfileEntity.Layers.AddRange(GetAllLayers().Select(f => f.LayerEntity));
|
ProfileEntity.Layers.AddRange(GetAllLayers().Select(f => f.LayerEntity));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ApplyToProfile()
|
||||||
|
{
|
||||||
|
Name = ProfileEntity.Name;
|
||||||
|
|
||||||
|
lock (_children)
|
||||||
|
{
|
||||||
|
_children.Clear();
|
||||||
|
// Populate the profile starting at the root, the rest is populated recursively
|
||||||
|
var rootFolder = ProfileEntity.Folders.FirstOrDefault(f => f.ParentId == new Guid());
|
||||||
|
if (rootFolder == null)
|
||||||
|
AddChild(new Folder(this, null, "Root folder"));
|
||||||
|
else
|
||||||
|
AddChild(new Folder(this, null, rootFolder));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal void Activate(ArtemisSurface surface)
|
internal void Activate(ArtemisSurface surface)
|
||||||
{
|
{
|
||||||
lock (this)
|
lock (this)
|
||||||
|
|||||||
@ -19,5 +19,19 @@ namespace Artemis.Core.Services.Storage.Interfaces
|
|||||||
/// <param name="module">The module to activate the profile for</param>
|
/// <param name="module">The module to activate the profile for</param>
|
||||||
/// <param name="profile">The profile to activate</param>
|
/// <param name="profile">The profile to activate</param>
|
||||||
void ActivateProfile(ProfileModule module, Profile profile);
|
void ActivateProfile(ProfileModule module, Profile profile);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Attempts to restore the profile to the state it had before the last <see cref="UpdateProfile" /> call.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="selectedProfile"></param>
|
||||||
|
/// <param name="module"></param>
|
||||||
|
void UndoUpdateProfile(Profile selectedProfile, ProfileModule module);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Attempts to restore the profile to the state it had before the last <see cref="UndoUpdateProfile" /> call.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="selectedProfile"></param>
|
||||||
|
/// <param name="module"></param>
|
||||||
|
void RedoUpdateProfile(Profile selectedProfile, ProfileModule module);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7,7 +7,9 @@ using Artemis.Core.Plugins.Abstract;
|
|||||||
using Artemis.Core.Plugins.LayerBrush;
|
using Artemis.Core.Plugins.LayerBrush;
|
||||||
using Artemis.Core.Services.Interfaces;
|
using Artemis.Core.Services.Interfaces;
|
||||||
using Artemis.Core.Services.Storage.Interfaces;
|
using Artemis.Core.Services.Storage.Interfaces;
|
||||||
|
using Artemis.Storage.Entities.Profile;
|
||||||
using Artemis.Storage.Repositories.Interfaces;
|
using Artemis.Storage.Repositories.Interfaces;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Artemis.Core.Services.Storage
|
namespace Artemis.Core.Services.Storage
|
||||||
{
|
{
|
||||||
@ -92,6 +94,10 @@ namespace Artemis.Core.Services.Storage
|
|||||||
|
|
||||||
public void UpdateProfile(Profile profile, bool includeChildren)
|
public void UpdateProfile(Profile profile, bool includeChildren)
|
||||||
{
|
{
|
||||||
|
var memento = JsonConvert.SerializeObject(profile.ProfileEntity);
|
||||||
|
profile.RedoStack.Clear();
|
||||||
|
profile.UndoStack.Push(memento);
|
||||||
|
|
||||||
profile.ApplyToEntity();
|
profile.ApplyToEntity();
|
||||||
if (includeChildren)
|
if (includeChildren)
|
||||||
{
|
{
|
||||||
@ -104,6 +110,34 @@ namespace Artemis.Core.Services.Storage
|
|||||||
_profileRepository.Save(profile.ProfileEntity);
|
_profileRepository.Save(profile.ProfileEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UndoUpdateProfile(Profile profile, ProfileModule module)
|
||||||
|
{
|
||||||
|
if (!profile.UndoStack.Any())
|
||||||
|
return;
|
||||||
|
|
||||||
|
ActivateProfile(module, null);
|
||||||
|
var top = profile.UndoStack.Pop();
|
||||||
|
var memento = JsonConvert.SerializeObject(profile.ProfileEntity);
|
||||||
|
profile.RedoStack.Push(memento);
|
||||||
|
profile.ProfileEntity = JsonConvert.DeserializeObject<ProfileEntity>(top);
|
||||||
|
profile.ApplyToProfile();
|
||||||
|
ActivateProfile(module, profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RedoUpdateProfile(Profile profile, ProfileModule module)
|
||||||
|
{
|
||||||
|
if (!profile.RedoStack.Any())
|
||||||
|
return;
|
||||||
|
|
||||||
|
ActivateProfile(module, null);
|
||||||
|
var top = profile.RedoStack.Pop();
|
||||||
|
var memento = JsonConvert.SerializeObject(profile.ProfileEntity);
|
||||||
|
profile.UndoStack.Push(memento);
|
||||||
|
profile.ProfileEntity = JsonConvert.DeserializeObject<ProfileEntity>(top);
|
||||||
|
profile.ApplyToProfile();
|
||||||
|
ActivateProfile(module, profile);
|
||||||
|
}
|
||||||
|
|
||||||
private void InstantiateProfileLayerBrushes(Profile profile)
|
private void InstantiateProfileLayerBrushes(Profile profile)
|
||||||
{
|
{
|
||||||
var layerBrushProviders = _pluginService.GetPluginsOfType<LayerBrushProvider>();
|
var layerBrushProviders = _pluginService.GetPluginsOfType<LayerBrushProvider>();
|
||||||
|
|||||||
@ -70,6 +70,6 @@ namespace Artemis.UI.Ninject.Factories
|
|||||||
|
|
||||||
public interface IPropertyTrackKeyframeViewModelFactory : IViewModelFactory
|
public interface IPropertyTrackKeyframeViewModelFactory : IViewModelFactory
|
||||||
{
|
{
|
||||||
PropertyTrackKeyframeViewModel Create(BaseKeyframe keyframe);
|
PropertyTrackKeyframeViewModel Create(PropertyTrackViewModel propertyTrackViewModel, BaseKeyframe keyframe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -51,7 +51,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
|||||||
{
|
{
|
||||||
// Either create a new first keyframe or clear all the keyframes
|
// Either create a new first keyframe or clear all the keyframes
|
||||||
if (_keyframesEnabled)
|
if (_keyframesEnabled)
|
||||||
LayerProperty.CreateNewKeyframe(_profileEditorService.CurrentTime);
|
LayerProperty.CreateNewKeyframe(_profileEditorService.CurrentTime, LayerProperty.GetCurrentValue());
|
||||||
else
|
else
|
||||||
LayerProperty.ClearKeyframes();
|
LayerProperty.ClearKeyframes();
|
||||||
|
|
||||||
|
|||||||
@ -15,8 +15,7 @@
|
|||||||
Padding="0 -1"
|
Padding="0 -1"
|
||||||
materialDesign:ValidationAssist.UsePopup="True"
|
materialDesign:ValidationAssist.UsePopup="True"
|
||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
Text="{Binding FloatInputValue}"
|
Text="{Binding FloatInputValue}" />
|
||||||
Cursor="/Resources/aero_drag_ew.cur" />
|
|
||||||
<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>
|
||||||
@ -15,8 +15,7 @@
|
|||||||
Padding="0 -1"
|
Padding="0 -1"
|
||||||
materialDesign:ValidationAssist.UsePopup="True"
|
materialDesign:ValidationAssist.UsePopup="True"
|
||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
Text="{Binding IntInputValue}"
|
Text="{Binding IntInputValue}"/>
|
||||||
Cursor="/Resources/aero_drag_ew.cur" />
|
|
||||||
<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>
|
||||||
@ -23,7 +23,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
|
|||||||
|
|
||||||
protected object InputValue
|
protected object InputValue
|
||||||
{
|
{
|
||||||
get => LayerPropertyViewModel.LayerProperty.KeyframeEngine.GetCurrentValue();
|
get => LayerPropertyViewModel.LayerProperty.GetCurrentValue();
|
||||||
set => UpdateInputValue(value);
|
set => UpdateInputValue(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -16,8 +16,7 @@
|
|||||||
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}" />
|
||||||
Cursor="/Resources/aero_drag_ew.cur" KeyboardNavigation.IsTabStop="True" TabIndex="1" />
|
|
||||||
<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"
|
||||||
@ -25,8 +24,7 @@
|
|||||||
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}" />
|
||||||
Cursor="/Resources/aero_drag_ew.cur" KeyboardNavigation.IsTabStop="True" TabIndex="2" />
|
|
||||||
<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>
|
||||||
@ -16,8 +16,7 @@
|
|||||||
materialDesign:ValidationAssist.UsePopup="True"
|
materialDesign:ValidationAssist.UsePopup="True"
|
||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
ToolTip="Height"
|
ToolTip="Height"
|
||||||
Text="{Binding Height}"
|
Text="{Binding Height}"/>
|
||||||
Cursor="/Resources/aero_drag_ew.cur" />
|
|
||||||
<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"
|
||||||
@ -25,8 +24,7 @@
|
|||||||
materialDesign:ValidationAssist.UsePopup="True"
|
materialDesign:ValidationAssist.UsePopup="True"
|
||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
ToolTip="Width"
|
ToolTip="Width"
|
||||||
Text="{Binding Width}"
|
Text="{Binding Width}" />
|
||||||
Cursor="/Resources/aero_drag_ew.cur" />
|
|
||||||
<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>
|
||||||
@ -14,15 +14,18 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
|
|||||||
private readonly IProfileEditorService _profileEditorService;
|
private readonly IProfileEditorService _profileEditorService;
|
||||||
private int _pixelsPerSecond;
|
private int _pixelsPerSecond;
|
||||||
|
|
||||||
public PropertyTrackKeyframeViewModel(BaseKeyframe keyframe, IProfileEditorService profileEditorService)
|
public PropertyTrackKeyframeViewModel(PropertyTrackViewModel propertyTrackViewModel, BaseKeyframe keyframe, IProfileEditorService profileEditorService)
|
||||||
{
|
{
|
||||||
_profileEditorService = profileEditorService;
|
_profileEditorService = profileEditorService;
|
||||||
|
|
||||||
|
PropertyTrackViewModel = propertyTrackViewModel;
|
||||||
Keyframe = keyframe;
|
Keyframe = keyframe;
|
||||||
EasingViewModels = new BindableCollection<PropertyTrackEasingViewModel>();
|
EasingViewModels = new BindableCollection<PropertyTrackEasingViewModel>();
|
||||||
CreateEasingViewModels();
|
CreateEasingViewModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsSelected { get; set; }
|
||||||
|
public PropertyTrackViewModel PropertyTrackViewModel { get; }
|
||||||
public BaseKeyframe Keyframe { get; }
|
public BaseKeyframe Keyframe { get; }
|
||||||
public BindableCollection<PropertyTrackEasingViewModel> EasingViewModels { get; set; }
|
public BindableCollection<PropertyTrackEasingViewModel> EasingViewModels { get; set; }
|
||||||
public double X { get; set; }
|
public double X { get; set; }
|
||||||
@ -49,6 +52,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
|
|||||||
public void KeyframeMouseUp(object sender, MouseButtonEventArgs e)
|
public void KeyframeMouseUp(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
((IInputElement) sender).ReleaseMouseCapture();
|
((IInputElement) sender).ReleaseMouseCapture();
|
||||||
|
_profileEditorService.UpdateSelectedProfileElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void KeyframeMouseMove(object sender, MouseEventArgs e)
|
public void KeyframeMouseMove(object sender, MouseEventArgs e)
|
||||||
@ -72,7 +76,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
|
|||||||
Keyframe.Position = newTime;
|
Keyframe.Position = newTime;
|
||||||
|
|
||||||
Update(_pixelsPerSecond);
|
Update(_pixelsPerSecond);
|
||||||
_profileEditorService.UpdateSelectedProfileElement();
|
_profileEditorService.UpdateProfilePreview();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,12 +89,29 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
|
|||||||
Keyframe.Position = newTime;
|
Keyframe.Position = newTime;
|
||||||
|
|
||||||
Update(_pixelsPerSecond);
|
Update(_pixelsPerSecond);
|
||||||
_profileEditorService.UpdateSelectedProfileElement();
|
_profileEditorService.UpdateProfilePreview();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Context menu actions
|
||||||
|
|
||||||
|
public void Copy()
|
||||||
|
{
|
||||||
|
var keyframe = PropertyTrackViewModel.LayerPropertyViewModel.LayerProperty.CreateNewKeyframe(Keyframe.Position, Keyframe.BaseValue);
|
||||||
|
keyframe.EasingFunction = Keyframe.EasingFunction;
|
||||||
|
_profileEditorService.UpdateSelectedProfileElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Delete()
|
||||||
|
{
|
||||||
|
PropertyTrackViewModel.LayerPropertyViewModel.LayerProperty.RemoveKeyframe(Keyframe);
|
||||||
|
_profileEditorService.UpdateSelectedProfileElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Easing
|
#region Easing
|
||||||
|
|
||||||
private void CreateEasingViewModels()
|
private void CreateEasingViewModels()
|
||||||
|
|||||||
@ -39,7 +39,17 @@
|
|||||||
MouseMove="{s:Action KeyframeMouseMove}">
|
MouseMove="{s:Action KeyframeMouseMove}">
|
||||||
<Ellipse.ContextMenu>
|
<Ellipse.ContextMenu>
|
||||||
<ContextMenu>
|
<ContextMenu>
|
||||||
<MenuItem Header="Copy" />
|
<MenuItem Header="Copy" Command="{s:Action Copy}">
|
||||||
|
<MenuItem.Icon>
|
||||||
|
<materialDesign:PackIcon Kind="ContentCopy" />
|
||||||
|
</MenuItem.Icon>
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem Header="Delete" Command="{s:Action Delete}">
|
||||||
|
<MenuItem.Icon>
|
||||||
|
<materialDesign:PackIcon Kind="Delete" />
|
||||||
|
</MenuItem.Icon>
|
||||||
|
</MenuItem>
|
||||||
|
<Separator />
|
||||||
<MenuItem Header="Easing" ItemsSource="{Binding EasingViewModels}">
|
<MenuItem Header="Easing" ItemsSource="{Binding EasingViewModels}">
|
||||||
<MenuItem.ItemContainerStyle>
|
<MenuItem.ItemContainerStyle>
|
||||||
<Style TargetType="{x:Type MenuItem}" BasedOn="{StaticResource MaterialDesignMenuItem}">
|
<Style TargetType="{x:Type MenuItem}" BasedOn="{StaticResource MaterialDesignMenuItem}">
|
||||||
|
|||||||
@ -39,7 +39,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
|
|||||||
{
|
{
|
||||||
if (KeyframeViewModels.Any(k => k.Keyframe == keyframe))
|
if (KeyframeViewModels.Any(k => k.Keyframe == keyframe))
|
||||||
continue;
|
continue;
|
||||||
KeyframeViewModels.Add(_propertyTrackKeyframeViewModelFactory.Create(keyframe));
|
KeyframeViewModels.Add(_propertyTrackKeyframeViewModelFactory.Create(this, keyframe));
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateKeyframes(PropertyTimelineViewModel.LayerPropertiesViewModel.PixelsPerSecond);
|
UpdateKeyframes(PropertyTimelineViewModel.LayerPropertiesViewModel.PixelsPerSecond);
|
||||||
|
|||||||
@ -20,6 +20,11 @@
|
|||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
|
|
||||||
|
<UserControl.InputBindings>
|
||||||
|
<KeyBinding Command="{s:Action Undo}" Modifiers="Control" Key="Z"></KeyBinding>
|
||||||
|
<KeyBinding Command="{s:Action Redo}" Modifiers="Control" Key="Y"></KeyBinding>
|
||||||
|
</UserControl.InputBindings>
|
||||||
|
|
||||||
<Grid Margin="16">
|
<Grid Margin="16">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<!-- Left side -->
|
<!-- Left side -->
|
||||||
|
|||||||
@ -125,6 +125,16 @@ namespace Artemis.UI.Screens.Module.ProfileEditor
|
|||||||
_profileService.DeleteProfile(profile);
|
_profileService.DeleteProfile(profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Undo()
|
||||||
|
{
|
||||||
|
_profileEditorService.UndoUpdateProfile(Module);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Redo()
|
||||||
|
{
|
||||||
|
_profileEditorService.RedoUpdateProfile(Module);
|
||||||
|
}
|
||||||
|
|
||||||
private void ModuleOnActiveProfileChanged(object sender, EventArgs e)
|
private void ModuleOnActiveProfileChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (SelectedProfile == Module.ActiveProfile)
|
if (SelectedProfile == Module.ActiveProfile)
|
||||||
|
|||||||
@ -45,7 +45,7 @@
|
|||||||
<!-- The part of the layer's shape that is inside the layer -->
|
<!-- The part of the layer's shape that is inside the layer -->
|
||||||
<Path Data="{Binding ShapeGeometry, Mode=OneWay}">
|
<Path Data="{Binding ShapeGeometry, Mode=OneWay}">
|
||||||
<Path.Fill>
|
<Path.Fill>
|
||||||
<SolidColorBrush Color="{StaticResource Accent700}" Opacity="0.25" />
|
<SolidColorBrush Color="{StaticResource Accent700}" Opacity="0.15" />
|
||||||
</Path.Fill>
|
</Path.Fill>
|
||||||
<Path.Stroke>
|
<Path.Stroke>
|
||||||
<SolidColorBrush Color="{StaticResource Accent700}" />
|
<SolidColorBrush Color="{StaticResource Accent700}" />
|
||||||
|
|||||||
@ -22,7 +22,13 @@
|
|||||||
Cursor="Hand"
|
Cursor="Hand"
|
||||||
MouseDown="{s:Action ShapeEditMouseDown}"
|
MouseDown="{s:Action ShapeEditMouseDown}"
|
||||||
MouseUp="{s:Action ShapeEditMouseUp}"
|
MouseUp="{s:Action ShapeEditMouseUp}"
|
||||||
MouseMove="{s:Action Move}"/>
|
MouseMove="{s:Action Move}" />
|
||||||
|
|
||||||
|
<!-- Anchor point -->
|
||||||
|
<Ellipse MouseDown="{s:Action ShapeEditMouseDown}"
|
||||||
|
MouseUp="{s:Action ShapeEditMouseUp}"
|
||||||
|
MouseMove="{s:Action AnchorMove}"
|
||||||
|
Width="6" Height="6" Fill="{DynamicResource SecondaryAccentBrush}" Canvas.Left="{Binding AnchorSkPoint.X}" Canvas.Top="{Binding AnchorSkPoint.Y}" Margin="-3,-3,0,0" Cursor="SizeAll" />
|
||||||
|
|
||||||
<!-- Top left display -->
|
<!-- Top left display -->
|
||||||
<Rectangle Width="4" Height="4" Canvas.Left="{Binding ShapeSkRect.Left}" Canvas.Top="{Binding ShapeSkRect.Top}" Fill="{DynamicResource SecondaryAccentBrush}" Margin="-2,-2,0,0" />
|
<Rectangle Width="4" Height="4" Canvas.Left="{Binding ShapeSkRect.Left}" Canvas.Top="{Binding ShapeSkRect.Top}" Fill="{DynamicResource SecondaryAccentBrush}" Margin="-2,-2,0,0" />
|
||||||
|
|||||||
@ -1,10 +1,12 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics.Eventing.Reader;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using Artemis.Core.Models.Profile;
|
using Artemis.Core.Models.Profile;
|
||||||
using Artemis.UI.Services.Interfaces;
|
using Artemis.UI.Services.Interfaces;
|
||||||
using SkiaSharp;
|
using SkiaSharp;
|
||||||
|
using SkiaSharp.Views.WPF;
|
||||||
|
|
||||||
namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
||||||
{
|
{
|
||||||
@ -13,6 +15,9 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
|||||||
private bool _isDragging;
|
private bool _isDragging;
|
||||||
private double _dragOffsetY;
|
private double _dragOffsetY;
|
||||||
private double _dragOffsetX;
|
private double _dragOffsetX;
|
||||||
|
private Point _dragStart;
|
||||||
|
private bool _draggingHorizontally;
|
||||||
|
private bool _draggingVertically;
|
||||||
|
|
||||||
public EditToolViewModel(ProfileViewModel profileViewModel, IProfileEditorService profileEditorService) : base(profileViewModel, profileEditorService)
|
public EditToolViewModel(ProfileViewModel profileViewModel, IProfileEditorService profileEditorService) : base(profileViewModel, profileEditorService)
|
||||||
{
|
{
|
||||||
@ -24,16 +29,21 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
|||||||
profileEditorService.ProfilePreviewUpdated += (sender, args) => Update();
|
profileEditorService.ProfilePreviewUpdated += (sender, args) => Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SKRect ShapeSkRect { get; set; }
|
||||||
|
public SKPoint AnchorSkPoint { get; set; }
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
if (ProfileEditorService.SelectedProfileElement is Layer layer)
|
if (ProfileEditorService.SelectedProfileElement is Layer layer)
|
||||||
{
|
{
|
||||||
ShapeSkRect = layer.LayerShape.GetUnscaledRectangle();
|
if (layer.LayerShape != null)
|
||||||
|
{
|
||||||
|
ShapeSkRect = layer.LayerShape.GetUnscaledRectangle();
|
||||||
|
AnchorSkPoint = layer.LayerShape.GetUnscaledAnchor();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SKRect ShapeSkRect { get; set; }
|
|
||||||
|
|
||||||
public void ShapeEditMouseDown(object sender, MouseButtonEventArgs e)
|
public void ShapeEditMouseDown(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
if (_isDragging)
|
if (_isDragging)
|
||||||
@ -46,9 +56,13 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
|||||||
var skRect = layer.LayerShape.GetUnscaledRectangle();
|
var skRect = layer.LayerShape.GetUnscaledRectangle();
|
||||||
_dragOffsetX = skRect.Left - dragStartPosition.X;
|
_dragOffsetX = skRect.Left - dragStartPosition.X;
|
||||||
_dragOffsetY = skRect.Top - dragStartPosition.Y;
|
_dragOffsetY = skRect.Top - dragStartPosition.Y;
|
||||||
|
_dragStart = dragStartPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
_isDragging = true;
|
_isDragging = true;
|
||||||
|
_draggingHorizontally = false;
|
||||||
|
_draggingVertically = false;
|
||||||
|
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,9 +72,22 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
|||||||
ProfileEditorService.UpdateSelectedProfileElement();
|
ProfileEditorService.UpdateSelectedProfileElement();
|
||||||
|
|
||||||
_isDragging = false;
|
_isDragging = false;
|
||||||
|
_draggingHorizontally = false;
|
||||||
|
_draggingVertically = false;
|
||||||
|
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AnchorMove(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
if (!_isDragging || !(ProfileEditorService.SelectedProfileElement is Layer layer))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var position = GetRelativePosition(sender, e);
|
||||||
|
layer.LayerShape.SetFromUnscaledAnchor(new SKPoint((float) position.X, (float) position.Y), ProfileEditorService.CurrentTime);
|
||||||
|
ProfileEditorService.UpdateProfilePreview();
|
||||||
|
}
|
||||||
|
|
||||||
public void Move(object sender, MouseEventArgs e)
|
public void Move(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
if (!_isDragging || !(ProfileEditorService.SelectedProfileElement is Layer layer))
|
if (!_isDragging || !(ProfileEditorService.SelectedProfileElement is Layer layer))
|
||||||
@ -68,10 +95,24 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
|||||||
|
|
||||||
var position = GetRelativePosition(sender, e);
|
var position = GetRelativePosition(sender, e);
|
||||||
var skRect = layer.LayerShape.GetUnscaledRectangle();
|
var skRect = layer.LayerShape.GetUnscaledRectangle();
|
||||||
layer.LayerShape.SetFromUnscaledRectangle(
|
var x = (float) (position.X + _dragOffsetX);
|
||||||
SKRect.Create((float) (position.X + _dragOffsetX), (float) (position.Y + _dragOffsetY), skRect.Width, skRect.Height),
|
var y = (float) (position.Y + _dragOffsetY);
|
||||||
ProfileEditorService.CurrentTime
|
|
||||||
);
|
if (!Keyboard.IsKeyDown(Key.LeftShift) && !Keyboard.IsKeyDown(Key.RightShift))
|
||||||
|
layer.LayerShape.SetFromUnscaledRectangle(SKRect.Create(x, y, skRect.Width, skRect.Height), ProfileEditorService.CurrentTime);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_draggingVertically)
|
||||||
|
layer.LayerShape.SetFromUnscaledRectangle(SKRect.Create(skRect.Left, y, skRect.Width, skRect.Height), ProfileEditorService.CurrentTime);
|
||||||
|
else if (_draggingHorizontally)
|
||||||
|
layer.LayerShape.SetFromUnscaledRectangle(SKRect.Create(x, skRect.Top, skRect.Width, skRect.Height), ProfileEditorService.CurrentTime);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_draggingHorizontally = Math.Abs(position.X - _dragStart.X) > Math.Abs(position.Y - _dragStart.Y);
|
||||||
|
_draggingVertically = Math.Abs(position.X - _dragStart.X) < Math.Abs(position.Y - _dragStart.Y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ProfileEditorService.UpdateProfilePreview();
|
ProfileEditorService.UpdateProfilePreview();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,6 +122,24 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
|||||||
|
|
||||||
public void TopLeftResize(object sender, MouseEventArgs e)
|
public void TopLeftResize(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
|
if (!_isDragging || !(ProfileEditorService.SelectedProfileElement is Layer layer))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var position = GetRelativePosition(sender, e);
|
||||||
|
var skRect = layer.LayerShape.GetUnscaledRectangle();
|
||||||
|
if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift))
|
||||||
|
{
|
||||||
|
// Take the greatest difference
|
||||||
|
// Base the smallest difference on the greatest difference, maintaining aspect ratio
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
skRect.Top = (float) Math.Min(position.Y, skRect.Bottom);
|
||||||
|
skRect.Left = (float) Math.Min(position.X, skRect.Bottom);
|
||||||
|
}
|
||||||
|
|
||||||
|
layer.LayerShape.SetFromUnscaledRectangle(skRect, ProfileEditorService.CurrentTime);
|
||||||
|
ProfileEditorService.UpdateProfilePreview();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TopCenterResize(object sender, MouseEventArgs e)
|
public void TopCenterResize(object sender, MouseEventArgs e)
|
||||||
@ -102,6 +161,24 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
|||||||
|
|
||||||
public void TopRightResize(object sender, MouseEventArgs e)
|
public void TopRightResize(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
|
if (!_isDragging || !(ProfileEditorService.SelectedProfileElement is Layer layer))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var position = GetRelativePosition(sender, e);
|
||||||
|
var skRect = layer.LayerShape.GetUnscaledRectangle();
|
||||||
|
if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift))
|
||||||
|
{
|
||||||
|
// Take the greatest difference
|
||||||
|
// Base the smallest difference on the greatest difference, maintaining aspect ratio
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
skRect.Top = (float) Math.Min(position.Y, skRect.Bottom);
|
||||||
|
skRect.Right = (float) Math.Max(position.X, skRect.Left);
|
||||||
|
}
|
||||||
|
|
||||||
|
layer.LayerShape.SetFromUnscaledRectangle(skRect, ProfileEditorService.CurrentTime);
|
||||||
|
ProfileEditorService.UpdateProfilePreview();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CenterRightResize(object sender, MouseEventArgs e)
|
public void CenterRightResize(object sender, MouseEventArgs e)
|
||||||
@ -129,6 +206,24 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
|||||||
|
|
||||||
public void BottomRightResize(object sender, MouseEventArgs e)
|
public void BottomRightResize(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
|
if (!_isDragging || !(ProfileEditorService.SelectedProfileElement is Layer layer))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var position = GetRelativePosition(sender, e);
|
||||||
|
var skRect = layer.LayerShape.GetUnscaledRectangle();
|
||||||
|
if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift))
|
||||||
|
{
|
||||||
|
// Take the greatest difference
|
||||||
|
// Base the smallest difference on the greatest difference, maintaining aspect ratio
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
skRect.Bottom = (float) Math.Max(position.Y, skRect.Top);
|
||||||
|
skRect.Right = (float) Math.Max(position.X, skRect.Left);
|
||||||
|
}
|
||||||
|
|
||||||
|
layer.LayerShape.SetFromUnscaledRectangle(skRect, ProfileEditorService.CurrentTime);
|
||||||
|
ProfileEditorService.UpdateProfilePreview();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BottomCenterResize(object sender, MouseEventArgs e)
|
public void BottomCenterResize(object sender, MouseEventArgs e)
|
||||||
@ -150,6 +245,24 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
|||||||
|
|
||||||
public void BottomLeftResize(object sender, MouseEventArgs e)
|
public void BottomLeftResize(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
|
if (!_isDragging || !(ProfileEditorService.SelectedProfileElement is Layer layer))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var position = GetRelativePosition(sender, e);
|
||||||
|
var skRect = layer.LayerShape.GetUnscaledRectangle();
|
||||||
|
if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift))
|
||||||
|
{
|
||||||
|
// Take the greatest difference
|
||||||
|
// Base the smallest difference on the greatest difference, maintaining aspect ratio
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
skRect.Bottom = (float) Math.Max(position.Y, skRect.Top);
|
||||||
|
skRect.Left = (float) Math.Min(position.X, skRect.Right);
|
||||||
|
}
|
||||||
|
|
||||||
|
layer.LayerShape.SetFromUnscaledRectangle(skRect, ProfileEditorService.CurrentTime);
|
||||||
|
ProfileEditorService.UpdateProfilePreview();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CenterLeftResize(object sender, MouseEventArgs e)
|
public void CenterLeftResize(object sender, MouseEventArgs e)
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using Artemis.Core.Models.Profile;
|
using Artemis.Core.Models.Profile;
|
||||||
using Artemis.Core.Models.Profile.LayerProperties;
|
using Artemis.Core.Plugins.Abstract;
|
||||||
|
|
||||||
namespace Artemis.UI.Services.Interfaces
|
namespace Artemis.UI.Services.Interfaces
|
||||||
{
|
{
|
||||||
@ -15,6 +15,8 @@ namespace Artemis.UI.Services.Interfaces
|
|||||||
void ChangeSelectedProfileElement(ProfileElement profileElement);
|
void ChangeSelectedProfileElement(ProfileElement profileElement);
|
||||||
void UpdateSelectedProfileElement();
|
void UpdateSelectedProfileElement();
|
||||||
void UpdateProfilePreview();
|
void UpdateProfilePreview();
|
||||||
|
void UndoUpdateProfile(ProfileModule module);
|
||||||
|
void RedoUpdateProfile(ProfileModule module);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Occurs when a new profile is selected
|
/// Occurs when a new profile is selected
|
||||||
@ -42,8 +44,10 @@ namespace Artemis.UI.Services.Interfaces
|
|||||||
event EventHandler CurrentTimeChanged;
|
event EventHandler CurrentTimeChanged;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Occurs when the profile preview has been updated
|
/// Occurs when the profile preview has been updated
|
||||||
/// </summary>
|
/// </summary>
|
||||||
event EventHandler ProfilePreviewUpdated;
|
event EventHandler ProfilePreviewUpdated;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,5 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using Artemis.Core.Models.Profile;
|
using Artemis.Core.Models.Profile;
|
||||||
|
using Artemis.Core.Plugins.Abstract;
|
||||||
using Artemis.Core.Services.Storage.Interfaces;
|
using Artemis.Core.Services.Storage.Interfaces;
|
||||||
using Artemis.UI.Services.Interfaces;
|
using Artemis.UI.Services.Interfaces;
|
||||||
|
|
||||||
@ -72,7 +74,7 @@ namespace Artemis.UI.Services
|
|||||||
baseLayerProperty.KeyframeEngine?.OverrideProgress(CurrentTime);
|
baseLayerProperty.KeyframeEngine?.OverrideProgress(CurrentTime);
|
||||||
|
|
||||||
// Force layer shape to redraw
|
// Force layer shape to redraw
|
||||||
layer.LayerShape?.CalculateRenderProperties(layer.PositionProperty.GetCurrentValue(), layer.SizeProperty.GetCurrentValue());
|
layer.LayerShape?.CalculateRenderProperties(layer.PositionProperty.CurrentValue, layer.SizeProperty.CurrentValue);
|
||||||
// Update the brush with the delta (which can now be negative ^^)
|
// Update the brush with the delta (which can now be negative ^^)
|
||||||
layer.Update(delta.TotalSeconds);
|
layer.Update(delta.TotalSeconds);
|
||||||
}
|
}
|
||||||
@ -81,6 +83,32 @@ namespace Artemis.UI.Services
|
|||||||
OnProfilePreviewUpdated();
|
OnProfilePreviewUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UndoUpdateProfile(ProfileModule module)
|
||||||
|
{
|
||||||
|
_profileService.UndoUpdateProfile(SelectedProfile, module);
|
||||||
|
OnSelectedProfileChanged();
|
||||||
|
|
||||||
|
var elements = SelectedProfile.GetAllLayers().Cast<ProfileElement>().ToList();
|
||||||
|
elements.AddRange(SelectedProfile.GetAllFolders());
|
||||||
|
|
||||||
|
var element = elements.FirstOrDefault(l => l.EntityId == SelectedProfileElement.EntityId);
|
||||||
|
ChangeSelectedProfileElement(element);
|
||||||
|
UpdateProfilePreview();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RedoUpdateProfile(ProfileModule module)
|
||||||
|
{
|
||||||
|
_profileService.RedoUpdateProfile(SelectedProfile, module);
|
||||||
|
OnSelectedProfileChanged();
|
||||||
|
|
||||||
|
var elements = SelectedProfile.GetAllLayers().Cast<ProfileElement>().ToList();
|
||||||
|
elements.AddRange(SelectedProfile.GetAllFolders());
|
||||||
|
|
||||||
|
var element = elements.FirstOrDefault(l => l.EntityId == SelectedProfileElement.EntityId);
|
||||||
|
ChangeSelectedProfileElement(element);
|
||||||
|
UpdateProfilePreview();
|
||||||
|
}
|
||||||
|
|
||||||
public event EventHandler SelectedProfileChanged;
|
public event EventHandler SelectedProfileChanged;
|
||||||
public event EventHandler SelectedProfileUpdated;
|
public event EventHandler SelectedProfileUpdated;
|
||||||
public event EventHandler SelectedProfileElementChanged;
|
public event EventHandler SelectedProfileElementChanged;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user