/// <inheritdoc/>
            public IHitTestable GetHitTestable(INode item, INodeStyle style)
            {
                var geometry = shapeNodeStyle.Renderer.GetShapeGeometry(item, shapeNodeStyle);
                var outline  = geometry.GetOutline();

                return(HitTestables.Create((context, location) => outline.PathContains(location, context.HitTestRadius)));
            }
示例#2
0
        /// <summary>
        /// Adds the input modes that handle the resizing and movement of the rectangular area.
        /// </summary>
        /// <param name="inputMode"></param>
        private void AddClearRectInputModes(MultiplexingInputMode inputMode)
        {
            // create handles for interactively resizing the rectangle
            var rectangleHandles = new RectangleReshapeHandleProvider(clearRect)
            {
                MinimumSize = new SizeD(10, 10)
            };

            // create a mode that deals with the handles
            var handleInputMode = new HandleInputMode {
                Priority = 1
            };

            // add it to the graph editor mode
            inputMode.Add(handleInputMode);

            // now the handles
            var inputModeContext = Contexts.CreateInputModeContext(handleInputMode);

            handleInputMode.Handles = new DefaultObservableCollection <IHandle> {
                rectangleHandles.GetHandle(inputModeContext, HandlePositions.NorthEast),
                rectangleHandles.GetHandle(inputModeContext, HandlePositions.NorthWest),
                rectangleHandles.GetHandle(inputModeContext, HandlePositions.SouthEast),
                rectangleHandles.GetHandle(inputModeContext, HandlePositions.SouthWest),
            };

            // create a mode that allows for dragging the rectangle at the sides
            var moveInputMode = new MoveInputMode {
                PositionHandler = new RectanglePositionHandler(clearRect),
                HitTestable     = HitTestables.Create((context, location) => clearRect.Contains(location)),
                Priority        = 41
            };

            // handle dragging the rectangle
            moveInputMode.DragStarting += OnDragStarting;
            moveInputMode.Dragged      += OnDragged;
            moveInputMode.DragCanceled += OnDragCanceled;
            moveInputMode.DragFinished += OnDragFinished;

            // handle resizing the rectangle
            handleInputMode.DragStarting += OnDragStarting;
            handleInputMode.Dragged      += OnDragged;
            handleInputMode.DragCanceled += OnDragCanceled;
            handleInputMode.DragFinished += OnDragFinished;

            // add it to the edit mode
            inputMode.Add(moveInputMode);
        }
示例#3
0
        /// <summary>
        /// Adds the view modes that handle the resizing and movement of the export rectangle.
        /// </summary>
        /// <param name="inputMode"></param>
        private void AddExportRectInputModes(MultiplexingInputMode inputMode)
        {
            // create handles for interactivel resizing the export rectangle
            var rectangleHandles = new RectangleReshapeHandleProvider(exportRect)
            {
                MinimumSize = new SizeD(1, 1)
            };

            // create a mode that deals with the handles
            var exportHandleInputMode = new HandleInputMode {
                Priority = 1
            };

            // add it to the graph editor mode
            inputMode.Add(exportHandleInputMode);

            // now the handles
            var inputModeContext = Contexts.CreateInputModeContext(exportHandleInputMode);

            exportHandleInputMode.Handles = new DefaultObservableCollection <IHandle>
            {
                rectangleHandles.GetHandle(inputModeContext, HandlePositions.NorthEast),
                rectangleHandles.GetHandle(inputModeContext, HandlePositions.NorthWest),
                rectangleHandles.GetHandle(inputModeContext, HandlePositions.SouthEast),
                rectangleHandles.GetHandle(inputModeContext, HandlePositions.SouthWest),
            };

            // create a mode that allows for dragging the export rectangle at the sides

            var moveInputMode = new MoveInputMode
            {
                PositionHandler = new ExportRectanglePositionHandler(exportRect),
                HitTestable     = HitTestables.Create(
                    (context, location) => {
                    var path = new GeneralPath(5);
                    path.AppendRectangle(exportRect, false);
                    return(path.PathContains(location, context.HitTestRadius));
                }),
                Priority = 41
            };

            // add it to the edit mode
            inputMode.Add(moveInputMode);
        }
        public BezierCreateEdgeInputMode()
        {
            CreateSmoothSplines = true;
            //By default, we can't create orthogonal edges with this mode
            //(what would that look like)
            OrthogonalEdgeCreation = OrthogonalEdgeEditingPolicy.Never;

            ValidBendHitTestable = HitTestables.Create(delegate(IInputModeContext context, PointD location) {
                if (!(DummyEdge.Style is yWorks.Graph.Styles.BezierEdgeStyle) || !CreateSmoothSplines)
                {
                    return(true);
                }
                var lastBend = DummyEdge.Bends.LastOrDefault();
                if (lastBend == null)
                {
                    return(true);
                }
                //Require a minimum length for the control point triple
                return(lastBend.GetIndex() % 3 != 1 || (location - lastBend.Location.ToPointD()).VectorLength > 10);
            });
        }
 /// <summary>
 /// Creates a new instance.
 /// </summary>
 /// <param name="window">The <see cref="CustomSnappingForm"/> the
 /// <see cref="CustomSnappingForm.AdditionalSnapLineVisualCreators"/> can be received from.</param>
 public AdditionalSnapLineMoveInputMode(CustomSnappingForm window)
 {
     this.window     = window;
     PositionHandler = null;
     HitTestable     = HitTestables.Create(IsValidHit);
 }