本文整理汇总了C#中Panel.UpdateLayout方法的典型用法代码示例。如果您正苦于以下问题:C# Panel.UpdateLayout方法的具体用法?C# Panel.UpdateLayout怎么用?C# Panel.UpdateLayout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Panel
的用法示例。
在下文中一共展示了Panel.UpdateLayout方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WrapElement
private double WrapElement(Panel parent, ref Panel p, double offset, string text, CaptionElement element, TextAlignment align, bool directionApplied = false)
{
if (text == null || text == "") return offset;
var effectiveSize = this.GetEffectiveSize();
var style = element.CurrentStyle;
var panelSize = style.Extent.ToPixelSize(effectiveSize);
double panelWidth = panelSize.Width;
double panelHeight = panelSize.Height;
if (style.Direction == FlowDirection.RightToLeft && !directionApplied)
{
text = new string(text.ToCharArray().Reverse().ToArray());
}
double height = style.FontSize.Unit == LengthUnit.PixelProportional || style.FontSize.Unit == LengthUnit.Cell ? effectiveSize.Height : panelHeight;
TextBlock textblock = GetStyledTextblock(style, panelWidth, height, false);
SetContent(textblock, text);
Border border = new Border();
border.Background = GetCachedBrush(style.BackgroundColor);
FrameworkElement contentElement;
double outlineWidth = style.OutlineWidth.ToPixelLength(effectiveSize.Height);
if (outlineWidth > 0)
{
switch (style.TextStyle)
{
case TextStyle.Default:
contentElement = AddOutlineTextStyle(text, style, panelWidth, height, textblock, outlineWidth);
break;
case TextStyle.DepressedEdge:
contentElement = AddDepressedEdgeTextStyle(text, style, panelWidth, height, textblock, outlineWidth);
break;
case TextStyle.DropShadow:
contentElement = AddDropShadowTextStyle(text, style, panelWidth, height, textblock, outlineWidth);
break;
case TextStyle.None:
contentElement = textblock;
break;
case TextStyle.Outline:
contentElement = AddOutlineTextStyle(text, style, panelWidth, height, textblock, outlineWidth);
break;
case TextStyle.RaisedEdge:
contentElement = AddRaisedEdgeTextStyle(text, style, panelWidth, height, textblock, outlineWidth);
break;
default:
contentElement = AddOutlineTextStyle(text, style, panelWidth, height, textblock, outlineWidth);
break;
}
}
else
{
contentElement = textblock;
}
contentElement.Opacity = System.Convert.ToDouble(style.Color.A) / 255.0;
border.Opacity = System.Convert.ToDouble(style.Color.A) / 255.0;
border.Child = contentElement;
p.Children.Add(border);
string head = text;
string tail = string.Empty;
double elementWidth = textblock.GetEffectiveWidth();
if (offset + elementWidth > panelSize.Width && style.WrapOption == TextWrapping.Wrap)
{
if (text.Length > 0 && text.IndexOf(' ') < 0)
{
if (offset != 0 && elementWidth < panelSize.Width)
{
p.Children.Remove(border);
p = NewPanel(parent, ref offset, element, align);
return WrapElement(parent, ref p, 0, text, element, align, true);
}
int idx = text.Length - 1;
head = text.Substring(0, idx);
tail = text.Substring(idx);
SetAllContent(contentElement, head);
while (offset + textblock.GetEffectiveWidth() > panelSize.Width)
{
idx--;
head = text.Substring(0, idx);
tail = text.Substring(idx);
SetAllContent(contentElement, head);
p.UpdateLayout();
}
p = NewPanel(parent, ref offset, element, align);
return WrapElement(parent, ref p, offset, tail, element, align, true);
}
while (offset + textblock.GetEffectiveWidth() > panelSize.Width)
{
int idx = head.LastIndexOf(' ');
//.........这里部分代码省略.........