Crunchy-Downloader/CRD/Views/ToastNotification.axaml.cs
Elwador 4f6d0f2257 Add - Added --historyRefreshActive parameter
Add - Added **hardware acceleration options** for sync timings
Add - Added an **icon for episodes removed from Crunchyroll** or moved to a different season
Add - Added **highlighting for selected dubs/subs** in history
Add - Added **highlighting of episode titles** when all selected dubs/subs are available
Add - Added option to **set history series to inactive**
Add - Added **filter for Active and Inactive** series in history
Add - Added **download retry options** to settings, making retry variables editable
Chg - Changed **Sonarr missing filter** to respect the "Skip Unmonitored" setting
Chg - Changed to **show an error** if an episode wasn't added to the queue
Chg - Changed to show **dates for episodes** in the history
Chg - Changed **sync timings algorithm** to improve overall performance
Chg - Changed **sync timings algorithm** to more accurately synchronize dubs
Chg - Changed **series/season refresh messages** to indicate failure or success more clearly
Chg - Changed **error display frequency** to reduce repeated popups for the same message
Fix - Fixed **movie detection** to properly verify if the ID corresponds to a movie
Fix - Fixed **long option hiding remove buttons** for FFmpeg and MKVMerge additional options
Fix - Fixed **toast message timer** not updating correctly
Fix - Fixed **path length error**
Fix - Fixed a **rare crash when navigating history**
2025-04-23 22:36:05 +02:00

56 lines
No EOL
1.5 KiB
C#

using System;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.Threading;
namespace CRD.Views;
public partial class ToastNotification : UserControl{
public ToastNotification(){
InitializeComponent();
}
private void InitializeComponent(){
AvaloniaXamlLoader.Load(this);
}
private DispatcherTimer? currentTimer;
public void Show(string message, ToastType type, int durationInSeconds){
var text = this.FindControl<TextBlock>("MessageText");
if (text != null) text.Text = message;
SetStyle(type);
currentTimer?.Stop();
currentTimer = new DispatcherTimer{ Interval = TimeSpan.FromSeconds(durationInSeconds) };
currentTimer.Tick += (sender, args) => {
currentTimer?.Stop();
IsVisible = false;
};
currentTimer.Start();
IsVisible = true;
}
private void SetStyle(ToastType type){
var border = this.FindControl<Border>("MessageBorder");
border?.Classes.Clear(); // Clear previous styles
switch (type){
case ToastType.Information:
border?.Classes.Add("info");
break;
case ToastType.Error:
border?.Classes.Add("error");
break;
case ToastType.Warning:
border?.Classes.Add("warning");
break;
}
}
}
public enum ToastType{
Information,
Error,
Warning
}