From ba1fa2a2e3ee9841b353e507f0fa21b970c884ff Mon Sep 17 00:00:00 2001 From: "waffle.lord" Date: Thu, 20 Jul 2023 21:50:50 -0400 Subject: [PATCH] add elapsed time to patch views --- Patcher/PatchClient/PatchClient.csproj | 4 +-- .../ViewModels/PatcherViewModel.cs | 28 +++++++++++++++++++ Patcher/PatchClient/Views/PatcherView.axaml | 1 + Patcher/PatchGenerator/PatchGenerator.csproj | 4 +-- .../PatchGenerator/Resources/PatchClient.exe | 4 +-- .../ViewModels/PatchGenerationViewModel.cs | 22 +++++++++++++++ .../Views/PatchGenerationView.axaml | 3 ++ 7 files changed, 60 insertions(+), 6 deletions(-) diff --git a/Patcher/PatchClient/PatchClient.csproj b/Patcher/PatchClient/PatchClient.csproj index 3fba677..99a4935 100644 --- a/Patcher/PatchClient/PatchClient.csproj +++ b/Patcher/PatchClient/PatchClient.csproj @@ -4,8 +4,8 @@ net6.0 true enable - 2.9.3 - 2.9.3 + 2.9.4 + 2.9.4 diff --git a/Patcher/PatchClient/ViewModels/PatcherViewModel.cs b/Patcher/PatchClient/ViewModels/PatcherViewModel.cs index d8ba4e2..63a1cc3 100644 --- a/Patcher/PatchClient/ViewModels/PatcherViewModel.cs +++ b/Patcher/PatchClient/ViewModels/PatcherViewModel.cs @@ -4,11 +4,13 @@ using PatcherUtils; using ReactiveUI; using System; using System.Collections.ObjectModel; +using System.Diagnostics; using System.IO; using System.Linq; using System.Reactive.Disposables; using System.Reflection; using System.Threading.Tasks; +using System.Timers; namespace PatchClient.ViewModels { @@ -16,6 +18,9 @@ namespace PatchClient.ViewModels { private bool _initLineItemProgress = true; private bool _autoClose = false; + private Stopwatch _patchStopwatch; + private Timer _udpatePatchElapsedTimer = new Timer(1000); + public ObservableCollection LineItems { get; set; } = new ObservableCollection(); private string _ProgressMessage = ""; @@ -39,10 +44,19 @@ namespace PatchClient.ViewModels set => this.RaiseAndSetIfChanged(ref _PatchMessage, value); } + private string _ElapsedPatchTimeDetails; + public string ElapsedPatchTimeDetails + { + get => _ElapsedPatchTimeDetails; + set => this.RaiseAndSetIfChanged(ref _ElapsedPatchTimeDetails, value); + } + public PatcherViewModel(IScreen Host, bool autoClose) : base(Host) { _autoClose = autoClose; + ElapsedPatchTimeDetails = "Starting ..."; + _udpatePatchElapsedTimer.Elapsed += _udpatePatchElapsedTimer_Elapsed; this.WhenActivated((CompositeDisposable disposables) => { @@ -76,6 +90,14 @@ namespace PatchClient.ViewModels }); } + private void _udpatePatchElapsedTimer_Elapsed(object? sender, ElapsedEventArgs e) + { + Dispatcher.UIThread.InvokeAsync(() => + { + ElapsedPatchTimeDetails = $"Elapsed Patch Time: {_patchStopwatch.Elapsed.ToString("hh':'mm':'ss")}"; + }); + } + private void RunPatcher() { Task.Run(async() => @@ -86,8 +108,14 @@ namespace PatchClient.ViewModels patcher.ProgressChanged += patcher_ProgressChanged; + _udpatePatchElapsedTimer.Start(); + _patchStopwatch = Stopwatch.StartNew(); + var patchMessage = patcher.ApplyPatches(); + _patchStopwatch.Stop(); + _udpatePatchElapsedTimer.Stop(); + LazyOperations.CleanupTempDir(); Directory.Delete(LazyOperations.PatchFolder, true); diff --git a/Patcher/PatchClient/Views/PatcherView.axaml b/Patcher/PatchClient/Views/PatcherView.axaml index 1197554..f9ae578 100644 --- a/Patcher/PatchClient/Views/PatcherView.axaml +++ b/Patcher/PatchClient/Views/PatcherView.axaml @@ -20,6 +20,7 @@