示例#1
0
        private async void RecoveryBackupGetButton_Click(object sender, RoutedEventArgs e)
        {
            _ = sender;
            _ = e;

            CultureInfo ci        = new CultureInfo("en-US");
            string      resultMsg = "";
            string      bkfname   = (string)BackupFilesCombo.SelectedValue;

            if (string.IsNullOrEmpty(bkfname))
            {
                return;
            }

            // Recovery
            if (AppData.RecoveryFromBackup(bkfname))
            {
                resultMsg = GlbFunc.GetResourceString("RECOVERY_BACKUP_RESULT_SUCCEED", "Succeed recovery from backup {0}");
            }
            else
            {
                resultMsg = GlbFunc.GetResourceString("RECOVERY_BACKUP_RESULT_FAILED", "Failed to recovery from backup {0}");
            }
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat(ci, resultMsg, bkfname);
            RecoveryBackupResultText.Text = sb.ToString();

            // Update Conbobox
            await UpdateBackupFilesList().ConfigureAwait(true);
        }
示例#2
0
        private async Task UpdateBackupFilesList()
        {
            BackupFilesCombo.Items.Clear();

            // Get backuped date
            string [] bkDate = AppData.GetBackupDate();

            if (bkDate.Length <= 0)
            {
                BackupFilesCombo.IsEnabled        = false;
                RecoveryBackupGetButton.IsEnabled = false;
                await GlbFunc.ShowMessage("MSG_BUCKUP_FILE_NOT_EXIST", "There are no Backup files.").ConfigureAwait(true);

                return;
            }
            else
            {
                BackupFilesCombo.SelectedIndex    = 0;
                BackupFilesCombo.IsEnabled        = true;
                RecoveryBackupGetButton.IsEnabled = true;
            }

            // Add backup file names to combo box
            for (int i = 0; i < bkDate.Length; i++)
            {
                BackupFilesCombo.Items.Add(bkDate[i]);
            }
        }
示例#3
0
        private async void InquiryList_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e)
        {
            _ = sender;

            if (e.OriginalSource.GetType() == typeof(Grid))
            {
                return;
            }

            // If password file is not loaded, ignore this operation.
            if (null == m_PasswordFile)
            {
                return;
            }

            // If in Read-Only mode, ignore this operation.
            if (!m_EnableEdit)
            {
                return;
            }

            // If Account list item is not selected, ignore this event
            if (m_SelectedAccount < 0 || m_SelectedAccount >= m_PasswordFile.GetCount())
            {
                return;
            }

            int         idx = InquiryList.SelectedIndex;
            AccountInfo ai  = m_PasswordFile.GetAccountInfo(m_SelectedAccount);

            // show edit dialog
            string      hiddenString = GlbFunc.GetResourceString("PASS_HIDDEN_STRING", "******");
            EditInquiry d            = new EditInquiry(CreateEditInquiryCondidateDic());

            d.ItemName      = ai.GetInquiryName(idx);
            d.ItemValue     = ai.GetInquiryValue(idx);
            d.HideItemValue = ai.GetHideFlag(idx);
            await d.ShowAsync();

            if (!d.IsOK)
            {
                return;
            }

            ai.SetInquiry(idx, d.ItemName, d.ItemValue, d.HideItemValue);
            m_InquiryList_ItemTitles[idx].Text = d.ItemName;
            if (d.HideItemValue)
            {
                m_InquiryList_ItemTexts[idx].Text = hiddenString;
            }
            else
            {
                m_InquiryList_ItemTexts[idx].Text = d.ItemValue;
            }

            // Save explicitly
            SaveAccountFile();
        }
示例#4
0
        private async void Page_Loaded(object sender, RoutedEventArgs e)
        {
            _ = sender;
            _ = e;

            m_SaveTimer          = new DispatcherTimer();
            m_SaveTimer.Interval = TimeSpan.FromMilliseconds(1000);
            m_SaveTimer.Tick    += OnSaveTimer;
            m_SaveTimer.Start();
            m_LastEditDate = DateTime.UtcNow;

            MODIFIED_LABEL_TEXT        = GlbFunc.GetResourceString("EditEnableToggle_ModifiedText", "Ediable *");
            SAVED_LABEL_TEXT           = GlbFunc.GetResourceString("EditEnableToggle_SavedText", "Ediable");
            EditEnableToggle.OnContent = SAVED_LABEL_TEXT;

            // all of controls are disabled.
            AccountList.Items.Clear();
            InquiryList.Items.Clear();
            m_AccountList_ItemCount = 0;
            SetEdiableState(false);

            // load password file
            if (!await LoadPasswordFile().ConfigureAwait(true))
            {
                // If failed to load password file, all of controls are remain disabled.
                m_PasswordFile             = null;
                EditEnableToggle.IsEnabled = false;
                return;
            }
            AccountList.Items.Clear();
            AccountList.IsEnabled   = true;
            m_AccountList_ItemCount = 0;

            // Insert loaded account information to list
            UpdateAccountList();

            if (m_PasswordFile.GetCount() > 0)
            {
                m_AccountListSelectionFlg = true;
                AccountList.SelectedIndex = 0;
                m_AccountListSelectionFlg = false;
                UpdateInquiryList(0);
            }
            else
            {
                UpdateInquiryList(-1);
            }

            // If account info is empty, default is editable. Others, default is read-only.
            EditEnableToggle.IsOn = (m_PasswordFile.GetCount() == 0);

            Application.Current.Suspending += new SuspendingEventHandler(App_Suspending);
        }
示例#5
0
        /// <summary>
        /// It called on starting of the application.
        /// It decide that configurations is made up or not, and show the next page.
        /// </summary>
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            if (!await AppData.IsInitialized().ConfigureAwait(true))
            {
                // If first time, show FileSettingsPage.
                await GlbFunc.ShowMessage("MSG_INITIAL_USE_MSG", "On first use, specify password file name and master pasword.").ConfigureAwait(true);

                MainPageConfiguRadio.IsChecked = true;
            }
            else
            {
                MainPageAccountListRadio.IsChecked = true;
            }
        }
示例#6
0
        public SetNewPassDialog(bool needOldPassword, bool unmatchMsg)
        {
            this.InitializeComponent();

            IsOK = false;
            if (null == Password)
            {
                Password = "";
            }

            m_NeedOldPassword = needOldPassword;

            if (needOldPassword)
            {
                SetPasswordDlgOldTitle.Visibility = Windows.UI.Xaml.Visibility.Visible;
                OldPasswordText.Visibility        = Windows.UI.Xaml.Visibility.Visible;
                if (unmatchMsg)
                {
                    PasswordErrorText.Visibility = Windows.UI.Xaml.Visibility.Visible;
                }
                else
                {
                    PasswordErrorText.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                }
                PrimaryButtonText = GlbFunc.GetResourceString("SetNewPassDialog_ChangePass_PrimaryButtonText", "OK");
            }
            else
            {
                SetPasswordDlgOldTitle.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                OldPasswordText.Visibility        = Windows.UI.Xaml.Visibility.Collapsed;
                PasswordErrorText.Visibility      = Windows.UI.Xaml.Visibility.Collapsed;
                PrimaryButtonText = GlbFunc.GetResourceString("SetNewPassDialog_SetNewPass_PrimaryButtonText", "OK");
            }

            OldPasswordText.Text        = "";
            NewPasswordText.Text        = Password;
            ConfirmText.Text            = Password;
            SavePasswordCheck.IsChecked = false;

            this.IsPrimaryButtonEnabled = false;
        }
示例#7
0
        /// <summary>
        /// Export password file button is clicked.
        /// </summary>
        private async void ExportPasswordFileButton_Click(object sender, RoutedEventArgs e)
        {
            _ = sender;
            _ = e;

            // Load selected password file. If not selected ignore this event
            var r = await LoadSelectedPasswordFile().ConfigureAwait(true);

            PasswordFile pwfile   = r.Item1;
            string       password = r.Item2;

            if (string.IsNullOrEmpty(password) || null == pwfile)
            {
                return;
            }

            // Get output path name of a new plain text file
            FileSavePicker p = new FileSavePicker();

            p.FileTypeChoices.Add(GlbFunc.GetResourceString("TextFileTypeDescription", "Text File"), new List <string>()
            {
                ".txt"
            });
            p.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
            StorageFile txtFile = await p.PickSaveFileAsync();

            if (null == txtFile)
            {
                return;
            }

            // Generate string for output
            string plainText = pwfile.BuildStringForOutput(true);

            // write plain text file
            await FileIO.WriteBufferAsync(txtFile, Encoding.GetEncoding( "UTF-8" ).GetBytes( plainText ).AsBuffer());
        }
示例#8
0
        private void ContentDialog_Loaded(object sender, RoutedEventArgs e)
        {
            _ = sender;
            _ = e;

            // Set values before editing to controls.
            if (null == ItemName)
            {
                ItemName = "";
            }
            if (null == ItemValue)
            {
                ItemValue = "";
            }
            InquiryItemName.Text         = ItemName;
            InquiryItemValue.Text        = ItemValue;
            HideItemValueCheck.IsChecked = HideItemValue;
            IsOK = false;

            // Restore password configuration
            if (ApplicationData.Current.LocalSettings.Values.ContainsKey("PasswordDigit"))
            {
                string passwordDigit = (string)ApplicationData.Current.LocalSettings.Values["PasswordDigit"];
                if (String.IsNullOrEmpty(passwordDigit))
                {
                    PasswordDigit.Text = "";
                }
                else
                {
                    PasswordDigit.Text = passwordDigit;
                }
            }
            else
            {
                PasswordDigit.Text = GlbFunc.GetResourceString("DefaultPasswordDigits", "8");
            }

            if (ApplicationData.Current.LocalSettings.Values.ContainsKey("PassLowerCaseCheck"))
            {
                PassLowerCaseCheck.IsChecked = (bool)ApplicationData.Current.LocalSettings.Values["PassLowerCaseCheck"];
            }
            else
            {
                PassLowerCaseCheck.IsChecked = true;
            }
            if (ApplicationData.Current.LocalSettings.Values.ContainsKey("PassUpperCaseCheck"))
            {
                PassUpperCaseCheck.IsChecked = (bool)ApplicationData.Current.LocalSettings.Values["PassUpperCaseCheck"];
            }
            else
            {
                PassUpperCaseCheck.IsChecked = true;
            }
            if (ApplicationData.Current.LocalSettings.Values.ContainsKey("PassNumberCheck"))
            {
                PassNumberCheck.IsChecked = (bool)ApplicationData.Current.LocalSettings.Values["PassNumberCheck"];
            }
            else
            {
                PassNumberCheck.IsChecked = true;
            }
            if (ApplicationData.Current.LocalSettings.Values.ContainsKey("PassSymbolCheck"))
            {
                PassSymbolCheck.IsChecked = (bool)ApplicationData.Current.LocalSettings.Values["PassSymbolCheck"];
            }
            else
            {
                PassSymbolCheck.IsChecked = true;
            }
            if (ApplicationData.Current.LocalSettings.Values.ContainsKey("PassSymbolCandidate"))
            {
                string passSymbolCandidate = (string)ApplicationData.Current.LocalSettings.Values["PassSymbolCandidate"];
                if (String.IsNullOrEmpty(passSymbolCandidate))
                {
                    PassSymbolCandidate.Text = "";
                }
                else
                {
                    PassSymbolCandidate.Text = passSymbolCandidate;
                }
            }
            else
            {
                PassSymbolCandidate.Text = GlbFunc.GetResourceString("DefaultSymbolCandidateString", "!$%'()*,/;=>?[]{}");
            }
            if (ApplicationData.Current.LocalSettings.Values.ContainsKey("PassExcludeConfuseCheck"))
            {
                PassExcludeConfuseCheck.IsChecked = (bool)ApplicationData.Current.LocalSettings.Values["PassExcludeConfuseCheck"];
            }
            else
            {
                PassExcludeConfuseCheck.IsChecked = true;
            }

            // Register ItemName candidate strings to InquiryItemName conbo box
            if (null != m_CandidateDic)
            {
                m_NameCandidate = new string[m_CandidateDic.Values.Count];
                int cnt = 0;
                foreach (KeyValuePair <string, SortedDictionary <string, string> > k in m_CandidateDic.Values)
                {
                    m_NameCandidate[cnt] = k.Key;
                    cnt++;
                    InquiryItemNameCandList.Items.Add(new TextBlock {
                        Text = k.Key, Margin = new Thickness(0.0)
                    });
                }
            }
            else
            {
                InquiryItemNameCandBtn.IsEnabled  = false;
                InquiryItemValueCandBtn.IsEnabled = false;
            }
        }
示例#9
0
        // PassGenerateButton is clicked
        private void PassGenerateButton_Click(object sender, RoutedEventArgs e)
        {
            _ = sender;
            _ = e;
            int digit = 8;

            // Get password digit. If failed, default is 8.
            if (!Int32.TryParse(PasswordDigit.Text, out digit))
            {
                digit = 8;
                PasswordDigit.Text = GlbFunc.GetResourceString("DefaultPasswordDigits", "8");
            }
            if (digit <= 0)
            {
                InquiryItemValue.Text = "";
                return;
            }
            if (digit > 128)
            {
                digit = 128;
            }

            int candCnt = 0;

            if (PassLowerCaseCheck.IsChecked.GetValueOrDefault(false))
            {
                candCnt++;
            }
            if (PassUpperCaseCheck.IsChecked.GetValueOrDefault(false))
            {
                candCnt++;
            }
            if (PassNumberCheck.IsChecked.GetValueOrDefault(false))
            {
                candCnt++;
            }
            if (PassSymbolCheck.IsChecked.GetValueOrDefault(false) && PassSymbolCandidate.Text.Length > 0)
            {
                candCnt++;
            }

            if (candCnt <= 0)
            {
                // If usable condidate chars is not exist, clear password text and exit.
                InquiryItemValue.Text = "";
                return;
            }

            String [] cand           = new String[candCnt];
            bool      excludeConfuse = PassExcludeConfuseCheck.IsChecked.GetValueOrDefault(false);

            candCnt = 0;
            if (PassLowerCaseCheck.IsChecked.GetValueOrDefault(false))
            {
                if (excludeConfuse)
                {
                    cand[candCnt] = "acdefhijkmprstuvxyz";
                }
                else
                {
                    cand[candCnt] = "abcdefghijklmnopqrstuvwxyz";
                }
                candCnt++;
            }
            if (PassUpperCaseCheck.IsChecked.GetValueOrDefault(false))
            {
                if (excludeConfuse)
                {
                    cand[candCnt] = "ABCDEFGHJKLMNPQRSTUVXYZ";
                }
                else
                {
                    cand[candCnt] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
                }
                candCnt++;
            }
            if (PassNumberCheck.IsChecked.GetValueOrDefault(false))
            {
                if (excludeConfuse)
                {
                    cand[candCnt] = "1234578";
                }
                else
                {
                    cand[candCnt] = "0123456789";
                }
                candCnt++;
            }
            if (PassSymbolCheck.IsChecked.GetValueOrDefault(false) && PassSymbolCandidate.Text.Length > 0)
            {
                cand[candCnt] = PassSymbolCandidate.Text;
                candCnt++;
            }

            StringBuilder allCandCharsSB = new StringBuilder();

            for (int i = 0; i < candCnt; i++)
            {
                allCandCharsSB.Append(cand[i]);
            }
            string allCandChars = allCandCharsSB.ToString();

            StringBuilder sb = new StringBuilder();
            Random        r  = new Random();

            for (int i = 0; i < digit; i++)
            {
                if (i < candCnt)
                {
                    sb.Append(cand[i].Substring(r.Next(0, cand[i].Length - 1), 1));
                }
                else
                {
                    sb.Append(allCandChars.Substring(r.Next(0, allCandChars.Length - 1), 1));
                }
            }

            InquiryItemValue.Text = new String(sb.ToString().OrderBy(i => r.Next(0, 1073741824)).ToArray());

            // If password string is generated, hide flag is automatically checked.
            HideItemValueCheck.IsChecked = true;
        }
示例#10
0
        private void UpdateInquiryList(int accountInfoIdx)
        {
            string hiddenString = GlbFunc.GetResourceString("PASS_HIDDEN_STRING", "******");

            m_SelectedAccount = accountInfoIdx;
            if (AccountList.Items.Count <= 0 || m_SelectedAccount < 0)
            {
                // Clear all of controls in Account info pane.
                m_AccountNameTextUpdateFlg = true;
                AccountNameText.Text       = "";
                m_AccountNameTextUpdateFlg = false;
                InquiryList.Items.Clear();

                for (int i = 0; i < m_InquiryList_ItemTitles.Length; i++)
                {
                    m_InquiryList_ItemTitles[i] = null;
                }
                for (int i = 0; i < m_InquiryList_ItemTexts.Length; i++)
                {
                    m_InquiryList_ItemTexts[i] = null;
                }
                for (int i = 0; i < m_InquiryList_CopyButton.Length; i++)
                {
                    m_InquiryList_CopyButton[i] = null;
                }
                for (int i = 0; i < m_InquiryList_CopyButton_Click.Length; i++)
                {
                    m_InquiryList_CopyButton_Click[i] = null;
                }
                for (int i = 0; i < m_InquiryList_Border.Length; i++)
                {
                    m_InquiryList_Border[i] = null;
                }
                m_InquiryList_ItemCount = 0;
            }
            else
            {
                // select specified item in AccountList
                m_AccountListSelectionFlg = true;
                AccountList.SelectedIndex = m_SelectedAccount;
                m_AccountListSelectionFlg = false;

                // Show selected account info in Account info pane.
                AccountInfo ai           = m_PasswordFile.GetAccountInfo(m_SelectedAccount);
                int         inquiryCount = ai.GetInquiryCount();
                m_AccountNameTextUpdateFlg = true;
                AccountNameText.Text       = ai.AccountName;
                m_AccountNameTextUpdateFlg = false;

                // Allocate TextBlock vectors if necessary.
                if (inquiryCount >= m_InquiryList_ItemTitles.Length)
                {
                    Array.Resize(ref m_InquiryList_ItemTitles, Math.Max(m_InquiryList_ItemTitles.Length * 2, inquiryCount + 1));
                }
                if (inquiryCount >= m_InquiryList_ItemTexts.Length)
                {
                    Array.Resize(ref m_InquiryList_ItemTexts, Math.Max(m_InquiryList_ItemTexts.Length * 2, inquiryCount + 1));
                }
                if (inquiryCount >= m_InquiryList_CopyButton.Length)
                {
                    Array.Resize(ref m_InquiryList_CopyButton, Math.Max(m_InquiryList_CopyButton.Length * 2, inquiryCount + 1));
                }
                if (inquiryCount >= m_InquiryList_CopyButton_Click.Length)
                {
                    Array.Resize(ref m_InquiryList_CopyButton_Click, Math.Max(m_InquiryList_CopyButton_Click.Length * 2, inquiryCount + 1));
                }
                if (inquiryCount >= m_InquiryList_Border.Length)
                {
                    Array.Resize(ref m_InquiryList_Border, Math.Max(m_InquiryList_Border.Length * 2, inquiryCount + 1));
                }

                for (int i = 0; i < m_InquiryList_ItemCount && i < inquiryCount; i++)
                {
                    // update Inquiry Title and inquily text in existing control
                    m_InquiryList_ItemTitles[i].Text = ai.GetInquiryName(i);
                    if (!ai.GetHideFlag(i))
                    {
                        m_InquiryList_ItemTexts[i].Text = ai.GetInquiryValue(i);
                    }
                    else
                    {
                        m_InquiryList_ItemTexts[i].Text = hiddenString;
                    }
                    m_InquiryList_Border[i].Background = new SolidColorBrush(CalcBorderColor(m_AccountList_ItemCount, accountInfoIdx, EditEnableToggle.IsOn));
                }
                if (m_InquiryList_ItemCount < inquiryCount)
                {
                    System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("en-US");
                    SolidColorBrush wBorderBrush        = new SolidColorBrush(CalcBorderColor(m_AccountList_ItemCount, accountInfoIdx, EditEnableToggle.IsOn));
                    // add missing items to InquiryList
                    for (int i = m_InquiryList_ItemCount; i < inquiryCount; i++)
                    {
                        int  copy_i = i;
                        Grid g      = new Grid {
                            Name   = i.ToString(ci),
                            Height = 80,
                            Margin = new Thickness(0, 3, 0, 3)
                        };
                        g.ColumnDefinitions.Add(new ColumnDefinition {
                            Width = new GridLength(3.0)
                        });
                        g.ColumnDefinitions.Add(new ColumnDefinition());
                        StackPanel sp = new StackPanel {
                            Orientation = Orientation.Horizontal,
                            Margin      = new Thickness(10, 0, 0, 0)
                        };
                        m_InquiryList_CopyButton[i] =
                            new Button {
                            HorizontalAlignment = HorizontalAlignment.Stretch,
                            Margin            = new Thickness(5, 0, 5, 0),
                            VerticalAlignment = VerticalAlignment.Center,
                            Height            = 40,
                            Width             = 40,
                            Content           = new FontIcon {
                                FontFamily = new FontFamily("Segoe MDL2 Assets"),
                                Glyph      = "\uF0E3"
                            },
                        };
                        m_InquiryList_CopyButton_Click[i]  = (sender, e) => { OnCopyClipboardInquiryButton_Click(sender, e, copy_i); };
                        m_InquiryList_CopyButton[i].Click += m_InquiryList_CopyButton_Click[i];
                        sp.Children.Add(m_InquiryList_CopyButton[i]);
                        StackPanel spSub = new StackPanel {
                            HorizontalAlignment = HorizontalAlignment.Stretch,
                            VerticalAlignment   = VerticalAlignment.Stretch,
                            Margin = new Thickness(10, 5, 10, 0)
                        };
                        m_InquiryList_ItemTitles[i] = new TextBlock {
                            Margin = new Thickness(5, 5, 0, 3),
                            Text   = ai.GetInquiryName(i)
                        };
                        m_InquiryList_ItemTexts[i] = new TextBlock {
                            Margin   = new Thickness(15, 3, 0, 3),
                            FontSize = 20.0
                        };
                        if (!ai.GetHideFlag(i))
                        {
                            m_InquiryList_ItemTexts[i].Text = ai.GetInquiryValue(i);
                        }
                        else
                        {
                            m_InquiryList_ItemTexts[i].Text = hiddenString;
                        }
                        spSub.Children.Add(m_InquiryList_ItemTitles[i]);
                        spSub.Children.Add(m_InquiryList_ItemTexts[i]);
                        sp.Children.Add(spSub);
                        Grid.SetColumn(sp, 1);
                        g.Children.Add(sp);
                        m_InquiryList_Border[i] = new Border {
                            Background = wBorderBrush
                        };
                        Grid.SetColumn(m_InquiryList_Border[i], 0);
                        g.Children.Add(m_InquiryList_Border[i]);
                        InquiryList.Items.Add(g);
                    }
                }
                else
                {
                    // delete excessive items from InquiryList
                    for (int i = m_InquiryList_ItemCount - 1; i >= inquiryCount; i--)
                    {
                        m_InquiryList_ItemTitles[i] = null;
                        m_InquiryList_ItemTexts[i]  = null;
                        m_InquiryList_CopyButton[i] = null;
                        m_InquiryList_Border[i]     = null;
                        InquiryList.Items.RemoveAt(i);
                    }
                }
                m_InquiryList_ItemCount = inquiryCount;

                if (m_InquiryList_ItemCount > 0)
                {
                    InquiryList.SelectedItem = 0;
                }
            }
            SetEdiableState(m_EnableEdit);
        }
示例#11
0
        /// <summary>
        /// CreateNewPasswordFileButton button was selected.
        /// </summary>
        private async void CreateNewPasswordFileButton_Click(object sender, RoutedEventArgs e)
        {
            _ = sender;
            _ = e;

            ResourceLoader r = ResourceLoader.GetForCurrentView();

            if (await AppData.IsInitialized().ConfigureAwait(true))
            {
                // Clear existing account information and set new password

                string titleStr = null;
                if (null != r)
                {
                    titleStr = r.GetString("INIT_CONFIRM_MSG_TITLE");
                }
                if (null == titleStr)
                {
                    titleStr = "Confirmation";
                }

                string msgStr = null;
                if (null != r)
                {
                    msgStr = r.GetString("INIT_CONFIRM_MSG");
                }
                if (null == msgStr)
                {
                    msgStr = "All registered data will be deleted, including backup. Do you want to run it?";
                }

                MessageDialog msgDlg      = new MessageDialog(msgStr, titleStr);
                string        okLabel     = GlbFunc.GetResourceString("CONFIRM_INITIALIZE_OK_MSG", "OK");
                string        cancelLabel = GlbFunc.GetResourceString("CONFIRM_INITIALIZE_CANCEL_MSG", "Cancel");
                msgDlg.Commands.Add(new UICommand(okLabel));
                msgDlg.Commands.Add(new UICommand(cancelLabel));
                var result = await msgDlg.ShowAsync();

                if (result.Label != okLabel)
                {
                    return;
                }

                // Get the password of the new file.
                SetNewPassDialog newPassDlg = new SetNewPassDialog(false, false);
                await newPassDlg.ShowAsync();

                if (!newPassDlg.IsOK)
                {
                    return;
                }
                AppData.Initialize(newPassDlg.Password, newPassDlg.SavePassword);
            }
            else
            {
                // Specify new password and initialize data structure.

                // Get the password of the new file.
                SetNewPassDialog d = new SetNewPassDialog(false, false);
                await d.ShowAsync();

                if (!d.IsOK)
                {
                    return;
                }
                AppData.Initialize(d.Password, d.SavePassword);
            }
            await UpdateWindowStat().ConfigureAwait(true);
        }