Beispiel #1
0
  /// <summary>Adds a key to the list.</summary>
  public void AddKey(Key key)
  {
    if(key == null) throw new ArgumentNullException();

    PGPListViewItem item = CreateKeyItem(key);
    if(item != null)
    {
      SetFont(item, GetItemStatus(key));
      Items.Add(item);
    }
  }
Beispiel #2
0
  /// <include file="documentation.xml" path="/UI/ListBase/CreateKeyItem/*"/>
  protected virtual PGPListViewItem CreateKeyItem(Key key)
  {
    PrimaryKey primaryKey = key as PrimaryKey;
    PGPListViewItem item = primaryKey != null ?
      (PGPListViewItem)new PrimaryKeyItem(primaryKey) : new SubkeyItem((Subkey)key);

    item.Text = primaryKey != null ? "primary" : "subkey";
    item.SubItems.Add(key.ShortKeyId);
    item.SubItems.Add(key.KeyType);
    item.SubItems.Add(key.Length.ToString());
    item.SubItems.Add(key.CreationTime.ToShortDateString());
    item.SubItems.Add(key.ExpirationTime.HasValue ? key.ExpirationTime.Value.ToShortDateString() : "n/a");

    char[] capChars = new char[4];
    int caps = 0;
    if((key.Capabilities & KeyCapabilities.Authenticate) != 0) capChars[caps++] = 'A';
    if((key.Capabilities & KeyCapabilities.Certify) != 0) capChars[caps++] = 'C';
    if((key.Capabilities & KeyCapabilities.Encrypt) != 0) capChars[caps++] = 'E';
    if((key.Capabilities & KeyCapabilities.Sign) != 0) capChars[caps++] = 'S';
    item.SubItems.Add(caps == 0 ? "none" : new string(capChars, 0, caps));

    return item;
  }