private void MenuItem_SetPass_Click(object sender, RoutedEventArgs e)
        {
            var entry = listView.SelectedItem as AddressBookEntry;

            if (entry != null && Entries.Contains(entry))
            {
                string serverName = string.IsNullOrWhiteSpace(entry.Name) ? string.IsNullOrWhiteSpace(entry.Address) ? "[null]" : entry.Address.ToString() : entry.Name;
                string message    = string.Format("Enter new pass for {0}", serverName);
                string pass       = entry.Password;
                if (LoginPassWindow.Prompt(ref pass, message, "Apply"))
                {
                    entry.Password = string.IsNullOrWhiteSpace(pass) ? null : pass;
                    listView.Items.Refresh();
                }
            }
        }
예제 #2
0
 /// <summary>
 /// Prompt for password entry in new modal window
 /// </summary>
 /// <param name="password">the initial password to show, and the resultant user response</param>
 /// <param name="message">Message to display to user in window</param>
 /// <param name="buttonText">Label for affirm/login button</param>
 /// <returns>False if canceled</returns>
 public static bool Prompt(ref string password, string message = null, string buttonText = "Login")
 {
     using (LoginPassWindow pwWindow = new LoginPassWindow(
                initialPassword: password,
                messsage: message,
                confirmButtonText: buttonText))
     {
         pwWindow.ShowDialog();
         if (!pwWindow.Canceled)
         {
             password = pwWindow.GetInput();
             return(true);
         }
     }
     return(false);
 }
 /// <summary>
 /// Prompt for password entry in new modal window
 /// </summary>
 /// <param name="password">the initial password to show, and the resultant user response</param>
 /// <param name="message">Message to display to user in window</param>
 /// <param name="buttonText">Label for affirm/login button</param>
 /// <returns>False if canceled</returns>
 public static bool Prompt(ref string password, string message = null, string buttonText = "Login")
 {
     using (LoginPassWindow pwWindow = new LoginPassWindow(
         initialPassword: password,
         messsage: message,
         confirmButtonText: buttonText))
     {
         pwWindow.ShowDialog();
         if (!pwWindow.Canceled)
         {
             password = pwWindow.GetInput();
             return true;
         }
     }
     return false;
 }