Beispiel #1
0
        //private async void SaveAccountFile()
        private void SaveAccountFile()
        {
            // If password file is not loaded, there are not to save data.
            if (null == m_PasswordFile)
            {
                return;
            }

            // If current password file is not modified, skip save file.
            if (!m_PasswordFile.IsModified)
            {
                return;
            }

            // save
            m_PasswordFile.Save(m_Password);

            // Update last editing time
            m_LastEditDate = DateTime.UtcNow;

            EditEnableToggle.OnContent = SAVED_LABEL_TEXT;
        }
Beispiel #2
0
        /// <summary>
        /// Import password file button is clicked.
        /// </summary>
        private async void ImportPasswordFileButton_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 import source file.
            FileOpenPicker p = new FileOpenPicker();

            p.FileTypeFilter.Add(".txt");
            StorageFile txtFile = await p.PickSingleFileAsync();

            if (null == txtFile)
            {
                return;
            }

            // read all of text from file
            string str = await FileIO.ReadTextAsync(txtFile);

            // Initialize password file object
            pwfile.Import(str);

            // Save new password file
            pwfile.Save(password);
        }