/// <summary>Sets the font of an <see cref="AttributeItem"/>, based on the properties of the /// <see cref="UserAttribute"/> it represents. /// </summary> void SetFont(AttributeItem item) { if(item.Attribute.Revoked) { item.Font = new Font(Font, FontStyle.Italic); item.ForeColor = SystemColors.GrayText; } else if(item.Attribute.Primary) item.Font = new Font(Font, FontStyle.Bold); }
/// <include file="documentation.xml" path="/UI/ListBase/SetAttributeItemFont/*"/> protected virtual void SetFont(AttributeItem item) { if(item.Attribute.Revoked) { if(revokedIdFont == null) revokedIdFont = new Font(Font, FontStyle.Italic | FontStyle.Bold); item.Font = revokedIdFont; item.ForeColor = SystemColors.GrayText; } else { if(userIdFont == null) userIdFont = new Font(Font, FontStyle.Bold); item.Font = userIdFont; } }
/// <summary>Reloads the key and redisplays its attributes and user IDs.</summary> void ReloadKey() { if(key != null) { key = pgp.RefreshKey(key, ListOptions.RetrieveAttributes | ListOptions.RetrieveSecretKeys); if(key == null) { foreach(Control control in Controls) { if(control != lblDescription) control.Enabled = false; } lblDescription.Text = "The key you were editing no longer exists."; } else { userIds.Items.Clear(); foreach(UserId id in key.UserIds) { AttributeItem item = new AttributeItem(id, PGPUI.GetAttributeName(id)); if(id.Revoked) item.Text += " (revoked)"; item.ImageIndex = UserIdIcon; SetFont(item); userIds.Items.Add(item); } foreach(UserAttribute attr in key.Attributes) { bool isPhoto = attr is UserImage; AttributeItem item = new AttributeItem(attr, PGPUI.GetAttributeName(attr)); if(attr.Revoked) item.Text += " (revoked)"; item.ImageIndex = isPhoto ? PhotoIdIcon : UnknownIcon; SetFont(item); userIds.Items.Add(item); } } } }
/// <summary>Called when the given list item is activated by the user, either with the keyboard or mouse.</summary> void ActivateUserId(AttributeItem item) { // activating a photo ID will display it UserImage image = item.Attribute as UserImage; if(image != null) new PhotoIdForm(image).ShowDialog(); }
/// <include file="documentation.xml" path="/UI/ListBase/CreateAttributeItem/*"/> protected override AttributeItem CreateAttributeItem(UserAttribute attr) { AttributeItem item = base.CreateAttributeItem(attr); if(attr.Revoked) item.Text += " (revoked)"; return item; }