private int FindReferenceMode(IntrinsicReferenceMode intRefMode) { for (int i = 0; i < myIntrinsicReferenceModesList.Count; i++) { IntrinsicReferenceMode mode = myIntrinsicReferenceModesList[i]; if (mode == intRefMode) { return(i); } } return(-1); }
/// <summary> /// An IMS event to track the shape element added to the associated /// diagram during this connect action. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ReferenceModeKindChangeEvent(object sender, ElementPropertyChangedEventArgs e) { if (myModify != null) { ReferenceModeKind referenceModeKind = e.ModelElement as ReferenceModeKind; if (referenceModeKind != null && referenceModeKind.Model == this.myModel) { foreach (ReferenceMode refMode in referenceModeKind.ReferenceModeCollection) { IntrinsicReferenceMode intrinsicRefMode = refMode as IntrinsicReferenceMode; if (intrinsicRefMode != null) { int row = this.FindReferenceMode(intrinsicRefMode); myModify(this, BranchModificationEventArgs.DisplayDataChanged(new DisplayDataChangedData(VirtualTreeDisplayDataChanges.Text, this, row, (int)Columns.FormatString, 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)); } } }
private int FindReferenceMode(IntrinsicReferenceMode intRefMode) { for (int i = 0; i < myIntrinsicReferenceModesList.Count; i++) { IntrinsicReferenceMode mode = myIntrinsicReferenceModesList[i]; if (mode == intRefMode) { return i; } } return -1; }