protected override LabelEditResult OnCreatorNodeEditCommitted(int index, object value, int insertIndex) { var columnName = value as string; if (!string.IsNullOrEmpty(columnName)) { var treeGridColumns = GetColumns(); Debug.Assert( treeGridColumns != null && treeGridColumns.Length > 0, "TreeGridColumns does not have expected number of columns"); if (treeGridColumns != null && treeGridColumns.Length > 0) { var treeGridColumn = treeGridColumns[0]; Debug.Assert(treeGridColumn != null, "First TreeGridColumn is null"); if (treeGridColumn != null) { var mc = new MappingCondition(_mappingStorageEntityType.Context, null, _mappingStorageEntityType); var lovElement = mc.FindMappingLovElement(columnName, ListOfValuesCollection.FirstColumn); // if lovElement is LovEmptyPlaceHolder then user is clicking off the 'Empty' // entry in the drop-down list and there's nothing to insert if (lovElement != null && lovElement != MappingEFElement.LovEmptyPlaceHolder) { treeGridColumn.SetValue(mc, lovElement); DoBranchModification(BranchModificationEventArgs.InsertItems(this, insertIndex, 1)); return(LabelEditResult.AcceptEdit); } } } } return(base.OnCreatorNodeEditCommitted(index, value, insertIndex)); }
private void CustomReferenceModeAddEvent(object sender, ElementAddedEventArgs e) { ModelHasReferenceMode link = e.ModelElement as ModelHasReferenceMode; CustomReferenceMode customReferenceMode = link.ReferenceMode as CustomReferenceMode; if (customReferenceMode != null && !customReferenceMode.IsDeleted && link.Model == this.myModel) { int index = myCustomReferenceModesList.BinarySearch(customReferenceMode, NamedElementComparer <CustomReferenceMode> .CurrentCulture); int insertAt = 0; insertAt = (index < 0) ? ~index : index; myCustomReferenceModesList.Insert(insertAt, customReferenceMode); if (myModify != null) { if (myIDidIt) { myIDidIt = false; myModify(this, BranchModificationEventArgs.InsertItems(this, myCustomReferenceModesList.Count - 1, 1)); if (insertAt != index) { myModify(this, BranchModificationEventArgs.MoveItem(this, myCustomReferenceModesList.Count - 1, insertAt)); } } else { myModify(this, BranchModificationEventArgs.InsertItems(this, insertAt - 1, 1)); } } } }
public virtual void OnColumnValueChanged(TreeGridDesignerBranchChangedArgs args) { if (args.InsertingItem) { DoBranchModification(BranchModificationEventArgs.InsertItems(this, args.Row, 1)); } else if (args.DeletingItem) { DoBranchModification(BranchModificationEventArgs.DeleteItems(this, args.Row, 1)); } else { DoBranchModification( BranchModificationEventArgs.DisplayDataChanged( new DisplayDataChangedData(VirtualTreeDisplayDataChanges.All, this, args.Row, args.Column, 1))); } }
/// <summary> /// Sets the reference modes for the control /// </summary> /// <param name="model"></param> public void SetModel(ORMModel model) { if (model != myModel) { Store newStore = (model == null) ? null : model.Store; if (myStore != null && myStore != newStore && !myStore.Disposed) { ManageStoreEvents(myStore, EventHandlerAction.Remove); } if (newStore != null && newStore != myStore) { ManageStoreEvents(newStore, EventHandlerAction.Add); } this.myModel = model; this.myStore = newStore; int count = myIntrinsicReferenceModesList.Count; this.myIntrinsicReferenceModesList.Clear(); if (myModify != null && count != 0) { myModify(this, BranchModificationEventArgs.DeleteItems(this, 0, count)); } if (model != null) { foreach (ReferenceMode mode in model.ReferenceModeCollection) { IntrinsicReferenceMode intMode = mode as IntrinsicReferenceMode; if (intMode != null) { this.myIntrinsicReferenceModesList.Add(intMode); } } myIntrinsicReferenceModesList.Sort(); } count = myIntrinsicReferenceModesList.Count; if (myModify != null && count != 0) { myModify(this, BranchModificationEventArgs.InsertItems(this, -1, count)); } } }
protected override LabelEditResult OnCreatorNodeEditCommitted(int index, object value, int insertIndex) { var columnName = value as string; if (!string.IsNullOrEmpty(columnName)) { var mrb = new MappingResultBinding(null, null, _mappingResultBindings); if (mrb.CreateModelItem(null, _mappingResultBindings.Context, columnName)) { DoBranchModification(BranchModificationEventArgs.InsertItems(this, insertIndex, 1)); return(LabelEditResult.AcceptEdit); } else { // attempt to create model item failed (no properties to map to) return(LabelEditResult.CancelEdit); } } else { return(LabelEditResult.CancelEdit); } }