using InABox.Wpf; using System; using System.Windows; using System.Windows.Controls; using System.Windows.Media; using System.Windows.Media.Animation; namespace InABox.WPF { /// /// Interaction logic for ProgressForm.xaml /// public partial class ProgressForm : ThemableWindow { private ImageSource? _image = null; private DoubleAnimation _fader = new DoubleAnimation(1d, 0.3d, new Duration(TimeSpan.FromMilliseconds(3000))) { AutoReverse = true }; public ProgressForm() { InitializeComponent(); Topmost = true; Loaded += (sender, args) => { _fader.Completed += (o, e) => Splash.BeginAnimation(Image.OpacityProperty, _fader); Splash.BeginAnimation(Image.OpacityProperty, _fader); }; } public ImageSource? DisplayImage { get => Splash.Source; set => Splash.Source = value; } public void UpdateWindow(string message) { if (Progress.Dispatcher.CheckAccess()) Progress.Content = message; else Progress.Dispatcher.Invoke(() => { Progress.Content = message; }); } public void CloseWindow() { if (Progress.Dispatcher.CheckAccess()) Close(); else Progress.Dispatcher.Invoke(() => { Close(); }); } public string GetMessage() { return Progress.Content as string; } private void Window_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { if(e.ChangedButton == System.Windows.Input.MouseButton.Left) { DragMove(); } } } }