2024-05-30 01:12:28 -07:00
|
|
|
using Avalonia;
|
|
|
|
using Avalonia.Controls;
|
2024-05-30 01:28:21 -07:00
|
|
|
using Avalonia.Controls.Shapes;
|
2024-05-30 01:12:28 -07:00
|
|
|
using Avalonia.Interactivity;
|
2024-05-30 01:28:21 -07:00
|
|
|
using Avalonia.Media;
|
2024-05-30 01:12:28 -07:00
|
|
|
|
|
|
|
namespace SourceGit.Views
|
|
|
|
{
|
|
|
|
public partial class LoadingIcon : UserControl
|
|
|
|
{
|
|
|
|
public LoadingIcon()
|
|
|
|
{
|
|
|
|
IsHitTestVisible = false;
|
|
|
|
InitializeComponent();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void OnLoaded(RoutedEventArgs e)
|
|
|
|
{
|
|
|
|
base.OnLoaded(e);
|
2024-05-30 02:30:54 -07:00
|
|
|
|
|
|
|
if (IsVisible)
|
|
|
|
StartAnim();
|
2024-05-30 01:12:28 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void OnUnloaded(RoutedEventArgs e)
|
|
|
|
{
|
2024-05-30 01:28:21 -07:00
|
|
|
StopAnim();
|
2024-05-30 01:12:28 -07:00
|
|
|
base.OnUnloaded(e);
|
2024-05-30 01:28:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
|
|
|
|
{
|
|
|
|
base.OnPropertyChanged(change);
|
|
|
|
|
|
|
|
if (change.Property == IsVisibleProperty)
|
|
|
|
{
|
|
|
|
if (IsVisible)
|
|
|
|
StartAnim();
|
|
|
|
else
|
|
|
|
StopAnim();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void StartAnim()
|
|
|
|
{
|
|
|
|
Content = new Path()
|
|
|
|
{
|
|
|
|
Data = this.FindResource("Icons.Loading") as StreamGeometry,
|
|
|
|
Classes = { "rotating" },
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
private void StopAnim()
|
|
|
|
{
|
|
|
|
if (Content is Path path)
|
|
|
|
path.Classes.Clear();
|
|
|
|
|
|
|
|
Content = null;
|
2024-05-30 01:12:28 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|