public void GeneratePassword() { try { if (pwdGenWindow == null || pwdGenWindow.IsClosed) { pwdGenWindow = new PwdGenWindow(); pwdGenWindow.Show(); } } catch (Exception ex) { HandleError(ex); } }
private void Window_Closing(object sender, CancelEventArgs e) { bool canceled = false; if (PromptSaveChanges(ref canceled)) { if (!canceled) { if (pwdGenWindow != null && !pwdGenWindow.IsClosed) { pwdGenWindow.Close(); pwdGenWindow = null; } try { if (copiedToClipboard) { copiedToClipboard = false; Clipboard.Clear(); } if (WindowState == WindowState.Normal) { Properties.Settings.Default.Left = Left; Properties.Settings.Default.Top = Top; Properties.Settings.Default.Width = Width; Properties.Settings.Default.Height = Height; } Properties.Settings.Default.Save(); if (thumbnailCache != null) { thumbnailCache.Save(); } if (keyDirectoryCache != null) { keyDirectoryCache.Save(); } } catch (Exception ex) { HandleError(ex); } return; } } e.Cancel = true; }