sourcegit/src/Views/PopupRunningStatus.axaml.cs

66 lines
1.6 KiB
C#
Raw Normal View History

2024-05-30 02:30:54 -07:00
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Shapes;
using Avalonia.Interactivity;
namespace SourceGit.Views
{
public partial class PopupRunningStatus : UserControl
{
public static readonly StyledProperty<string> DescriptionProperty =
AvaloniaProperty.Register<PopupRunningStatus, string>(nameof(Description));
public string Description
{
get => GetValue(DescriptionProperty);
set => SetValue(DescriptionProperty, value);
}
public PopupRunningStatus()
{
InitializeComponent();
}
protected override void OnLoaded(RoutedEventArgs e)
{
base.OnLoaded(e);
if (IsVisible)
StartAnim();
}
protected override void OnUnloaded(RoutedEventArgs e)
{
StopAnim();
base.OnUnloaded(e);
}
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
{
base.OnPropertyChanged(change);
if (change.Property == IsVisibleProperty)
{
if (IsVisible)
StartAnim();
else
StopAnim();
}
}
private void StartAnim()
{
2024-07-14 00:55:15 -07:00
Icon.Content = new Path() { Classes = { "waiting" } };
ProgressBar.IsIndeterminate = true;
2024-05-30 02:30:54 -07:00
}
private void StopAnim()
{
2024-07-14 00:55:15 -07:00
if (Icon.Content is Path path)
2024-05-30 02:30:54 -07:00
path.Classes.Clear();
2024-07-14 00:55:15 -07:00
Icon.Content = null;
ProgressBar.IsIndeterminate = false;
2024-05-30 02:30:54 -07:00
}
}
}