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


C# DrawingContext.DrawRectangle方法代码示例

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


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

示例1: CreateBitmap

        public void CreateBitmap()
        {
            int width = 100;
            int height = 100;
            int dpi = 96;

            Tracing.Log(">> CreateBitmap");
            var thread = new Thread(new ThreadStart(() => 
            {
                Tracing.Log(">> CreateBitmap - Thread start; creating drawing visual");
                //Dispatcher.Invoke(new Action(() => {
                _drawingVisual = new DrawingVisual();
                _drawingContext = _drawingVisual.RenderOpen();
                //}));

                Tracing.Log(">> CreateBitmap - Drawing to context");
                _drawingContext.DrawRectangle(new SolidColorBrush(Colors.HotPink), new Pen(), new Rect(0, 0, 50, 50));
                _drawingContext.DrawRectangle(new SolidColorBrush(Colors.Blue), new Pen(), new Rect(50, 0, 50, 50));
                _drawingContext.DrawRectangle(new SolidColorBrush(Colors.Orange), new Pen(), new Rect(0, 50, 50, 50));
                _drawingContext.DrawRectangle(new SolidColorBrush(Colors.DarkRed), new Pen(), new Rect(50, 50, 50, 50));
                _drawingContext.Close();

                Tracing.Log(">> CreateBitmap - Finished drawing; creating render target bitmap");
                _bitmap = new RenderTargetBitmap(width, height, dpi, dpi, PixelFormats.Default);
                _bitmap.Render(_drawingVisual);
                Tracing.Log(">> CreateBitmap - Finished work");
                _bitmap.Freeze();
            }));
            //thread.IsBackground = true;
            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
        }
开发者ID:pascalfr,项目名称:MPfm,代码行数:32,代码来源:TestControl.cs

示例2: OnRender

		protected override void OnRender(DrawingContext drawingContext)
		{
			Size renderSize = this.RenderSize;
			TextView textView = this.TextView;
			
			if (textView != null && textView.VisualLinesValid) {
				foreach (VisualLine line in textView.VisualLines) {
					Rect rect = new Rect(0, line.VisualTop - textView.ScrollOffset.Y, 5, line.Height);
					
					LineChangeInfo info = changeWatcher.GetChange(line.FirstDocumentLine.LineNumber);
					
					switch (info.Change) {
						case ChangeType.None:
							break;
						case ChangeType.Added:
							drawingContext.DrawRectangle(Brushes.LightGreen, null, rect);
							break;
						case ChangeType.Deleted:
						case ChangeType.Modified:
							drawingContext.DrawRectangle(Brushes.LightBlue, null, rect);
							break;
						case ChangeType.Unsaved:
							drawingContext.DrawRectangle(Brushes.Yellow, null, rect);
							break;
						default:
							throw new Exception("Invalid value for ChangeType");
					}
				}
			}
		}
开发者ID:xiaochuwang,项目名称:SharpDevelop-master,代码行数:30,代码来源:ChangeMarkerMargin.cs

示例3: RenderClippedEdges

        private static void RenderClippedEdges(Skeleton skeleton, DrawingContext drawingContext)
        {
            if (skeleton.ClippedEdges.HasFlag(FrameEdges.Bottom))
            {
                drawingContext.DrawRectangle(
                    Brushes.Red,
                    null,
                    new Rect(0, RenderHeight - ClipBoundsThickness, RenderWidth, ClipBoundsThickness));
            }

            if (skeleton.ClippedEdges.HasFlag(FrameEdges.Top))
            {
                drawingContext.DrawRectangle(
                    Brushes.Red,
                    null,
                    new Rect(0, 0, RenderWidth, ClipBoundsThickness));
            }

            if (skeleton.ClippedEdges.HasFlag(FrameEdges.Left))
            {
                drawingContext.DrawRectangle(
                    Brushes.Red,
                    null,
                    new Rect(0, 0, ClipBoundsThickness, RenderHeight));
            }

            if (skeleton.ClippedEdges.HasFlag(FrameEdges.Right))
            {
                drawingContext.DrawRectangle(
                    Brushes.Red,
                    null,
                    new Rect(RenderWidth - ClipBoundsThickness, 0, ClipBoundsThickness, RenderHeight));
            }
        }
开发者ID:nathad02,项目名称:CITS3200--Group-H,代码行数:34,代码来源:MainWindow.xaml.cs

示例4: DrawChanges

		private void DrawChanges(DrawingContext drawingContext, NormalizedSnapshotSpanCollection changes, Brush brush)
		{
			if (changes.Count > 0)
			{
				double yTop = Math.Floor(_scrollBar.GetYCoordinateOfBufferPosition(changes[0].Start)) + markerStartOffset;
				double yBottom = Math.Ceiling(_scrollBar.GetYCoordinateOfBufferPosition(changes[0].End)) + markerEndOffset;

				for (int i = 1; i < changes.Count; ++i)
				{
					double y = _scrollBar.GetYCoordinateOfBufferPosition(changes[i].Start) + markerStartOffset;
					if (yBottom < y)
					{
						drawingContext.DrawRectangle(
							brush,
							null,
							new Rect(0, yTop, markerWidth, yBottom - yTop));

						yTop = y;
					}

					yBottom = Math.Ceiling(_scrollBar.GetYCoordinateOfBufferPosition(changes[i].End)) + markerEndOffset;
				}

				drawingContext.DrawRectangle(
					brush,
					null,
					new Rect(0, yTop, markerWidth, yBottom - yTop));
			}
		}
开发者ID:jburrow,项目名称:progressive-scroll,代码行数:29,代码来源:ChangeRenderer.cs

示例5: OnRender

        protected override void OnRender(DrawingContext drawingContext)
        {
            Rect rect = new Rect(startPoint, endPoint);
            rect.Offset(-0.5d, -0.5d);

            drawingContext.DrawRectangle(fill, stroke, rect);
        }
开发者ID:kinectitude,项目名称:kinectitude,代码行数:7,代码来源:PlacementAdorner.cs

示例6: DrawTile

 protected override void DrawTile(DrawingContext dc, Rect TileRect)
 {
     if (!_tileImage.IsReady)
         dc.DrawRectangle(Brushes.LemonChiffon, null, TileRect);
     else
         dc.DrawImage(_tileImage.Image, TileRect);
 }
开发者ID:NpoSaut,项目名称:netMapViewControlLib,代码行数:7,代码来源:MapImageTileElement.cs

示例7: OnRender

 protected override void OnRender(DrawingContext drawingContext)
 {
     Rect rect = new Rect(-1, -1, this.ActualWidth + 2.0, this.ActualHeight + 2.0);
     drawingContext.DrawRectangle(Background, null, rect);
     rect = new Rect(1.0, 1.0, this.ActualWidth + 2.0, this.ActualHeight + 2.0);
     drawingContext.DrawRectangle(Shadow, null, rect);
 }
开发者ID:byteit101,项目名称:ZomB-Dashboard-System,代码行数:7,代码来源:DropShadowChrome.cs

示例8: OnRender

 protected override void OnRender(DrawingContext dc)
 {
     base.OnRender(dc);
     dc.DrawRectangle(Brushes.Transparent, null, new Rect(RenderSize));
     if (this.startPoint.HasValue && this.endPoint.HasValue)
         dc.DrawRectangle(Brushes.Transparent, rubberbandPen, new Rect(this.startPoint.Value, this.endPoint.Value));
 }
开发者ID:ohzxc,项目名称:DesignerCanvasTest,代码行数:7,代码来源:RubberbandAdorner.cs

示例9: OnRender

        protected override void OnRender(DrawingContext drawingContext)
        {
            ScreenReplicator replicator = Visual as ScreenReplicator;
            if (replicator != null)
            {                
                if (replicator.IsRunning)
                {
                    if (replicator.IsReplicating)
                    {
                        _screenBrush = CreateImageBrush(replicator);
                    }
                    else if (replicator.BlankOnStop)
                    {
                        _screenBrush = null;
                    }

                    if (_screenBrush != null)
                    {
                        drawingContext.DrawRectangle(_screenBrush, null, _displayRect);
                    }
                }
                else
                {
                    drawingContext.DrawRectangle(null, _inactivePen, _displayRect);
                    _inactiveTextFormat.RenderText(drawingContext, _inactiveBrush, "Screen Replicator", _displayRect);
                }
            }
        }
开发者ID:Heliflyer,项目名称:helios,代码行数:28,代码来源:ScreenReplicatorRenderer.cs

示例10: OnRender

        protected override void OnRender(DrawingContext dc)
        {
            var inColumns = PointsInColumn();
            var inRows = PointsInRow();

            var noOfPoints = inColumns*inRows;

            int finishedPoints = (int) (Progress*noOfPoints);
            int currentPoint = 0;

            for (int rowIndex = 0; rowIndex < inRows; rowIndex++)
            {
                for (int columnIndex = 0; columnIndex < inColumns; columnIndex++)
                {
                    currentPoint++;

                    var point = new Point((columnIndex + 1)*Spacing + columnIndex*PointSize, Spacing * (rowIndex+1) + rowIndex*PointSize);
                    if (currentPoint > finishedPoints)
                    {
                        dc.DrawRectangle(PendingBrush, null, new Rect(point, new Size(PointSize, PointSize)));
                    }
                    else
                    {
                        dc.DrawRectangle(FinishedBrush, null, new Rect(point, new Size(PointSize, PointSize)));
                    }
                }
            }
        }
开发者ID:ppiotrowicz,项目名称:Pomidoro,代码行数:28,代码来源:PointMatrix.cs

示例11: OnRender

 protected override void OnRender(DrawingContext drawingContext)
 {
     var torrent = DataContext as PeriodicTorrent;
     if (torrent == null)
     {
         drawingContext.DrawRectangle(null, new Pen(Brushes.DarkGray, 1), new Rect(0, 0, this.ActualWidth, this.ActualHeight));
         return;
     }
     var pieces = torrent.RecievedPieces;
     if (pieces == null)
     {
         drawingContext.DrawRectangle(null, new Pen(Brushes.DarkGray, 1), new Rect(0, 0, this.ActualWidth, this.ActualHeight));
         return;
     }
     double width = ActualWidth / pieces.Length;
     int increment = (int)(1 / width);
     if (increment == 0) increment = 1;
     for (int i = 0; i < pieces.Length; i += increment)
     {
         if (pieces[i])
         {
             drawingContext.DrawRectangle(Brushes.LightGreen, null,
                 new Rect(Math.Ceiling(i * width), 0, Math.Ceiling(width), ActualHeight));
         }
         else
             drawingContext.DrawRectangle(Background, null,
                 new Rect(Math.Ceiling(i * width), 0, Math.Ceiling(width), ActualHeight));
     }
     drawingContext.DrawRectangle(null, new Pen(Brushes.DarkGray, 1), new Rect(0, 0, this.ActualWidth, this.ActualHeight));
     base.OnRender(drawingContext);
 }
开发者ID:naiduv,项目名称:Patchy,代码行数:31,代码来源:PiecedProgressBar.xaml.cs

示例12: DrawConnectionPoint

 static void DrawConnectionPoint(ConnectionPoint connPoint, Point actualLocation, Brush renderBrush, Pen renderPen, DrawingContext drawingContext)
 {
     // actualLocation is the point on the Edge with respect to the coordinate system defined by the top left corner of the adorned element
     // We will need this transparent rectangle to make sure OnMouseOver event can be triggered, for hit test.
     drawingContext.DrawRectangle(Brushes.Transparent, new Pen(Brushes.Transparent, 0),
         new Rect(actualLocation + connPoint.HitTestOffset, connPoint.HitTestSize));
     drawingContext.DrawRectangle(renderBrush, renderPen,
         new Rect(actualLocation + connPoint.DrawingOffset, connPoint.DrawingSize));
 }
开发者ID:blacklensama,项目名称:1709,代码行数:9,代码来源:ConnectionPointsAdorner.cs

示例13: RedrawDots

        public static void RedrawDots(DrawingContext dc, ICollection<IP> dots, Rectangle rect, ShapeType t = ShapeType.Default)
        {
            if (!IsDrawEnabled) return;

            foreach (var p in dots.Where(p => p != null))
            {
                dc.DrawRectangle(Pens.BackgroundColor, null, GetShape(p, rect, t));
                dc.DrawRectangle(GetColor(p, ShapeType.Default), null, GetShape(p, rect, ShapeType.Default));
            }
        }
开发者ID:kunukn,项目名称:single-detect,代码行数:10,代码来源:DrawUtil.cs

示例14: OnRender

 protected override void OnRender(DrawingContext drawingContext)
 {
     drawingContext.DrawRectangle(Brushes.Red, new Pen(), new Rect(5, _playerPaddlePos - 20, 10, 40));
     drawingContext.DrawRectangle(Brushes.Red, new Pen(),
                                  new Rect(RenderSize.Width - 7.5, _computerPaddlePos - 20, 10, 40));
     drawingContext.DrawEllipse(Brushes.WhiteSmoke, new Pen(), _ballPos, 5, 5);
     drawingContext.DrawText(
         new FormattedText(String.Format("{0} - {1}", _playerScore, _computerScore), CultureInfo.CurrentCulture, FlowDirection.LeftToRight,
                           new Typeface("Courier New"), 12, Brushes.White), new Point(RenderSize.Width / 2, 10));
     base.OnRender(drawingContext);
 }
开发者ID:itsbth,项目名称:E2Edit,代码行数:11,代码来源:PongGame.cs

示例15: PaintBackground

		public static void PaintBackground(this Altaxo.Worksheet.ColumnStyle thiss, DrawingContext dc, RectangleD2D cellRectangle, bool bSelected)
		{
			var cellRect = cellRectangle.ToWpf();
			if (bSelected)
				dc.DrawRectangle(thiss.DefaultSelectedBackgroundBrush.ToWpf(), null, cellRect);
			else
				dc.DrawRectangle(thiss.BackgroundBrush.ToWpf(), null, cellRect);

			dc.DrawLine(thiss.CellBorder.ToWpf(), cellRect.BottomLeft, cellRect.BottomRight);
			dc.DrawLine(thiss.CellBorder.ToWpf(), cellRect.BottomRight, cellRect.TopRight);
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:11,代码来源:ColumnStylePaintingWpf.cs


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