Exemple #1
0
 void recipients_MouseDoubleClick(object sender, MouseEventArgs e)
 {
   if(e.Button == MouseButtons.Left) // double-clicking a recipient closes the window
   {
     PrimaryKeyItem item = recipients.GetItemAt(e.X, e.Y) as PrimaryKeyItem;
     if(item != null) DialogResult = DialogResult.OK;
   }
 }
 /// <summary>Creates a <see cref="PrimaryKeyItem"/> to represent the <see cref="PrimaryKey"/> from the search
 /// result.
 /// </summary>
 protected virtual PrimaryKeyItem CreateResultItem(PrimaryKey key)
 {
   PrimaryKeyItem item = new PrimaryKeyItem(key, PGPUI.GetKeyName(key));
   item.SubItems.Add(key.CreationTime.ToShortDateString());
   item.SubItems.Add(key.ShortKeyId);
   item.SubItems.Add(key.Revoked ? "Revoked" : key.Expired ? "Expired" : "Valid");
   if(key.Revoked || key.Expired) item.ForeColor = SystemColors.GrayText;
   return item;
 }
Exemple #3
0
 /// <summary>Gets the recipients that are selected in the list.</summary>
 public PrimaryKey[] GetSelectedRecipients()
 {
   List<PrimaryKey> keys = new List<PrimaryKey>(SelectedItems.Count);
   foreach(ListViewItem item in SelectedItems)
   {
     PrimaryKeyItem primaryItem = item as PrimaryKeyItem;
     if(primaryItem != null) keys.Add(primaryItem.PublicKey);
   }
   return keys.ToArray();
 }
Exemple #4
0
  /// <include file="documentation.xml" path="/UI/ListBase/RecreateItems/*"/>
  protected override void RecreateItems()
  {
    List<PrimaryKey> keys = new List<PrimaryKey>(Items.Count);
    foreach(ListViewItem item in Items)
    {
      PrimaryKeyItem primaryItem = item as PrimaryKeyItem;
      if(primaryItem != null) keys.Add(primaryItem.PublicKey);
    }

    AddKeyItems(keys.ToArray());
  }
Exemple #5
0
  /// <include file="documentation.xml" path="/UI/ListBase/RecreateItems/*"/>
  protected override void RecreateItems()
  {
    List<Key> keys = new List<Key>(Items.Count);
    foreach(ListViewItem item in Items)
    {
      PrimaryKeyItem primaryItem = item as PrimaryKeyItem;
      keys.Add(primaryItem != null ? (Key)primaryItem.PublicKey : ((SubkeyItem)item).Subkey);
    }

    Items.Clear();
    foreach(Key key in keys) AddKey(key);
  }
  /// <summary>Adds a chunk of results from the search process to the form.</summary>
  public void AddResults(PrimaryKey[] publicKeys)
  {
    if(publicKeys == null) throw new ArgumentNullException();

    foreach(PrimaryKey key in publicKeys)
    {
      if(key == null) throw new ArgumentException("A key was null.");

      PrimaryKeyItem item = CreateResultItem(key);
      if(item != null)
      {
        item.Tag = key;
        Items.Add(item);
      }
    }
  }
Exemple #7
0
  /// <summary>Clears the current list items, and displays the given keys in the list.</summary>
  void AddKeyItems(PrimaryKey[] keys)
  {
    Items.Clear();

    foreach(PrimaryKey key in keys)
    {
      if(key.HasCapabilities(KeyCapabilities.Encrypt))
      {
        PrimaryKeyItem item = CreatePrimaryKeyItem(key);
        if(item != null)
        {
          SetFont(item, GetItemStatus(key));
          Items.Add(item);
        }
      }
    }
  }