Exemple #1
0
        public static void ChangeMultiplicityOfElement(Model.MultiplicityElement element, XCase.Model.Element associatedElement, uint?lower, UnlimitedNatural upper, ModelController modelControlller)
        {
            ChangeElementMultiplicityMacroCommand c = (ChangeElementMultiplicityMacroCommand)ChangeElementMultiplicityMacroCommandFactory.Factory().Create(modelControlller);

            if (associatedElement != null)
            {
                c.AssociatedElements.Add(associatedElement);
            }
            c.Lower   = lower;
            c.Upper   = upper;
            c.Element = element;
            c.InitializeCommand();
            if (c.Commands.Count > 0)
            {
                c.Execute();
            }
        }
Exemple #2
0
            /// <summary>
            /// If mouse is over a connectable item, <see cref="DraggedConnectionProcessor"/>'s
            /// <see cref="IDraggedConnectionProcessor.DragConnectionCompleted"/> handler is called
            /// to finilize the operation. Otherwise nothing happens.
            /// </summary>
            /// <param name="e"></param>
            public override void OnMouseUp(MouseButtonEventArgs e)
            {
                if (e.ChangedButton == MouseButton.Right)
                {
                    Canvas.State = ECanvasState.Normal;
                    e.Handled    = true;
                    return;
                }
                base.OnMouseUp(e);

                Canvas.ReleaseMouseCapture();
                InConnectionDrag = false;
                Mouse.SetCursor(Cursors.Arrow);

                if (draggedConnection != null)
                {
                    if (draggedConnection.SourceElement != null)
                    {
                        ((IConnectable)draggedConnection.SourceElement).UnHighlight();
                    }
                    if (draggedConnection.TargetElement != null)
                    {
                        ((IConnectable)draggedConnection.TargetElement).UnHighlight();
                    }

                    draggedConnection.DeleteFromCanvas();

                    if (DraggedConnectionProcessor != null)
                    {
                        Element sourceElement = null;
                        Element targetElement = null;

                        if (draggedConnection.SourceElement is XCaseViewBase)
                        {
                            sourceElement = ((XCaseViewBase)draggedConnection.SourceElement).ModelElement;
                        }
                        if (draggedConnection.TargetElement is XCaseViewBase)
                        {
                            targetElement = ((XCaseViewBase)draggedConnection.TargetElement).ModelElement;
                        }
                        if (draggedConnection.SourceElement != null && ItemDraggedOver == draggedConnection.SourceElement)
                        {
                            targetElement = sourceElement;
                        }
                        if (draggedConnection.SourceElement is PIM_Class && draggedConnection.TargetElement is AssociationDiamond)
                        {
                            targetElement = ((PIM_Class)draggedConnection.SourceElement).ModelElement;
                            sourceElement = ((AssociationDiamond)draggedConnection.TargetElement).Association.Association;
                        }
                        if (draggedConnection.SourceElement is AssociationDiamond && draggedConnection.TargetElement is PIM_Class)
                        {
                            targetElement = ((PIM_Class)draggedConnection.TargetElement).ModelElement;
                            sourceElement = ((AssociationDiamond)draggedConnection.SourceElement).Association.Association;
                        }
                        DraggedConnectionProcessor.DragConnectionCompleted(sourceElement, targetElement);
                        ItemDraggedOver = (IConnectable)draggedConnection.TargetElement;
                    }
                }

                draggedConnection = null;
                Canvas.Children.Remove(draggedPoint);
                draggedPoint = null;
            }