private void CustomReferenceModeChangeEvent(object sender, ElementPropertyChangedEventArgs e)
                    {
                        CustomReferenceMode customReferenceMode = e.ModelElement as CustomReferenceMode;

                        if (customReferenceMode != null && !customReferenceMode.IsDeleted && customReferenceMode.Model == this.myModel)
                        {
                            if (myModify != null)
                            {
                                Guid attributeId = e.DomainProperty.Id;
                                int  column      = -1;
                                if (attributeId == CustomReferenceMode.CustomFormatStringDomainPropertyId)
                                {
                                    column = (int)Columns.FormatString;
                                }
                                else if (attributeId == CustomReferenceMode.NameDomainPropertyId)
                                {
                                    column = (int)Columns.Name;
                                }
                                // The reference mode kind column keys off the relationship between
                                // a reference mode and its kind. The change may also fire here if the
                                // ReferenceMode.KindDisplay is used to change it, but we ignore the
                                // property change in favor of the backing object.
                                if (column != -1)
                                {
                                    int row = this.FindReferenceMode(customReferenceMode);
                                    myModify(this, BranchModificationEventArgs.DisplayDataChanged(new DisplayDataChangedData(VirtualTreeDisplayDataChanges.Text, this, row, column, 1)));
                                }
                            }
                        }
                    }
        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));
        }
Example #3
0
 /// <summary>
 ///     Should be called by derived classes to indicate that a branch modification (add, remove, reorder) has occurred.
 /// </summary>
 /// <param name="modification">Indicates the type of modification</param>
 protected void DoBranchModification(BranchModificationEventArgs modification)
 {
     if (_onBranchModification != null)
     {
         _onBranchModification(this, modification);
     }
 }
Example #4
0
            private void MoveDiagramTo(int diagramIndex, int targetIndex)
            {
                if (diagramIndex == targetIndex)
                {
                    return;
                }
                Diagram[] diagrams         = myDiagrams;
                Diagram   newTargetDiagram = diagrams[diagramIndex];

                if (diagramIndex > targetIndex)
                {
                    // Move items down
                    for (int i = diagramIndex; i > targetIndex; --i)
                    {
                        diagrams[i] = diagrams[i - 1];
                    }
                }
                else
                {
                    // Move items up
                    for (int i = diagramIndex; i < targetIndex; ++i)
                    {
                        diagrams[i] = diagrams[i + 1];
                    }
                }
                diagrams[targetIndex] = newTargetDiagram;
                if (myModifications != null)
                {
                    myModifications(this, BranchModificationEventArgs.MoveItem(this, diagramIndex, targetIndex));
                }
            }
                    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));
                                }
                            }
                        }
                    }
Example #6
0
 private void OnInnerBranchModification(object sender, BranchModificationEventArgs args)
 {
     if (OnBranchModification != null)
     {
         args.Index  = FindIndexForBranch(args.Branch, args.Index);
         args.Branch = this;
         OnBranchModification(this, args);
     }
 }
Example #7
0
 public override void OnColumnValueChanged(TreeGridDesignerBranchChangedArgs args)
 {
     if (!args.InsertingItem &&
         _expandedBranch != null)
     {
         DoBranchModification(BranchModificationEventArgs.RemoveBranch(_expandedBranch));
         _expandedBranch = null;
     }
 }
 public override void OnColumnValueChanged(TreeGridDesignerBranchChangedArgs args)
 {
     Debug.Assert(
         args.Row < _expandedBranches.Length,
         "args.Row (" + args.Row + ") should be < _expandedBranches.Length (" + _expandedBranches.Length + ")");
     if (args.Row < _expandedBranches.Length &&
         _expandedBranches[args.Row] != null)
     {
         DoBranchModification(BranchModificationEventArgs.RemoveBranch(_expandedBranches[args.Row]));
         _expandedBranches[args.Row] = null;
     }
     base.OnColumnValueChanged(args);
 }
                    /// <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)
                    {
                        ReferenceModeKind referenceModeKind = e.ModelElement as ReferenceModeKind;

                        if (referenceModeKind != null && referenceModeKind.Model == this.myModel)
                        {
                            if (myModify != null)
                            {
                                int row = this.FindReferenceModeKind(referenceModeKind);
                                myModify(this, BranchModificationEventArgs.DisplayDataChanged(new DisplayDataChangedData(VirtualTreeDisplayDataChanges.Text, this, row, (int)Columns.FormatString, 1)));
                            }
                        }
                    }
Example #10
0
 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)));
     }
 }
                    private void CustomReferenceModeRemoveEvent(object sender, ElementDeletedEventArgs e)
                    {
                        ModelHasReferenceMode link = e.ModelElement as ModelHasReferenceMode;
                        CustomReferenceMode   customReferenceMode = link.ReferenceMode as CustomReferenceMode;

                        if (customReferenceMode != null && link.Model == this.myModel)
                        {
                            int row = this.FindReferenceMode(customReferenceMode);
                            if (row >= 0)
                            {
                                myCustomReferenceModesList.RemoveAt(row);
                                if (myModify != null)
                                {
                                    myModify(this, BranchModificationEventArgs.DeleteItems(this, row, 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.IsDeleted && referenceModeKind.Model == this.myModel)
                            {
                                foreach (ReferenceMode refMode in referenceModeKind.ReferenceModeCollection)
                                {
                                    CustomReferenceMode custRefMode = refMode as CustomReferenceMode;
                                    if (custRefMode != null)
                                    {
                                        int row = this.FindReferenceMode(custRefMode);
                                        myModify(this, BranchModificationEventArgs.DisplayDataChanged(new DisplayDataChangedData(VirtualTreeDisplayDataChanges.Text, this, row, (int)Columns.FormatString, 1)));
                                    }
                                }
                            }
                        }
                    }
Example #13
0
 /// <summary>
 /// Move all items up one
 /// </summary>
 public void MoveUpOne(int[] items)
 {
     Array.Sort <int>(items);
     Diagram[] diagrams = myDiagrams;
     for (int i = 0; i < items.Length; ++i)
     {
         int index = items[i];
         if (index > 0)
         {
             Diagram targetDiagram = diagrams[index];
             diagrams[index]     = diagrams[index - 1];
             diagrams[index - 1] = targetDiagram;
             BranchModificationEventHandler handler = myModifications;
             if (handler != null)
             {
                 handler(this, BranchModificationEventArgs.MoveItem(this, index, index - 1));
             }
         }
     }
 }
Example #14
0
					/// <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));
							}
						}
					}
Example #15
0
 private void OnChildBranchModification(object sender, BranchModificationEventArgs e)
 {
     if (e.Action == BranchModificationAction.DeleteItems
         ||
         e.Action == BranchModificationAction.InsertItems)
     {
         // this can also cause changes in column check box state.  Find and refresh appropriate row
         for (var i = 0; i < _childBranchArray.Length; i++)
         {
             if (_childBranchArray[i].Branch == e.Branch)
             {
                 if (_onBranchModification != null)
                 {
                     _onBranchModification(
                         this,
                         BranchModificationEventArgs.DisplayDataChanged(
                             new DisplayDataChangedData(VirtualTreeDisplayDataChanges.StateImage, this, i, -1, 1)));
                 }
             }
         }
     }
 }
Example #16
0
 public override void OnColumnValueChanged(TreeGridDesignerBranchChangedArgs args)
 {
     if (!args.InsertingItem)
     {
         Debug.Assert(
             args.Row < _expandedBranches.Count,
             "args.Row(" + args.Row + ") should be < _expandedBranches.Count (" + _expandedBranches.Count + ")");
         if (args.DeletingItem)
         {
             _expandedBranches.RemoveAt(args.Row);
         }
         else
         {
             if (_expandedBranches[args.Row] != null)
             {
                 DoBranchModification(BranchModificationEventArgs.RemoveBranch(_expandedBranches[args.Row]));
                 _expandedBranches[args.Row] = null;
             }
         }
     }
     base.OnColumnValueChanged(args);
 }
Example #17
0
            /// <summary>
            /// Move all items down one
            /// </summary>
            public void MoveDownOne(int[] items)
            {
                Array.Sort <int>(items);
                Diagram[] diagrams = myDiagrams;
                int       lastItem = diagrams.Length - 1;

                for (int i = items.Length - 1; i >= 0; --i)
                {
                    int index = items[i];
                    if (index < lastItem)
                    {
                        Diagram targetDiagram = diagrams[index];
                        diagrams[index]     = diagrams[index + 1];
                        diagrams[index + 1] = targetDiagram;
                        BranchModificationEventHandler handler = myModifications;
                        if (handler != null)
                        {
                            handler(this, BranchModificationEventArgs.MoveItem(this, index, index + 1));
                        }
                    }
                }
            }
Example #18
0
        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);
            }
        }
 private void ReferenceModeHasKindChangeEvent(object sender, RolePlayerChangedEventArgs e)
 {
     if (myModify != null)
     {
         ReferenceModeHasReferenceModeKind link = e.ElementLink as ReferenceModeHasReferenceModeKind;
         if (link != null)
         {
             ReferenceModeKind referenceModeKind = link.Kind;
             if (referenceModeKind.Model == this.myModel && !link.IsDeleted)
             {
                 foreach (ReferenceMode refMode in referenceModeKind.ReferenceModeCollection)
                 {
                     CustomReferenceMode custRefMode = refMode as CustomReferenceMode;
                     if (custRefMode != null)
                     {
                         int row = this.FindReferenceMode(custRefMode);
                         myModify(this, BranchModificationEventArgs.DisplayDataChanged(new DisplayDataChangedData(VirtualTreeDisplayDataChanges.Text, this, row, -1, 1)));
                     }
                 }
             }
         }
     }
 }
Example #20
0
 protected virtual void BranchModified(BranchModificationEventArgs e)
 {
     if (OnBranchModification != null)
         OnBranchModification(this, e);
 }
Example #21
0
        /// <summary>
        ///     Process key down events.
        /// </summary>
        public ProcessKeyResult ProcessKeyDown(int row, int column, KeyEventArgs e)
        {
            var result = new ProcessKeyResult(KeyAction.Process);

            if (e != null)
            {
                switch (e.KeyCode)
                {
                case Keys.Tab:
                    result.Action    = KeyAction.Handle;
                    result.Direction = !e.Shift ? NavigationDirection.Right : NavigationDirection.Left;
                    result.Local     = false;
                    return(result);

                case Keys.Space:
                    if (_columns[column].ColumnIsCheckBox)
                    {
                        // if we're on a check box, use standard processing
                        return(new ProcessKeyResult(KeyAction.Process));
                    }

                    // special case for only one checkbox in the row,
                    // it should be toggled no matter where the focus is.
                    var checkBoxIndex = -1;
                    for (var i = 0; i < _columns.Length; i++)
                    {
                        if (_columns[i].ColumnIsCheckBox &&
                            (GetCheckBoxValue(row, i) != CheckBoxState.Unsupported))
                        {
                            if (checkBoxIndex == -1)
                            {
                                checkBoxIndex = i;
                            }
                            else
                            {
                                // more than one checkbox, use standard processing
                                return(new ProcessKeyResult(KeyAction.Process));
                            }
                        }

                        if (checkBoxIndex != -1)
                        {
                            ((IBranch)this).ToggleState(row, checkBoxIndex);

                            // need to refresh both ourselves and our children.  Do we need BranchModificationAction.ToggleState?
                            if (_onBranchModification != null)
                            {
                                _onBranchModification(
                                    this,
                                    BranchModificationEventArgs.DisplayDataChanged(
                                        new DisplayDataChangedData(
                                            VirtualTreeDisplayDataChanges.StateImage, this, row, checkBoxIndex, 1)));
                                _onBranchModification(
                                    this,
                                    BranchModificationEventArgs.DisplayDataChanged(
                                        new DisplayDataChangedData(
                                            VirtualTreeDisplayDataChanges.StateImage, _childBranchArray[row].Branch, -1, checkBoxIndex,
                                            -1)));
                            }

                            return(new ProcessKeyResult(KeyAction.Discard));    // we've handled this, no further processing necessary
                        }
                    }
                    break;

                case Keys.Up:
                    // let Ctrl-Up fall through to the base control processing.
                    if (!e.Control)
                    {
                        result.Action    = KeyAction.Handle;
                        result.Local     = false;
                        result.Direction = NavigationDirection.Up;
                    }
                    break;

                case Keys.Down:
                    // let Ctrl-Down fall through to the base control processing.
                    if (!e.Control)
                    {
                        result.Action    = KeyAction.Handle;
                        result.Local     = false;
                        result.Direction = NavigationDirection.Down;
                    }
                    break;
                }
            }

            return(result);
        }