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


C# DrawingContext.DrawRoundedRectangle方法代码示例

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


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

示例1: OnRender

        protected override void OnRender(DrawingContext drawingContext)
        {
            var visualTargetItem = DropInfo.VisualTargetItem;
            if (visualTargetItem != null)
            {
                var rect = Rect.Empty;

                var tvItem = visualTargetItem as TreeViewItem;
                if (tvItem != null && VisualTreeHelper.GetChildrenCount(tvItem) > 0)
                {
                    var descendant = VisualTreeHelper.GetDescendantBounds(tvItem);
                    var translatePoint = tvItem.TranslatePoint(new Point(), AdornedElement);
                    var itemRect = new Rect(translatePoint, tvItem.RenderSize);
                    descendant.Union(itemRect);
                    rect = new Rect(translatePoint, new Size(descendant.Width - translatePoint.X, tvItem.ActualHeight));
                }
                if (rect.IsEmpty)
                {
                    rect = new Rect(visualTargetItem.TranslatePoint(new Point(), AdornedElement),
                        VisualTreeHelper.GetDescendantBounds(visualTargetItem).Size);
                }
                var color = (Color) ThemeManager.DetectAppStyle(Application.Current).Item2.Resources["AccentColor"];
                drawingContext.DrawRoundedRectangle(null, new Pen(new SolidColorBrush(color), 2), rect, 2, 2);
            }
        }
开发者ID:SpoinkyNL,项目名称:Artemis,代码行数:25,代码来源:DropTargetMetroHighlightAdorner.cs

示例2: DrawBackground

        private void DrawBackground( DrawingContext ctx )
        {
            var pen = new Pen( Brushes.Black, 1 );
            var rect = new Rect( 0, 0, m_layers.ActualWidth, m_layers.ActualHeight );
            ctx.DrawRoundedRectangle( Brushes.Black, pen, rect, 50, 50 );

            Log( "background" );
        }
开发者ID:andrevdm,项目名称:WpfLayeredDrawingDemo,代码行数:8,代码来源:MainWindow.xaml.cs

示例3: DrawBackgroundBlock

        private void DrawBackgroundBlock( DrawingContext ctx )
        {
            var pen = new Pen( Brushes.DarkOliveGreen, 1 );
            var rect = new Rect( 20, 60, 200, 50 );
            ctx.DrawRoundedRectangle( Brushes.DarkOliveGreen, pen, rect, 50, 50 );

            Log( "background block" );
        }
开发者ID:andrevdm,项目名称:WpfLayeredDrawingDemo,代码行数:8,代码来源:MainWindow.xaml.cs

示例4: OnRender

        protected override void OnRender(DrawingContext drawingContext)
        {
            Rect adornedElementRect = new Rect(this.AdornedElement.DesiredSize);

            drawingContext.DrawRectangle(null, _borderPen, adornedElementRect);
            drawingContext.DrawRoundedRectangle(Brushes.White, _borderPen,
                    new Rect(adornedElementRect.X + (adornedElementRect.Width / 2d) - 7d, adornedElementRect.Y + (adornedElementRect.Height / 2d) - 7d, 14d, 14d), 2d, 2d);
            _textFormat.RenderText(drawingContext, Brushes.Black, _label, adornedElementRect);
        }
开发者ID:Heliflyer,项目名称:helios,代码行数:9,代码来源:MonitorAdorner.cs

示例5: OnRender

 protected override void OnRender(DrawingContext drawingContext, double scaleX, double scaleY)
 {
     if (_image != null)
     {
         ImageDecoration profileImage = Visual as ImageDecoration;
         Rect scaledRect = new Rect(_imageRect.X, _imageRect.Y, _imageRect.Width * scaleX, _imageRect.Height * scaleY);
         drawingContext.DrawRoundedRectangle(_imageBrush, _borderPen, scaledRect, profileImage.CornerRadius, profileImage.CornerRadius);
     }            
 }
开发者ID:Heliflyer,项目名称:helios,代码行数:9,代码来源:ImageDecorationRenderer.cs

示例6: OnRender

 protected override void OnRender(DrawingContext dc)
 {
     RadialGradientBrush brush = new RadialGradientBrush(
         IsPressed ? SystemColors.ControlDarkColor : SystemColors.ControlLightLightColor,
         SystemColors.ControlColor);
     brush.GradientOrigin = IsPressed ? new Point(0.75, 0.75) : new Point(0.25, 0.25);
     dc.DrawRoundedRectangle(brush, new Pen(SystemColors.ControlDarkDarkBrush, 1),
         new Rect(new Point(0, 0), RenderSize), RenderSize.Height/2, RenderSize.Height/2);
 }
开发者ID:JianchengZh,项目名称:kasicass,代码行数:9,代码来源:RoundedButtonDecorator.cs

示例7: OnRender

 /// <summary>
 /// Render.
 /// </summary>
 /// <param name="drawingContext"></param>
 protected override void OnRender(DrawingContext drawingContext)
 {
     if (DropInfo.VisualTargetItem != null)
     {
         Rect rect = new Rect(
             DropInfo.VisualTargetItem.TranslatePoint(new Point(), AdornedElement),
             VisualTreeHelper.GetDescendantBounds(DropInfo.VisualTargetItem).Size);
         drawingContext.DrawRoundedRectangle(null, new Pen(Brushes.Gray, 2), rect, 2, 2);
     }
 }
开发者ID:apoorv-vijay-joshi,项目名称:FSE-2011-PDE,代码行数:14,代码来源:DropTargetHighlightAdorner.cs

示例8: OnRender

    protected override void OnRender(DrawingContext drawingContext)
    {
      if (DropInfo.VisualTargetItem == null)
        return;

      var location = DropInfo.VisualTargetItem.TranslatePoint(new Point(), AdornedElement);
      var size = VisualTreeHelper.GetDescendantBounds(DropInfo.VisualTargetItem).Size;

      var rect = new Rect(location, size);
      drawingContext.DrawRoundedRectangle(null, new Pen(Brushes.Gray, 2), rect, 2, 2);
    }
开发者ID:modulexcite,项目名称:LoreSoft.Shared,代码行数:11,代码来源:DropTargetHighlightAdorner.cs

示例9: ApplyFilter

        protected override void ApplyFilter(FastBitmap source, DrawingContext dc, int width, int height)
        {
            // Draw image.
            dc.PushTransform(new TranslateTransform(BorderWidth, BorderWidth));
            dc.DrawImage(source.InnerBitmap, new Rect(0, 0, source.Width, source.Height));
            dc.Pop();

            // Draw border.
            dc.DrawRoundedRectangle(null, new Pen(new SolidColorBrush(BorderColor), BorderWidth),
                new Rect(BorderWidth / 2.0, BorderWidth / 2.0, width - BorderWidth, height - BorderWidth),
                Roundness, Roundness);
        }
开发者ID:sitdap,项目名称:dynamic-image,代码行数:12,代码来源:RoundCornersFilter.cs

示例10: OnRender

        protected override void OnRender(DrawingContext dc)
        {
            var offX = 0;
            var offY = 0;
            var width = ActualWidth;
            var height = ActualHeight;

            var brush = BorderBackground;
            var pen = new Pen(brush, 1);
            pen.Freeze();
            var rect = new Rect(offX, offY, width, height);

            dc.DrawRoundedRectangle(brush, pen, rect, CornerRadius, CornerRadius);
            base.OnRender(dc);
        }
开发者ID:EmptyBucket,项目名称:DungeonCrawlBot,代码行数:15,代码来源:BorderGrid.cs

示例11: OnRender

        protected override void OnRender(DrawingContext drawingContext)
        {
            var visualTargetItem = this.DropInfo.VisualTargetItem;
              if (visualTargetItem != null) {
            var rect = Rect.Empty;

            var tvItem = visualTargetItem as TreeViewItem;
            if (tvItem != null && VisualTreeHelper.GetChildrenCount(tvItem) > 0) {
              var descendant = VisualTreeHelper.GetDescendantBounds(tvItem);
              rect = new Rect(tvItem.TranslatePoint(new Point(), this.AdornedElement), new Size(descendant.Width + 4, tvItem.ActualHeight));
            }
            if (rect.IsEmpty) {
              rect = new Rect(visualTargetItem.TranslatePoint(new Point(), this.AdornedElement), VisualTreeHelper.GetDescendantBounds(visualTargetItem).Size);
            }
            drawingContext.DrawRoundedRectangle(null, new Pen(Brushes.Gray, 2), rect, 2, 2);
              }
        }
开发者ID:Gwynneth,项目名称:gong-wpf-dragdrop,代码行数:17,代码来源:DropTargetHighlightAdorner.cs

示例12: Draw

 public void Draw(TextView textView, DrawingContext drawingContext)
 {
     textView.EnsureVisualLines();
     if (_line.IsDeleted) return;
     var segment = new TextSegment
     {
         StartOffset = _line.Offset,
         EndOffset = _line.EndOffset
     };
     // ReSharper disable once RedundantArgumentDefaultValue
     foreach (var current in BackgroundGeometryBuilder.GetRectsForSegment(textView, segment, false))
     {
         drawingContext.DrawRoundedRectangle(new SolidColorBrush(EditorOptions.Instance.HighlightedLineColor),
             new Pen(Brushes.Red, 0.0),
             new Rect(current.Location, new Size(textView.ActualWidth, current.Height)), 3.0, 3.0);
     }
 }
开发者ID:mookiejones,项目名称:miEditor,代码行数:17,代码来源:BackgroundRenderer.cs

示例13: Draw

        public void Draw(TextView textView, DrawingContext ctx)
        {
            if (line == null)
                return;

            foreach(var color in colors)
            {
                var from = GetPositionFromOffset(tab.Editor, VisualYPosition.LineTop, line.Offset + color.Match.Index);
                var to = GetPositionFromOffset(tab.Editor, VisualYPosition.LineTop, line.Offset + color.Match.Index + color.Match.Length);

                var x = from.X - tab.Editor.TextArea.TextView.ScrollOffset.X - 3;
                var y = from.Y - 18 - tab.Editor.TextArea.TextView.ScrollOffset.Y;
                var width = to.X - from.X + 12;
                var height = 16;

                ctx.DrawRoundedRectangle(new SolidColorBrush(color.Color), new Pen(), new Rect(x, y, width, height), 3, 3);
            }
        }
开发者ID:anaimi,项目名称:farawla,代码行数:18,代码来源:ColorPreviewRenderer.cs

示例14: Draw

        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            textView.EnsureVisualLines();

            #region Highlight Current Line

            if(lastLine != _editor.TextArea.Caret.Line) {
                var line = _editor.Document.GetLineByOffset(_editor.CaretOffset);
                var segment = new TextSegment { StartOffset = line.Offset, EndOffset = line.EndOffset };
                foreach(Rect r in BackgroundGeometryBuilder.GetRectsForSegment(textView, segment)) {
                    drawingContext.DrawRoundedRectangle(_lineSelection, _borderPen, new Rect(r.Location, new Size(textView.ActualWidth, r.Height)), 3, 3);
                }
            }

            #endregion

            #region Highlight Brackets

            if(_editor.TextArea.Caret.Offset > 1 && TokenHelper.BRAKETS.ContainsKey(_editor.TextArea.Document.GetCharAt(_editor.TextArea.Caret.Offset - 1))) {
                var offset = _editor.TextArea.Caret.Offset;
                var seg = _projectitem.SegmentService.QueryCodeSegmentAt(offset);
                if(seg != null && TokenHelper.BRAKETS.ContainsValue(seg.Token)) {
                    var other = seg.FindOtherBracked(true);

                    var col = other != null ? _braketMatch : _braketMatchFail;
                    var braketsegment = new TextSegment { StartOffset = seg.Range.Offset, EndOffset = seg.Range.EndOffset };
                    foreach(Rect r in BackgroundGeometryBuilder.GetRectsForSegment(textView, braketsegment)) {
                        drawingContext.DrawRectangle(col, _borderPen, r);
                    }

                    if(other != null) {
                        braketsegment = new TextSegment { StartOffset = other.Range.Offset, EndOffset = other.Range.EndOffset };
                        foreach(Rect r in BackgroundGeometryBuilder.GetRectsForSegment(textView, braketsegment)) {
                            drawingContext.DrawRectangle(_braketMatch, _borderPen, r);
                        }
                    }
                }
            }

            #endregion
        }
开发者ID:RaptorOne,项目名称:SmartDevelop,代码行数:41,代码来源:CurrentLineHighlightRenderer.cs

示例15: OnRender

        protected override void OnRender(DrawingContext drawingContext)
        {
            Rect adornedElementRect = new Rect(this.AdornedElement.RenderSize);
            
            //Point relativePoint = this.AdornedElement.TransformToAncestor(Application.Current.MainWindow).Transform(new Point(0, 0));
            adornedElementRect.Location = new Point(adornedElementRect.Location.X, adornedElementRect.Location.Y + adornedElementRect.Height + 10);            

            // Some arbitrary drawing implements.
            SolidColorBrush renderBrush = new SolidColorBrush(Color.FromRgb(0, 107,194));            
            Pen renderPen = new Pen(new SolidColorBrush(Colors.Navy), 1.5);                    
            
            drawingContext.DrawRoundedRectangle(renderBrush, null, adornedElementRect, 0.0, 0.0);

            

            //drawingContext.DrawImage()
            //drawingContext.DrawGeometry()
            var text = new FormattedText("Navigate between Triggers, Logs and the home screen.", CultureInfo.InvariantCulture, System.Windows.FlowDirection.LeftToRight, new Typeface("Segoe UI"), 16, Brushes.White);
            drawingContext.DrawText(text, new Point(adornedElementRect.Location.X, adornedElementRect.Location.Y));


        }
开发者ID:Woriworiwa,项目名称:MahApps.Metro,代码行数:22,代码来源:Bubble.cs


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