103 lines
2.6 KiB
C#
103 lines
2.6 KiB
C#
using System;
|
|
using Avalonia.Animation;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Media;
|
|
using Avalonia.Styling;
|
|
using System;
|
|
using System.Globalization;
|
|
using Avalonia;
|
|
using Avalonia.Animation;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Data.Converters;
|
|
using Avalonia.Interactivity;
|
|
using Avalonia.Markup.Xaml;
|
|
using static Avalonia.Visual;
|
|
using Avalonia.Styling;
|
|
using ReactiveUI;
|
|
|
|
namespace Valheim_Dashboard;
|
|
|
|
public class Animationen
|
|
{
|
|
|
|
public static void RunSlideAnimation(double offset,Animatable ziel)
|
|
{
|
|
var animation = new Animation
|
|
{
|
|
Duration = TimeSpan.FromSeconds(0.5),
|
|
FillMode = FillMode.Forward,
|
|
Children =
|
|
{
|
|
new KeyFrame
|
|
{
|
|
Cue = new Cue(0.0),
|
|
Setters =
|
|
{
|
|
new Setter(TranslateTransform.YProperty, 0.0) // Startposition
|
|
}
|
|
},
|
|
new KeyFrame
|
|
{
|
|
Cue = new Cue(1.0),
|
|
Setters =
|
|
{
|
|
new Setter(TranslateTransform.YProperty, offset) // Endposition
|
|
},
|
|
|
|
}
|
|
}
|
|
};
|
|
|
|
|
|
animation.RunAsync(ziel);
|
|
|
|
}
|
|
|
|
|
|
public static void FadeOutAnimation(Control control, double durationSeconds = 0.5)
|
|
{
|
|
|
|
var fadeOutAnimation = new Animation
|
|
{
|
|
Duration = TimeSpan.FromSeconds(durationSeconds),
|
|
FillMode = FillMode.Forward,
|
|
Children =
|
|
{
|
|
new KeyFrame
|
|
{
|
|
Cue = new Cue(0.0),
|
|
Setters = { new Setter(OpacityProperty, 1.0) }
|
|
},
|
|
new KeyFrame
|
|
{
|
|
Cue = new Cue(1.0),
|
|
Setters = { new Setter(OpacityProperty, 0.0) }
|
|
}
|
|
}
|
|
};
|
|
|
|
fadeOutAnimation.RunAsync(control);
|
|
|
|
}
|
|
}
|
|
|
|
public class DoubleOffsetConverter : IValueConverter
|
|
{
|
|
public static readonly DoubleOffsetConverter Instance = new DoubleOffsetConverter();
|
|
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
if (value is double doubleValue && parameter is string stringParameter && double.TryParse(stringParameter, out double offset))
|
|
{
|
|
return doubleValue + offset;
|
|
}
|
|
return value;
|
|
}
|
|
|
|
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
} |