protected override PointD GetFactor(double x, double y, RectD originalNodeLayout, bool centered, HandlePositions position) { var xRatio = centered ? 2 * (x - OriginalBounds.CenterX) / OriginalBounds.Width : (x - OriginalBounds.X) / OriginalBounds.Width; var yRatio = centered ? 2 * (y - OriginalBounds.CenterY) / OriginalBounds.Height : (y - OriginalBounds.Y) / OriginalBounds.Height; double fx = 0; if (position.IsAnyWest()) { fx = centered ? -xRatio : 1 - xRatio; } else if (position.IsAnyEast()) { fx = xRatio; } double fy = 0; if (position.IsAnyNorth()) { fy = centered ? -yRatio : 1 - yRatio; } else if (position.IsAnySouth()) { fy = yRatio; } return(new PointD(fx, fy)); }
protected override PointD GetFactor(double x, double y, RectD originalNodeLayout, bool centered, HandlePositions position) { double fx = 0; if ((position & HandlePositions.Vertical) == 0) { var boundsWidth = (OriginalBounds.Width - originalNodeLayout.Width); if (boundsWidth <= 0) { fx = centered ? 0 : 0.5; } else { var xRatio = centered ? 2 * (originalNodeLayout.CenterX - OriginalBounds.CenterX) / boundsWidth : (originalNodeLayout.MinX - OriginalBounds.X) / boundsWidth; if (position.IsAnyWest()) { fx = centered ? -xRatio : 1 - xRatio; } else if (position.IsAnyEast()) { fx = xRatio; } } } double fy = 0; if ((position & HandlePositions.Horizontal) == 0) { var boundsHeight = (OriginalBounds.Height - originalNodeLayout.Height); if (boundsHeight <= 0) { fy = centered ? 0 : 0.5; } else { var yRatio = centered ? 2 * (originalNodeLayout.CenterY - OriginalBounds.CenterY) / boundsHeight : (originalNodeLayout.MinY - OriginalBounds.Y) / boundsHeight; if (position.IsAnyNorth()) { fy = centered ? -yRatio : 1 - yRatio; } else if (position.IsAnySouth()) { fy = yRatio; } } } return(new PointD(fx, fy)); }