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


C# Border.SetValue方法代码示例

本文整理汇总了C#中Border.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# Border.SetValue方法的具体用法?C# Border.SetValue怎么用?C# Border.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Border的用法示例。


在下文中一共展示了Border.SetValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RenderLabel

        public static UIElement RenderLabel(Geometries.Point position, LabelStyle labelStyle, IViewport viewport, string labelText)
        {
            var screenPosition = viewport.WorldToScreen(position);
            var windowsPosition = screenPosition.ToXaml();

            //set some defaults which should be configurable someday
            const double witdhMargin = 3.0;
            const double heightMargin = 0.0;

            var textblock = new TextBlock
            {
                Text = labelText,
                Foreground = new SolidColorBrush(labelStyle.ForeColor.ToXaml()),

                FontFamily = new FontFamily(labelStyle.Font.FontFamily),
                FontSize = labelStyle.Font.Size,
                Margin = new Thickness(witdhMargin, heightMargin, witdhMargin, heightMargin),
                FontWeight = FontWeights.Bold
            };

            var border = new Border
                {
                    Background = new SolidColorBrush(labelStyle.BackColor == null ? Colors.Transparent : labelStyle.BackColor.Color.ToXaml()),
                    CornerRadius = new CornerRadius(4),
                    Child = textblock
                };

            double textWidth;
            double textHeight;

#if NETFX_CORE
            DetermineTextWidthAndHeightWindows8(out textWidth, out textHeight, border, textblock);
#elif SILVERLIGHT
            DetermineTextWidthAndHeightSilverlight(out textWidth, out textHeight, textblock);
#else // WPF
            DetermineTextWidthAndHeightWpf(out textWidth, out textHeight, labelStyle, labelText);
#endif
            border.SetValue(Canvas.LeftProperty, windowsPosition.X + labelStyle.Offset.X
                - (textWidth + 2 * witdhMargin) * (short)labelStyle.HorizontalAlignment * 0.5f);
            border.SetValue(Canvas.TopProperty, windowsPosition.Y + labelStyle.Offset.Y
                - (textHeight + 2 * heightMargin) * (short)labelStyle.VerticalAlignment * 0.5f);

            return border;
        }
开发者ID:jdeksup,项目名称:Mapsui.Net4,代码行数:44,代码来源:SingleLabelRenderer.cs

示例2: InitializeBusyIndicator

        partial void InitializeBusyIndicator()
        {
            if (_busyIndicator != null)
            {
                return;
            }

            _grid = new Grid();
            _grid.RowDefinitions.Add(new RowDefinition {Height = new GridLength(1, GridUnitType.Star)});
            _grid.RowDefinitions.Add(new RowDefinition {Height = new GridLength(1, GridUnitType.Auto)});
            _grid.RowDefinitions.Add(new RowDefinition {Height = new GridLength(1, GridUnitType.Auto)});
            _grid.RowDefinitions.Add(new RowDefinition {Height = new GridLength(1, GridUnitType.Star)});

            var backgroundBorder = new Border();
            backgroundBorder.Background = new SolidColorBrush(Colors.Gray);
            backgroundBorder.Opacity = 0.5;
            backgroundBorder.SetValue(Grid.RowSpanProperty, 4);
            _grid.Children.Add(backgroundBorder);

            _statusTextBlock = new TextBlock();
            //_statusTextBlock.Style = (Style)Application.Current.Resources["PhoneTextNormalStyle"];
            _statusTextBlock.HorizontalAlignment = HorizontalAlignment.Center;
            _statusTextBlock.SetValue(Grid.RowProperty, 1);
            _grid.Children.Add(_statusTextBlock);

            _busyIndicator = ConstructorBusyIndicator();
            _busyIndicator.SetValue(Grid.RowProperty, 2);
            _grid.Children.Add(_busyIndicator);

            _containerPopup = new Popup();
            _containerPopup.VerticalAlignment = VerticalAlignment.Center;
            _containerPopup.HorizontalAlignment = HorizontalAlignment.Center;
            _containerPopup.Child = _grid;

            double rootWidth = Window.Current.Bounds.Width;
            double rootHeight = Window.Current.Bounds.Height;

            _busyIndicator.Width = rootWidth;

            _grid.Width = rootWidth;
            _grid.Height = rootHeight;

            _containerPopup.UpdateLayout();
        }
开发者ID:matthijskoopman,项目名称:Catel,代码行数:44,代码来源:PleaseWaitService.winrt.cs

示例3: RenderLabel

        public static UIElement RenderLabel(Mapsui.Geometries.Point point, Offset stackOffset, LabelStyle style, IViewport viewport, string text)
        {
            Mapsui.Geometries.Point p = viewport.WorldToScreen(point);
            var windowsPoint = new WinPoint(p.X, p.Y);

            var border = new Border();
            var textblock = new TextBlock();

            //Text
            textblock.Text = text;

            //Colors
            textblock.Foreground = new SolidColorBrush(style.ForeColor.ToXaml());
            border.Background = new SolidColorBrush(style.BackColor.Color.ToXaml());

            //Font
            textblock.FontFamily = new FontFamily(style.Font.FontFamily);
            textblock.FontSize = style.Font.Size;

            //set some defaults which should be configurable someday
            const double witdhMargin = 3.0;
            const double heightMargin = 0.0;
            textblock.Margin = new Thickness(witdhMargin, heightMargin, witdhMargin, heightMargin);
            border.CornerRadius = new CornerRadius(4);
            border.Child = textblock;
            //Offset

            var textWidth = textblock.ActualWidth;
            var textHeight = textblock.ActualHeight;
#if !SILVERLIGHT && !NETFX_CORE
            // in WPF the width and height is not calculated at this point. So we use FormattedText
            getTextWidthAndHeight(ref textWidth, ref textHeight, style, text);
#endif
            border.SetValue(Canvas.LeftProperty, windowsPoint.X + style.Offset.X + stackOffset.X - (textWidth + 2 * witdhMargin) * (short)style.HorizontalAlignment * 0.5f);
            border.SetValue(Canvas.TopProperty, windowsPoint.Y + style.Offset.Y + stackOffset.Y - (textHeight + 2 * heightMargin) * (short)style.VerticalAlignment * 0.5f);
                
            return border;
        }
开发者ID:HackatonArGP,项目名称:Guardianes,代码行数:38,代码来源:LabelRenderer.cs


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