Skip to content

Commit

Permalink
hide app content on first run
Browse files Browse the repository at this point in the history
  • Loading branch information
Vlad Somai authored and Vlad Somai committed Jul 20, 2022
1 parent 4f90814 commit 240f9c4
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 23 deletions.
10 changes: 5 additions & 5 deletions Necta/Necta.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,11 @@
<ItemGroup>
<Compile Include="API\ReceiptType.cs" />
<Compile Include="API\WinPrinter.cs" />
<Compile Include="Form1.cs">
<Compile Include="NectaApp.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
<Compile Include="NectaApp.Designer.cs">
<DependentUpon>NectaApp.cs</DependentUpon>
</Compile>
<Compile Include="API\API.cs" />
<Compile Include="PasswordModal.cs">
Expand All @@ -164,8 +164,8 @@
<Compile Include="NectaServices\NectaService.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
<EmbeddedResource Include="NectaApp.resx">
<DependentUpon>NectaApp.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="PasswordModal.resx">
<DependentUpon>PasswordModal.cs</DependentUpon>
Expand Down
4 changes: 2 additions & 2 deletions Necta/Form1.Designer.cs → Necta/NectaApp.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 19 additions & 3 deletions Necta/Form1.cs → Necta/NectaApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -28,7 +28,7 @@ public static bool printingInProgress
set { lock (printingInProgressLock) { _printingInProgress = value; } }
}

public Necta()
public NectaApp()
{
InitializeComponent();
var materialSkinManager = MaterialSkinManager.Instance;
Expand All @@ -53,6 +53,7 @@ public Necta()
NectaLogService.WriteLog(ex.Message, LogLevels.ERROR);
}

SetTextboxesToVisible(false);
CheckPassword();
}

Expand Down Expand Up @@ -196,7 +197,7 @@ private static async Task<int> 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();
}
Expand Down Expand Up @@ -224,6 +225,7 @@ private static void ProcessPrint()

private void CheckPassword()
{
this.Visible = false;
PasswordModal.mInstance.showPasswordFrom();
}

Expand All @@ -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;
}
}
}
File renamed without changes.
10 changes: 5 additions & 5 deletions Necta/NectaServices/NectaService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ class NectaService

public static void RunService()
{
PrintReceiptDelegate PRdel = new PrintReceiptDelegate(Necta.PrintReceipt);
PrintReceiptDelegate PRdel = new PrintReceiptDelegate(NectaApp.PrintReceipt);

List<Receipt> receipts = null;

while (true)
{
while (Necta.printingInProgress)
while (NectaApp.printingInProgress)
Thread.Sleep(500);

Thread.Sleep(API_Handler.API_REQUEST_INTERVAL);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand Down
15 changes: 8 additions & 7 deletions Necta/PasswordModal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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)
Expand All @@ -45,6 +44,7 @@ private void PasswordButton_Click(object sender, EventArgs e)
{
passwordOK = true;
hidePasswordForm();
MainInstance.SetTextboxesToVisible(true);
MainInstance.showMainFrom();
}
else
Expand All @@ -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()
Expand All @@ -65,6 +65,7 @@ private void hidePasswordForm()

public void showPasswordFrom()
{
MainInstance.hideMainForm();
PasswordTextbox.Text = "";
passwordOK = false;
Show();
Expand Down
2 changes: 1 addition & 1 deletion Necta/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Necta());
Application.Run(new NectaApp());
}
}
}

0 comments on commit 240f9c4

Please sign in to comment.