0

嗨,我想将我的图表分成四个部分。我如何定义其他 3 个边界。

Rect b = activeDiagram.Panel.DiagramBounds; // b = (-370, -190, 3099, 2450)
Rect bounds1 = new Rect((new System.Windows.Point(b.X,b.Y)), (new System.Windows.Point( (w/2) + b.X, (h/2) + b.Y ))); // bounds1 = (-370, -190, 1549.5, 1225)
4

1 回答 1

2

考虑到您想从图表边界中获得 4 个相等的矩形,w并且h在您的示例中是宽度和高度,您可以使用以下代码:

Rect bounds1 = new Rect(b.X, b.Y, w/2, h/2); //top left corner
Rect bounds2 = new Rect(b.X, b.Y + h/2, w/2, h/2); //bottom left corner
Rect bounds3 = new Rect(b.X + w/2, b.Y, w/2, h/2); //top right corner 
Rect bounds4 = new Rect(b.X + w/2, b.Y h/2, w/2, h/2); //bottom right corner
于 2012-09-06T13:24:44.560 回答