Skip to content

Commit

Permalink
update temp
Browse files Browse the repository at this point in the history
  • Loading branch information
Scighost committed Jul 23, 2024
1 parent df7f25a commit e038ab3
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/Starward/MyWindows/TestInstallWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8" ?>
<local:WindowEx x:Class="Starward.MyWindows.TestInstallWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:Starward.MyWindows"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Loaded="Grid_Loaded">


<StackPanel HorizontalAlignment="Center"
VerticalAlignment="Center"
Spacing="12">
<TextBlock x:Name="TextBlock_State" />
<TextBlock x:Name="TextBlock_Progress" />
<Button x:Name="Button_Action"
Click="Button_Action_Click"
Content="Action" />
</StackPanel>


</Grid>
</local:WindowEx>
64 changes: 64 additions & 0 deletions src/Starward/MyWindows/TestInstallWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using Microsoft.UI.Dispatching;
using Microsoft.UI.Windowing;
using Microsoft.UI.Xaml;
using Starward.Core;
using Starward.Services.Download;
using System;

// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.

namespace Starward.MyWindows;

/// <summary>
/// An empty window that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class TestInstallWindow : WindowEx
{


private readonly InstallGameService _installGameService = AppConfig.GetService<InstallGameService>();

private readonly DispatcherQueueTimer _timer;

public GameBiz GameBiz { get; set; }



public TestInstallWindow()
{
this.InitializeComponent();
AppWindow.TitleBar.ExtendsContentIntoTitleBar = true;
AdaptTitleBarButtonColorToActuallTheme();
CenterInScreen(400, 400);
_timer = DispatcherQueue.CreateTimer();
_timer.Interval = TimeSpan.FromSeconds(0.1);
_timer.IsRepeating = true;
_timer.Tick += _timer_Tick;
}

private void _timer_Tick(DispatcherQueueTimer sender, object args)
{
TextBlock_State.Text = _installGameService.State.ToString();
TextBlock_Progress.Text = $"{_installGameService.FinishCount} / {_installGameService.TotalCount} - {_installGameService.FinishBytes:N0} / {_installGameService.TotalBytes:N0} - {_installGameService.ConcurrentExecuteThreadCount}";
}

private void Grid_Loaded(object sender, RoutedEventArgs e)
{
_installGameService.Initialize(GameBiz, $@"D:\test\{GameBiz}");
_ = _installGameService.StartRepairGameAsync();
_timer.Start();
}

private void Button_Action_Click(object sender, RoutedEventArgs e)
{
if (_installGameService.State is InstallGameState.None)
{
_installGameService.Continue();
}
else
{
_installGameService.Pause();
}
}
}
17 changes: 17 additions & 0 deletions src/Starward/Pages/GameLauncherPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,23 @@
Glyph="&#xF012;"
IsTextScaleFactorEnabled="False" />
</Button>
<!-- Test -->
<Button Width="40"
Height="40"
Margin="4"
Padding="0"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
BorderThickness="0"
Command="{x:Bind TestInstallGameWindowCommand}"
CornerRadius="8"
Style="{ThemeResource DateTimePickerFlyoutButtonStyle}"
ToolTipService.ToolTip="Test">
<FontIcon FontSize="16"
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
Glyph="&#xEBE8;"
IsTextScaleFactorEnabled="False" />
</Button>

</StackPanel>

Expand Down
7 changes: 7 additions & 0 deletions src/Starward/Pages/GameLauncherPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1318,6 +1318,13 @@ private void OpenGamePackageWindow()
}


[RelayCommand]
private void TestInstallGameWindow()
{
WindowManager.Active(new TestInstallWindow { GameBiz = CurrentGameBiz });
}


#endregion


Expand Down

0 comments on commit e038ab3

Please sign in to comment.