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;
|
|
|
|
|
|
|
|
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
|
|
|
|
2024-06-06 00:31:02 -07:00
|
|
|
if (IsVisible)
|
2024-05-30 02:30:54 -07:00
|
|
|
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
|
2024-06-06 00:31:02 -07:00
|
|
|
StopAnim();
|
2024-05-30 01:28:21 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void StartAnim()
|
|
|
|
{
|
2024-07-14 00:55:15 -07:00
|
|
|
Content = new Path() { Classes = { "rotating" } };
|
2024-05-30 01:28:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
private void StopAnim()
|
|
|
|
{
|
|
|
|
if (Content is Path path)
|
|
|
|
path.Classes.Clear();
|
|
|
|
|
|
|
|
Content = null;
|
2024-05-30 01:12:28 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|