/// <summary> /// Called to handle the "edit" action. /// </summary> /// <param name="items">A list of items to edit.</param> /// <param name="editedItems">The list of items that were edited.</param> /// <returns>True if items were edited, false otherwise.</returns> protected override bool EditItems(IList <EmailAddressDetail> items, out IList <EmailAddressDetail> editedItems) { editedItems = new List <EmailAddressDetail>(); EmailAddressDetail oldItem = CollectionUtils.FirstElement(items); EmailAddressDetail newItem = (EmailAddressDetail)oldItem.Clone(); EmailAddressEditorComponent editor = new EmailAddressEditorComponent(newItem); ApplicationComponentExitCode exitCode = LaunchAsDialog(this.Host.DesktopWindow, editor, SR.TitleUpdateEmailAddress); if (exitCode == ApplicationComponentExitCode.Accepted) { editedItems.Add(newItem); // Since there is no way to use IsSameItem to identify the address before and after are the same // We must manually remove the old and add the new item this.Table.Items.Replace( delegate(EmailAddressDetail x) { return(IsSameItem(oldItem, x)); }, newItem); // Preserve the order of the items int index = _emailAddressList.IndexOf(oldItem); _emailAddressList.Insert(index, newItem); _emailAddressList.Remove(oldItem); return(true); } return(false); }
/// <summary> /// Called to handle the "add" action. /// </summary> /// <param name="addedItems"></param> /// <returns>True if items were added, false otherwise.</returns> protected override bool AddItems(out IList <EmailAddressDetail> addedItems) { addedItems = new List <EmailAddressDetail>(); EmailAddressDetail emailAddress = new EmailAddressDetail(); EmailAddressEditorComponent editor = new EmailAddressEditorComponent(emailAddress); ApplicationComponentExitCode exitCode = LaunchAsDialog(this.Host.DesktopWindow, editor, SR.TitleAddEmailAddress); if (exitCode == ApplicationComponentExitCode.Accepted) { addedItems.Add(emailAddress); _emailAddressList.Add(emailAddress); return(true); } return(false); }