Added slideshow
This commit is contained in:
parent
cac88090b0
commit
674b40f205
74
HighGroundRoyaleLauncher/BackgroundSlideshowManager.cs
Normal file
74
HighGroundRoyaleLauncher/BackgroundSlideshowManager.cs
Normal file
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
@ -68,6 +68,7 @@
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="BackgroundSlideshowManager.cs" />
|
||||
<Compile Include="MainWindow.xaml.cs">
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
@ -106,6 +107,10 @@
|
||||
<Resource Include="SW_Logo_NoBackground.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="img1.jpg" />
|
||||
<Resource Include="img2.jpg" />
|
||||
<Resource Include="img3.jpg" />
|
||||
<Resource Include="installbtn.jpg" />
|
||||
<Content Include="SW_Logo_NoBackground.ico" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
|
@ -1,27 +1,34 @@
|
||||
<Window x:Class="HighGroundRoyaleLauncher.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="Siege Worlds Installer" Height="500
|
||||
" Width="500">
|
||||
Title="Siege Worlds Installer" Height="500" Width="500"
|
||||
WindowStartupLocation="CenterScreen">
|
||||
|
||||
<Window.Background>
|
||||
<ImageBrush ImageSource="LoginScreen_Background.jpg" Stretch="UniformToFill"/>
|
||||
</Window.Background>
|
||||
<Grid>
|
||||
|
||||
<Grid Margin="10">
|
||||
<Border Background="#AA000000" CornerRadius="8" Padding="10">
|
||||
<StackPanel>
|
||||
<TextBlock Text="Choose Installation Directory:" Foreground="White" Margin="0,0,0,5"/>
|
||||
<!-- Slideshow Background -->
|
||||
<Image x:Name="SlideshowImage" Stretch="UniformToFill" Panel.ZIndex="0" />
|
||||
|
||||
<DockPanel>
|
||||
<TextBox Name="installPathBox" Width="380" Margin="0,0,5,0"/>
|
||||
<Button Content="Browse..." Width="80" Click="Browse_Click"/>
|
||||
</DockPanel>
|
||||
<!-- Installer UI -->
|
||||
<Grid Margin="10" Panel.ZIndex="2">
|
||||
<Border CornerRadius="8" Padding="10">
|
||||
<StackPanel>
|
||||
<TextBlock Text="Choose Installation Directory:" Foreground="White" Margin="0,0,0,5"/>
|
||||
|
||||
<DockPanel>
|
||||
<TextBox Name="installPathBox" Width="380" Margin="0,0,5,0"/>
|
||||
<Button Content="Browse..." Width="80" Click="Browse_Click"/>
|
||||
</DockPanel>
|
||||
|
||||
<TextBlock Name="statusText" Text="Status: Idle" Foreground="White" Margin="0,10,0,10"/>
|
||||
<ProgressBar Name="progressBar" Height="20" Minimum="0" Maximum="100"/>
|
||||
<Button Name="installButton" Click="InstallButton_Click" Margin="0,10,0,0" BorderThickness="0" Background="Transparent">
|
||||
<Image Source="installbtn.jpg" Stretch="None"/>
|
||||
</Button>
|
||||
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
<TextBlock Name="statusText" Text="Status: Idle" Foreground="White" Margin="0,10,0,10"/>
|
||||
<ProgressBar Name="progressBar" Height="20" Minimum="0" Maximum="100"/>
|
||||
<Button Name="installButton" Content="Install And Launch" Click="InstallButton_Click" Margin="0,10,0,0"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
@ -18,11 +18,20 @@ namespace HighGroundRoyaleLauncher
|
||||
private string versionPath => Path.Combine(installPath, "version.txt");
|
||||
private string gameFolder => Path.Combine(installPath, "Game");
|
||||
private string exePath => Path.Combine(gameFolder, "Siege Worlds.exe");
|
||||
private BackgroundSlideshowManager _slideshow;
|
||||
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
installPathBox.Text = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "Siege worlds");
|
||||
|
||||
_slideshow = new BackgroundSlideshowManager(
|
||||
SlideshowImage,
|
||||
new[] { "img1.jpg", "img2.jpg", "img3.jpg" },
|
||||
TimeSpan.FromSeconds(4)
|
||||
);
|
||||
_slideshow.Start();
|
||||
}
|
||||
|
||||
private void Browse_Click(object sender, RoutedEventArgs e)
|
||||
|
BIN
HighGroundRoyaleLauncher/img1.jpg
Normal file
BIN
HighGroundRoyaleLauncher/img1.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 240 KiB |
BIN
HighGroundRoyaleLauncher/img2.jpg
Normal file
BIN
HighGroundRoyaleLauncher/img2.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 392 KiB |
BIN
HighGroundRoyaleLauncher/img3.jpg
Normal file
BIN
HighGroundRoyaleLauncher/img3.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 310 KiB |
BIN
HighGroundRoyaleLauncher/installbtn.jpg
Normal file
BIN
HighGroundRoyaleLauncher/installbtn.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
Loading…
x
Reference in New Issue
Block a user