本文整理汇总了C#中DevComponents.DotNetBar.ButtonItem.SetDisplayRectangle方法的典型用法代码示例。如果您正苦于以下问题:C# ButtonItem.SetDisplayRectangle方法的具体用法?C# ButtonItem.SetDisplayRectangle怎么用?C# ButtonItem.SetDisplayRectangle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DevComponents.DotNetBar.ButtonItem
的用法示例。
在下文中一共展示了ButtonItem.SetDisplayRectangle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LayoutButton
public static void LayoutButton(ButtonItem button, bool startButtonType)
{
Control objCtrl = button.ContainerControl as Control;
if (objCtrl == null || objCtrl.Disposing || objCtrl.IsDisposed) //if(!BarFunctions.IsHandleValid(objCtrl))
return;
if (objCtrl is ButtonX && button._FitContainer)
{
LayoutButtonX(button);
return;
}
else if (button.FixedSize.Width > 0 && button.FixedSize.Height > 0)
{
button.SetDisplayRectangle(new Rectangle(button.DisplayRectangle.Location, button.FixedSize));
LayoutButtonX(button);
return;
}
bool isOnMenu = button.IsOnMenu;
if (isOnMenu && button.Parent is ItemContainer)
isOnMenu = false;
bool bHasImage = false;
bool isSymbolImage = false;
if (!string.IsNullOrEmpty(button.Symbol))
{
bHasImage = true;
isSymbolImage = true;
}
else
{
using (CompositeImage buttonImage = button.GetImage())
{
if (buttonImage != null || startButtonType)
bHasImage = true;
}
}
eImagePosition imagePosition = button.ImagePosition;
bool rightToLeft = (objCtrl.RightToLeft == RightToLeft.Yes);
Rectangle textDrawRect = Rectangle.Empty;
Rectangle imageDrawRect = Rectangle.Empty;
Rectangle subItemsRect = Rectangle.Empty;
Rectangle bounds = new Rectangle(button.DisplayRectangle.Location, Size.Empty); // Critical to preserve the location for compatibility reasons
if (rightToLeft && button.Orientation == eOrientation.Horizontal)
{
if (imagePosition == eImagePosition.Left)
imagePosition = eImagePosition.Right;
else if (imagePosition == eImagePosition.Right)
imagePosition = eImagePosition.Left;
}
int measureStringWidth = 0;
if (button._FitContainer)
measureStringWidth = button.DisplayRectangle.Width - 4;
bounds.Width = 0;
bounds.Height = 0;
Graphics g = BarFunctions.CreateGraphics(objCtrl);
try
{
eTextFormat stringFormat = GetTextFormat(button);
// Get the right image size that we will use for calculation
Size imageSize = Size.Empty;
if (isSymbolImage)
{
Font symFont = Symbols.GetFontAwesome(button.SymbolSize);
if(button.IsOnMenu) // Need to do this to get consistent size for the symbol since they are not all the same width we pick widest
imageSize = TextDrawing.MeasureString(g, "\uF00A", symFont);
else
imageSize = TextDrawing.MeasureString(g, button.Symbol, symFont);
int descent = (int)Math.Ceiling((symFont.FontFamily.GetCellDescent(symFont.Style) *
symFont.Size / symFont.FontFamily.GetEmHeight(symFont.Style)));
imageSize.Height -= descent;
button.ImageSize = imageSize;
}
else
{
imageSize = GetLayoutImageSize(button, bHasImage, isOnMenu, startButtonType);
}
bool ribbonBarButton = false;
if (button._FitContainer && bHasImage && (imagePosition == eImagePosition.Left || imagePosition == eImagePosition.Right))
{
measureStringWidth -= (imageSize.Width + 10);
}
else if (button.RibbonWordWrap && bHasImage && imagePosition == eImagePosition.Top && objCtrl is RibbonBar && UseRibbonWordBreak(button))
{
measureStringWidth = imageSize.Width + 4;
stringFormat |= eTextFormat.WordBreak;
ribbonBarButton = true;
}
// Measure string
Font font = button.GetFont(null, true);
//.........这里部分代码省略.........