/// <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); }
/// <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); }