Ejemplo n.º 1
0
  void btnDelete_Click(object sender, EventArgs e)
  {
    if(userIds.SelectedItems.Count != 0)
    {
      if(!EnsureNotAllUserIdsSelected("delete")) return;

      // inform the user that deleting published user IDs is pointless, and get confirmation
      bool onlyOne = userIds.SelectedItems.Count == 1;
      string deleting = onlyOne ? "\""+userIds.SelectedItems[0].Text+"\"" : "multiple user IDs";
      string userId = (onlyOne ? "this user ID" : "these user IDs");
      string s = (onlyOne ? null : "s"), them = (onlyOne ? "it" : "them"), they = (onlyOne ? "it" : "they");
      if(MessageBox.Show("You are about to delete " + deleting + "! Note that you cannot retract a user ID once it "+
                         "has been distributed, so if this key (with " + userId + ") has ever been given to another "+
                         "person or uploaded to a public key server, you should revoke the user ID" + s + " instead "+
                         "of deleting " + them + ", because " + they + " would only be deleted from your machine, "+
                         "and could reappear in the future.\n\nAre you sure you want to delete " + userId + "?",
                         "Delete user IDs?",
                         MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2)
          == DialogResult.Yes)
      {
        PGPUI.DoWithErrorHandling("deleting a user ID", delegate { pgp.DeleteAttributes(GetSelectedAttributes()); });
        ReloadKey();
      }
    }
  }
Ejemplo n.º 2
0
  void btnAddPhotoId_Click(object sender, EventArgs e)
  {
    OpenFileDialog ofd = new OpenFileDialog();

    ofd.Filter = "Image files (*.jpg;*.png;*.gif;*.bmp;*.tif;*.jpeg;*.tiff)|"+
                 "*.jpg;*.png;*.gif;*.bmp;*.tif;*.jpeg;*.tiff|All files (*.*)|*.*";
    ofd.Title  = "Select the image file for your photo ID";
    ofd.SupportMultiDottedExtensions = true;
    if(ofd.ShowDialog() == DialogResult.OK)
    {
      NewPhotoIdForm form = new NewPhotoIdForm();

      try { form.Initialize(ofd.FileName); }
      catch(Exception ex)
      {
        if(ex is System.IO.IOException || ex is System.ArgumentException)
        {
          MessageBox.Show("The selected file is not a valid image, or no longer exists.", "Not an image",
                          MessageBoxButtons.OK, MessageBoxIcon.Error);
          return;
        }
        else
        {
          throw ex;
        }
      }

      if(form.ShowDialog() == DialogResult.OK)
      {
        PGPUI.DoWithErrorHandling("adding the photo", delegate { pgp.AddPhoto(key, form.Bitmap, null); });
        ReloadKey();
      }
    }
  }
Ejemplo n.º 3
0
 void btnAddUserId_Click(object sender, EventArgs e)
 {
   UserIdForm form = new UserIdForm();
   if(form.ShowDialog() == DialogResult.OK)
   {
     PGPUI.DoWithErrorHandling("adding the user ID",
                               delegate { pgp.AddUserId(key, form.RealName, form.Email, form.Comment, form.Preferences); });
     ReloadKey();
   }
 }
Ejemplo n.º 4
0
 void btnRevoke_Click(object sender, EventArgs e)
 {
   if(subkeys.SelectedItems.Count != 0)
   {
     Subkey[] selectedKeys = GetSelectedKeys();
     KeyRevocationForm form = new KeyRevocationForm(selectedKeys);
     if(form.ShowDialog() == DialogResult.OK)
     {
       PGPUI.DoWithErrorHandling("revoking a subkey", delegate { pgp.RevokeSubkeys(form.Reason, selectedKeys); });
       ReloadKey();
     }
   }
 }
Ejemplo n.º 5
0
  void btnRevoke_Click(object sender, EventArgs e)
  {
    if(userIds.SelectedItems.Count != 0)
    {
      if(!EnsureNotAllUserIdsSelected("revoke")) return;

      UserAttribute[] attrs = GetSelectedAttributes();
      UserRevocationForm form = new UserRevocationForm(attrs);
      if(form.ShowDialog() == DialogResult.OK)
      {
        PGPUI.DoWithErrorHandling("revoking a user ID", delegate { pgp.RevokeAttributes(form.Reason, attrs); });
        ReloadKey();
      }
    }
  }