예제 #1
0
 /// <summary>
 /// Proceeds with dragging.
 /// </summary>
 /// <param name="e">The <see cref="T:System.Windows.Input.MouseEventArgs"/> that contains the event data.</param>
 public void OnMouseMove(MouseEventArgs e)
 {
     if (IsDragging && Movable)
     {
         Point  newPoint = e.GetPosition(ExolutioCanvas);
         Vector delta    = Vector.SubtractPoints(newPoint, PrevPoint);
         PrevPoint  = newPoint;
         MousePoint = Vector.AddVector(MousePoint, delta);
         this.DragDelta(new DragDeltaEventArgs(delta.X, delta.Y));
     }
 }
예제 #2
0
 /// <summary>
 /// Ends dragging
 /// </summary>
 /// <param name="e">The <see cref="T:System.Windows.Input.MouseButtonEventArgs"/> that contains the event data. The event data reports that the mouse button was released.</param>
 public void OnMouseUp(MouseButtonEventArgs e)
 {
     #if SILVERLIGHT
     #else
     if (e.ChangedButton == MouseButton.Left)
     #endif
     {
         IsDragging = false;
         DraggedControl.ReleaseMouseCapture();
         //e.Handled = true;
         DragCompleted(PrevPoint, Vector.SubtractPoints(PrevPoint, DragStartPoint));
     }
 }
예제 #3
0
        /// <summary>
        /// Drags the completed.
        /// </summary>
        /// <param name="finalPoint">The final point.</param>
        /// <param name="totalShift">The total shift.</param>
        private void DragCompleted(Point finalPoint, Vector totalShift)
        {
            IsDragged = false;
            //if (visualAidsAdorner != null)
            //{
            //    AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(ExolutioCanvas);
            //    adornerLayer.Remove(visualAidsAdorner);
            //    visualAidsAdorner = null;
            //}


            if (DragStartPoint != finalPoint)
            {
                //DiagramController controller = ExolutioCanvas.Controller;

                //MacroCommand<DiagramController> moveMacroCommand =
                //    MacroCommandFactory<DiagramController>.Factory().Create(controller);
                //moveMacroCommand.Description = CommandDescription.MOVE_MACRO;

                //JunctionPointCommand.PointMoveDataDictionary pointMoveDataCollection = null;

                //foreach (KeyValuePair<DragThumb, rPoint> pair in startPositions)
                //{
                //    if (pair.Key is IAlignable)
                //    {
                //        IAlignable element = (IAlignable)pair.Key;

                //        DragThumb dragThumb = element as DragThumb;

                //        double _x;
                //        double _y;
                //        if (dragThumb != null && dragThumb.Placement == EPlacementKind.RelativeCanvas)
                //        {
                //            _x = dragThumb.Left - dragThumb.ReferentialElement.CanvasPosition.X;
                //            _y = dragThumb.Top - dragThumb.ReferentialElement.CanvasPosition.Y;
                //        }
                //        else
                //        {
                //            _x = element.Left;
                //            _y = element.Top;
                //        }

                //        CommandBase command = ViewController.CreateMoveCommand(
                //                _x,
                //                _y,
                //                element.ViewHelper,
                //                controller);
                //        moveMacroCommand.Commands.Add(command);
                //    }
                //    else if (pair.Key is JunctionPoint)
                //    {
                //        JunctionPoint junctionPoint = (JunctionPoint)pair.Key;

                //        JunctionPointCommand.PointMoveData data = new JunctionPointCommand.PointMoveData
                //        {
                //            Index = junctionPoint.OrderInConnector,
                //            OldPosition = pair.Value,
                //            NewPosition = new rPoint(junctionPoint.Position) { tag = junctionPoint.Placement },
                //        };

                //        if (pointMoveDataCollection == null)
                //            pointMoveDataCollection = new JunctionPointCommand.PointMoveDataDictionary();

                //        if (!pointMoveDataCollection.ContainsKey(junctionPoint.Connector.viewHelperPointsCollection))
                //        {
                //            pointMoveDataCollection[junctionPoint.Connector.viewHelperPointsCollection] = new List<JunctionPointCommand.PointMoveData>();
                //        }
                //        pointMoveDataCollection[junctionPoint.Connector.viewHelperPointsCollection].Add(data);
                //    }
                //}

                //// add one command for each affected junction
                //if (pointMoveDataCollection != null)
                //{
                //    JunctionPointCommand junctionPointCommand = (JunctionPointCommand)JunctionPointCommandFactory.Factory().Create(controller);
                //    junctionPointCommand.Action = JunctionPointCommand.EJunctionPointAction.MovePoints;
                //    junctionPointCommand.PointMoveDataCollection = pointMoveDataCollection;
                //    junctionPointCommand.Description = CommandDescription.MOVE_JUNCTION_POINTS;
                //    moveMacroCommand.Commands.Add(junctionPointCommand);
                //}

                //moveMacroCommand.Execute();

                if (Dropped != null)
                {
                    Dropped();
                }
            }
        }