Beispiel #1
0
 /// <summary>
 /// Initializes dragging of a line segment.
 /// </summary>
 /// <seealso cref="AutoPosModeOnly"/>
 /// <param name="e">The <see cref="T:System.Windows.Input.MouseButtonEventArgs"/> that contains the event data. This event data reports details about the mouse button that was pressed and the handled state.</param>
 protected override void OnMouseDown(MouseButtonEventArgs e)
 {
     if (e.ChangedButton == MouseButton.Left && !AutoPosModeOnly)
     {
         segmentDragging = true;
         dragLast        = e.GetPosition(XCaseCanvas);
         int i = JunctionGeometryHelper.FindHitSegmentIndex(dragLast, Points);
         affectedPoints = new JunctionPoint[] { Points[i], Points[i + 1] };
         startPositions = new Dictionary <DragThumb, rPoint>();
         if (affectedPoints[0].Movable)
         {
             startPositions[affectedPoints[0]] = new rPoint(affectedPoints[0].Position)
             {
                 tag = affectedPoints[0].Placement
             }
         }
         ;
         if (affectedPoints[1].Movable)
         {
             startPositions[affectedPoints[1]] = new rPoint(affectedPoints[1].Position)
             {
                 tag = affectedPoints[1].Placement
             }
         }
         ;
         this.CaptureMouse();
     }
     base.OnMouseDown(e);
 }
Beispiel #2
0
        /// <summary>
        /// Returns context menu items for junction.
        /// </summary>
        /// <returns></returns>
        internal IEnumerable <ContextMenuItem> JunctionMenuItems()
        {
            if (!AutoPosModeOnly)
            {
                ContextMenuItem breakCommand = new ContextMenuItem("Break line here");
                breakCommand.Click += delegate
                {
                    ViewController.BreakLine(downPos,
                                             JunctionGeometryHelper.FindHitSegmentIndex(downPos, Points) + 1,
                                             viewHelperPointsCollection, XCaseCanvas.Controller);
                };
                ContextMenuItem autoPosEndsCommand = new ContextMenuItem("Line ends auto-position");
                autoPosEndsCommand.Click += delegate
                {
                    StartPoint.Placement = EPlacementKind.ParentAutoPos;
                    EndPoint.Placement   = EPlacementKind.ParentAutoPos;
                    InvalidateGeometry();
                };

                if (this.Association != null)
                {
                    ContextMenuItem removeEndCommand = new ContextMenuItem("Remove from association");
                    removeEndCommand.Click += delegate
                    {
                        Association.Controller.RemoveAssociationEnd(this.AssociationEnd.AssociationEnd);
                    };
                    return(new[] { breakCommand, autoPosEndsCommand, removeEndCommand });
                }

                return(new[] { breakCommand, autoPosEndsCommand });
            }
            else
            {
                return(new ContextMenuItem[0]);
            }
        }