From ab88df90ad17f6be134ee60ce57df9bd4643f114 Mon Sep 17 00:00:00 2001 From: Dyakov Eugene Date: Tue, 2 May 2023 17:51:27 +0500 Subject: [PATCH] fix qr visibility (#57) fix qr visibility --- PrinterApp/PrinterApp.csproj | 2 +- PrinterApp/PrinterModel.cs | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/PrinterApp/PrinterApp.csproj b/PrinterApp/PrinterApp.csproj index 0d86497..133c224 100644 --- a/PrinterApp/PrinterApp.csproj +++ b/PrinterApp/PrinterApp.csproj @@ -1,4 +1,4 @@ - + WinExe diff --git a/PrinterApp/PrinterModel.cs b/PrinterApp/PrinterModel.cs index b63583b..974a79c 100644 --- a/PrinterApp/PrinterModel.cs +++ b/PrinterApp/PrinterModel.cs @@ -114,13 +114,13 @@ public async void PrintAsync(bool printDialog) } PrinterViewModel.DownloadNotInProgress = false; + PrinterViewModel.PrintQrVisibility = Visibility.Collapsed; if (PrinterViewModel.CodeTextBoxText.ToUpper() == "IDDQD") { var saveFilePath = _configFile.TempSavePath + Path.DirectorySeparatorChar + "iddqd.pdf"; saveFilePath = saveFilePath.Replace(Path.DirectorySeparatorChar.ToString(), "/"); - PrinterViewModel.PrintQrVisibility = Visibility.Collapsed; ShowComplement(); await using var s = await _httpClient.GetStreamAsync( @@ -133,14 +133,13 @@ await _httpClient.GetStreamAsync( PrinterViewModel.DownloadNotInProgress = true; Log.Information( $"{GetType().Name} {MethodBase.GetCurrentMethod()?.Name}: Easter"); - + PrintAsyncCompleteEvent?.Invoke(); return; } Log.Debug( $"{GetType().Name} {MethodBase.GetCurrentMethod()?.Name}: Start response code {PrinterViewModel.CodeTextBoxText}"); var patchFrom = $"{FileUrl}/{PrinterViewModel.CodeTextBoxText}"; - PrinterViewModel.DownloadNotInProgress = false; try { var response = @@ -198,7 +197,6 @@ await _httpClient.GetStreamAsync( PrinterViewModel.ErrorTextBlockVisibility = Visibility.Visible; PrinterViewModel.ErrorTextBlockText = HttpError; } - PrinterViewModel.DownloadNotInProgress = true; Log.Debug( $"{GetType().Name} {MethodBase.GetCurrentMethod()?.Name}: End response code {PrinterViewModel.CodeTextBoxText}"); @@ -219,7 +217,6 @@ private async Task Download(FileWithOptions fileWithOptions, string patchFrom, var name = Guid.NewGuid() + ".pdf"; var saveFilePath = _configFile.TempSavePath + Path.DirectorySeparatorChar + name; saveFilePath = saveFilePath.Replace(Path.DirectorySeparatorChar.ToString(), "/"); - PrinterViewModel.PrintQrVisibility = Visibility.Collapsed; ShowComplement(); await using var s = await _httpClient.GetStreamAsync($"{StaticUrl}/{fileWithOptions.Filename}"); @@ -296,7 +293,8 @@ private void ShowComplement() PrinterViewModel.Compliment = Compliments.GetRandomCompliment(); await Task.Delay(5000); PrinterViewModel.Compliment = ""; - PrinterViewModel.PrintQrVisibility = Visibility.Visible; + if(PrinterViewModel.DownloadNotInProgress) + PrinterViewModel.PrintQrVisibility = Visibility.Visible; }).Start(); } @@ -382,9 +380,10 @@ private async Task ParseResponseFromSocket(WebsocketReceiveOptions? websocketRec } PrinterViewModel.PrintQr = null!; - PrinterViewModel.DownloadNotInProgress = false; if (websocketReceiveOptions.Files != null!) { + PrinterViewModel.DownloadNotInProgress = false; + PrinterViewModel.PrintQrVisibility = Visibility.Collapsed; DeleteOldFiles(); foreach (var fileWithOptions in websocketReceiveOptions.Files) { @@ -416,9 +415,10 @@ private async Task ParseResponseFromSocket(WebsocketReceiveOptions? websocketRec PrinterViewModel.ErrorTextBlockText = HttpError; } } + + PrinterViewModel.DownloadNotInProgress = true; } - PrinterViewModel.DownloadNotInProgress = true; GenerateQr(websocketReceiveOptions.QrToken); }