Beispiel #1
0
  /// <summary>Filters the list of recipients by showing only those with a user ID or key fingerprint that contains at
  /// least one of the given keyword strings. If the keywords array is null or contains no keywords,
  /// all keys are shown.
  /// </summary>
  public void FilterItems(string[] keywords)
  {
    if(keys == null) throw new InvalidOperationException("ShowKeyring has not been called.");

    if(keywords == null || keywords.Length == 0 || keywords.Length == 1 && string.IsNullOrEmpty(keywords[0]))
    {
      AddKeyItems(keys);
      return;
    }

    List<PrimaryKey> keysToShow = new List<PrimaryKey>();
    foreach(PrimaryKey key in keys)
    {
      foreach(string keyword in keywords)
      {
        if(PGPUI.KeyMatchesKeyword(key, keyword))
        {
          keysToShow.Add(key);
          break;
        }
      }
    }

    AddKeyItems(keysToShow.ToArray());
  }