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


C# Geometry.GetRenderBounds方法代码示例

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


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

示例1: PostInfoDisplay

        public PostInfoDisplay(double textRightEdge,
            double viewRightEdge,
            Geometry newTextGeometry,
            string body)
        {
            if (brush == null)
            {
                brush = new SolidColorBrush(Color.FromArgb(0x20, 0x48, 0x3d, 0x8b));
                brush.Freeze();
                Brush penBrush = new SolidColorBrush(Colors.DarkSlateBlue);
                penBrush.Freeze();
                solidPen = new Pen(penBrush, 0.5);
                solidPen.Freeze();
                dashPen = new Pen(penBrush, 0.5);
                dashPen.DashStyle = DashStyles.Dash;
                dashPen.Freeze();
            }

            this.textGeometry = newTextGeometry;

            TextBlock tb = new TextBlock();
            tb.Text = "Blog Entry: " + body;

            const int MarginWidth = 8;
            this.postGrid = new Grid();
            this.postGrid.RowDefinitions.Add(new RowDefinition());
            this.postGrid.RowDefinitions.Add(new RowDefinition());
            ColumnDefinition cEdge = new ColumnDefinition();
            cEdge.Width = new GridLength(MarginWidth);
            ColumnDefinition cEdge2 = new ColumnDefinition();
            cEdge2.Width = new GridLength(MarginWidth);
            this.postGrid.ColumnDefinitions.Add(cEdge);
            this.postGrid.ColumnDefinitions.Add(new ColumnDefinition());
            this.postGrid.ColumnDefinitions.Add(cEdge2);

            System.Windows.Shapes.Rectangle rect = new System.Windows.Shapes.Rectangle();
            rect.RadiusX = 6;
            rect.RadiusY = 3;
            rect.Fill = brush;
            rect.Stroke = Brushes.DarkSlateBlue;

            Size inf = new Size(double.PositiveInfinity, double.PositiveInfinity);
            tb.Measure(inf);
            this.postGrid.Width = tb.DesiredSize.Width + 2 * MarginWidth;

            Grid.SetColumn(rect, 0);
            Grid.SetRow(rect, 0);
            Grid.SetRowSpan(rect, 1);
            Grid.SetColumnSpan(rect, 3);
            Grid.SetRow(tb, 0);
            Grid.SetColumn(tb, 1);
            this.postGrid.Children.Add(rect);
            this.postGrid.Children.Add(tb);

            Canvas.SetLeft(this.postGrid, Math.Max(viewRightEdge - this.postGrid.Width - 20.0, textRightEdge + 20.0));
            Canvas.SetTop(this.postGrid, textGeometry.GetRenderBounds(solidPen).Top);

            this.Children.Add(this.postGrid);
        }
开发者ID:detroitpro,项目名称:ProStudioSearch,代码行数:59,代码来源:PostInfoDisplay.cs

示例2: DrawGeometry

        public static void DrawGeometry(
            this IPixelCanvas pc,
            int x,
            int y,
            Geometry geometry, 
            Brush fillBrush, 
            Pen pen,
            BlendMode blendMode)
        {
            var size = geometry.GetRenderBounds(pen).Size;
            var width = (int)size.Width;
            var height = (int)size.Height;
            
            var bmp = 
                geometry.RenderToBitmap(
                    size,
                    new Point(),
                    size,
                    fillBrush, 
                    pen, 
                    PixelFormats.Pbgra32);

            int[] pixels;

            if (blendMode == BlendMode.Copy && width == pc.Width && height == pc.Height)
            {
                pixels = pc.GetPixels();
                bmp.CopyPixels(pixels, pc.Stride, 0);
            }
            else
            {
                var pc2 = new PixelArrayCanvas(width, height);
                pixels = pc2.GetPixels();

                bmp.CopyPixels(pixels, pc2.Stride, 0);

                pc.Blit(
                    new Rectangle(x, y, width, height),
                    pc2,
                    new Rectangle(0, 0, width, height),
                    255, 255, 255, 255, blendMode);
            }
        }
开发者ID:squaredinfinity,项目名称:Foundation,代码行数:43,代码来源:PixelCanvas.extensions.cs


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