/// <summary>Adds the given signatures to the list.</summary> void AddSignatures(IEnumerable<KeySignature> sigs) { bool hadItem = false; foreach(KeySignature sig in sigs) { KeySignatureItem item = CreateSignatureItem(sig); if(item != null) { SetFont(item); item.ImageIndex = IndentImage; item.IndentCount = 1; Items.Add(item); hadItem = true; } } if(hadItem) // change the last item's image to the corner, if we added an item { Items[Items.Count-1].ImageIndex = CornerImage; } else // otherwise, add an item that says there are no signatures { ListViewItem item = new ListViewItem("No signatures"); item.ImageIndex = CornerImage; item.IndentCount = 1; Items.Add(item); } }
/// <include file="documentation.xml" path="/UI/ListBase/SetKeySignatureItemFont/*"/> protected virtual void SetFont(KeySignatureItem item) { if(item.Signature.IsInvalid) // if the signature failed verification, it may indicate a security problem { item.ForeColor = Color.FromArgb(255, 96, 0); // so make it colorful } else if(item.Signature.Revocation && !item.Signature.SelfSignature) // if the signature says this key is NOT owned { // by the real user // we want to make it striking, but if the signature is of unknown validity, it shouldn't be too striking item.ForeColor = item.Signature.IsValid ? Color.Red : Color.FromArgb(255, 96, 96); } else if(!item.Signature.IsValid) // if the signature could not be verified, then gray it out { item.ForeColor = SystemColors.GrayText; } }
/// <include file="documentation.xml" path="/UI/ListBase/CreateSignatureItem/*"/> protected virtual KeySignatureItem CreateSignatureItem(KeySignature sig) { if(sig == null) throw new ArgumentNullException(); string name = string.IsNullOrEmpty(sig.SignerName) ? "(User ID not found)" : sig.SignerName; if(sig.Revocation && sig.SelfSignature) name += " (self revocation)"; else if(sig.SelfSignature) name += " (self signature)"; else if(sig.Revocation) name += " (revocation)"; KeySignatureItem item = new KeySignatureItem(sig, name); item.SubItems.Add(sig.ShortKeyId); item.SubItems.Add((sig.Exportable ? "Exportable " : "Local ") + PGPUI.GetSignatureDescription(sig.Type)); item.SubItems.Add(sig.Expired ? "Expired" : sig.IsValid ? "Valid" : sig.IsInvalid ? "Invalid" : sig.ErrorOccurred ? "Error" : "Unverified"); item.SubItems.Add(sig.CreationTime.ToShortDateString()); return item; }