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


C# Media.DrawingContext类代码示例

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


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

示例1: OnRender

        protected override void OnRender(DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);

            double segmentStart;
            double segmentEnd;
            if (Edge.Orientation == Orientation.Vertical)
            {
                segmentStart = Math.Min(Edge.Range.SegmentStart, CanvasItem.Top);
                segmentEnd = Math.Max(Edge.Range.SegmentEnd, CanvasItem.Bottom);
            }
            else
            {
                segmentStart = Math.Min(Edge.Range.SegmentStart, CanvasItem.Left);
                segmentEnd = Math.Max(Edge.Range.SegmentEnd, CanvasItem.Right);
            }

            var point1 = new Point(Edge.AxisDistance, segmentStart);
            var point2 = new Point(Edge.AxisDistance, segmentEnd);

            if (Edge.Orientation == Orientation.Horizontal)
            {
                point1 = point1.Swap();
                point2 = point2.Swap();
            }

            drawingContext.DrawLine(Pen, point1, point2);
        }
开发者ID:modulexcite,项目名称:VisualDesigner,代码行数:28,代码来源:EdgeAdorner.cs

示例2: OnRender

 protected override void OnRender(DrawingContext drawingContext)
 {
     FoldingMargin margin = VisualParent as FoldingMargin;
     Pen activePen = new Pen(margin.SelectedFoldingMarkerBrush, 1);
     Pen inactivePen = new Pen(margin.FoldingMarkerBrush, 1);
     activePen.StartLineCap = inactivePen.StartLineCap = PenLineCap.Square;
     activePen.EndLineCap = inactivePen.EndLineCap = PenLineCap.Square;
     Size pixelSize = PixelSnapHelpers.GetPixelSize(this);
     Rect rect = new Rect(pixelSize.Width / 2,
                          pixelSize.Height / 2,
                          this.RenderSize.Width - pixelSize.Width,
                          this.RenderSize.Height - pixelSize.Height);
     drawingContext.DrawRectangle(
         IsMouseDirectlyOver ? margin.SelectedFoldingMarkerBackgroundBrush : margin.FoldingMarkerBackgroundBrush,
         IsMouseDirectlyOver ? activePen : inactivePen, rect);
     double middleX = rect.Left + rect.Width / 2;
     double middleY = rect.Top + rect.Height / 2;
     double space = PixelSnapHelpers.Round(rect.Width / 8, pixelSize.Width) + pixelSize.Width;
     drawingContext.DrawLine(activePen,
                             new Point(rect.Left + space, middleY),
                             new Point(rect.Right - space, middleY));
     if (!isExpanded) {
         drawingContext.DrawLine(activePen,
                                 new Point(middleX, rect.Top + space),
                                 new Point(middleX, rect.Bottom - space));
     }
 }
开发者ID:eolandezhang,项目名称:Diagram,代码行数:27,代码来源:FoldingMarginMarker.cs

示例3: DrawBone

        /// <summary>
        /// Draws a bone line between two joints
        /// </summary>
        /// <param name="skeleton">skeleton to draw bones from</param>
        /// <param name="drawingContext">drawing context to draw to</param>
        /// <param name="jointType0">joint to start drawing from</param>
        /// <param name="jointType1">joint to end drawing at</param>
        public static void DrawBone(TSkeleton skeleton, DrawingContext drawingContext, TJointType jointType0, TJointType jointType1)
        {
            TJoint joint0 = skeleton.Joints[(int)jointType0];
            TJoint joint1 = skeleton.Joints[(int)jointType1];

            // If we can't find either of these joints, exit
            if (joint0.TrackingState == TJointTrackingState.NotTracked ||
                joint1.TrackingState == TJointTrackingState.NotTracked)
            {
                return;
            }

            // Don't draw if both points are inferred
            if (joint0.TrackingState == TJointTrackingState.Inferred &&
                joint1.TrackingState == TJointTrackingState.Inferred)
            {
                return;
            }

            // We assume all drawn bones are inferred unless BOTH joints are tracked
            Pen drawPen = inferredBonePen;
            if (joint0.TrackingState == TJointTrackingState.Tracked && joint1.TrackingState == TJointTrackingState.Tracked)
            {
                drawPen = trackedBonePen;
            }

            drawingContext.DrawLine(drawPen, SkeletonPointToScreen(joint0.Position), SkeletonPointToScreen(joint1.Position));
        }
开发者ID:Styrna,项目名称:TKinect,代码行数:35,代码来源:SkeletonDisplayHelper.cs

示例4: Draw

        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (textView == null)
                throw new ArgumentNullException("textView");
            if (drawingContext == null)
                throw new ArgumentNullException("drawingContext");

            if (currentResults == null || !textView.VisualLinesValid)
                return;

            var visualLines = textView.VisualLines;
            if (visualLines.Count == 0)
                return;

            int viewStart = visualLines.First().FirstDocumentLine.Offset;
            int viewEnd = visualLines.Last().LastDocumentLine.EndOffset;

            foreach (SearchResult result in currentResults.FindOverlappingSegments(viewStart, viewEnd - viewStart)) {
                BackgroundGeometryBuilder geoBuilder = new BackgroundGeometryBuilder();
                geoBuilder.AlignToMiddleOfPixels = true;
                geoBuilder.CornerRadius = 3;
                geoBuilder.AddSegment(textView, result);
                Geometry geometry = geoBuilder.CreateGeometry();
                if (geometry != null) {
                    drawingContext.DrawGeometry(markerBrush, markerPen, geometry);
                }
            }
        }
开发者ID:eolandezhang,项目名称:Diagram,代码行数:28,代码来源:SearchResultBackgroundRenderer.cs

示例5: Draw

        /// <summary>
        /// Draw object
        /// </summary>
        public override void Draw(DrawingContext drawingContext)
        {
            if ( drawingContext == null )
            {
                throw new ArgumentNullException("drawingContext");
            }

            Rect r = Rectangle;

            Point center = new Point(
                (r.Left + r.Right) / 2.0,
                (r.Top + r.Bottom) / 2.0);

            double radiusX = (r.Right - r.Left) / 2.0;
            double radiusY = (r.Bottom - r.Top) / 2.0;

            drawingContext.DrawEllipse(
                null,
                new Pen(new SolidColorBrush(ObjectColor), ActualLineWidth),
                center,
                radiusX,
                radiusY);

            base.Draw(drawingContext);
        }
开发者ID:VictorHelios,项目名称:OpenCVBestPractice,代码行数:28,代码来源:GraphicsEllipse.cs

示例6: 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

示例7: 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

示例8: OnRender

 protected override void OnRender(DrawingContext dc)
 {
     if (background != null)
     {
         dc.DrawImage(background, new Rect(0, 0, background.PixelWidth, background.PixelHeight));
     }
 }
开发者ID:JayStilla,项目名称:SpriteMapGenerator,代码行数:7,代码来源:MyCanvas.cs

示例9: OnRender

        protected override void OnRender(DrawingContext drawingContext)
        {
            double width = RenderSize.Width;
            double height = RenderSize.Height;
            MeshGeometry3D mesh = Mesh;

            if (mesh != null)
            {
                Pen pen = new Pen(Brushes.Black, 1.0);

                int numTriangles = mesh.TriangleIndices.Count/3;

                for(int i = 0; i < numTriangles; i++)
                {
                    DrawTriangle(drawingContext,
                                 pen,
                                 mesh.TextureCoordinates[mesh.TriangleIndices[i * 3]],
                                 mesh.TextureCoordinates[mesh.TriangleIndices[i * 3 + 1]],
                                 mesh.TextureCoordinates[mesh.TriangleIndices[i * 3 + 2]],
                                 width,
                                 height);
                }
            }

            base.OnRender(drawingContext);
        }
开发者ID:JazzFisch,项目名称:AnotherCombatManager,代码行数:26,代码来源:MeshTextureCoordinateVisualizer.cs

示例10: DrawSearchHighlight

		private void DrawSearchHighlight(DrawingContext dc, Block block)
		{
			foreach (var pair in _curSearchMatches)
			{
				int txtOffset = 0;
				double y = block.Y;

				for (int i = 0; i < block.Text.Length; i++)
				{
					int start = Math.Max(txtOffset, pair.Item1);
					int end = Math.Min(txtOffset + block.Text[i].Length, pair.Item2);

					if (end > start)
					{
						double x1 = block.Text[i].GetDistanceFromCharacterHit(new CharacterHit(start, 0)) + block.TextX;
						double x2 = block.Text[i].GetDistanceFromCharacterHit(new CharacterHit(end, 0)) + block.TextX;

						dc.DrawRectangle(_searchBrush.Value, null,
							new Rect(new Point(x1, y), new Point(x2, y + _lineHeight)));
					}

					y += _lineHeight;
					txtOffset += block.Text[i].Length;
				}
			}
		}
开发者ID:derrickcreamer,项目名称:Floe,代码行数:26,代码来源:ChatPresenter_Searching.cs

示例11: 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

示例12: OnRender

 protected override void OnRender(DrawingContext drawingContext)
 {
     base.OnRender(drawingContext);
     DrawGrid(drawingContext);
     DrawChart(drawingContext);
     UpdateParent();
 }
开发者ID:BGCX261,项目名称:zpi-modeler-svn-to-git,代码行数:7,代码来源:GoniometricCanvas.xaml.cs

示例13: 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

示例14: Draw

        public override void Draw(DrawingContext dc)
        {

            if (HasConnection())
                CoreDraw.DrawLine(dc, StartConn.getPort().getCenter(), EndConn.getPort().getCenter(), LineWidth, Brushes.Blue, CoreDraw.LineStyle_StraightLine);

        }
开发者ID:SAM33,项目名称:2016-OOP-UMLEditor,代码行数:7,代码来源:AssociationConnShape.cs

示例15: PaintCovexHull

 protected virtual void PaintCovexHull(HandData cluster, DrawingContext drawingContext)
 {
     if (cluster.ConvexHull.Count > 3)
     {
         this.DrawLines(drawingContext, this.whitePen, cluster.ConvexHull.Points.Select(p => new System.Windows.Point(p.X, p.Y)).ToArray());
     }
 }
开发者ID:aabrohi,项目名称:kinect-kollage,代码行数:7,代码来源:WpfHandLayer.cs


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