コード例 #1
0
ファイル: DialogCreator.cs プロジェクト: mdddev/pass-winmenu
        /// <summary>
        /// Asks the user to choose a password file.
        /// </summary>
        /// <returns>
        /// The path to the chosen password file (relative to the password directory),
        /// or null if the user didn't choose anything.
        /// </returns>
        public PasswordFile RequestPasswordFile()
        {
            EnsureStaThread();

            // Find GPG-encrypted password files
            var passFiles = passwordManager.GetPasswordFiles(ConfigManager.Config.PasswordStore.PasswordFileMatch).ToList();

            if (passFiles.Count == 0)
            {
                MessageBox.Show("Your password store doesn't appear to contain any passwords yet.", "Empty password store", MessageBoxButton.OK, MessageBoxImage.Information);
                return(null);
            }
            var selection = ShowPasswordMenu(passFiles.Select(f => f.RelativePath));

            if (selection == null)
            {
                return(null);
            }
            return(passFiles.Single(f => f.RelativePath == selection));
        }
コード例 #2
0
        /// <summary>
        /// Asks the user to choose a password file.
        /// </summary>
        /// <returns>
        /// The path to the chosen password file (relative to the password directory),
        /// or null if the user didn't choose anything.
        /// </returns>
        private PasswordFile RequestPasswordFile()
        {
            Helpers.AssertOnUiThread();

            // Find GPG-encrypted password files
            var passFiles = passwordManager.GetPasswordFiles(ConfigManager.Config.PasswordStore.PasswordFileMatch).ToList();

            if (passFiles.Count == 0)
            {
                MessageBox.Show("Your password store doesn't appear to contain any passwords yet.", "Empty password store", MessageBoxButton.OK, MessageBoxImage.Information);
                return(null);
            }
            var selection = ShowPasswordMenu(passFiles.Select(pathDisplayHelper.GetDisplayPath));

            if (selection == null)
            {
                return(null);
            }
            return(passFiles.Single(f => pathDisplayHelper.GetDisplayPath(f) == selection));
        }