本文整理匯總了C#中System.Drawing.Size.ConstrainedTo方法的典型用法代碼示例。如果您正苦於以下問題:C# Size.ConstrainedTo方法的具體用法?C# Size.ConstrainedTo怎麽用?C# Size.ConstrainedTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Drawing.Size
的用法示例。
在下文中一共展示了Size.ConstrainedTo方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GetSplitModeImageRectangles
/// <summary>
/// Retrieves the rectangles in which images should be placed in side-by-side mode
/// </summary>
public static void GetSplitModeImageRectangles(Rectangle clientRectangle, Size maxImageSize, out Rectangle rectangle1, out Rectangle rectangle2)
{
var halfRectangle = new Rectangle(clientRectangle.X, clientRectangle.Y, clientRectangle.Width / 2, clientRectangle.Height);
var imageSize = maxImageSize.ConstrainedTo(halfRectangle.Size);
var center1 = halfRectangle.Center();
var center2 = new Point(center1.X + halfRectangle.Width, center1.Y);
rectangle1 = new Rectangle(imageSize.CenteredAround(center1), imageSize);
rectangle2 = new Rectangle(imageSize.CenteredAround(center2), imageSize);
if (rectangle1.X - clientRectangle.X > MIN_BORDER)
{
int shift = rectangle1.X - clientRectangle.X - MIN_BORDER;
rectangle1.X -= shift;
rectangle2.X += shift;
}
}