private void GetNewOverflow4TopCustomLabels(CustomAxisLabels customLabels, Double leftOverflow, Double rightOverflow, ref Double newLeftOverflow, ref Double newRightOverflow, Double visualHeight) { if ((Double)customLabels.InternalAngle > 0) { Double maxXPos = customLabels.AxisLabelList[0].Position.X; Point firstLabelPosition = new Point(customLabels.AxisLabelList[0].Position.X, customLabels.AxisLabelList[0].Position.Y); Point actualLeftPosition = new Point(customLabels.AxisLabelList[0].ActualLeft - customLabels.AxisLabelList[0].ActualWidth, customLabels.AxisLabelList[0].ActualTop); Point leftOffsetPosition = new Point(actualLeftPosition.X, firstLabelPosition.Y); Double height = Graphics.DistanceBetweenTwoPoints(leftOffsetPosition, actualLeftPosition); Double labelBase = Graphics.DistanceBetweenTwoPoints(leftOffsetPosition, firstLabelPosition); Double theta = Math.Atan(height / labelBase); if (height > visualHeight) height = visualHeight; leftOverflow = (height / Math.Tan(theta)); leftOverflow = leftOverflow - maxXPos; newLeftOverflow = leftOverflow; customLabels.LeftOverflow = newLeftOverflow; } else if ((Double)AxisLabels.InternalAngle < 0) { Double maxXPos = customLabels.AxisLabelList[customLabels.AxisLabelList.Count - 1].Position.X; Point lastLabelPosition = new Point(customLabels.AxisLabelList[customLabels.AxisLabelList.Count - 1].Position.X, customLabels.AxisLabelList[customLabels.AxisLabelList.Count - 1].Position.Y); Point actualRightPosition = new Point(customLabels.AxisLabelList[customLabels.AxisLabelList.Count - 1].ActualLeft + customLabels.AxisLabelList[customLabels.AxisLabelList.Count - 1].ActualWidth, customLabels.AxisLabelList[customLabels.AxisLabelList.Count - 1].ActualHeight); Point rightOffsetPosition = new Point(actualRightPosition.X, lastLabelPosition.Y); Double height = Graphics.DistanceBetweenTwoPoints(rightOffsetPosition, actualRightPosition); Double labelBase = Graphics.DistanceBetweenTwoPoints(rightOffsetPosition, lastLabelPosition); Double theta = Math.Atan(height / labelBase); if (height > visualHeight) height = visualHeight; rightOverflow = (height / Math.Tan(theta)); rightOverflow = rightOverflow + maxXPos; rightOverflow = rightOverflow - Width; newRightOverflow = rightOverflow; customLabels.RightOverflow = newRightOverflow; } }
private void GetNewOverflow4RightCustomLabels(CustomAxisLabels customLabels, Double topOverflow, Double bottomOverflow, ref Double newTopOverflow, ref Double newBottomOverflow, Double visualWidth) { if ((Double)customLabels.InternalAngle < 0) { Double maxYPos = customLabels.AxisLabelList[customLabels.AxisLabelList.Count - 1].Position.Y; Point lastLabelPosition = new Point(customLabels.AxisLabelList[customLabels.AxisLabelList.Count - 1].Position.X, customLabels.AxisLabelList[customLabels.AxisLabelList.Count - 1].Position.Y); Point actualTopPosition = new Point(customLabels.AxisLabelList[customLabels.AxisLabelList.Count - 1].ActualLeft - customLabels.AxisLabelList[customLabels.AxisLabelList.Count - 1].ActualWidth, customLabels.AxisLabelList[customLabels.AxisLabelList.Count - 1].ActualTop); Point topOffsetPosition = new Point(lastLabelPosition.X, actualTopPosition.Y); Double width = Graphics.DistanceBetweenTwoPoints(topOffsetPosition, actualTopPosition); Double labelBase = Graphics.DistanceBetweenTwoPoints(topOffsetPosition, lastLabelPosition); Double theta = Math.Atan(width / labelBase); if (width > visualWidth) width = visualWidth; topOverflow = (width / Math.Tan(theta)); topOverflow = topOverflow - maxYPos; newTopOverflow = topOverflow; customLabels.TopOverflow = newTopOverflow; } else if ((Double)customLabels.InternalAngle > 0) { Double maxYPos = customLabels.AxisLabelList[0].Position.Y; Point firstLabelPosition = new Point(customLabels.AxisLabelList[0].Position.X, customLabels.AxisLabelList[0].Position.Y); Point actualBottomPosition = new Point(customLabels.AxisLabelList[0].ActualLeft, customLabels.AxisLabelList[0].ActualTop + customLabels.AxisLabelList[0].ActualHeight); Point bottomOffsetPosition = new Point(firstLabelPosition.X, actualBottomPosition.Y); Double width = Graphics.DistanceBetweenTwoPoints(bottomOffsetPosition, actualBottomPosition); Double labelBase = Graphics.DistanceBetweenTwoPoints(bottomOffsetPosition, firstLabelPosition); Double theta = Math.Atan(width / labelBase); if (width > visualWidth) width = visualWidth; bottomOverflow = (width / Math.Tan(theta)); bottomOverflow = bottomOverflow + maxYPos; newBottomOverflow = bottomOverflow - Height; customLabels.BottomOverflow = newBottomOverflow; } }