public void ReshapeFinished(IInputModeContext context, RectD originalBounds, RectD newBounds) { shadowObject.Remove(); simulationRectangle = null; originalHandler.HandleReshape(context, this.originalBounds, newBounds); originalHandler.ReshapeFinished(context, this.originalBounds, newBounds); }
/// <summary> /// Updates the node according to the moving handle. /// </summary> public void HandleMove(IInputModeContext context, PointD originalLocation, PointD newLocation) { // calculate the angle var vector = (newLocation - rotationCenter).Normalized; var angle = CalculateAngle(vector); if (ShouldSnap(context)) { angle = SnapAngle(context, angle); } SetAngle(context, angle); var portContext = new DelegatingContext(context); foreach (var portHandle in portHandles) { portHandle.HandleMove(portContext, originalLocation, newLocation); } if (reshapeHandler != null) { reshapeHandler.HandleReshape(context, node.Layout.ToRectD(), node.Layout.ToRectD()); } }
/// <summary> /// Adjusts the node location and size according to the new handle location. /// </summary> public void HandleMove(IInputModeContext inputModeContext, PointD originalLocation, PointD newLocation) { // calculate how much the handle was moved var upNormal = new PointD(-initialLayout.UpY, initialLayout.UpX); var deltaW = GetWidthDelta(originalLocation, newLocation, upNormal); var up = initialLayout.GetUp(); var deltaH = GetHeightDelta(originalLocation, newLocation, up); // add one or two times delta to the width to expand the node right and left dummySize = new SizeD( initialLayout.Width + deltaW * (symmetricResize ? 2 : 1), initialLayout.Height + deltaH * (symmetricResize ? 2 : 1)); // Calculate the new location. // Depending on our handle position, a different corner of the node should stay fixed. if (symmetricResize) { var dx = upNormal.X * deltaW + up.X * deltaH; var dy = upNormal.Y * deltaW + up.Y * deltaH; dummyLocation = initialLayout.GetAnchorLocation() - new PointD(dx, dy); } else { var w = dummySize.Width - initialLayout.Width; var h = dummySize.Height - initialLayout.Height; switch (position) { case HandlePositions.NorthWest: dummyLocation = initialLayout.GetAnchorLocation() - new PointD(-up.Y * w, up.X * w); break; case HandlePositions.South: case HandlePositions.SouthWest: case HandlePositions.West: dummyLocation = initialLayout.GetAnchorLocation() - new PointD(up.X * h - up.Y * w, up.Y * h + up.X * w); break; case HandlePositions.SouthEast: dummyLocation = initialLayout.GetAnchorLocation() - new PointD(up.X * h, up.Y * h); break; // case HandlePositions.North: // case HandlePositions.NorthEast: // case HandlePositions.East: default: dummyLocation = initialLayout.GetAnchorLocation(); break; } } var newLayout = SetNodeLocationAndSize(inputModeContext, dummyLocation, dummySize); var portContext = new DelegatingContext(inputModeContext); foreach (var portHandle in portHandles) { portHandle.HandleMove(portContext, dummyLocation, newLocation); } if (reshapeHandler != null) { // if there is a reshape handler: // ensure proper handling of a parent group node reshapeHandler.HandleReshape(inputModeContext, initialRect, newLayout); } }
/// <summary> /// The node is resized. /// </summary> public void HandleReshape(IInputModeContext context, RectD originalBounds, RectD newBounds) { handler.HandleReshape(context, originalBounds, newBounds); layoutHelper.RunLayout(); }