private void ResetToState(IList <TItem> items) { if (items == null || items.Count == 0) { ItemEditors.Clear(); return; } var itemsArray = items.ToList(); var maxLevel = items.Count > ItemEditors.Count ? ItemEditors.Count : items.Count; var level = 0; for (; level < maxLevel; level++) { ItemEditors[level].EditableTarget = itemsArray[level]; } if (items.Count > ItemEditors.Count) { for (; level < itemsArray.Count; level++) { AddItemEditor(itemsArray[level]); } } else { for (; level < itemsArray.Count; level++) { ItemEditors.RemoveAt(ItemEditors.Count - 1); } } }
void OnItemUpdated(object sender, EventArgs e) { var itemEditor = (IDataEditor <TItem>)sender; var index = ItemEditors.IndexOf(itemEditor); if (index < 0) { itemEditor.TargetUpdated -= OnItemUpdated; return; } var items = TargetNullCheck.IsNull(_editableTarget) ? default(IList <TItem>) : _propertyAdapter.GetValue(_editableTarget); if (items != null) { items[index] = itemEditor.EditableTarget; } var handler = TargetUpdated; if (handler != null) { handler(this, EventArgs.Empty); } }
void IValidatedComponent <TValidationState> .ClearValidationState() { foreach (var itemEditor in ItemEditors.OfType <IValidatedComponent <TItemValidationState> >()) { itemEditor.ClearValidationState(); } }
private ItemEditor AddItemEditor(ContentItem item, Control container) { var itemEditor = new ItemEditor(); itemEditor.ID = ID + "_ie_" + itemEditorIndex; container.Controls.Add(itemEditor); itemEditor.ZoneName = ZoneName; ItemEditors.Add(itemEditor); itemEditor.CurrentItem = item; return(itemEditor); }
private void AddItemEditor(TItem item) { var itemEditor = _itemEditorFactory(item); if (itemEditor != null) { ItemEditors.Add(itemEditor); itemEditor.TargetUpdated += OnItemUpdated; } }