-
Notifications
You must be signed in to change notification settings - Fork 0
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
Vlad Somai
authored and
Vlad Somai
committed
Jul 20, 2022
1 parent
e77026e
commit 4f90814
Showing
8 changed files
with
923 additions
and
20 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,74 @@ | ||
using MaterialSkin; | ||
using MaterialSkin.Controls; | ||
using Necta.NectaServices; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Data; | ||
using System.Drawing; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Forms; | ||
|
||
namespace Necta | ||
{ | ||
public partial class PasswordModal : MaterialForm | ||
{ | ||
public static PasswordModal mInstance = null; | ||
private Necta MainInstance = null; | ||
private static bool passwordOK = false; | ||
|
||
public static void CreatePasswordModal(Necta instance) | ||
{ | ||
if(mInstance==null) | ||
mInstance = new PasswordModal(instance); | ||
} | ||
private PasswordModal(Necta instance) | ||
{ | ||
MainInstance = instance; | ||
|
||
InitializeComponent(); | ||
var materialSkinManager = MaterialSkinManager.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) | ||
{ | ||
passwordOK = false; | ||
|
||
var currentPassword = ConfigContent<PasswordType>.ReadConfig(NectaConfigService.nectaPasswordFile); | ||
if (currentPassword.Password == Hasher.GetSha256Hash(PasswordTextbox.Text)) | ||
{ | ||
passwordOK = true; | ||
hidePasswordForm(); | ||
MainInstance.showMainFrom(); | ||
} | ||
else | ||
MessageBox.Show(this, "Invalid password, please try again.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign); | ||
} | ||
|
||
private void PasswordForm_Closing(object e, FormClosingEventArgs ev) | ||
{ | ||
if(!passwordOK) | ||
Application.Exit(); | ||
} | ||
|
||
private void hidePasswordForm() | ||
{ | ||
Hide(); | ||
this.WindowState = FormWindowState.Minimized; | ||
} | ||
|
||
public void showPasswordFrom() | ||
{ | ||
PasswordTextbox.Text = ""; | ||
passwordOK = false; | ||
Show(); | ||
this.WindowState = FormWindowState.Normal; | ||
} | ||
} | ||
} |
Oops, something went wrong.