-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters