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