From 240f9c4ac690449ae372b4436a657ad8f96ebc47 Mon Sep 17 00:00:00 2001 From: Vlad Somai Date: Wed, 20 Jul 2022 22:33:26 +0300 Subject: [PATCH] hide app content on first run --- Necta/Necta.csproj | 10 ++++----- ...Form1.Designer.cs => NectaApp.Designer.cs} | 4 ++-- Necta/{Form1.cs => NectaApp.cs} | 22 ++++++++++++++++--- Necta/{Form1.resx => NectaApp.resx} | 0 Necta/NectaServices/NectaService.cs | 10 ++++----- Necta/PasswordModal.cs | 15 +++++++------ Necta/Program.cs | 2 +- 7 files changed, 40 insertions(+), 23 deletions(-) rename Necta/{Form1.Designer.cs => NectaApp.Designer.cs} (99%) rename Necta/{Form1.cs => NectaApp.cs} (92%) rename Necta/{Form1.resx => NectaApp.resx} (100%) diff --git a/Necta/Necta.csproj b/Necta/Necta.csproj index eb291db..ccac25f 100644 --- a/Necta/Necta.csproj +++ b/Necta/Necta.csproj @@ -146,11 +146,11 @@ - + Form - - Form1.cs + + NectaApp.cs @@ -164,8 +164,8 @@ - - Form1.cs + + NectaApp.cs PasswordModal.cs diff --git a/Necta/Form1.Designer.cs b/Necta/NectaApp.Designer.cs similarity index 99% rename from Necta/Form1.Designer.cs rename to Necta/NectaApp.Designer.cs index d89eec4..2a4a326 100644 --- a/Necta/Form1.Designer.cs +++ b/Necta/NectaApp.Designer.cs @@ -2,7 +2,7 @@ namespace Necta { - partial class Necta + partial class NectaApp { /// /// Required designer variable. @@ -34,7 +34,7 @@ protected override void Dispose(bool disposing) private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Necta)); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(NectaApp)); this.Print = new System.Windows.Forms.Button(); this.ApiGetUri_lable = new System.Windows.Forms.Label(); this.RequestInterval_label = new System.Windows.Forms.Label(); diff --git a/Necta/Form1.cs b/Necta/NectaApp.cs similarity index 92% rename from Necta/Form1.cs rename to Necta/NectaApp.cs index 1263d0e..7743143 100644 --- a/Necta/Form1.cs +++ b/Necta/NectaApp.cs @@ -12,7 +12,7 @@ namespace Necta { - public partial class Necta : MaterialForm + public partial class NectaApp : MaterialForm { //the following dispatcher object will be used to invoke the print method from another thread public static Dispatcher MainThreadDispatcher = Dispatcher.CurrentDispatcher; @@ -28,7 +28,7 @@ public static bool printingInProgress set { lock (printingInProgressLock) { _printingInProgress = value; } } } - public Necta() + public NectaApp() { InitializeComponent(); var materialSkinManager = MaterialSkinManager.Instance; @@ -53,6 +53,7 @@ public Necta() NectaLogService.WriteLog(ex.Message, LogLevels.ERROR); } + SetTextboxesToVisible(false); CheckPassword(); } @@ -196,7 +197,7 @@ private static async Task ChromeConvertHtmlToPdf(string html) await page.SetContentAsync(html, navigtionOptions); await page.WaitForTimeoutAsync(1000); NectaLogService.WriteLog("Saving the PDF", LogLevels.INFO); - await page.PdfAsync(PathToReceipt, new PdfOptions() { PrintBackground = true, OmitBackground=false}); + await page.PdfAsync(PathToReceipt, new PdfOptions() { PrintBackground = true, OmitBackground = false }); } await browserForConverting.CloseAsync(); } @@ -224,6 +225,7 @@ private static void ProcessPrint() private void CheckPassword() { + this.Visible = false; PasswordModal.mInstance.showPasswordFrom(); } @@ -240,5 +242,19 @@ public void showMainFrom() this.WindowState = FormWindowState.Normal; NectaNotifyIcon1.Visible = false; } + + public void SetTextboxesToVisible(bool what) + { + ApiGetUri_textBox.Visible = what; + ApiGetUri_lable.Visible = what; + ApiUpdateUri_textBox.Visible = what; + ApiUpdateUri_label.Visible = what; + ApiPrinterInfoUri_textBox.Visible = what; + ApiPrinterInfoUri_label.Visible = what; + ApiRequestInterval_value.Visible = what; + RequestIntervalTime_label.Visible = what; + RequestInterval_label.Visible = what; + SaveButton.Visible = what; + } } } diff --git a/Necta/Form1.resx b/Necta/NectaApp.resx similarity index 100% rename from Necta/Form1.resx rename to Necta/NectaApp.resx diff --git a/Necta/NectaServices/NectaService.cs b/Necta/NectaServices/NectaService.cs index 5619bd3..0017faa 100644 --- a/Necta/NectaServices/NectaService.cs +++ b/Necta/NectaServices/NectaService.cs @@ -12,13 +12,13 @@ class NectaService public static void RunService() { - PrintReceiptDelegate PRdel = new PrintReceiptDelegate(Necta.PrintReceipt); + PrintReceiptDelegate PRdel = new PrintReceiptDelegate(NectaApp.PrintReceipt); List receipts = null; while (true) { - while (Necta.printingInProgress) + while (NectaApp.printingInProgress) Thread.Sleep(500); Thread.Sleep(API_Handler.API_REQUEST_INTERVAL); @@ -49,7 +49,7 @@ public static void RunService() foreach (Receipt receipt in receipts) { - while (Necta.printingInProgress) + while (NectaApp.printingInProgress) Thread.Sleep(500); PrinterInfo printer = null; @@ -90,9 +90,9 @@ public static void RunService() } - Necta.printingInProgress = true; + NectaApp.printingInProgress = true; //call PrintReceipt from main thread - Necta.MainThreadDispatcher.Invoke(PRdel, new object[] { receipt }); + NectaApp.MainThreadDispatcher.Invoke(PRdel, new object[] { receipt }); } catch (Exception ex) { diff --git a/Necta/PasswordModal.cs b/Necta/PasswordModal.cs index 0560a62..dbd54c5 100644 --- a/Necta/PasswordModal.cs +++ b/Necta/PasswordModal.cs @@ -16,15 +16,15 @@ namespace Necta public partial class PasswordModal : MaterialForm { public static PasswordModal mInstance = null; - private Necta MainInstance = null; + private NectaApp MainInstance = null; private static bool passwordOK = false; - public static void CreatePasswordModal(Necta instance) + public static void CreatePasswordModal(NectaApp instance) { - if(mInstance==null) + if (mInstance == null) mInstance = new PasswordModal(instance); } - private PasswordModal(Necta instance) + private PasswordModal(NectaApp instance) { MainInstance = instance; @@ -33,7 +33,6 @@ private PasswordModal(Necta instance) materialSkinManager.AddFormToManage(this); materialSkinManager.Theme = MaterialSkinManager.Themes.LIGHT; materialSkinManager.ColorScheme = new ColorScheme(Primary.Red300, Primary.Red300, Primary.BlueGrey500, Accent.LightBlue200, TextShade.BLACK); - instance.hideMainForm(); } private void PasswordButton_Click(object sender, EventArgs e) @@ -45,6 +44,7 @@ private void PasswordButton_Click(object sender, EventArgs e) { passwordOK = true; hidePasswordForm(); + MainInstance.SetTextboxesToVisible(true); MainInstance.showMainFrom(); } else @@ -53,8 +53,8 @@ private void PasswordButton_Click(object sender, EventArgs e) private void PasswordForm_Closing(object e, FormClosingEventArgs ev) { - if(!passwordOK) - Application.Exit(); + if (!passwordOK) + Application.Exit(); } private void hidePasswordForm() @@ -65,6 +65,7 @@ private void hidePasswordForm() public void showPasswordFrom() { + MainInstance.hideMainForm(); PasswordTextbox.Text = ""; passwordOK = false; Show(); diff --git a/Necta/Program.cs b/Necta/Program.cs index 019d2a5..d3fb7f4 100644 --- a/Necta/Program.cs +++ b/Necta/Program.cs @@ -18,7 +18,7 @@ static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new Necta()); + Application.Run(new NectaApp()); } } }