mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Implemented sliding animations
This commit is contained in:
parent
399a6f97ca
commit
2c1ddb824a
@ -15,17 +15,19 @@ namespace Artemis.Models.Profiles
|
|||||||
public int Height { get; set; }
|
public int Height { get; set; }
|
||||||
public int Opacity { get; set; }
|
public int Opacity { get; set; }
|
||||||
public bool ContainedBrush { get; set; }
|
public bool ContainedBrush { get; set; }
|
||||||
public LayerColorMode ColorMode { get; set; }
|
public LayerAnimation Animation { get; set; }
|
||||||
public bool Rotate { get; set; }
|
public double AnimationSpeed { get; set; }
|
||||||
public double RotateSpeed { get; set; }
|
|
||||||
public Brush Brush { get; set; }
|
public Brush Brush { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum LayerColorMode
|
public enum LayerAnimation
|
||||||
{
|
{
|
||||||
[Description("Gradient")] Gradient,
|
[Description("None")] None,
|
||||||
[Description("Moving gradient")] MovingGradient,
|
[Description("Slide left")] SlideLeft,
|
||||||
[Description("Shift")] Shift,
|
[Description("Slide right")] SlideRight,
|
||||||
|
[Description("Slide up")] SlideUp,
|
||||||
|
[Description("Slide down")] SlideDown,
|
||||||
|
[Description("Grow")] Grow,
|
||||||
[Description("Pulse")] Pulse
|
[Description("Pulse")] Pulse
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -70,11 +70,11 @@ namespace Artemis.Modules.Games.CounterStrike
|
|||||||
// Draw the layers
|
// Draw the layers
|
||||||
foreach (var layerModel in Profile.Layers)
|
foreach (var layerModel in Profile.Layers)
|
||||||
layerModel.Draw<CounterStrikeDataModel>(GameDataModel, drawingContext);
|
layerModel.Draw<CounterStrikeDataModel>(GameDataModel, drawingContext);
|
||||||
|
|
||||||
// Remove the clip
|
// Remove the clip
|
||||||
drawingContext.Pop();
|
drawingContext.Pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
bitmap = ImageUtilities.DrawinVisualToBitmap(visual, keyboardRect);
|
bitmap = ImageUtilities.DrawinVisualToBitmap(visual, keyboardRect);
|
||||||
});
|
});
|
||||||
return bitmap;
|
return bitmap;
|
||||||
|
|||||||
@ -8,15 +8,16 @@ namespace Artemis.Utilities
|
|||||||
internal class LayerDrawer
|
internal class LayerDrawer
|
||||||
{
|
{
|
||||||
private readonly LayerModel _layerModel;
|
private readonly LayerModel _layerModel;
|
||||||
|
private double _animationProgress;
|
||||||
|
private Rect _firstRect;
|
||||||
private Rect _rectangle;
|
private Rect _rectangle;
|
||||||
private double _rotationProgress;
|
private Rect _secondRect;
|
||||||
private Rect _userRectangle;
|
|
||||||
|
|
||||||
public LayerDrawer(LayerModel layerModel, int scale)
|
public LayerDrawer(LayerModel layerModel, int scale)
|
||||||
{
|
{
|
||||||
Scale = scale;
|
Scale = scale;
|
||||||
_layerModel = layerModel;
|
_layerModel = layerModel;
|
||||||
_rotationProgress = 0;
|
_animationProgress = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Scale { get; set; }
|
public int Scale { get; set; }
|
||||||
@ -30,22 +31,60 @@ namespace Artemis.Utilities
|
|||||||
_rectangle = new Rect(_layerModel.LayerCalculatedProperties.X*Scale,
|
_rectangle = new Rect(_layerModel.LayerCalculatedProperties.X*Scale,
|
||||||
_layerModel.LayerCalculatedProperties.Y*Scale, _layerModel.LayerCalculatedProperties.Width*Scale,
|
_layerModel.LayerCalculatedProperties.Y*Scale, _layerModel.LayerCalculatedProperties.Width*Scale,
|
||||||
_layerModel.LayerCalculatedProperties.Height*Scale);
|
_layerModel.LayerCalculatedProperties.Height*Scale);
|
||||||
_userRectangle = new Rect(_layerModel.LayerUserProperties.X*Scale,
|
|
||||||
_layerModel.LayerUserProperties.Y*Scale, _layerModel.LayerUserProperties.Width*Scale,
|
|
||||||
_layerModel.LayerUserProperties.Height*Scale);
|
|
||||||
|
|
||||||
if (_layerModel.LayerType == LayerType.KeyboardRectangle)
|
if (_layerModel.LayerType == LayerType.KeyboardRectangle)
|
||||||
DrawRectangle(c);
|
_layerModel.LayerCalculatedProperties.Brush.Dispatcher.Invoke(() => DrawRectangle(c));
|
||||||
else if (_layerModel.LayerType == LayerType.KeyboardEllipse)
|
else if (_layerModel.LayerType == LayerType.KeyboardEllipse)
|
||||||
DrawEllipse(c);
|
_layerModel.LayerCalculatedProperties.Brush.Dispatcher.Invoke(() => DrawEllipse(c));
|
||||||
|
|
||||||
|
UpdateAnimation();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateAnimation()
|
||||||
|
{
|
||||||
|
if (_layerModel.LayerCalculatedProperties.Animation == LayerAnimation.SlideRight)
|
||||||
|
{
|
||||||
|
_firstRect = new Rect(new Point(_rectangle.X + _animationProgress, _rectangle.Y),
|
||||||
|
new Size(_rectangle.Width, _rectangle.Height));
|
||||||
|
_secondRect = new Rect(new Point(_firstRect.X - _rectangle.Width, _rectangle.Y),
|
||||||
|
new Size(_rectangle.Width + 1, _rectangle.Height));
|
||||||
|
|
||||||
|
if (_animationProgress > _layerModel.LayerCalculatedProperties.Width*4)
|
||||||
|
_animationProgress = 0;
|
||||||
|
}
|
||||||
|
if (_layerModel.LayerCalculatedProperties.Animation == LayerAnimation.SlideLeft)
|
||||||
|
{
|
||||||
|
_firstRect = new Rect(new Point(_rectangle.X - _animationProgress, _rectangle.Y),
|
||||||
|
new Size(_rectangle.Width + 1, _rectangle.Height));
|
||||||
|
_secondRect = new Rect(new Point(_firstRect.X + _rectangle.Width, _rectangle.Y),
|
||||||
|
new Size(_rectangle.Width , _rectangle.Height));
|
||||||
|
|
||||||
|
if (_animationProgress > _layerModel.LayerCalculatedProperties.Width*4)
|
||||||
|
_animationProgress = 0;
|
||||||
|
}
|
||||||
|
if (_layerModel.LayerCalculatedProperties.Animation == LayerAnimation.SlideDown)
|
||||||
|
{
|
||||||
|
_firstRect = new Rect(new Point(_rectangle.X, _rectangle.Y + _animationProgress),
|
||||||
|
new Size(_rectangle.Width, _rectangle.Height));
|
||||||
|
_secondRect = new Rect(new Point(_firstRect.X, _firstRect.Y - _rectangle.Height),
|
||||||
|
new Size(_rectangle.Width, _rectangle.Height));
|
||||||
|
|
||||||
|
if (_animationProgress > _layerModel.LayerCalculatedProperties.Height * 4)
|
||||||
|
_animationProgress = 0;
|
||||||
|
}
|
||||||
|
if (_layerModel.LayerCalculatedProperties.Animation == LayerAnimation.SlideUp)
|
||||||
|
{
|
||||||
|
_firstRect = new Rect(new Point(_rectangle.X, _rectangle.Y - _animationProgress),
|
||||||
|
new Size(_rectangle.Width, _rectangle.Height));
|
||||||
|
_secondRect = new Rect(new Point(_firstRect.X, _firstRect.Y + _rectangle.Height),
|
||||||
|
new Size(_rectangle.Width, _rectangle.Height));
|
||||||
|
|
||||||
|
if (_animationProgress > _layerModel.LayerCalculatedProperties.Height * 4)
|
||||||
|
_animationProgress = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Update the rotation progress
|
// Update the rotation progress
|
||||||
_rotationProgress = _rotationProgress + _layerModel.LayerCalculatedProperties.RotateSpeed;
|
_animationProgress = _animationProgress + _layerModel.LayerCalculatedProperties.AnimationSpeed;
|
||||||
|
|
||||||
if (_layerModel.LayerCalculatedProperties.ContainedBrush && _rotationProgress > _rectangle.Width)
|
|
||||||
_rotationProgress = _layerModel.LayerCalculatedProperties.RotateSpeed;
|
|
||||||
else if (!_layerModel.LayerCalculatedProperties.ContainedBrush && _rotationProgress > _userRectangle.Width)
|
|
||||||
_rotationProgress = _layerModel.LayerCalculatedProperties.RotateSpeed;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public BitmapImage GetThumbnail()
|
public BitmapImage GetThumbnail()
|
||||||
@ -54,7 +93,6 @@ namespace Artemis.Utilities
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
_rectangle = new Rect(0, 0, 18, 18);
|
_rectangle = new Rect(0, 0, 18, 18);
|
||||||
_userRectangle = new Rect(0, 0, 18, 18);
|
|
||||||
|
|
||||||
//var bitmap = new Bitmap(18, 18);
|
//var bitmap = new Bitmap(18, 18);
|
||||||
|
|
||||||
@ -93,15 +131,28 @@ namespace Artemis.Utilities
|
|||||||
|
|
||||||
public void DrawRectangle(DrawingContext c)
|
public void DrawRectangle(DrawingContext c)
|
||||||
{
|
{
|
||||||
_layerModel.LayerCalculatedProperties.Brush.Dispatcher.Invoke(
|
_layerModel.LayerCalculatedProperties.Brush.Opacity = _layerModel.LayerCalculatedProperties.Opacity;
|
||||||
() => c.DrawRectangle(_layerModel.LayerCalculatedProperties.Brush, null, _rectangle));
|
|
||||||
|
if (_layerModel.LayerCalculatedProperties.Animation == LayerAnimation.SlideDown ||
|
||||||
|
_layerModel.LayerCalculatedProperties.Animation == LayerAnimation.SlideLeft ||
|
||||||
|
_layerModel.LayerCalculatedProperties.Animation == LayerAnimation.SlideRight ||
|
||||||
|
_layerModel.LayerCalculatedProperties.Animation == LayerAnimation.SlideUp)
|
||||||
|
{
|
||||||
|
c.PushClip(new RectangleGeometry(_rectangle));
|
||||||
|
c.DrawRectangle(_layerModel.LayerCalculatedProperties.Brush, null, _firstRect);
|
||||||
|
c.DrawRectangle(_layerModel.LayerCalculatedProperties.Brush, null, _secondRect);
|
||||||
|
c.Pop();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
c.DrawRectangle(_layerModel.LayerCalculatedProperties.Brush, null, _rectangle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawEllipse(DrawingContext c)
|
public void DrawEllipse(DrawingContext c)
|
||||||
{
|
{
|
||||||
_layerModel.LayerCalculatedProperties.Brush.Dispatcher.Invoke(
|
c.DrawEllipse(_layerModel.LayerCalculatedProperties.Brush, null,
|
||||||
() => c.DrawEllipse(_layerModel.LayerCalculatedProperties.Brush, null,
|
new Point(_rectangle.Width/2, _rectangle.Height/2), _rectangle.Width, _rectangle.Height);
|
||||||
new Point(_rectangle.Width/2, _rectangle.Height/2), _rectangle.Width, _rectangle.Height));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawGif(DrawingContext bmp)
|
public void DrawGif(DrawingContext bmp)
|
||||||
|
|||||||
@ -17,16 +17,9 @@
|
|||||||
<utilities:EnumDescriptionConverter x:Key="HEnumDescriptionConverter" />
|
<utilities:EnumDescriptionConverter x:Key="HEnumDescriptionConverter" />
|
||||||
<ObjectDataProvider MethodName="GetValues"
|
<ObjectDataProvider MethodName="GetValues"
|
||||||
ObjectType="{x:Type sys:Enum}"
|
ObjectType="{x:Type sys:Enum}"
|
||||||
x:Key="LayerEnumValues">
|
x:Key="AnimationEnumValues">
|
||||||
<ObjectDataProvider.MethodParameters>
|
<ObjectDataProvider.MethodParameters>
|
||||||
<x:Type TypeName="profileEnumerations:LayerType" />
|
<x:Type TypeName="profileEnumerations:LayerAnimation" />
|
||||||
</ObjectDataProvider.MethodParameters>
|
|
||||||
</ObjectDataProvider>
|
|
||||||
<ObjectDataProvider MethodName="GetValues"
|
|
||||||
ObjectType="{x:Type sys:Enum}"
|
|
||||||
x:Key="ColorEnumValues">
|
|
||||||
<ObjectDataProvider.MethodParameters>
|
|
||||||
<x:Type TypeName="profileEnumerations:LayerColorMode" />
|
|
||||||
</ObjectDataProvider.MethodParameters>
|
</ObjectDataProvider.MethodParameters>
|
||||||
</ObjectDataProvider>
|
</ObjectDataProvider>
|
||||||
</controls:MetroWindow.Resources>
|
</controls:MetroWindow.Resources>
|
||||||
@ -113,8 +106,8 @@
|
|||||||
<TextBlock Grid.Row="7" Grid.Column="0" Margin="10" FontSize="13.333" Text="Animation:"
|
<TextBlock Grid.Row="7" Grid.Column="0" Margin="10" FontSize="13.333" Text="Animation:"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Height="18" />
|
Height="18" />
|
||||||
<ComboBox Grid.Row="7" Grid.Column="1" ItemsSource="{Binding Source={StaticResource ColorEnumValues}}"
|
<ComboBox Grid.Row="7" Grid.Column="1" ItemsSource="{Binding Source={StaticResource AnimationEnumValues}}"
|
||||||
Margin="10,10,10,0" SelectedItem="{Binding Path=ProposedProperties.ColorMode}"
|
Margin="10,10,10,0" SelectedItem="{Binding Path=ProposedProperties.Animation}"
|
||||||
VerticalAlignment="Top" Height="22">
|
VerticalAlignment="Top" Height="22">
|
||||||
<ComboBox.ItemTemplate>
|
<ComboBox.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
@ -128,7 +121,7 @@
|
|||||||
VerticalAlignment="Center" Height="18" />
|
VerticalAlignment="Center" Height="18" />
|
||||||
<Slider x:Name="RotationSpeed" Grid.Row="7" Grid.Column="3" VerticalAlignment="Center"
|
<Slider x:Name="RotationSpeed" Grid.Row="7" Grid.Column="3" VerticalAlignment="Center"
|
||||||
TickPlacement="BottomRight" TickFrequency="0.1"
|
TickPlacement="BottomRight" TickFrequency="0.1"
|
||||||
Value="{Binding Path=ProposedProperties.RotateSpeed, Mode=TwoWay}" Minimum="0.1" Maximum="3"
|
Value="{Binding Path=ProposedProperties.AnimationSpeed, Mode=TwoWay}" Minimum="0.1" Maximum="3"
|
||||||
SmallChange="1" IsSnapToTickEnabled="True" Margin="10,7" Height="24" />
|
SmallChange="1" IsSnapToTickEnabled="True" Margin="10,7" Height="24" />
|
||||||
|
|
||||||
<!-- Opacity -->
|
<!-- Opacity -->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user