当前位置: 首页>>代码示例>>C#>>正文


C# Panel.UpdateLayout方法代码示例

本文整理汇总了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(' ');
//.........这里部分代码省略.........
开发者ID:bondarenkod,项目名称:pf-arm-deploy-error,代码行数:101,代码来源:CaptionBlockRegion.cs


注:本文中的Panel.UpdateLayout方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。