mirror of
https://github.com/achiez/NebulaAuth-Steam-Desktop-Authenticator-by-Achies.git
synced 2026-07-26 14:51:42 +00:00
882d39b8f3
- Refactored file handling: added backup directories, improved mafile naming strategy, and introduced renaming functionality. - Enhanced UI: updated `MainWindow`, `SettingsView`, and dialogs with new controls, commands, and improved layouts. - Introduced `TextFieldDialog` for user input with localization support. - Improved localization: added new strings for buttons, errors, and tooltips. Removed all user-observed not localized strings - Fixed clipboard handling logic in `ClipboardHelper`. - Added 'Create Group' button in mafile's context menu and corresponding dialog view - Implemented `RequiresAdminAccess` check before updating program and requesting previlegies
58 lines
1.7 KiB
C#
58 lines
1.7 KiB
C#
using System;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Media.Animation;
|
|
|
|
namespace NebulaAuth;
|
|
|
|
public class CodeProgressBar : ProgressBar
|
|
{
|
|
public static readonly DependencyProperty TimeRemainingProperty =
|
|
DependencyProperty.Register(nameof(TimeRemaining), typeof(double), typeof(CodeProgressBar),
|
|
new PropertyMetadata(-1.0, OnTimeRemainingChanged));
|
|
|
|
public static readonly DependencyProperty MaxTimeProperty =
|
|
DependencyProperty.Register(nameof(MaxTime), typeof(double), typeof(CodeProgressBar),
|
|
new PropertyMetadata(30.0));
|
|
|
|
public double TimeRemaining
|
|
{
|
|
get => (double) GetValue(TimeRemainingProperty);
|
|
set => SetValue(TimeRemainingProperty, value);
|
|
}
|
|
|
|
public double MaxTime
|
|
{
|
|
get => (double) GetValue(MaxTimeProperty);
|
|
set => SetValue(MaxTimeProperty, value);
|
|
}
|
|
|
|
private static void OnTimeRemainingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
|
{
|
|
if (d is CodeProgressBar progressBar)
|
|
{
|
|
var newValue = (double) e.NewValue;
|
|
progressBar.StartProgressAnimation(newValue);
|
|
}
|
|
}
|
|
|
|
private void StartProgressAnimation(double timeRemaining)
|
|
{
|
|
if (timeRemaining <= 0 || MaxTime <= 0) return;
|
|
|
|
var progress = (1 - timeRemaining / MaxTime) * 100;
|
|
Value = 0;
|
|
Value = 100;
|
|
var animation = new DoubleAnimation
|
|
{
|
|
From = progress,
|
|
To = 100,
|
|
Duration = TimeSpan.FromSeconds(timeRemaining),
|
|
AccelerationRatio = 0,
|
|
DecelerationRatio = 0
|
|
};
|
|
|
|
|
|
BeginAnimation(ValueProperty, animation);
|
|
}
|
|
} |