本文整理汇总了C#中System.Windows.Forms.ToolStripItem.ContentRectangle属性的典型用法代码示例。如果您正苦于以下问题:C# ToolStripItem.ContentRectangle属性的具体用法?C# ToolStripItem.ContentRectangle怎么用?C# ToolStripItem.ContentRectangle使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Windows.Forms.ToolStripItem
的用法示例。
在下文中一共展示了ToolStripItem.ContentRectangle属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ComputeImageAndTextLayout
// This utility method computes the layout of the
// RolloverItem control's image area and the text area.
// For brevity, only the following settings are
// supported:
//
// ToolStripTextDirection.Horizontal
// TextImageRelation.ImageBeforeText
// TextImageRelation.ImageBeforeText
//
// It would not be difficult to support vertical text
// directions and other image/text relationships.
private void ComputeImageAndTextLayout()
{
Rectangle cr = base.ContentRectangle;
Image img = base.Owner.ImageList.Images[base.ImageKey];
// Compute the center of the item's ContentRectangle.
int centerY = (cr.Height - img.Height) / 2;
// Find the dimensions of the image and the text
// areas of the item. The text occupies the space
// not filled by the image.
if (base.TextImageRelation == TextImageRelation.ImageBeforeText &&
base.TextDirection == ToolStripTextDirection.Horizontal)
{
imageRect = new Rectangle(
base.ContentRectangle.Left,
centerY,
base.Image.Width,
base.Image.Height);
textRect = new Rectangle(
imageRect.Width,
base.ContentRectangle.Top,
base.ContentRectangle.Width - imageRect.Width,
base.ContentRectangle.Height);
}
else if (base.TextImageRelation == TextImageRelation.TextBeforeImage &&
base.TextDirection == ToolStripTextDirection.Horizontal)
{
imageRect = new Rectangle(
base.ContentRectangle.Right - base.Image.Width,
centerY,
base.Image.Width,
base.Image.Height);
textRect = new Rectangle(
base.ContentRectangle.Left,
base.ContentRectangle.Top,
imageRect.X,
base.ContentRectangle.Bottom);
}
}