public virtual bool EndEdit(bool apply) { if (this.itemEditor == null) { return(true); } if (apply) { if (!this.itemEditor.ApplyValueToItem(this.editedItem.Item)) { return(false); } else { this.OnItemEdited(new TiledViewItemEventArgs(this, this.editedItem.ModelIndex, this.editedItem.Item)); } } this.itemEditor.StopEditing -= this.itemEditor_StopEditing; this.DestroyItemEditor(this.itemEditor); this.Controls.Remove(this.itemEditor.MainControl); this.itemEditor.MainControl.Dispose(); this.itemEditor = null; this.InvalidateModelIndices(this.editedItem.ModelIndex, 1); this.editedItem = new SelectedItem(-1, null); this.Focus(); return(true); }
public virtual bool BeginEdit(int modelIndex) { if (modelIndex == -1) { return(false); } if (this.itemEditor != null) { return(false); } Point editorPos = this.GetModelIndexLocation(modelIndex); this.editedItem = new SelectedItem(modelIndex, this.model.GetItemAt(modelIndex)); this.itemEditor = this.CreateItemEditor(this.editedItem.ModelIndex, this.editedItem.Item, editorPos); if (this.itemEditor != null && this.itemEditor.MainControl != null) { this.itemEditor.GetValueFromItem(this.editedItem.Item); this.itemEditor.StopEditing += this.itemEditor_StopEditing; this.Controls.Add(this.itemEditor.MainControl); this.itemEditor.MainControl.Focus(); } else { this.editedItem = new SelectedItem(-1, null); this.itemEditor = null; return(false); } this.itemEditIndex = -1; this.InvalidateModelIndices(modelIndex, 1); return(true); }
/// <summary> /// Override this method to clean up after editing an item in the <see cref="TiledView"/>. /// </summary> /// <param name="editor"></param> protected virtual void DestroyItemEditor(ITiledViewItemEditor editor) { }