-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainPage.xaml.cs
708 lines (635 loc) · 31.1 KB
/
MainPage.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
using SQLite;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Core;
using Windows.ApplicationModel.DataTransfer;
using Windows.Storage;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace PassDefend
{
public partial class MainPage : Page
{
//prepare application files
public StorageFolder localFolder = ApplicationData.Current.LocalFolder;
//prepare basic variables
public static string userpass { get; set; }
public bool newaccount = false;
public int selectedID = 0;
public static bool welcomeActive { get; set; }
public static SQLiteConnection dbconnection { get; set; }
//prepare storage for the accounts
internal List<DataAccess.AccountList> AccountData { get; set; }
public MainPage()
{
//initialize the window
this.InitializeComponent();
//stylize the window to match the colour scheme of the application
ColorScheme_CheckForScheme();
//collapse the account details so that the "choose an account" screen is displayed first
AccountDetailScroller.Visibility = Visibility.Collapsed;
//inform of page load completion
Loaded += Page_Loaded;
//set the user facing version information
versionInfo.Text = "PassDefend v" + GetAppVersion();
}
//function that activates upon page load completion
private void Page_Loaded(object sender, RoutedEventArgs e)
{
LoginSequence();
}
//function to handle the login system
private async void LoginSequence()
{
if (await localFolder.TryGetItemAsync("hash") != null) //if login file exists
{
//display the login dialog
DisplayLoginDialog();
}
else //if login file does not exist
{
welcomeActive = true;
Frame.Navigate(typeof(OnboardingPage)); //navigate to the new onboarding page
if (welcomeActive == false)
{
CreatePassword(); //comment this line out if using the new onboarding page
}
}
}
//function to run the login dialogue, begin creation of database, etc
private async void DisplayLoginDialog()
{
bool notLoggedIn = true;
//show the login dialog...
PasswordPrompt signInDialog = new PasswordPrompt();
while (notLoggedIn == true)
{
await signInDialog.ShowAsync();
if (signInDialog.Result == PasswordPromptResult.SignInOK)
{
//...sign in was successful
notLoggedIn = false;
//begin decryption process
//create the credential database if necessary, otherwise continue execution
dbconnection = DataAccess.OpenDB(userpass);
DataAccess.InitializeDatabase(dbconnection);
//first load of database accounts into account bar
RefreshAccounts();
//then load the stored settings of the password generator, if applicable
PassGenerator.loadSettings(generateLowercaseOption, generateCapitalsOption, generateNumbersOption, generateSymbolsOption, generateLengthSlider);
decryptingText.Visibility = Visibility.Collapsed;
//hide the login rectangle to show the main ui
//note, the login rectangle is NOT a security feature, it is simply to make the login dialog look nice. The data behind remains encrypted and unloaded until the password is confirmed.
fadeLoginBackground.Begin(); //begin the fade animation
fadeLoginBackground.Completed += (s, e) => //when the fade animation is completed...
{
loginRectangle.Width = 0; //...set the width and height of the now invisible box to 0 pixels so that it is out of the way and user can interact with the ui
loginRectangle.Height = 0;
};
//begin the login breach check
CheckForBreaches();
}
else if (signInDialog.Result == PasswordPromptResult.SignInCancel)
{
//...sign in was cancelled by the user, exiting application
CoreApplication.Exit();
}
}
}
//function to refresh the accounts from database
private void RefreshAccounts()
{
//if account bar is not empty, clear it
if (AccountData != null)
{
AccountData.Clear();
}
//request account data from database
AccountData = DataAccess.GetAccountData(dbconnection);
AccountData.RemoveAt(0);
//display account data in the account bar
accountList.ItemsSource = AccountData;
}
//function to check all passwords against password breach databases
private async void CheckForBreaches()
{
timeSinceBreachText.Text = "Checking for password breaches...";
foreach (var account in AccountData)
{ //for each account in account data...
bool passCheck = await BreachCheck.checkPassword(account.Password); //check the password against the API
if (passCheck == true) //if the password is found in the breach list...
{
ContentDialog deleteConfirmDialog = new ContentDialog
{
Title = "WARNING! Breach detected on your " + account.Name + " account.",
Content = "The password to your '" + account.Name + "' account appeared in an online breach as identified by HaveIBeenPwned. Please change the password on the service as soon as possible.",
PrimaryButtonText = "Okay"
};
await deleteConfirmDialog.ShowAsync();
}
}
timeSinceBreachText.Text = "Last password breach check: " + DateTime.Now;
}
//function to complete the creation of the master password
private async void CreatePassword()
{
bool dialogNotCompleted = true;
//show the change password dialog...
PasswordCreation createPasswordDialog = new PasswordCreation();
while (dialogNotCompleted == true)
{
await createPasswordDialog.ShowAsync();
if (createPasswordDialog.Result == PasswordCreationResult.PassCreateOK)
{
dialogNotCompleted = false; //breaking loop because password change completed
DisplayLoginDialog(); //ask user for the password, for the first time
}
else if (createPasswordDialog.Result == PasswordCreationResult.PassCreateCancel)
{
CoreApplication.Exit(); //exiting application because onboarding process has been cancelled
}
}
}
//function to complete the changing of the master password
private async void ChangePassword()
{
bool dialogNotCompleted = true;
//show the change password dialog...
PasswordChange changePasswordDialog = new PasswordChange();
while (dialogNotCompleted == true)
{
await changePasswordDialog.ShowAsync();
if (changePasswordDialog.Result == PasswordChangeResult.PassChangeOK)
{
dialogNotCompleted = false; //breaking loop because password change completed
}
else if (changePasswordDialog.Result == PasswordChangeResult.PassChangeCancel)
{
dialogNotCompleted = false; //breaking loop because password change cancelled
}
}
}
//function to check for saved color scheme
private async void ColorScheme_CheckForScheme()
{
if (await localFolder.TryGetItemAsync("colorScheme") != null) //if colorscheme file exists
{
//set scheme
StorageFile colorschemefile = await localFolder.GetFileAsync("colorScheme");
string fileContent = await FileIO.ReadTextAsync(colorschemefile);
if (fileContent == "green")
{
ColorSchemes.Green(AccountDetailWindow, MainBackground, OptionBar, StatusBar, SideBar, accountList, loginRectangle);
}
else if (fileContent == "red")
{
ColorSchemes.Red(AccountDetailWindow, MainBackground, OptionBar, StatusBar, SideBar, accountList, loginRectangle);
}
else if (fileContent == "purple")
{
ColorSchemes.Purple(AccountDetailWindow, MainBackground, OptionBar, StatusBar, SideBar, accountList, loginRectangle);
}
else if (fileContent == "black")
{
ColorSchemes.Black(AccountDetailWindow, MainBackground, OptionBar, StatusBar, SideBar, accountList, loginRectangle);
}
else
{
ColorSchemes.Green(AccountDetailWindow, MainBackground, OptionBar, StatusBar, SideBar, accountList, loginRectangle);
}
}
else //if colorscheme file does not exist
{
ColorSchemes.Green(AccountDetailWindow, MainBackground, OptionBar, StatusBar, SideBar, accountList, loginRectangle);
}
}
private async void resetProgram()
{
//The resetProgram function deletes all user data and returns the program back to the freshly installed state
if (await localFolder.TryGetItemAsync("hash") != null) //if login file exists
{
StorageFile deleteTarget = await localFolder.GetFileAsync("hash");
await deleteTarget.DeleteAsync(); //delete the hash
}
if (await localFolder.TryGetItemAsync("core") != null) //if core exists
{
DataAccess.CloseDB(dbconnection); //close core
StorageFile deleteTarget = await localFolder.GetFileAsync("core");
await deleteTarget.DeleteAsync(); //delete the core
}
if (await localFolder.TryGetItemAsync("colorScheme") != null) //if color personalisation exists
{
StorageFile deleteTarget = await localFolder.GetFileAsync("colorScheme");
await deleteTarget.DeleteAsync(); //delete the color
}
if (await localFolder.TryGetItemAsync("genSettings") != null) //if password generation settings exist
{
StorageFile deleteTarget = await localFolder.GetFileAsync("genSettings");
await deleteTarget.DeleteAsync(); //delete the settings
}
ContentDialog deleteCompleteDialog = new ContentDialog
{
Title = "Reset complete",
Content = "PassDefend has been reset and will now restart.",
PrimaryButtonText = "Okay"
};
ContentDialogResult result = await deleteCompleteDialog.ShowAsync();
if (result == ContentDialogResult.Primary)
{
await CoreApplication.RequestRestartAsync(""); //reboot the application
}
}
//function to get application version
public static string GetAppVersion()
{
Package package = Package.Current;
PackageId packageId = package.Id;
PackageVersion version = packageId.Version;
return string.Format("{0}.{1}.{2}", version.Major, version.Minor, version.Build);
}
/* --- EVERYTHING PAST THIS LINE IS EVENT FUNCTIONS --- */
//function to take searchbox content and filter out the account list
private void SearchBox_TextChanged(object sender, TextChangedEventArgs e)
{
var cont = from s in AccountData where s.Name.Contains(SearchBox.Text, StringComparison.CurrentCultureIgnoreCase) select s;
accountList.ItemsSource = cont;
}
//add account button
private void addAccountButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
//Deselect account list item if listed
accountList.SelectedItem = null;
newaccount = true;
deleteEntryButton.IsEnabled = false;
//clear out the account panel information if filled
accountNameTextBox.Text = "";
usernameTextBox.Text = "";
emailTextBox.Text = "";
passwordTextBox.Text = "";
notesTextBox.Text = "";
//bring up the account panel if not already up
this.AccountDetailScroller.Visibility = Windows.UI.Xaml.Visibility.Visible;
}
//account selected
private void accountList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
newaccount = false;
saveButton.IsEnabled = false;
revertButton.IsEnabled = false;
deleteEntryButton.IsEnabled = true;
if (accountList.SelectedIndex != -1)
{
//get the ID of the requested content
object info = accountList.SelectedValue;
Type type = info.GetType();
IList<PropertyInfo> props = new List<PropertyInfo>(type.GetProperties());
foreach (PropertyInfo prop in props)
{
object propValue = prop.GetValue(info, null);
if (prop.Name == "ID")
{
selectedID = Int32.Parse((string)propValue);
}
}
//Fill the data
foreach (var item in AccountData)
{
if (Int32.Parse(item.ID) == selectedID)
{
accountNameHeader.Text = "Your " + item.Name + " account";
accountNameTextBox.Text = item.Name;
usernameTextBox.Text = item.Username;
emailTextBox.Text = item.Email;
passwordTextBox.Text = item.Password;
notesTextBox.Text = item.Notes;
}
}
}
//bring up the account panel if not already up
this.AccountDetailScroller.Visibility = Windows.UI.Xaml.Visibility.Visible;
}
//function to copy username to clipboard upon button press
private void copyUsernameButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
var dataPackage = new DataPackage();
dataPackage.SetText(usernameTextBox.Text);
Clipboard.SetContent(dataPackage);
}
//function to copy username to clipboard upon button press
private void copyEmailButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
var dataPackage = new DataPackage();
dataPackage.SetText(emailTextBox.Text);
Clipboard.SetContent(dataPackage);
}
//function to copy username to clipboard upon button press
private void copyPasswordButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
var dataPackage = new DataPackage();
dataPackage.SetText(passwordTextBox.Text);
Clipboard.SetContent(dataPackage);
}
//save the account button
private void saveButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
if (newaccount == true)
{
//add new account entry to database
DataAccess.AddData(dbconnection, accountNameTextBox.Text, emailTextBox.Text, usernameTextBox.Text, passwordTextBox.Text, notesTextBox.Text);
RefreshAccounts();
saveButton.IsEnabled = false;
revertButton.IsEnabled = false;
accountList.SelectedIndex = accountList.Items.Count - 1;
}
else
{
//update the account entry in the database
DataAccess.UpdateData(dbconnection, selectedID, accountNameTextBox.Text, emailTextBox.Text, usernameTextBox.Text, passwordTextBox.Text, notesTextBox.Text);
RefreshAccounts();
saveButton.IsEnabled = false;
revertButton.IsEnabled = false;
}
}
//change title of account window as textbox changes
private void accountNameTextbox_TextChanged(object sender, TextChangedEventArgs e)
{
//if textbox is changed...
if (accountNameTextBox.Text.Length == 0) //...and textbox is empty...
{
//...set text to default
accountNameHeader.Text = "New account";
}
else //...or textbox is not empty...
{
//...set text to the textbox content
accountNameHeader.Text = "Your " + accountNameTextBox.Text + " account";
}
if (accountNameTextBox.Text.Length > 0 && (usernameTextBox.Text.Length > 0 || emailTextBox.Text.Length > 0) && passwordTextBox.Text.Length > 0)
{
saveButton.IsEnabled = true;
if (newaccount == false)
{
revertButton.IsEnabled = true;
}
}
else
{
saveButton.IsEnabled = false;
revertButton.IsEnabled = false;
}
}
//function to change the header text with the account name
private void usernameTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
if (accountNameTextBox.Text.Length > 0 && (usernameTextBox.Text.Length > 0 || emailTextBox.Text.Length > 0) && passwordTextBox.Text.Length > 0)
{
saveButton.IsEnabled = true;
if (newaccount == false)
{
revertButton.IsEnabled = true;
}
}
else
{
saveButton.IsEnabled = false;
revertButton.IsEnabled = false;
}
}
//handling the allowance of the save button being used
private void emailTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
if (accountNameTextBox.Text.Length > 0 && (usernameTextBox.Text.Length > 0 || emailTextBox.Text.Length > 0) && passwordTextBox.Text.Length > 0)
{
saveButton.IsEnabled = true;
if (newaccount == false)
{
revertButton.IsEnabled = true;
}
}
else
{
saveButton.IsEnabled = false;
revertButton.IsEnabled = false;
}
}
//handling the allowance of the save button being used
private void notesTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
if (accountNameTextBox.Text.Length > 0 && (usernameTextBox.Text.Length > 0 || emailTextBox.Text.Length > 0) && passwordTextBox.Text.Length > 0)
{
saveButton.IsEnabled = true;
if (newaccount == false)
{
revertButton.IsEnabled = true;
}
}
else
{
saveButton.IsEnabled = false;
revertButton.IsEnabled = false;
}
}
//handling the allowance of the save button being used
private void passwordTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
if (accountNameTextBox.Text.Length > 0 && (usernameTextBox.Text.Length > 0 || emailTextBox.Text.Length > 0) && passwordTextBox.Text.Length > 0)
{
saveButton.IsEnabled = true;
if (newaccount == false)
{
revertButton.IsEnabled = true;
}
}
else
{
saveButton.IsEnabled = false;
revertButton.IsEnabled = false;
}
}
//handling the reverting of details when clicked
private void revertButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
foreach (var item in AccountData)
{
if (Int32.Parse(item.ID) == selectedID)
{
accountNameHeader.Text = "Your " + item.Name + " account";
accountNameTextBox.Text = item.Name;
usernameTextBox.Text = item.Username;
emailTextBox.Text = item.Email;
passwordTextBox.Text = item.Password;
notesTextBox.Text = item.Notes;
}
}
saveButton.IsEnabled = false;
revertButton.IsEnabled = false;
}
//handling of deleting entry when clicked
private async void deleteEntryButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
ContentDialog deleteConfirmDialog = new ContentDialog
{
Title = "Are you sure?",
Content = "You are about to delete this account. \r\nThis cannot be undone!",
PrimaryButtonText = "Delete",
SecondaryButtonText = "Cancel"
};
ContentDialogResult result = await deleteConfirmDialog.ShowAsync();
if (result == ContentDialogResult.Primary)
{
DataAccess.DeleteData(dbconnection, selectedID);
RefreshAccounts();
accountList.SelectedIndex = -1;
this.AccountDetailScroller.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
deleteEntryButton.IsEnabled = false;
}
}
//handling of refresh breach check button
private void refreshBreachCheckButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
CheckForBreaches();
}
private void MenuFlyoutItem_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
//change master password
ChangePassword();
}
//the following functions change the color scheme when selected in the menu
private async void MenuFlyoutItem_Click_1(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
//change colour green
ColorSchemes.Green(AccountDetailWindow, MainBackground, OptionBar, StatusBar, SideBar, accountList, loginRectangle);
StorageFile colorschemefile = await localFolder.CreateFileAsync("colorScheme", CreationCollisionOption.OpenIfExists);
await FileIO.WriteTextAsync(colorschemefile, "green");
}
private async void MenuFlyoutItem_Click_2(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
//change colour red
ColorSchemes.Red(AccountDetailWindow, MainBackground, OptionBar, StatusBar, SideBar, accountList, loginRectangle);
StorageFile colorschemefile = await localFolder.CreateFileAsync("colorScheme", CreationCollisionOption.OpenIfExists);
await FileIO.WriteTextAsync(colorschemefile, "red");
}
private async void MenuFlyoutItem_Click_3(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
//change colour purple
ColorSchemes.Purple(AccountDetailWindow, MainBackground, OptionBar, StatusBar, SideBar, accountList, loginRectangle);
StorageFile colorschemefile = await localFolder.CreateFileAsync("colorScheme", CreationCollisionOption.OpenIfExists);
await FileIO.WriteTextAsync(colorschemefile, "purple");
}
private async void MenuFlyoutItem_Click_4(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
//change colour black
ColorSchemes.Black(AccountDetailWindow, MainBackground, OptionBar, StatusBar, SideBar, accountList, loginRectangle);
StorageFile colorschemefile = await localFolder.CreateFileAsync("colorScheme", CreationCollisionOption.OpenIfExists);
await FileIO.WriteTextAsync(colorschemefile, "black");
}
//end of color scheme changes
private void MenuFlyoutItem_Click_5(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
//Export database button
ImportExportEngine.ExportDB(userpass);
}
private async void MenuFlyoutItem_Click_6(object sender, RoutedEventArgs e)
{
//Reset button
ContentDialog deleteConfirmDialog = new ContentDialog
{
Title = "Are you sure you want to reset?",
Content = "You are about to completely reset PassDefend. \r\nThis will delete all information and restore PassDefend to being freshly installed. \r\n\nTHIS CANNOT BE REVERSED, so it is highly recommended to export the database before resetting. \r\n\nYou will be asked for your password to complete the reset.",
PrimaryButtonText = "Reset",
SecondaryButtonText = "Cancel"
};
ContentDialogResult result = await deleteConfirmDialog.ShowAsync();
if (result == ContentDialogResult.Primary)
{
//check for user password before running reset
bool notLoggedIn = true;
PasswordPrompt signInDialog = new PasswordPrompt();
while (notLoggedIn == true)
{
await signInDialog.ShowAsync();
if (signInDialog.Result == PasswordPromptResult.SignInOK)
{
//...sign in was successful
notLoggedIn = false;
//reset the program
resetProgram();
}
else if (signInDialog.Result == PasswordPromptResult.SignInCancel)
{
//...sign in was cancelled by the user, do not reset the program
notLoggedIn = false;
}
}
}
}
//store the generated password when button is clicked
private void storeGeneratedButton_Click(object sender, RoutedEventArgs e)
{
passwordTextBox.Text = generateResultBox.Text;
PassGenerator.saveSettings(generateLowercaseOption, generateCapitalsOption, generateNumbersOption, generateSymbolsOption, generateLengthSlider);
passwordGeneratorFlyout.Hide();
}
//call the function to regenerate the generated password when the regenerate button is pressed
private void regenerateGeneratedButton_Click(object sender, RoutedEventArgs e)
{
PassGenerator.regenerateGeneratedPass(regenerateGeneratedButton, storeGeneratedButton, generateLowercaseOption, generateCapitalsOption, generateNumbersOption, generateSymbolsOption, generateLengthSlider, generateResultBox);
}
//call the function to generate a password when the generator form is opened
private void passwordGeneratorFlyout_Opened(object sender, object e)
{
PassGenerator.regenerateGeneratedPass(regenerateGeneratedButton, storeGeneratedButton, generateLowercaseOption, generateCapitalsOption, generateNumbersOption, generateSymbolsOption, generateLengthSlider, generateResultBox);
}
//regenerate password when option changed
private void generateCapitalsOption_Click(object sender, RoutedEventArgs e)
{
PassGenerator.regenerateGeneratedPass(regenerateGeneratedButton, storeGeneratedButton, generateLowercaseOption, generateCapitalsOption, generateNumbersOption, generateSymbolsOption, generateLengthSlider, generateResultBox);
}
//regenerate password when option changed
private void generateLowercaseOption_Click(object sender, RoutedEventArgs e)
{
PassGenerator.regenerateGeneratedPass(regenerateGeneratedButton, storeGeneratedButton, generateLowercaseOption, generateCapitalsOption, generateNumbersOption, generateSymbolsOption, generateLengthSlider, generateResultBox);
}
//regenerate password when option changed
private void generateNumbersOption_Click(object sender, RoutedEventArgs e)
{
PassGenerator.regenerateGeneratedPass(regenerateGeneratedButton, storeGeneratedButton, generateLowercaseOption, generateCapitalsOption, generateNumbersOption, generateSymbolsOption, generateLengthSlider, generateResultBox);
}
//regenerate password when option changed
private void generateSymbolsOption_Click(object sender, RoutedEventArgs e)
{
PassGenerator.regenerateGeneratedPass(regenerateGeneratedButton, storeGeneratedButton, generateLowercaseOption, generateCapitalsOption, generateNumbersOption, generateSymbolsOption, generateLengthSlider, generateResultBox);
}
//regenerate password when option changed
private void generateLengthSlider_ValueChanged(object sender, Windows.UI.Xaml.Controls.Primitives.RangeBaseValueChangedEventArgs e)
{
if (passwordGeneratorFlyout.IsOpen)
{
PassGenerator.regenerateGeneratedPass(regenerateGeneratedButton, storeGeneratedButton, generateLowercaseOption, generateCapitalsOption, generateNumbersOption, generateSymbolsOption, generateLengthSlider, generateResultBox);
}
}
//open version info dialog
private async void versionInfo_Click(object sender, RoutedEventArgs e)
{
ContentDialog versionInfoDialog = new ContentDialog
{
Title = "PassDefend (Windows UWP) v" + GetAppVersion(),
Content = "You are running PassDefend (Windows UWP) version " + GetAppVersion() + ".\r\nwww.stevenwheeler.co.uk/passdefend\r\n\r\nPassDefend uses the HaveIBeenPwned Passwords API, licenced under a Creative Commons Attribution 4.0 International License, to provide password breach checking.\r\n\r\nPassword breach checking is secured by not transmitting the whole password and encoding the characters before transmission with SHA-1. All transmission is performed over HTTPS, and the API responds with many false results so that the real inputted password cannot be determined by an onlooker.\r\n\r\nMade in the UK.\r\nThank you for using PassDefend! ❤️",
PrimaryButtonText = "Okay",
SecondaryButtonText = "Diagnostics"
};
ContentDialogResult result = await versionInfoDialog.ShowAsync();
if (result == ContentDialogResult.Primary)
{
return;
}
else
{
DiagnosticMode.openDiagnostics();
}
}
}
}