From 674b40f205a7e8e4cb0cb590b1b93f3af4171474 Mon Sep 17 00:00:00 2001 From: Hazim Bin Ijaz Date: Thu, 17 Jul 2025 22:59:20 +0500 Subject: [PATCH] Added slideshow --- .../BackgroundSlideshowManager.cs | 74 ++++++++++++++++++ .../HighGroundRoyaleLauncher.csproj | 5 ++ HighGroundRoyaleLauncher/MainWindow.xaml | 43 +++++----- HighGroundRoyaleLauncher/MainWindow.xaml.cs | 9 +++ HighGroundRoyaleLauncher/img1.jpg | Bin 0 -> 246292 bytes HighGroundRoyaleLauncher/img2.jpg | Bin 0 -> 401035 bytes HighGroundRoyaleLauncher/img3.jpg | Bin 0 -> 317765 bytes HighGroundRoyaleLauncher/installbtn.jpg | Bin 0 -> 13832 bytes 8 files changed, 113 insertions(+), 18 deletions(-) create mode 100644 HighGroundRoyaleLauncher/BackgroundSlideshowManager.cs create mode 100644 HighGroundRoyaleLauncher/img1.jpg create mode 100644 HighGroundRoyaleLauncher/img2.jpg create mode 100644 HighGroundRoyaleLauncher/img3.jpg create mode 100644 HighGroundRoyaleLauncher/installbtn.jpg diff --git a/HighGroundRoyaleLauncher/BackgroundSlideshowManager.cs b/HighGroundRoyaleLauncher/BackgroundSlideshowManager.cs new file mode 100644 index 0000000..c4f175e --- /dev/null +++ b/HighGroundRoyaleLauncher/BackgroundSlideshowManager.cs @@ -0,0 +1,74 @@ +using System; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Media.Animation; +using System.Windows.Media.Imaging; +using System.Windows.Threading; + +namespace HighGroundRoyaleLauncher +{ + public class BackgroundSlideshowManager + { + private readonly string[] _imagePaths; + private readonly Image _targetImage; + private readonly DispatcherTimer _timer; + private int _currentIndex = 0; + + public BackgroundSlideshowManager(Image targetImage, string[] imagePaths, TimeSpan interval) + { + _targetImage = targetImage; + _imagePaths = imagePaths; + + _timer = new DispatcherTimer + { + Interval = interval + }; + _timer.Tick += OnTimerTick; + } + + public void Start() + { + UpdateImage(); // first image + _timer.Start(); + } + + private void OnTimerTick(object sender, EventArgs e) + { + _currentIndex = (_currentIndex + 1) % _imagePaths.Length; + FadeToNextImage(); + } + + private void FadeToNextImage() + { + var fadeOut = new DoubleAnimation(1.0, 0.0, new Duration(TimeSpan.FromSeconds(1.5))); + fadeOut.Completed += (s, e) => + { + UpdateImage(); + + var fadeIn = new DoubleAnimation(0.0, 1.0, new Duration(TimeSpan.FromSeconds(1.5))); + _targetImage.BeginAnimation(UIElement.OpacityProperty, fadeIn); + }; + + _targetImage.BeginAnimation(UIElement.OpacityProperty, fadeOut); + } + + private void UpdateImage() + { + try + { + var uri = new Uri($"pack://application:,,,/{_imagePaths[_currentIndex]}", UriKind.Absolute); + var bitmap = new BitmapImage(uri); + _targetImage.Source = bitmap; + } + catch + { + // Optional: silently fail or log if an image can't load + } + } + + public void Stop() + { + _timer.Stop(); + } + } +} diff --git a/HighGroundRoyaleLauncher/HighGroundRoyaleLauncher.csproj b/HighGroundRoyaleLauncher/HighGroundRoyaleLauncher.csproj index 1c38e8e..dedb9f0 100644 --- a/HighGroundRoyaleLauncher/HighGroundRoyaleLauncher.csproj +++ b/HighGroundRoyaleLauncher/HighGroundRoyaleLauncher.csproj @@ -68,6 +68,7 @@ App.xaml Code + MainWindow.xaml Code @@ -106,6 +107,10 @@ + + + + diff --git a/HighGroundRoyaleLauncher/MainWindow.xaml b/HighGroundRoyaleLauncher/MainWindow.xaml index 6cf467e..f3b74fc 100644 --- a/HighGroundRoyaleLauncher/MainWindow.xaml +++ b/HighGroundRoyaleLauncher/MainWindow.xaml @@ -1,27 +1,34 @@  + Title="Siege Worlds Installer" Height="500" Width="500" + WindowStartupLocation="CenterScreen"> - - - + - - - - + + - - - + + + + - - -