mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Merge branch 'feature/keyframe-copy-aste'
This commit is contained in:
commit
7805581c70
@ -16,10 +16,15 @@ namespace Artemis.Core
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the description attribute applied to this property
|
/// Gets the description attribute applied to this property
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public PropertyDescriptionAttribute PropertyDescription { get; }
|
PropertyDescriptionAttribute PropertyDescription { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the unique path of the property on the layer
|
/// The parent group of this layer property, set after construction
|
||||||
|
/// </summary>
|
||||||
|
LayerPropertyGroup LayerPropertyGroup { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the unique path of the property on the layer
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Path { get; }
|
public string Path { get; }
|
||||||
|
|
||||||
@ -30,7 +35,7 @@ namespace Artemis.Core
|
|||||||
/// <see cref="LayerProperty{T}" />
|
/// <see cref="LayerProperty{T}" />
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void Initialize(RenderProfileElement profileElement, LayerPropertyGroup @group, PropertyEntity entity, bool fromStorage, PropertyDescriptionAttribute description, string path);
|
void Initialize(RenderProfileElement profileElement, LayerPropertyGroup group, PropertyEntity entity, bool fromStorage, PropertyDescriptionAttribute description, string path);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a list off all data binding registrations
|
/// Returns a list off all data binding registrations
|
||||||
@ -38,7 +43,14 @@ namespace Artemis.Core
|
|||||||
List<IDataBindingRegistration> GetAllDataBindingRegistrations();
|
List<IDataBindingRegistration> GetAllDataBindingRegistrations();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Updates the layer properties internal state
|
/// Attempts to load and add the provided keyframe entity to the layer property
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="keyframeEntity">The entity representing the keyframe to add</param>
|
||||||
|
/// <returns>If succeeded the resulting keyframe, otherwise <see langword="null" /></returns>
|
||||||
|
ILayerPropertyKeyframe? AddKeyframeEntity(KeyframeEntity keyframeEntity);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates the layer properties internal state
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="timeline">The timeline to apply to the property</param>
|
/// <param name="timeline">The timeline to apply to the property</param>
|
||||||
void Update(Timeline timeline);
|
void Update(Timeline timeline);
|
||||||
|
|||||||
@ -0,0 +1,36 @@
|
|||||||
|
using System;
|
||||||
|
using Artemis.Storage.Entities.Profile;
|
||||||
|
|
||||||
|
namespace Artemis.Core
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a keyframe on a <see cref="ILayerProperty" /> containing a value and a timestamp
|
||||||
|
/// </summary>
|
||||||
|
public interface ILayerPropertyKeyframe
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets an untyped reference to the layer property of this keyframe
|
||||||
|
/// </summary>
|
||||||
|
ILayerProperty UntypedLayerProperty { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The position of this keyframe in the timeline
|
||||||
|
/// </summary>
|
||||||
|
TimeSpan Position { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The easing function applied on the value of the keyframe
|
||||||
|
/// </summary>
|
||||||
|
Easings.Functions EasingFunction { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the entity this keyframe uses for persistent storage
|
||||||
|
/// </summary>
|
||||||
|
KeyframeEntity GetKeyframeEntity();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes the keyframe from the layer property
|
||||||
|
/// </summary>
|
||||||
|
void Remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -118,9 +118,7 @@ namespace Artemis.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public RenderProfileElement ProfileElement { get; internal set; }
|
public RenderProfileElement ProfileElement { get; internal set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// The parent group of this layer property, set after construction
|
|
||||||
/// </summary>
|
|
||||||
public LayerPropertyGroup LayerPropertyGroup { get; internal set; }
|
public LayerPropertyGroup LayerPropertyGroup { get; internal set; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -282,6 +280,22 @@ namespace Artemis.Core
|
|||||||
OnKeyframeAdded();
|
OnKeyframeAdded();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public ILayerPropertyKeyframe? AddKeyframeEntity(KeyframeEntity keyframeEntity)
|
||||||
|
{
|
||||||
|
if (keyframeEntity.Position > ProfileElement.Timeline.Length)
|
||||||
|
return null;
|
||||||
|
T value = CoreJson.DeserializeObject<T>(keyframeEntity.Value);
|
||||||
|
if (value == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
LayerPropertyKeyframe<T> keyframe = new LayerPropertyKeyframe<T>(
|
||||||
|
CoreJson.DeserializeObject<T>(keyframeEntity.Value)!, keyframeEntity.Position, (Easings.Functions) keyframeEntity.EasingFunction, this
|
||||||
|
);
|
||||||
|
AddKeyframe(keyframe);
|
||||||
|
return keyframe;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Removes a keyframe from the layer property
|
/// Removes a keyframe from the layer property
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -508,6 +522,7 @@ namespace Artemis.Core
|
|||||||
if (!IsLoadedFromStorage)
|
if (!IsLoadedFromStorage)
|
||||||
ApplyDefaultValue(null);
|
ApplyDefaultValue(null);
|
||||||
else
|
else
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (Entity.Value != null)
|
if (Entity.Value != null)
|
||||||
@ -517,6 +532,7 @@ namespace Artemis.Core
|
|||||||
{
|
{
|
||||||
// ignored for now
|
// ignored for now
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CurrentValue = BaseValue;
|
CurrentValue = BaseValue;
|
||||||
KeyframesEnabled = Entity.KeyframesEnabled;
|
KeyframesEnabled = Entity.KeyframesEnabled;
|
||||||
@ -524,12 +540,8 @@ namespace Artemis.Core
|
|||||||
_keyframes.Clear();
|
_keyframes.Clear();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_keyframes.AddRange(Entity.KeyframeEntities
|
foreach (KeyframeEntity keyframeEntity in Entity.KeyframeEntities.Where(k => k.Position <= ProfileElement.Timeline.Length))
|
||||||
.Where(k => k.Position <= ProfileElement.Timeline.Length)
|
AddKeyframeEntity(keyframeEntity);
|
||||||
.Select(k => new LayerPropertyKeyframe<T>(
|
|
||||||
CoreJson.DeserializeObject<T>(k.Value)!, k.Position, (Easings.Functions) k.EasingFunction, this
|
|
||||||
))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
catch (JsonException)
|
catch (JsonException)
|
||||||
{
|
{
|
||||||
@ -559,12 +571,7 @@ namespace Artemis.Core
|
|||||||
Entity.Value = CoreJson.SerializeObject(BaseValue);
|
Entity.Value = CoreJson.SerializeObject(BaseValue);
|
||||||
Entity.KeyframesEnabled = KeyframesEnabled;
|
Entity.KeyframesEnabled = KeyframesEnabled;
|
||||||
Entity.KeyframeEntities.Clear();
|
Entity.KeyframeEntities.Clear();
|
||||||
Entity.KeyframeEntities.AddRange(Keyframes.Select(k => new KeyframeEntity
|
Entity.KeyframeEntities.AddRange(Keyframes.Select(k => k.GetKeyframeEntity()));
|
||||||
{
|
|
||||||
Value = CoreJson.SerializeObject(k.Value),
|
|
||||||
Position = k.Position,
|
|
||||||
EasingFunction = (int) k.EasingFunction
|
|
||||||
}));
|
|
||||||
|
|
||||||
Entity.DataBindingEntities.Clear();
|
Entity.DataBindingEntities.Clear();
|
||||||
foreach (IDataBinding dataBinding in _dataBindings)
|
foreach (IDataBinding dataBinding in _dataBindings)
|
||||||
|
|||||||
@ -1,11 +1,12 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using Artemis.Storage.Entities.Profile;
|
||||||
|
|
||||||
namespace Artemis.Core
|
namespace Artemis.Core
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a keyframe on a <see cref="LayerProperty{T}" /> containing a value and a timestamp
|
/// Represents a keyframe on a <see cref="LayerProperty{T}" /> containing a value and a timestamp
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class LayerPropertyKeyframe<T> : CorePropertyChanged
|
public class LayerPropertyKeyframe<T> : CorePropertyChanged, ILayerPropertyKeyframe
|
||||||
{
|
{
|
||||||
private LayerProperty<T> _layerProperty;
|
private LayerProperty<T> _layerProperty;
|
||||||
private TimeSpan _position;
|
private TimeSpan _position;
|
||||||
@ -45,10 +46,10 @@ namespace Artemis.Core
|
|||||||
set => SetAndNotify(ref _value, value);
|
set => SetAndNotify(ref _value, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public ILayerProperty UntypedLayerProperty => LayerProperty;
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// The position of this keyframe in the timeline
|
|
||||||
/// </summary>
|
|
||||||
public TimeSpan Position
|
public TimeSpan Position
|
||||||
{
|
{
|
||||||
get => _position;
|
get => _position;
|
||||||
@ -59,14 +60,21 @@ namespace Artemis.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// The easing function applied on the value of the keyframe
|
|
||||||
/// </summary>
|
|
||||||
public Easings.Functions EasingFunction { get; set; }
|
public Easings.Functions EasingFunction { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Removes the keyframe from the layer property
|
public KeyframeEntity GetKeyframeEntity()
|
||||||
/// </summary>
|
{
|
||||||
|
return new KeyframeEntity
|
||||||
|
{
|
||||||
|
Value = CoreJson.SerializeObject(Value),
|
||||||
|
Position = Position,
|
||||||
|
EasingFunction = (int) EasingFunction
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public void Remove()
|
public void Remove()
|
||||||
{
|
{
|
||||||
LayerProperty.RemoveKeyframe(this);
|
LayerProperty.RemoveKeyframe(this);
|
||||||
|
|||||||
@ -123,7 +123,7 @@ namespace Artemis.Core
|
|||||||
/// Adds a profile element to the <see cref="Children" /> collection, optionally at the given position (1-based)
|
/// Adds a profile element to the <see cref="Children" /> collection, optionally at the given position (1-based)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="child">The profile element to add</param>
|
/// <param name="child">The profile element to add</param>
|
||||||
/// <param name="order">The order where to place the child (1-based), defaults to the end of the collection</param>
|
/// <param name="order">The order where to place the child (0-based), defaults to the end of the collection</param>
|
||||||
public virtual void AddChild(ProfileElement child, int? order = null)
|
public virtual void AddChild(ProfileElement child, int? order = null)
|
||||||
{
|
{
|
||||||
if (Disposed)
|
if (Disposed)
|
||||||
@ -136,31 +136,19 @@ namespace Artemis.Core
|
|||||||
|
|
||||||
// Add to the end of the list
|
// Add to the end of the list
|
||||||
if (order == null)
|
if (order == null)
|
||||||
{
|
|
||||||
ChildrenList.Add(child);
|
ChildrenList.Add(child);
|
||||||
child.Order = ChildrenList.Count;
|
// Insert at the given index
|
||||||
}
|
|
||||||
// Shift everything after the given order
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (order < 0)
|
if (order < 0)
|
||||||
order = 0;
|
order = 0;
|
||||||
foreach (ProfileElement profileElement in ChildrenList.Where(c => c.Order >= order).ToList())
|
if (order > ChildrenList.Count)
|
||||||
profileElement.Order++;
|
order = ChildrenList.Count;
|
||||||
|
ChildrenList.Insert(order.Value, child);
|
||||||
int targetIndex;
|
|
||||||
if (order == 0)
|
|
||||||
targetIndex = 0;
|
|
||||||
else if (order > ChildrenList.Count)
|
|
||||||
targetIndex = ChildrenList.Count;
|
|
||||||
else
|
|
||||||
targetIndex = ChildrenList.FindIndex(c => c.Order == order + 1);
|
|
||||||
|
|
||||||
ChildrenList.Insert(targetIndex, child);
|
|
||||||
child.Order = order.Value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
child.Parent = this;
|
child.Parent = this;
|
||||||
|
StreamlineOrder();
|
||||||
}
|
}
|
||||||
|
|
||||||
OnChildAdded();
|
OnChildAdded();
|
||||||
@ -178,10 +166,7 @@ namespace Artemis.Core
|
|||||||
lock (ChildrenList)
|
lock (ChildrenList)
|
||||||
{
|
{
|
||||||
ChildrenList.Remove(child);
|
ChildrenList.Remove(child);
|
||||||
|
StreamlineOrder();
|
||||||
// Shift everything after the given order
|
|
||||||
foreach (ProfileElement profileElement in ChildrenList.Where(c => c.Order > child.Order).ToList())
|
|
||||||
profileElement.Order--;
|
|
||||||
|
|
||||||
child.Parent = null;
|
child.Parent = null;
|
||||||
}
|
}
|
||||||
@ -189,6 +174,12 @@ namespace Artemis.Core
|
|||||||
OnChildRemoved();
|
OnChildRemoved();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void StreamlineOrder()
|
||||||
|
{
|
||||||
|
for (int index = 0; index < ChildrenList.Count; index++)
|
||||||
|
ChildrenList[index].Order = index;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a flattened list of all child folders
|
/// Returns a flattened list of all child folders
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -43,7 +43,7 @@
|
|||||||
<PackageReference Include="SharpVectors.Reloaded" Version="1.6.0" />
|
<PackageReference Include="SharpVectors.Reloaded" Version="1.6.0" />
|
||||||
<PackageReference Include="SkiaSharp" Version="2.80.2" />
|
<PackageReference Include="SkiaSharp" Version="2.80.2" />
|
||||||
<PackageReference Include="SkiaSharp.Views.WPF" Version="2.80.2" />
|
<PackageReference Include="SkiaSharp.Views.WPF" Version="2.80.2" />
|
||||||
<PackageReference Include="Stylet" Version="1.3.4" />
|
<PackageReference Include="Stylet" Version="1.3.5" />
|
||||||
<PackageReference Include="System.Buffers" Version="4.5.0" />
|
<PackageReference Include="System.Buffers" Version="4.5.0" />
|
||||||
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
|
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
|
||||||
<PackageReference Include="Unclassified.NetRevisionTask" Version="0.3.0">
|
<PackageReference Include="Unclassified.NetRevisionTask" Version="0.3.0">
|
||||||
|
|||||||
@ -156,6 +156,11 @@ namespace Artemis.UI.Shared.Services
|
|||||||
/// <returns>The pasted render element</returns>
|
/// <returns>The pasted render element</returns>
|
||||||
ProfileElement? PasteProfileElement(Folder target, int position);
|
ProfileElement? PasteProfileElement(Folder target, int position);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a boolean indicating whether a profile element is on the clipboard
|
||||||
|
/// </summary>
|
||||||
|
bool GetCanPasteProfileElement();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Occurs when a new profile is selected
|
/// Occurs when a new profile is selected
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -384,6 +384,12 @@ namespace Artemis.UI.Shared.Services
|
|||||||
return clipboardObject != null ? PasteClipboardData(clipboardObject, target, position) : null;
|
return clipboardObject != null ? PasteClipboardData(clipboardObject, target, position) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool GetCanPasteProfileElement()
|
||||||
|
{
|
||||||
|
object? clipboardObject = JsonClipboard.GetData();
|
||||||
|
return clipboardObject is LayerEntity || clipboardObject is FolderClipboardModel;
|
||||||
|
}
|
||||||
|
|
||||||
private RenderProfileElement? PasteClipboardData(object clipboardObject, Folder target, int position)
|
private RenderProfileElement? PasteClipboardData(object clipboardObject, Folder target, int position)
|
||||||
{
|
{
|
||||||
RenderProfileElement? pasted = null;
|
RenderProfileElement? pasted = null;
|
||||||
|
|||||||
@ -85,9 +85,9 @@
|
|||||||
},
|
},
|
||||||
"Stylet": {
|
"Stylet": {
|
||||||
"type": "Direct",
|
"type": "Direct",
|
||||||
"requested": "[1.3.4, )",
|
"requested": "[1.3.5, )",
|
||||||
"resolved": "1.3.4",
|
"resolved": "1.3.5",
|
||||||
"contentHash": "bCEdA+AIi+TM9SQQGLYMsFRIfzZcDUDg2Mznyr72kOkcC/cdBj01/jel4/v2aoKwbFcxVjiqmpgnbsFgMEZ4zQ==",
|
"contentHash": "9vjjaTgf5sZAGHnxQWIslD32MG5gXj7ANgS+w965L5Eh//UC3qwZDrEf226Pf+v1P/ldAJDpUySnOyGlb3TSSw==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"System.Drawing.Common": "4.6.0"
|
"System.Drawing.Common": "4.6.0"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -145,7 +145,7 @@
|
|||||||
<PackageReference Include="RawInput.Sharp" Version="0.0.3" />
|
<PackageReference Include="RawInput.Sharp" Version="0.0.3" />
|
||||||
<PackageReference Include="Serilog" Version="2.9.0" />
|
<PackageReference Include="Serilog" Version="2.9.0" />
|
||||||
<PackageReference Include="SkiaSharp.Views.WPF" Version="2.80.2" />
|
<PackageReference Include="SkiaSharp.Views.WPF" Version="2.80.2" />
|
||||||
<PackageReference Include="Stylet" Version="1.3.4" />
|
<PackageReference Include="Stylet" Version="1.3.5" />
|
||||||
<PackageReference Include="System.Buffers" Version="4.5.0" />
|
<PackageReference Include="System.Buffers" Version="4.5.0" />
|
||||||
<PackageReference Include="System.ComponentModel.Annotations" Version="4.7.0" />
|
<PackageReference Include="System.ComponentModel.Annotations" Version="4.7.0" />
|
||||||
<PackageReference Include="System.Drawing.Common" Version="4.7.0" />
|
<PackageReference Include="System.Drawing.Common" Version="4.7.0" />
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Input;
|
||||||
using Microsoft.Xaml.Behaviors;
|
using Microsoft.Xaml.Behaviors;
|
||||||
|
|
||||||
namespace Artemis.UI.Behaviors
|
namespace Artemis.UI.Behaviors
|
||||||
@ -105,7 +106,8 @@ namespace Artemis.UI.Behaviors
|
|||||||
{
|
{
|
||||||
item.IsSelected = true;
|
item.IsSelected = true;
|
||||||
// Focus the newly selected item as if was clicked
|
// Focus the newly selected item as if was clicked
|
||||||
item.Focus();
|
if (FocusManager.GetIsFocusScope(item))
|
||||||
|
item.Focus();
|
||||||
if (ExpandSelected)
|
if (ExpandSelected)
|
||||||
item.IsExpanded = true;
|
item.IsExpanded = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -160,7 +160,9 @@
|
|||||||
VerticalScrollBarVisibility="Hidden"
|
VerticalScrollBarVisibility="Hidden"
|
||||||
ScrollChanged="TimelineScrollChanged">
|
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 TreeViewModel}" />
|
<ContentControl s:View.Model="{Binding TreeViewModel}"
|
||||||
|
shared:SizeObserver.Observe="True"
|
||||||
|
shared:SizeObserver.ObservedHeight="{Binding TreeViewModelHeight, Mode=OneWayToSource}"/>
|
||||||
</Border>
|
</Border>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
<materialDesign:TransitionerSlide>
|
<materialDesign:TransitionerSlide>
|
||||||
@ -197,6 +199,12 @@
|
|||||||
<materialDesign:CircleWipe />
|
<materialDesign:CircleWipe />
|
||||||
</materialDesign:TransitionerSlide.BackwardWipe>
|
</materialDesign:TransitionerSlide.BackwardWipe>
|
||||||
<Grid>
|
<Grid>
|
||||||
|
<Grid.InputBindings>
|
||||||
|
<KeyBinding Key="Delete" Command="{s:Action DeleteKeyframes}" s:View.ActionTarget="{Binding TimelineViewModel}"/>
|
||||||
|
<KeyBinding Key="D" Modifiers="Control" Command="{s:Action DuplicateKeyframes}" s:View.ActionTarget="{Binding TimelineViewModel}" />
|
||||||
|
<KeyBinding Key="C" Modifiers="Control" Command="{s:Action CopyKeyframes}" s:View.ActionTarget="{Binding TimelineViewModel}"/>
|
||||||
|
<KeyBinding Key="V" Modifiers="Control" Command="{s:Action PasteKeyframes}" s:View.ActionTarget="{Binding TimelineViewModel}"/>
|
||||||
|
</Grid.InputBindings>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="48" />
|
<RowDefinition Height="48" />
|
||||||
<RowDefinition Height="*" />
|
<RowDefinition Height="*" />
|
||||||
@ -204,7 +212,11 @@
|
|||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<!-- Timeline headers -->
|
<!-- Timeline headers -->
|
||||||
<ScrollViewer Grid.Row="0" x:Name="TimelineHeaderScrollViewer" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" ScrollChanged="TimelineScrollChanged">
|
<ScrollViewer Grid.Row="0"
|
||||||
|
x:Name="TimelineHeaderScrollViewer"
|
||||||
|
HorizontalScrollBarVisibility="Hidden"
|
||||||
|
VerticalScrollBarVisibility="Hidden"
|
||||||
|
ScrollChanged="TimelineScrollChanged">
|
||||||
<Canvas Background="{DynamicResource MaterialDesignCardBackground}" Width="{Binding ActualWidth, ElementName=PropertyTimeLine}">
|
<Canvas Background="{DynamicResource MaterialDesignCardBackground}" Width="{Binding ActualWidth, ElementName=PropertyTimeLine}">
|
||||||
<!-- Timeline segments -->
|
<!-- Timeline segments -->
|
||||||
<ContentControl Canvas.Left="{Binding EndTimelineSegmentViewModel.SegmentStartPosition}" s:View.Model="{Binding EndTimelineSegmentViewModel}" />
|
<ContentControl Canvas.Left="{Binding EndTimelineSegmentViewModel.SegmentStartPosition}" s:View.Model="{Binding EndTimelineSegmentViewModel}" />
|
||||||
|
|||||||
@ -35,6 +35,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties
|
|||||||
private int _rightSideIndex;
|
private int _rightSideIndex;
|
||||||
private RenderProfileElement _selectedProfileElement;
|
private RenderProfileElement _selectedProfileElement;
|
||||||
private DateTime _lastEffectsViewModelToggle;
|
private DateTime _lastEffectsViewModelToggle;
|
||||||
|
private double _treeViewModelHeight;
|
||||||
|
|
||||||
public LayerPropertiesViewModel(IProfileEditorService profileEditorService,
|
public LayerPropertiesViewModel(IProfileEditorService profileEditorService,
|
||||||
ICoreService coreService,
|
ICoreService coreService,
|
||||||
@ -157,6 +158,12 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties
|
|||||||
public Layer SelectedLayer => SelectedProfileElement as Layer;
|
public Layer SelectedLayer => SelectedProfileElement as Layer;
|
||||||
public Folder SelectedFolder => SelectedProfileElement as Folder;
|
public Folder SelectedFolder => SelectedProfileElement as Folder;
|
||||||
|
|
||||||
|
public double TreeViewModelHeight
|
||||||
|
{
|
||||||
|
get => _treeViewModelHeight;
|
||||||
|
set => SetAndNotify(ref _treeViewModelHeight, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#region Segments
|
#region Segments
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,86 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Artemis.Core;
|
||||||
|
using Artemis.Storage.Entities.Profile;
|
||||||
|
using Artemis.UI.Exceptions;
|
||||||
|
|
||||||
|
namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline.Models
|
||||||
|
{
|
||||||
|
public class KeyframesClipboardModel
|
||||||
|
{
|
||||||
|
// ReSharper disable once UnusedMember.Global - For JSON.NET
|
||||||
|
public KeyframesClipboardModel()
|
||||||
|
{
|
||||||
|
ClipboardModels = new List<KeyframeClipboardModel>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public KeyframesClipboardModel(IEnumerable<ILayerPropertyKeyframe> keyframes)
|
||||||
|
{
|
||||||
|
ClipboardModels = new List<KeyframeClipboardModel>();
|
||||||
|
foreach (ILayerPropertyKeyframe keyframe in keyframes.OrderBy(k => k.Position))
|
||||||
|
ClipboardModels.Add(new KeyframeClipboardModel(keyframe));
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<KeyframeClipboardModel> ClipboardModels { get; set; }
|
||||||
|
public bool HasBeenPasted { get; set; }
|
||||||
|
|
||||||
|
public List<ILayerPropertyKeyframe> Paste(RenderProfileElement target, TimeSpan pastePosition)
|
||||||
|
{
|
||||||
|
if (target == null) throw new ArgumentNullException(nameof(target));
|
||||||
|
if (HasBeenPasted)
|
||||||
|
throw new ArtemisUIException("Clipboard model can only be pasted once");
|
||||||
|
|
||||||
|
List<ILayerPropertyKeyframe> results = new List<ILayerPropertyKeyframe>();
|
||||||
|
if (!ClipboardModels.Any())
|
||||||
|
return results;
|
||||||
|
|
||||||
|
// Determine the offset by looking at the position of the first keyframe, start pasting from there
|
||||||
|
TimeSpan offset = pastePosition - ClipboardModels.First().KeyframeEntity.Position;
|
||||||
|
List<ILayerProperty> properties = target.GetAllLayerProperties();
|
||||||
|
foreach (KeyframeClipboardModel clipboardModel in ClipboardModels)
|
||||||
|
{
|
||||||
|
ILayerPropertyKeyframe layerPropertyKeyframe = clipboardModel.Paste(properties, offset);
|
||||||
|
if (layerPropertyKeyframe != null)
|
||||||
|
results.Add(layerPropertyKeyframe);
|
||||||
|
}
|
||||||
|
|
||||||
|
HasBeenPasted = true;
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class KeyframeClipboardModel
|
||||||
|
{
|
||||||
|
// ReSharper disable once UnusedMember.Global - For JSON.NET
|
||||||
|
public KeyframeClipboardModel()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public KeyframeClipboardModel(ILayerPropertyKeyframe layerPropertyKeyframe)
|
||||||
|
{
|
||||||
|
FeatureId = layerPropertyKeyframe.UntypedLayerProperty.LayerPropertyGroup.Feature.Id;
|
||||||
|
Path = layerPropertyKeyframe.UntypedLayerProperty.Path;
|
||||||
|
KeyframeEntity = layerPropertyKeyframe.GetKeyframeEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
public string FeatureId { get; set; }
|
||||||
|
public string Path { get; set; }
|
||||||
|
public KeyframeEntity KeyframeEntity { get; set; }
|
||||||
|
|
||||||
|
public ILayerPropertyKeyframe Paste(List<ILayerProperty> properties, TimeSpan offset)
|
||||||
|
{
|
||||||
|
ILayerProperty property = properties.FirstOrDefault(p => p.LayerPropertyGroup.Feature.Id == FeatureId && p.Path == Path);
|
||||||
|
if (property != null)
|
||||||
|
{
|
||||||
|
KeyframeEntity.Position += offset;
|
||||||
|
ILayerPropertyKeyframe keyframe = property.AddKeyframeEntity(KeyframeEntity);
|
||||||
|
KeyframeEntity.Position -= offset;
|
||||||
|
|
||||||
|
return keyframe;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -48,6 +48,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
|||||||
}
|
}
|
||||||
|
|
||||||
public TimeSpan Position => LayerPropertyKeyframe.Position;
|
public TimeSpan Position => LayerPropertyKeyframe.Position;
|
||||||
|
public ILayerPropertyKeyframe Keyframe => LayerPropertyKeyframe;
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
@ -159,34 +160,11 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
|||||||
|
|
||||||
#region Context menu actions
|
#region Context menu actions
|
||||||
|
|
||||||
public void Copy()
|
public void Delete(bool save = true)
|
||||||
{
|
|
||||||
LayerPropertyKeyframe<T> newKeyframe = new LayerPropertyKeyframe<T>(
|
|
||||||
LayerPropertyKeyframe.Value,
|
|
||||||
LayerPropertyKeyframe.Position,
|
|
||||||
LayerPropertyKeyframe.EasingFunction,
|
|
||||||
LayerPropertyKeyframe.LayerProperty
|
|
||||||
);
|
|
||||||
// If possible, shift the keyframe to the right by 11 pixels
|
|
||||||
TimeSpan desiredPosition = newKeyframe.Position + TimeSpan.FromMilliseconds(1000f / _profileEditorService.PixelsPerSecond * 11);
|
|
||||||
if (desiredPosition <= newKeyframe.LayerProperty.ProfileElement.Timeline.Length)
|
|
||||||
newKeyframe.Position = desiredPosition;
|
|
||||||
// Otherwise if possible shift it to the left by 11 pixels
|
|
||||||
else
|
|
||||||
{
|
|
||||||
desiredPosition = newKeyframe.Position - TimeSpan.FromMilliseconds(1000f / _profileEditorService.PixelsPerSecond * 11);
|
|
||||||
if (desiredPosition > TimeSpan.Zero)
|
|
||||||
newKeyframe.Position = desiredPosition;
|
|
||||||
}
|
|
||||||
|
|
||||||
LayerPropertyKeyframe.LayerProperty.AddKeyframe(newKeyframe);
|
|
||||||
_profileEditorService.UpdateSelectedProfileElement();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Delete()
|
|
||||||
{
|
{
|
||||||
LayerPropertyKeyframe.LayerProperty.RemoveKeyframe(LayerPropertyKeyframe);
|
LayerPropertyKeyframe.LayerProperty.RemoveKeyframe(LayerPropertyKeyframe);
|
||||||
_profileEditorService.UpdateSelectedProfileElement();
|
if (save)
|
||||||
|
_profileEditorService.UpdateSelectedProfileElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -196,6 +174,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
|||||||
{
|
{
|
||||||
bool IsSelected { get; set; }
|
bool IsSelected { get; set; }
|
||||||
TimeSpan Position { get; }
|
TimeSpan Position { get; }
|
||||||
|
ILayerPropertyKeyframe Keyframe { get; }
|
||||||
|
|
||||||
#region Movement
|
#region Movement
|
||||||
|
|
||||||
@ -210,8 +189,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
|||||||
|
|
||||||
void PopulateEasingViewModels();
|
void PopulateEasingViewModels();
|
||||||
void ClearEasingViewModels();
|
void ClearEasingViewModels();
|
||||||
void Copy();
|
void Delete(bool save = true);
|
||||||
void Delete();
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,8 +36,8 @@
|
|||||||
MouseDown="{s:Action KeyframeMouseDown}"
|
MouseDown="{s:Action KeyframeMouseDown}"
|
||||||
MouseUp="{s:Action KeyframeMouseUp}"
|
MouseUp="{s:Action KeyframeMouseUp}"
|
||||||
MouseMove="{s:Action KeyframeMouseMove}"
|
MouseMove="{s:Action KeyframeMouseMove}"
|
||||||
ContextMenuOpening="{s:Action ContextMenuOpening}"
|
ContextMenuOpening="{s:Action KeyframeContextMenuOpening}"
|
||||||
ContextMenuClosing="{s:Action ContextMenuClosing}">
|
ContextMenuClosing="{s:Action KeyframeContextMenuClosing}">
|
||||||
<Ellipse.Style>
|
<Ellipse.Style>
|
||||||
<Style TargetType="{x:Type Ellipse}">
|
<Style TargetType="{x:Type Ellipse}">
|
||||||
<Style.Triggers>
|
<Style.Triggers>
|
||||||
@ -62,17 +62,6 @@
|
|||||||
</Ellipse.Style>
|
</Ellipse.Style>
|
||||||
<Ellipse.ContextMenu>
|
<Ellipse.ContextMenu>
|
||||||
<ContextMenu>
|
<ContextMenu>
|
||||||
<MenuItem Header="Copy" Command="{s:Action Copy}" CommandParameter="{Binding}">
|
|
||||||
<MenuItem.Icon>
|
|
||||||
<materialDesign:PackIcon Kind="ContentCopy" />
|
|
||||||
</MenuItem.Icon>
|
|
||||||
</MenuItem>
|
|
||||||
<MenuItem Header="Delete" Command="{s:Action Delete}" CommandParameter="{Binding}">
|
|
||||||
<MenuItem.Icon>
|
|
||||||
<materialDesign:PackIcon Kind="Delete" />
|
|
||||||
</MenuItem.Icon>
|
|
||||||
</MenuItem>
|
|
||||||
<Separator />
|
|
||||||
<MenuItem Header="Easing" ItemsSource="{Binding EasingViewModels}">
|
<MenuItem Header="Easing" ItemsSource="{Binding EasingViewModels}">
|
||||||
<MenuItem.Icon>
|
<MenuItem.Icon>
|
||||||
<materialDesign:PackIcon Kind="Creation" />
|
<materialDesign:PackIcon Kind="Creation" />
|
||||||
@ -98,6 +87,28 @@
|
|||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</MenuItem.ItemTemplate>
|
</MenuItem.ItemTemplate>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
<Separator />
|
||||||
|
<MenuItem Header="Duplicate" Command="{s:Action DuplicateKeyframes}" CommandParameter="{Binding}" InputGestureText="Ctrl+D">
|
||||||
|
<MenuItem.Icon>
|
||||||
|
<materialDesign:PackIcon Kind="ContentDuplicate" />
|
||||||
|
</MenuItem.Icon>
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem Header="Copy" Command="{s:Action CopyKeyframes}" CommandParameter="{Binding}" InputGestureText="Ctrl+C">
|
||||||
|
<MenuItem.Icon>
|
||||||
|
<materialDesign:PackIcon Kind="ContentCopy" />
|
||||||
|
</MenuItem.Icon>
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem Header="Paste" Command="{s:Action PasteKeyframes}" CommandParameter="{Binding}" InputGestureText="Ctrl+V">
|
||||||
|
<MenuItem.Icon>
|
||||||
|
<materialDesign:PackIcon Kind="ContentPaste" />
|
||||||
|
</MenuItem.Icon>
|
||||||
|
</MenuItem>
|
||||||
|
<Separator />
|
||||||
|
<MenuItem Header="Delete" Command="{s:Action DeleteKeyframes}" InputGestureText="Del">
|
||||||
|
<MenuItem.Icon>
|
||||||
|
<materialDesign:PackIcon Kind="Delete" />
|
||||||
|
</MenuItem.Icon>
|
||||||
|
</MenuItem>
|
||||||
</ContextMenu>
|
</ContextMenu>
|
||||||
</Ellipse.ContextMenu>
|
</Ellipse.ContextMenu>
|
||||||
</Ellipse>
|
</Ellipse>
|
||||||
|
|||||||
@ -5,33 +5,61 @@
|
|||||||
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.ProfileEditor.LayerProperties.Timeline"
|
xmlns:local="clr-namespace:Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline"
|
||||||
xmlns:s="https://github.com/canton7/Stylet"
|
xmlns:s="https://github.com/canton7/Stylet"
|
||||||
|
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DesignHeight="25"
|
d:DesignHeight="25"
|
||||||
d:DesignWidth="800"
|
d:DesignWidth="800"
|
||||||
d:DataContext="{d:DesignInstance local:TimelineViewModel}">
|
d:DataContext="{d:DesignInstance local:TimelineViewModel}">
|
||||||
<Grid x:Name="TimelineContainerGrid"
|
<Grid Background="{DynamicResource MaterialDesignToolBarBackground}"
|
||||||
Background="{DynamicResource MaterialDesignToolBarBackground}"
|
|
||||||
MouseDown="{s:Action TimelineCanvasMouseDown}"
|
MouseDown="{s:Action TimelineCanvasMouseDown}"
|
||||||
MouseUp="{s:Action TimelineCanvasMouseUp}"
|
MouseUp="{s:Action TimelineCanvasMouseUp}"
|
||||||
MouseMove="{s:Action TimelineCanvasMouseMove}"
|
MouseMove="{s:Action TimelineCanvasMouseMove}"
|
||||||
Margin="0 0 -1 0">
|
ContextMenuOpening="{s:Action ContextMenuOpening}"
|
||||||
|
ContextMenuClosing="{s:Action ContextMenuClosing}"
|
||||||
|
Height="{Binding LayerPropertiesViewModel.TreeViewModelHeight}"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Focusable="True">
|
||||||
<Grid.Triggers>
|
<Grid.Triggers>
|
||||||
<EventTrigger RoutedEvent="UIElement.MouseLeftButtonDown">
|
<EventTrigger RoutedEvent="UIElement.MouseLeftButtonDown">
|
||||||
<BeginStoryboard>
|
<BeginStoryboard>
|
||||||
<Storyboard Storyboard.TargetName="MultiSelectionPath" Storyboard.TargetProperty="Opacity">
|
<Storyboard Storyboard.TargetName="MultiSelectionPath" Storyboard.TargetProperty="Opacity">
|
||||||
<DoubleAnimation From="0" To="1" Duration="0:0:0.1" />
|
<DoubleAnimation To="1" Duration="0:0:0.1" />
|
||||||
</Storyboard>
|
</Storyboard>
|
||||||
</BeginStoryboard>
|
</BeginStoryboard>
|
||||||
</EventTrigger>
|
</EventTrigger>
|
||||||
<EventTrigger RoutedEvent="UIElement.MouseLeftButtonUp">
|
<EventTrigger RoutedEvent="UIElement.MouseLeftButtonUp">
|
||||||
<BeginStoryboard>
|
<BeginStoryboard>
|
||||||
<Storyboard Storyboard.TargetName="MultiSelectionPath" Storyboard.TargetProperty="Opacity">
|
<Storyboard Storyboard.TargetName="MultiSelectionPath" Storyboard.TargetProperty="Opacity">
|
||||||
<DoubleAnimation From="1" To="0" Duration="0:0:0.2" />
|
<DoubleAnimation To="0" Duration="0:0:0.2" />
|
||||||
</Storyboard>
|
</Storyboard>
|
||||||
</BeginStoryboard>
|
</BeginStoryboard>
|
||||||
</EventTrigger>
|
</EventTrigger>
|
||||||
</Grid.Triggers>
|
</Grid.Triggers>
|
||||||
|
<Grid.ContextMenu>
|
||||||
|
<ContextMenu>
|
||||||
|
<MenuItem Header="Duplicate" Command="{s:Action DuplicateKeyframes}" CommandParameter="{Binding}" InputGestureText="Ctrl+D">
|
||||||
|
<MenuItem.Icon>
|
||||||
|
<materialDesign:PackIcon Kind="ContentDuplicate" />
|
||||||
|
</MenuItem.Icon>
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem Header="Copy" Command="{s:Action CopyKeyframes}" CommandParameter="{Binding}" InputGestureText="Ctrl+C">
|
||||||
|
<MenuItem.Icon>
|
||||||
|
<materialDesign:PackIcon Kind="ContentCopy" />
|
||||||
|
</MenuItem.Icon>
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem Header="Paste" Command="{s:Action PasteKeyframes}" CommandParameter="{Binding}" InputGestureText="Ctrl+V" >
|
||||||
|
<MenuItem.Icon>
|
||||||
|
<materialDesign:PackIcon Kind="ContentPaste" />
|
||||||
|
</MenuItem.Icon>
|
||||||
|
</MenuItem>
|
||||||
|
<Separator />
|
||||||
|
<MenuItem Header="Delete" Command="{s:Action DeleteKeyframes}" InputGestureText="Del">
|
||||||
|
<MenuItem.Icon>
|
||||||
|
<materialDesign:PackIcon Kind="Delete" />
|
||||||
|
</MenuItem.Icon>
|
||||||
|
</MenuItem>
|
||||||
|
</ContextMenu>
|
||||||
|
</Grid.ContextMenu>
|
||||||
<ItemsControl ItemsSource="{Binding LayerPropertyGroups}"
|
<ItemsControl ItemsSource="{Binding LayerPropertyGroups}"
|
||||||
MinWidth="{Binding TotalTimelineWidth}"
|
MinWidth="{Binding TotalTimelineWidth}"
|
||||||
HorizontalAlignment="Left">
|
HorizontalAlignment="Left">
|
||||||
@ -48,7 +76,7 @@
|
|||||||
X1="{Binding StartSegmentEndPosition}"
|
X1="{Binding StartSegmentEndPosition}"
|
||||||
X2="{Binding StartSegmentEndPosition}"
|
X2="{Binding StartSegmentEndPosition}"
|
||||||
Y1="0"
|
Y1="0"
|
||||||
Y2="{Binding ActualHeight, ElementName=TimelineContainerGrid}"
|
Y2="{Binding LayerPropertiesViewModel.TreeViewModelHeight}"
|
||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
Visibility="{Binding LayerPropertiesViewModel.StartTimelineSegmentViewModel.SegmentEnabled, Converter={x:Static s:BoolToVisibilityConverter.Instance}}" />
|
Visibility="{Binding LayerPropertiesViewModel.StartTimelineSegmentViewModel.SegmentEnabled, Converter={x:Static s:BoolToVisibilityConverter.Instance}}" />
|
||||||
<Line Stroke="{StaticResource PrimaryHueDarkBrush}"
|
<Line Stroke="{StaticResource PrimaryHueDarkBrush}"
|
||||||
@ -57,14 +85,14 @@
|
|||||||
X1="{Binding MainSegmentEndPosition}"
|
X1="{Binding MainSegmentEndPosition}"
|
||||||
X2="{Binding MainSegmentEndPosition}"
|
X2="{Binding MainSegmentEndPosition}"
|
||||||
Y1="0"
|
Y1="0"
|
||||||
Y2="{Binding ActualHeight, ElementName=TimelineContainerGrid}" />
|
Y2="{Binding LayerPropertiesViewModel.TreeViewModelHeight}" />
|
||||||
<Line Stroke="{StaticResource PrimaryHueDarkBrush}"
|
<Line Stroke="{StaticResource PrimaryHueDarkBrush}"
|
||||||
Opacity="0.5"
|
Opacity="0.5"
|
||||||
StrokeDashArray="4 2"
|
StrokeDashArray="4 2"
|
||||||
X1="{Binding EndSegmentEndPosition}"
|
X1="{Binding EndSegmentEndPosition}"
|
||||||
X2="{Binding EndSegmentEndPosition}"
|
X2="{Binding EndSegmentEndPosition}"
|
||||||
Y1="0"
|
Y1="0"
|
||||||
Y2="{Binding ActualHeight, ElementName=TimelineContainerGrid}"
|
Y2="{Binding LayerPropertiesViewModel.TreeViewModelHeight}"
|
||||||
Visibility="{Binding LayerPropertiesViewModel.EndTimelineSegmentViewModel.SegmentEnabled, Converter={x:Static s:BoolToVisibilityConverter.Instance}}" />
|
Visibility="{Binding LayerPropertiesViewModel.EndTimelineSegmentViewModel.SegmentEnabled, Converter={x:Static s:BoolToVisibilityConverter.Instance}}" />
|
||||||
|
|
||||||
<!-- Multi-selection rectangle -->
|
<!-- Multi-selection rectangle -->
|
||||||
|
|||||||
@ -3,11 +3,15 @@ using System.Collections.Generic;
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
|
using Artemis.Core;
|
||||||
|
using Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline.Models;
|
||||||
using Artemis.UI.Shared;
|
using Artemis.UI.Shared;
|
||||||
using Artemis.UI.Shared.Services;
|
using Artemis.UI.Shared.Services;
|
||||||
|
using Artemis.UI.Shared.Services.Models;
|
||||||
using Stylet;
|
using Stylet;
|
||||||
|
|
||||||
namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||||
@ -151,31 +155,120 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
|||||||
|
|
||||||
#region Context menu actions
|
#region Context menu actions
|
||||||
|
|
||||||
public void ContextMenuOpening(object sender, EventArgs e)
|
public bool CanDuplicateKeyframes => GetAllKeyframeViewModels().Any(k => k.IsSelected);
|
||||||
|
public bool CanCopyKeyframes => GetAllKeyframeViewModels().Any(k => k.IsSelected);
|
||||||
|
public bool CanDeleteKeyframes => GetAllKeyframeViewModels().Any(k => k.IsSelected);
|
||||||
|
public bool CanPasteKeyframes => JsonClipboard.GetData() is KeyframesClipboardModel;
|
||||||
|
|
||||||
|
private TimeSpan? _contextMenuOpenPosition;
|
||||||
|
|
||||||
|
public void ContextMenuOpening(object sender, ContextMenuEventArgs e)
|
||||||
{
|
{
|
||||||
if (sender is Ellipse ellipse && ellipse.DataContext is ITimelineKeyframeViewModel viewModel)
|
_contextMenuOpenPosition = GetCursorTime(new Point(e.CursorLeft, e.CursorTop));
|
||||||
|
NotifyOfPropertyChange(nameof(CanDuplicateKeyframes));
|
||||||
|
NotifyOfPropertyChange(nameof(CanCopyKeyframes));
|
||||||
|
NotifyOfPropertyChange(nameof(CanDeleteKeyframes));
|
||||||
|
NotifyOfPropertyChange(nameof(CanPasteKeyframes));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ContextMenuClosing(object sender, ContextMenuEventArgs e)
|
||||||
|
{
|
||||||
|
_contextMenuOpenPosition = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void KeyframeContextMenuOpening(object sender, ContextMenuEventArgs e)
|
||||||
|
{
|
||||||
|
if (sender is FrameworkElement fe && fe.DataContext is ITimelineKeyframeViewModel viewModel)
|
||||||
viewModel.PopulateEasingViewModels();
|
viewModel.PopulateEasingViewModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ContextMenuClosing(object sender, EventArgs e)
|
public void KeyframeContextMenuClosing(object sender, ContextMenuEventArgs e)
|
||||||
{
|
{
|
||||||
if (sender is Ellipse ellipse && ellipse.DataContext is ITimelineKeyframeViewModel viewModel)
|
if (sender is Ellipse ellipse && ellipse.DataContext is ITimelineKeyframeViewModel viewModel)
|
||||||
viewModel.ClearEasingViewModels();
|
viewModel.ClearEasingViewModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Copy(ITimelineKeyframeViewModel viewModel)
|
public void DeleteKeyframes()
|
||||||
{
|
{
|
||||||
// viewModel.Copy();
|
List<ITimelineKeyframeViewModel> keyframeViewModels = GetAllKeyframeViewModels().Where(k => k.IsSelected).ToList();
|
||||||
List<ITimelineKeyframeViewModel> keyframeViewModels = GetAllKeyframeViewModels();
|
foreach (ITimelineKeyframeViewModel keyframeViewModel in keyframeViewModels)
|
||||||
foreach (ITimelineKeyframeViewModel keyframeViewModel in keyframeViewModels.Where(k => k.IsSelected))
|
keyframeViewModel.Delete(false);
|
||||||
keyframeViewModel.Copy();
|
|
||||||
|
_profileEditorService.UpdateSelectedProfileElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Delete(ITimelineKeyframeViewModel viewModel)
|
public void DuplicateKeyframes(object sender)
|
||||||
{
|
{
|
||||||
List<ITimelineKeyframeViewModel> keyframeViewModels = GetAllKeyframeViewModels();
|
TimeSpan pastePosition = GetPastePosition(sender as ITimelineKeyframeViewModel);
|
||||||
foreach (ITimelineKeyframeViewModel keyframeViewModel in keyframeViewModels.Where(k => k.IsSelected))
|
|
||||||
keyframeViewModel.Delete();
|
List<ILayerPropertyKeyframe> keyframes = GetAllKeyframeViewModels().Where(k => k.IsSelected).Select(k => k.Keyframe).ToList();
|
||||||
|
List<ILayerPropertyKeyframe> newKeyframes = DuplicateKeyframes(keyframes, pastePosition);
|
||||||
|
// Select only the newly duplicated keyframes
|
||||||
|
foreach (ITimelineKeyframeViewModel timelineKeyframeViewModel in GetAllKeyframeViewModels())
|
||||||
|
timelineKeyframeViewModel.IsSelected = newKeyframes.Contains(timelineKeyframeViewModel.Keyframe);
|
||||||
|
|
||||||
|
_profileEditorService.UpdateSelectedProfileElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CopyKeyframes()
|
||||||
|
{
|
||||||
|
List<ILayerPropertyKeyframe> keyframes = GetAllKeyframeViewModels().Where(k => k.IsSelected).Select(k => k.Keyframe).ToList();
|
||||||
|
CopyKeyframes(keyframes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PasteKeyframes(object sender)
|
||||||
|
{
|
||||||
|
TimeSpan pastePosition = GetPastePosition(sender as ITimelineKeyframeViewModel);
|
||||||
|
List<ILayerPropertyKeyframe> newKeyframes = PasteKeyframes(pastePosition);
|
||||||
|
// Select only the newly pasted keyframes
|
||||||
|
foreach (ITimelineKeyframeViewModel timelineKeyframeViewModel in GetAllKeyframeViewModels())
|
||||||
|
timelineKeyframeViewModel.IsSelected = newKeyframes.Contains(timelineKeyframeViewModel.Keyframe);
|
||||||
|
|
||||||
|
_profileEditorService.UpdateSelectedProfileElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
private TimeSpan GetPastePosition(ITimelineKeyframeViewModel viewModel)
|
||||||
|
{
|
||||||
|
TimeSpan pastePosition = _profileEditorService.CurrentTime;
|
||||||
|
|
||||||
|
// If a keyframe VM is provided, paste onto there
|
||||||
|
if (viewModel != null)
|
||||||
|
pastePosition = viewModel.Position;
|
||||||
|
// Paste at the position the context menu was opened
|
||||||
|
else if (_contextMenuOpenPosition != null)
|
||||||
|
pastePosition = _contextMenuOpenPosition.Value;
|
||||||
|
|
||||||
|
return pastePosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<ILayerPropertyKeyframe> DuplicateKeyframes(List<ILayerPropertyKeyframe> keyframes, TimeSpan pastePosition)
|
||||||
|
{
|
||||||
|
KeyframesClipboardModel clipboardModel = CoreJson.DeserializeObject<KeyframesClipboardModel>(CoreJson.SerializeObject(new KeyframesClipboardModel(keyframes), true), true);
|
||||||
|
return PasteClipboardData(clipboardModel, pastePosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CopyKeyframes(List<ILayerPropertyKeyframe> keyframes)
|
||||||
|
{
|
||||||
|
KeyframesClipboardModel clipboardModel = new KeyframesClipboardModel(keyframes);
|
||||||
|
JsonClipboard.SetObject(clipboardModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<ILayerPropertyKeyframe> PasteKeyframes(TimeSpan pastePosition)
|
||||||
|
{
|
||||||
|
KeyframesClipboardModel clipboardObject = JsonClipboard.GetData<KeyframesClipboardModel>();
|
||||||
|
return PasteClipboardData(clipboardObject, pastePosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<ILayerPropertyKeyframe> PasteClipboardData(KeyframesClipboardModel clipboardModel, TimeSpan pastePosition)
|
||||||
|
{
|
||||||
|
List<ILayerPropertyKeyframe> pasted = new List<ILayerPropertyKeyframe>();
|
||||||
|
if (clipboardModel == null)
|
||||||
|
return pasted;
|
||||||
|
RenderProfileElement target = _profileEditorService.SelectedProfileElement;
|
||||||
|
if (target == null)
|
||||||
|
return pasted;
|
||||||
|
|
||||||
|
return clipboardModel.Paste(target, pastePosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -254,6 +347,9 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
|||||||
// ReSharper disable once UnusedMember.Global - Called from view
|
// ReSharper disable once UnusedMember.Global - Called from view
|
||||||
public void TimelineCanvasMouseDown(object sender, MouseButtonEventArgs e)
|
public void TimelineCanvasMouseDown(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
|
// Workaround for focus not being applied to the grid causing keybinds not to function
|
||||||
|
((IInputElement) sender).Focus();
|
||||||
|
|
||||||
if (e.LeftButton == MouseButtonState.Released)
|
if (e.LeftButton == MouseButtonState.Released)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using System.Windows.Input;
|
||||||
using Artemis.Core;
|
using Artemis.Core;
|
||||||
using Artemis.Core.Modules;
|
using Artemis.Core.Modules;
|
||||||
using Artemis.Core.Services;
|
using Artemis.Core.Services;
|
||||||
@ -209,6 +210,8 @@ namespace Artemis.UI.Screens.ProfileEditor
|
|||||||
// Expanded status is also undone because undoing works a bit crude, that's annoying
|
// Expanded status is also undone because undoing works a bit crude, that's annoying
|
||||||
List<LayerPropertyGroupViewModel> beforeGroups = LayerPropertiesViewModel.GetAllLayerPropertyGroupViewModels();
|
List<LayerPropertyGroupViewModel> beforeGroups = LayerPropertiesViewModel.GetAllLayerPropertyGroupViewModels();
|
||||||
List<string> expandedPaths = beforeGroups.Where(g => g.IsExpanded).Select(g => g.LayerPropertyGroup.Path).ToList();
|
List<string> expandedPaths = beforeGroups.Where(g => g.IsExpanded).Select(g => g.LayerPropertyGroup.Path).ToList();
|
||||||
|
// Store the focused element so we can restore it later
|
||||||
|
IInputElement focusedElement = FocusManager.GetFocusedElement(Window.GetWindow(View));
|
||||||
|
|
||||||
if (!_profileEditorService.UndoUpdateProfile())
|
if (!_profileEditorService.UndoUpdateProfile())
|
||||||
{
|
{
|
||||||
@ -219,6 +222,12 @@ namespace Artemis.UI.Screens.ProfileEditor
|
|||||||
// Restore the expanded status
|
// Restore the expanded status
|
||||||
foreach (LayerPropertyGroupViewModel allLayerPropertyGroupViewModel in LayerPropertiesViewModel.GetAllLayerPropertyGroupViewModels())
|
foreach (LayerPropertyGroupViewModel allLayerPropertyGroupViewModel in LayerPropertiesViewModel.GetAllLayerPropertyGroupViewModels())
|
||||||
allLayerPropertyGroupViewModel.IsExpanded = expandedPaths.Contains(allLayerPropertyGroupViewModel.LayerPropertyGroup.Path);
|
allLayerPropertyGroupViewModel.IsExpanded = expandedPaths.Contains(allLayerPropertyGroupViewModel.LayerPropertyGroup.Path);
|
||||||
|
// Restore the focused element
|
||||||
|
Execute.PostToUIThread(async () =>
|
||||||
|
{
|
||||||
|
await Task.Delay(50);
|
||||||
|
focusedElement?.Focus();
|
||||||
|
});
|
||||||
|
|
||||||
_snackbarMessageQueue.Enqueue("Undid profile update", "REDO", Redo);
|
_snackbarMessageQueue.Enqueue("Undid profile update", "REDO", Redo);
|
||||||
}
|
}
|
||||||
@ -228,6 +237,8 @@ namespace Artemis.UI.Screens.ProfileEditor
|
|||||||
// Expanded status is also undone because undoing works a bit crude, that's annoying
|
// Expanded status is also undone because undoing works a bit crude, that's annoying
|
||||||
List<LayerPropertyGroupViewModel> beforeGroups = LayerPropertiesViewModel.GetAllLayerPropertyGroupViewModels();
|
List<LayerPropertyGroupViewModel> beforeGroups = LayerPropertiesViewModel.GetAllLayerPropertyGroupViewModels();
|
||||||
List<string> expandedPaths = beforeGroups.Where(g => g.IsExpanded).Select(g => g.LayerPropertyGroup.Path).ToList();
|
List<string> expandedPaths = beforeGroups.Where(g => g.IsExpanded).Select(g => g.LayerPropertyGroup.Path).ToList();
|
||||||
|
// Store the focused element so we can restore it later
|
||||||
|
IInputElement focusedElement = FocusManager.GetFocusedElement(Window.GetWindow(View));
|
||||||
|
|
||||||
if (!_profileEditorService.RedoUpdateProfile())
|
if (!_profileEditorService.RedoUpdateProfile())
|
||||||
{
|
{
|
||||||
@ -238,6 +249,12 @@ namespace Artemis.UI.Screens.ProfileEditor
|
|||||||
// Restore the expanded status
|
// Restore the expanded status
|
||||||
foreach (LayerPropertyGroupViewModel allLayerPropertyGroupViewModel in LayerPropertiesViewModel.GetAllLayerPropertyGroupViewModels())
|
foreach (LayerPropertyGroupViewModel allLayerPropertyGroupViewModel in LayerPropertiesViewModel.GetAllLayerPropertyGroupViewModels())
|
||||||
allLayerPropertyGroupViewModel.IsExpanded = expandedPaths.Contains(allLayerPropertyGroupViewModel.LayerPropertyGroup.Path);
|
allLayerPropertyGroupViewModel.IsExpanded = expandedPaths.Contains(allLayerPropertyGroupViewModel.LayerPropertyGroup.Path);
|
||||||
|
// Restore the focused element
|
||||||
|
Execute.PostToUIThread(async () =>
|
||||||
|
{
|
||||||
|
await Task.Delay(50);
|
||||||
|
focusedElement?.Focus();
|
||||||
|
});
|
||||||
|
|
||||||
_snackbarMessageQueue.Enqueue("Redid profile update", "UNDO", Undo);
|
_snackbarMessageQueue.Enqueue("Redid profile update", "UNDO", Undo);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,7 +32,8 @@
|
|||||||
HorizontalContentAlignment="Stretch"
|
HorizontalContentAlignment="Stretch"
|
||||||
dd:DragDrop.IsDragSource="True"
|
dd:DragDrop.IsDragSource="True"
|
||||||
dd:DragDrop.IsDropTarget="True"
|
dd:DragDrop.IsDropTarget="True"
|
||||||
dd:DragDrop.DropHandler="{Binding}">
|
dd:DragDrop.DropHandler="{Binding}"
|
||||||
|
ContextMenuOpening="{s:Action ContextMenuOpening}">
|
||||||
<TreeView.InputBindings>
|
<TreeView.InputBindings>
|
||||||
<KeyBinding Key="F2" Command="{s:Action RenameElement}" s:View.ActionTarget="{Binding SelectedTreeItem}" />
|
<KeyBinding Key="F2" Command="{s:Action RenameElement}" s:View.ActionTarget="{Binding SelectedTreeItem}" />
|
||||||
<KeyBinding Key="Delete" Command="{s:Action DeleteElement}" s:View.ActionTarget="{Binding SelectedTreeItem}" />
|
<KeyBinding Key="Delete" Command="{s:Action DeleteElement}" s:View.ActionTarget="{Binding SelectedTreeItem}" />
|
||||||
@ -40,6 +41,47 @@
|
|||||||
<KeyBinding Key="C" Modifiers="Control" Command="{s:Action CopyElement}" s:View.ActionTarget="{Binding SelectedTreeItem}" />
|
<KeyBinding Key="C" Modifiers="Control" Command="{s:Action CopyElement}" s:View.ActionTarget="{Binding SelectedTreeItem}" />
|
||||||
<KeyBinding Key="V" Modifiers="Control" Command="{s:Action PasteElement}" s:View.ActionTarget="{Binding SelectedTreeItem}" />
|
<KeyBinding Key="V" Modifiers="Control" Command="{s:Action PasteElement}" s:View.ActionTarget="{Binding SelectedTreeItem}" />
|
||||||
</TreeView.InputBindings>
|
</TreeView.InputBindings>
|
||||||
|
<TreeView.ContextMenu>
|
||||||
|
<ContextMenu>
|
||||||
|
<MenuItem Header="Add new folder" Command="{s:Action AddFolder}">
|
||||||
|
<MenuItem.Icon>
|
||||||
|
<materialDesign:PackIcon Kind="CreateNewFolder" />
|
||||||
|
</MenuItem.Icon>
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem Header="Add new layer" Command="{s:Action AddLayer}">
|
||||||
|
<MenuItem.Icon>
|
||||||
|
<materialDesign:PackIcon Kind="LayersPlus" />
|
||||||
|
</MenuItem.Icon>
|
||||||
|
</MenuItem>
|
||||||
|
<Separator />
|
||||||
|
<MenuItem Header="Duplicate" Command="{s:Action DuplicateElement}" InputGestureText="Ctrl+D" IsEnabled="False">
|
||||||
|
<MenuItem.Icon>
|
||||||
|
<materialDesign:PackIcon Kind="ContentDuplicate" />
|
||||||
|
</MenuItem.Icon>
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem Header="Copy" Command="{s:Action CopyElement}" InputGestureText="Ctrl+C" IsEnabled="False">
|
||||||
|
<MenuItem.Icon>
|
||||||
|
<materialDesign:PackIcon Kind="ContentCopy" />
|
||||||
|
</MenuItem.Icon>
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem Header="Paste" Command="{s:Action PasteElement}" InputGestureText="Ctrl+V">
|
||||||
|
<MenuItem.Icon>
|
||||||
|
<materialDesign:PackIcon Kind="ContentPaste" />
|
||||||
|
</MenuItem.Icon>
|
||||||
|
</MenuItem>
|
||||||
|
<Separator />
|
||||||
|
<MenuItem Header="Rename" Command="{s:Action RenameElement}" InputGestureText="F2" IsEnabled="False">
|
||||||
|
<MenuItem.Icon>
|
||||||
|
<materialDesign:PackIcon Kind="RenameBox" />
|
||||||
|
</MenuItem.Icon>
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem Header="Delete" Command="{s:Action DeleteElement}" InputGestureText="Del" IsEnabled="False">
|
||||||
|
<MenuItem.Icon>
|
||||||
|
<materialDesign:PackIcon Kind="TrashCan" />
|
||||||
|
</MenuItem.Icon>
|
||||||
|
</MenuItem>
|
||||||
|
</ContextMenu>
|
||||||
|
</TreeView.ContextMenu>
|
||||||
<b:Interaction.Behaviors>
|
<b:Interaction.Behaviors>
|
||||||
<behaviors:TreeViewSelectionBehavior ExpandSelected="True" SelectedItem="{Binding SelectedTreeItem}" />
|
<behaviors:TreeViewSelectionBehavior ExpandSelected="True" SelectedItem="{Binding SelectedTreeItem}" />
|
||||||
</b:Interaction.Behaviors>
|
</b:Interaction.Behaviors>
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using Artemis.Core;
|
using Artemis.Core;
|
||||||
|
using Artemis.Storage.Entities.Profile;
|
||||||
using Artemis.UI.Ninject.Factories;
|
using Artemis.UI.Ninject.Factories;
|
||||||
using Artemis.UI.Screens.ProfileEditor.ProfileTree.TreeItem;
|
using Artemis.UI.Screens.ProfileEditor.ProfileTree.TreeItem;
|
||||||
using Artemis.UI.Shared;
|
using Artemis.UI.Shared;
|
||||||
@ -41,17 +42,7 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReSharper disable once UnusedMember.Global - Called from view
|
public bool CanPasteElement => _profileEditorService.GetCanPasteProfileElement();
|
||||||
public void AddFolder()
|
|
||||||
{
|
|
||||||
ActiveItem?.AddFolder();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ReSharper disable once UnusedMember.Global - Called from view
|
|
||||||
public void AddLayer()
|
|
||||||
{
|
|
||||||
ActiveItem?.AddLayer();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnInitialActivate()
|
protected override void OnInitialActivate()
|
||||||
{
|
{
|
||||||
@ -79,10 +70,12 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree
|
|||||||
_updatingTree = false;
|
_updatingTree = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region IDropTarget
|
||||||
|
|
||||||
private static DragDropType GetDragDropType(IDropInfo dropInfo)
|
private static DragDropType GetDragDropType(IDropInfo dropInfo)
|
||||||
{
|
{
|
||||||
TreeItemViewModel source = (TreeItemViewModel) dropInfo.Data;
|
TreeItemViewModel source = (TreeItemViewModel)dropInfo.Data;
|
||||||
TreeItemViewModel target = (TreeItemViewModel) dropInfo.TargetItem;
|
TreeItemViewModel target = (TreeItemViewModel)dropInfo.TargetItem;
|
||||||
if (source == target)
|
if (source == target)
|
||||||
return DragDropType.None;
|
return DragDropType.None;
|
||||||
|
|
||||||
@ -128,14 +121,14 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree
|
|||||||
|
|
||||||
public void Drop(IDropInfo dropInfo)
|
public void Drop(IDropInfo dropInfo)
|
||||||
{
|
{
|
||||||
TreeItemViewModel source = (TreeItemViewModel) dropInfo.Data;
|
TreeItemViewModel source = (TreeItemViewModel)dropInfo.Data;
|
||||||
TreeItemViewModel target = (TreeItemViewModel) dropInfo.TargetItem;
|
TreeItemViewModel target = (TreeItemViewModel)dropInfo.TargetItem;
|
||||||
|
|
||||||
DragDropType dragDropType = GetDragDropType(dropInfo);
|
DragDropType dragDropType = GetDragDropType(dropInfo);
|
||||||
switch (dragDropType)
|
switch (dragDropType)
|
||||||
{
|
{
|
||||||
case DragDropType.Add:
|
case DragDropType.Add:
|
||||||
((TreeItemViewModel) source.Parent).RemoveExistingElement(source);
|
((TreeItemViewModel)source.Parent).RemoveExistingElement(source);
|
||||||
target.AddExistingElement(source);
|
target.AddExistingElement(source);
|
||||||
break;
|
break;
|
||||||
case DragDropType.InsertBefore:
|
case DragDropType.InsertBefore:
|
||||||
@ -151,6 +144,34 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree
|
|||||||
Subscribe();
|
Subscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Context menu
|
||||||
|
|
||||||
|
public void AddFolder()
|
||||||
|
{
|
||||||
|
ActiveItem?.AddFolder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddLayer()
|
||||||
|
{
|
||||||
|
ActiveItem?.AddLayer();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PasteElement()
|
||||||
|
{
|
||||||
|
Folder rootFolder = _profileEditorService.SelectedProfile?.GetRootFolder();
|
||||||
|
if (rootFolder != null)
|
||||||
|
_profileEditorService.PasteProfileElement(rootFolder, rootFolder.Children.Count);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ContextMenuOpening(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
NotifyOfPropertyChange(nameof(CanPasteElement));
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Event handlers
|
#region Event handlers
|
||||||
|
|
||||||
private void Subscribe()
|
private void Subscribe()
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
d:DesignHeight="450" d:DesignWidth="800"
|
d:DesignHeight="450" d:DesignWidth="800"
|
||||||
d:DataContext="{d:DesignInstance {x:Type treeItem1:FolderViewModel}}">
|
d:DataContext="{d:DesignInstance {x:Type treeItem1:FolderViewModel}}">
|
||||||
<!-- Capture clicks on full tree view item -->
|
<!-- Capture clicks on full tree view item -->
|
||||||
<StackPanel Margin="-10" Background="Transparent">
|
<StackPanel Margin="-10" Background="Transparent" ContextMenuOpening="{s:Action ContextMenuOpening}">
|
||||||
<StackPanel.ContextMenu>
|
<StackPanel.ContextMenu>
|
||||||
<ContextMenu>
|
<ContextMenu>
|
||||||
<MenuItem Header="Add new folder" Command="{s:Action AddFolder}">
|
<MenuItem Header="Add new folder" Command="{s:Action AddFolder}">
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
d:DesignHeight="450" d:DesignWidth="800"
|
d:DesignHeight="450" d:DesignWidth="800"
|
||||||
d:DataContext="{d:DesignInstance {x:Type treeItem1:LayerViewModel}}">
|
d:DataContext="{d:DesignInstance {x:Type treeItem1:LayerViewModel}}">
|
||||||
<!-- Capture clicks on full tree view item -->
|
<!-- Capture clicks on full tree view item -->
|
||||||
<StackPanel Margin="-10" Background="Transparent">
|
<StackPanel Margin="-10" Background="Transparent" ContextMenuOpening="{s:Action ContextMenuOpening}">
|
||||||
<StackPanel.ContextMenu>
|
<StackPanel.ContextMenu>
|
||||||
<ContextMenu>
|
<ContextMenu>
|
||||||
<MenuItem Header="Duplicate" Command="{s:Action DuplicateElement}" InputGestureText="Ctrl+D">
|
<MenuItem Header="Duplicate" Command="{s:Action DuplicateElement}" InputGestureText="Ctrl+D">
|
||||||
|
|||||||
@ -48,6 +48,8 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree.TreeItem
|
|||||||
set => SetAndNotify(ref _profileElement, value);
|
set => SetAndNotify(ref _profileElement, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool CanPasteElement => _profileEditorService.GetCanPasteProfileElement();
|
||||||
|
|
||||||
public abstract bool SupportsChildren { get; }
|
public abstract bool SupportsChildren { get; }
|
||||||
|
|
||||||
public List<TreeItemViewModel> GetAllChildren()
|
public List<TreeItemViewModel> GetAllChildren()
|
||||||
@ -254,6 +256,11 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree.TreeItem
|
|||||||
_profileEditorService.UpdateSelectedProfile();
|
_profileEditorService.UpdateSelectedProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ContextMenuOpening(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
NotifyOfPropertyChange(nameof(CanPasteElement));
|
||||||
|
}
|
||||||
|
|
||||||
private void Subscribe()
|
private void Subscribe()
|
||||||
{
|
{
|
||||||
ProfileElement.ChildAdded += ProfileElementOnChildAdded;
|
ProfileElement.ChildAdded += ProfileElementOnChildAdded;
|
||||||
|
|||||||
@ -107,9 +107,9 @@
|
|||||||
},
|
},
|
||||||
"Stylet": {
|
"Stylet": {
|
||||||
"type": "Direct",
|
"type": "Direct",
|
||||||
"requested": "[1.3.4, )",
|
"requested": "[1.3.5, )",
|
||||||
"resolved": "1.3.4",
|
"resolved": "1.3.5",
|
||||||
"contentHash": "bCEdA+AIi+TM9SQQGLYMsFRIfzZcDUDg2Mznyr72kOkcC/cdBj01/jel4/v2aoKwbFcxVjiqmpgnbsFgMEZ4zQ==",
|
"contentHash": "9vjjaTgf5sZAGHnxQWIslD32MG5gXj7ANgS+w965L5Eh//UC3qwZDrEf226Pf+v1P/ldAJDpUySnOyGlb3TSSw==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"System.Drawing.Common": "4.6.0"
|
"System.Drawing.Common": "4.6.0"
|
||||||
}
|
}
|
||||||
@ -1410,7 +1410,7 @@
|
|||||||
"SharpVectors.Reloaded": "1.6.0",
|
"SharpVectors.Reloaded": "1.6.0",
|
||||||
"SkiaSharp": "2.80.2",
|
"SkiaSharp": "2.80.2",
|
||||||
"SkiaSharp.Views.WPF": "2.80.2",
|
"SkiaSharp.Views.WPF": "2.80.2",
|
||||||
"Stylet": "1.3.4",
|
"Stylet": "1.3.5",
|
||||||
"System.Buffers": "4.5.0",
|
"System.Buffers": "4.5.0",
|
||||||
"System.Numerics.Vectors": "4.5.0",
|
"System.Numerics.Vectors": "4.5.0",
|
||||||
"WriteableBitmapEx": "1.6.5"
|
"WriteableBitmapEx": "1.6.5"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user