當前位置: 首頁>>代碼示例>>C#>>正文


C# DrawingContext.DrawDrawing方法代碼示例

本文整理匯總了C#中System.Windows.Media.DrawingContext.DrawDrawing方法的典型用法代碼示例。如果您正苦於以下問題:C# DrawingContext.DrawDrawing方法的具體用法?C# DrawingContext.DrawDrawing怎麽用?C# DrawingContext.DrawDrawing使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Windows.Media.DrawingContext的用法示例。


在下文中一共展示了DrawingContext.DrawDrawing方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: DrawCore

        protected override void DrawCore(DrawingContext drawingContext, DrawingAttributes drawingAttributes)
        {
            if (drawingContext == null)
            {
                throw new ArgumentNullException("drawingContext");
            }
            if (null == drawingAttributes)
            {
                throw new ArgumentNullException("drawingAttributes");
            }
            Pen pen = new Pen
            {
                StartLineCap = PenLineCap.Round,
                EndLineCap = PenLineCap.Round,
                Brush = new SolidColorBrush(drawingAttributes.Color),
                Thickness = drawingAttributes.Width
            };

            BrushConverter bc = new BrushConverter();
            Brush BackGround = (Brush)bc.ConvertFromString(drawingAttributes.GetPropertyData(DrawAttributesGuid.BackgroundColor).ToString());
            GeometryConverter gc = new GeometryConverter();
            Geometry geometry = (Geometry)gc.ConvertFromString(string.Format("M {0},{1} {2},{3} {4},{5} Z", StylusPoints[0].X, StylusPoints[1].Y, (Math.Abs(StylusPoints[1].X - StylusPoints[0].X))/2 + StylusPoints[0].X, StylusPoints[0].Y, StylusPoints[1].X, StylusPoints[1].Y));
            GeometryDrawing gd = new GeometryDrawing(BackGround, pen, geometry);
            drawingContext.DrawDrawing(gd);
        }
開發者ID:sonicrang,項目名稱:RangPaint,代碼行數:25,代碼來源:TriangleStroke.cs

示例2: InnerDraw

		protected override void InnerDraw(DrawingContext drawingContext)
		{
			base.InnerDraw(drawingContext);
			drawingContext.PushTransform(_scaleTransform);
			drawingContext.DrawDrawing(_textDrawing);
			drawingContext.Pop();
		}
開發者ID:xbadcode,項目名稱:Rubezh,代碼行數:7,代碼來源:PassCardImagePropertyPainter.cs

示例3: OnRender

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

            var ellipse = new EllipseGeometry(new Point(250, 50), 50, 50);
            var drawing = new GeometryDrawing(Brushes.BlueViolet, new Pen(Brushes.Bisque, 2), ellipse);
            drawingContext.DrawDrawing(drawing);
        }
開發者ID:BerdyPango,項目名稱:Researches,代碼行數:8,代碼來源:02_MyEllipseGeometry.cs

示例4: OnRender

        /// <summary>
        /// 
        /// </summary>
        /// <param name="drawingContext"></param>
        protected override void OnRender(DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);

            foreach (var visual in Visuals)
            {
                drawingContext.DrawDrawing(visual.Drawing);
            }
        }
開發者ID:gitter-badger,項目名稱:Test2d,代碼行數:13,代碼來源:VisualHost.cs

示例5: OnRender

        protected override void OnRender(DrawingContext dc)
        {
            if (_drawings.Count == 0 || _size.Height != ActualHeight || _size.Width != ActualWidth)
            {
                RenderSizeChanged(_size = new Size(ActualWidth, ActualHeight));
            }
            if (_drawings.Count == 1)
                dc.DrawDrawing(_drawings[0]);

            base.OnRender(dc);
        }
開發者ID:mcwatt77,項目名稱:vimcontrols,代碼行數:11,代碼來源:VIMGraphPanel.cs

示例6: InnerDraw

		//private const int Margin = 3;
		protected override void InnerDraw(DrawingContext drawingContext)
		{
			base.InnerDraw(drawingContext);
			if (_scaleTransform != null)
				drawingContext.PushTransform(_scaleTransform);
			if (_clipGeometry != null)
				drawingContext.PushClip(_clipGeometry);
			drawingContext.DrawDrawing(_textDrawing);
			if (_clipGeometry != null)
				drawingContext.Pop();
			if (_scaleTransform != null)
				drawingContext.Pop();
		}
開發者ID:xbadcode,項目名稱:Rubezh,代碼行數:14,代碼來源:TextBlockPainter.cs

示例7: Render

 public void Render(DrawingContext drawingContext)
 {
     if (BackGround != null)
     {
         drawingContext.DrawDrawing(BackGround);
     }
     if (Overlay != null)
     {
         drawingContext.DrawDrawing(Overlay);
     }
 }
開發者ID:mrange,項目名稱:fgrid,代碼行數:11,代碼來源:FGridView.cs

示例8: DrawScenes


//.........這裏部分代碼省略.........
                                figures.Add(new PathFigure(bottomLeft.ToCanvasPoint(), segments, true));
                            }
                            var geo = new PathGeometry(figures, FillRule.Nonzero, null);
                            geo.GetOutlinedPathGeometry();
                            groupdc.DrawGeometry(RadarResources.WalkableTerrain, null, geo);
                        }
                        #endregion

                        #region Scene Borders
                        var sceneTopLeft = new Vector3(adventurerScene.Min.X, adventurerScene.Min.Y, 0);
                        var sceneTopRight = new Vector3(adventurerScene.Max.X, adventurerScene.Min.Y, 0);
                        var sceneBottomLeft = new Vector3(adventurerScene.Min.X, adventurerScene.Max.Y, 0);
                        var sceneBottomRight = new Vector3(adventurerScene.Max.X, adventurerScene.Max.Y, 0);

                        groupdc.DrawGeometry(null, RadarResources.WalkableTerrainBorder, new LineGeometry(sceneTopLeft.ToCanvasPoint(), sceneTopRight.ToCanvasPoint()));
                        groupdc.DrawGeometry(null, RadarResources.WalkableTerrainBorder, new LineGeometry(sceneBottomLeft.ToCanvasPoint(), sceneBottomRight.ToCanvasPoint()));
                        groupdc.DrawGeometry(null, RadarResources.WalkableTerrainBorder, new LineGeometry(sceneTopLeft.ToCanvasPoint(), sceneBottomLeft.ToCanvasPoint()));
                        groupdc.DrawGeometry(null, RadarResources.WalkableTerrainBorder, new LineGeometry(sceneTopRight.ToCanvasPoint(), sceneBottomRight.ToCanvasPoint()));
                        #endregion

                        #region Scene Title
                        var textPoint = adventurerScene.Center.ToVector3().ToCanvasPoint();
                        var glyphRun = DrawingUtilities.CreateGlyphRun(adventurerScene.Name, 10, textPoint);
                        groupdc.DrawGlyphRun(Brushes.Wheat, glyphRun);
                        textPoint = adventurerScene.Center.ToVector3().ToCanvasPoint();
                        textPoint.Y = textPoint.Y + 20;
                        glyphRun = DrawingUtilities.CreateGlyphRun((adventurerScene.Max - adventurerScene.Min) + " " + (adventurerScene.HasChild ? "HasSubScene" : string.Empty) + " " + (adventurerScene.SubScene != null ? " (Loaded)" : string.Empty), 8, textPoint);
                        groupdc.DrawGlyphRun(Brushes.Wheat, glyphRun);
                        #endregion

                        #region Nodes
                        var sceneNodePen = new Pen { Brush = Brushes.Black, Thickness = 0.1f };
                        foreach (var node in adventurerScene.Nodes)
                        {
                            if (node.HasEnoughNavigableCells)
                            {
                                groupdc.DrawGeometry(null, sceneNodePen,
                                    new LineGeometry(node.TopLeft.ToVector3().ToCanvasPoint(),
                                        node.TopRight.ToVector3().ToCanvasPoint()));
                                groupdc.DrawGeometry(null, sceneNodePen,
                                    new LineGeometry(node.TopLeft.ToVector3().ToCanvasPoint(),
                                        node.BottomLeft.ToVector3().ToCanvasPoint()));
                                groupdc.DrawGeometry(null, sceneNodePen,
                                    new LineGeometry(node.BottomLeft.ToVector3().ToCanvasPoint(),
                                        node.BottomRight.ToVector3().ToCanvasPoint()));
                                groupdc.DrawGeometry(null, sceneNodePen,
                                    new LineGeometry(node.TopRight.ToVector3().ToCanvasPoint(),
                                        node.BottomRight.ToVector3().ToCanvasPoint()));

                                //var textPoint1 = node.Center.ToVector3().ToCanvasPoint();
                                ////                                var glyphRun1 = DrawingUtilities.CreateGlyphRun(string.Format("{2} {0} ({1:P0})", node.NavigableCellCount, node.FillPercentage, node.LevelAreaId), 8, textPoint1);
                                //var glyphRun1 = DrawingUtilities.CreateGlyphRun(node.LevelAreaId.ToString(), 8, textPoint1);
                                //groupdc.DrawGlyphRun(Brushes.Wheat, glyphRun1);
                            }
                            //foreach (var navPoint in node.Nodes.Where(n=>n.NodeFlags.HasFlag(NodeFlags.NearWall)))
                            //{
                            //    DrawNavNode(groupdc, canvas, navPoint);
                            //    //groupdc.DrawEllipse(Brushes.LightSlateGray, sceneNodePen, navPoint.Center.ToVector3().ToCanvasPoint(), (float)GridSize / 2, (float)GridSize / 2);
                            //}
                        }
                        #endregion




                    }

                    // Have to use SceneHash as key because scenes can appear multiple times with the same name
                    Drawings.Relative.TryAdd(adventurerScene.HashName, new RelativeDrawing
                    {
                        Drawing = drawing,
                        Origin = CenterActor.Morph,
                        Center = adventurerScene.Center.ToVector3(),
                        WorldId = adventurerScene.DynamicWorldId,
                        //Image = new DrawingImage(drawing),
                        //ImageRect = drawing.Bounds

                    });
                }

                foreach (var pair in Drawings.Relative)
                {
                    //if (pair.Value.WorldId != AdvDia.CurrentWorldDynamicId)
                    //    continue;

                    if (!pair.Value.Drawing.Bounds.IntersectsWith(CanvasData.ClipRegion.Rect))
                        continue;
                    dc.DrawDrawing(pair.Value.Drawing);

                    //if (!pair.Value.ImageRect.IntersectsWith(CanvasData.ClipRegion.Rect))
                    //    continue;
                    //dc.DrawImage(pair.Value.Image, pair.Value.ImageRect);
                }

            }
            catch (Exception ex)
            {
                Logger.Debug("Exception in RadarUI.DrawScenes(). {0} {1} {2}", ex.Message, ex.InnerException, ex);
            }
        }
開發者ID:mythsya,項目名稱:db-plugins,代碼行數:101,代碼來源:RadarCanvas.cs

示例9: RenderFalseHorizon

 protected void RenderFalseHorizon(DrawingContext context)
 {
     if (falseHorizonPen == null)
     {
         return;
     }
     context.DrawDrawing(falseHorizonCrosshairs);
     context.DrawDrawing(pitchGauge);
 }
開發者ID:saihv,項目名稱:EERILControlSystem,代碼行數:9,代碼來源:HeadsUpDisplay.cs

示例10: OnRender

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

            var bc = new BrushConverter();

            var user = XIVInfoViewModel.Instance.CurrentUser;
            if (user == null)
            {
                return;
            }

            var origin = new Coordinate
            {
                X = (float) (ActualWidth / 2),
                Y = (float) (ActualHeight / 2)
            };

            var scale = ((float) (ActualHeight / 2.0f) / 125.0f);
            var angle = Math.Abs(user.Heading * (180 / Math.PI) - 180);

            if (Settings.Default.RadarCompassMode)
            {
                var drawingGroup = new DrawingGroup
                {
                    Transform = new RotateTransform
                    {
                        Angle = angle,
                        CenterX = origin.X,
                        CenterY = origin.Y
                    }
                };
                drawingGroup.Children.Add(new ImageDrawing(RadarIconHelper.RadarHeading, new Rect(origin.X - 64, origin.Y - 128, 128, 128)));
                drawingContext.DrawDrawing(drawingGroup);
            }
            else
            {
                drawingContext.DrawImage(RadarIconHelper.RadarHeading, new Rect(new Point(origin.X - 64, origin.Y - 128), new Size(128, 128)));
            }

            var sb = new StringBuilder();

            var npcEntites = new List<ActorEntity>(XIVInfoViewModel.Instance.CurrentNPCs.Select(kvp => kvp.Value)
                                                                   .ToList());
            var monsterEntites = new List<ActorEntity>(XIVInfoViewModel.Instance.CurrentMonsters.Select(kvp => kvp.Value)
                                                                       .ToList());
            var pcEntites = new List<ActorEntity>(XIVInfoViewModel.Instance.CurrentPCs.Select(kvp => kvp.Value)
                                                                  .ToList());

            if (Settings.Default.FilterRadarItems)
            {
                var npcFilters = PluginViewModel.Instance.Filters.Where(filter => filter.Type != Actor.Type.PC && filter.Type != Actor.Type.Monster)
                                                .ToList();
                if (npcFilters.Any())
                {
                    npcEntites = RadarFilterHelper.ResolveFilteredEntities(npcFilters, npcEntites);
                }

                var monsterFilters = PluginViewModel.Instance.Filters.Where(filter => filter.Type == Actor.Type.Monster)
                                                    .ToList();
                if (PluginViewModel.Instance.RankedFilters.Any())
                {
                    monsterFilters.AddRange(PluginViewModel.Instance.RankedFilters);
                }

                if (monsterFilters.Any())
                {
                    monsterEntites = RadarFilterHelper.ResolveFilteredEntities(monsterFilters, monsterEntites);
                }

                var pcFilters = PluginViewModel.Instance.Filters.Where(filter => filter.Type == Actor.Type.PC)
                                               .ToList();
                if (pcFilters.Any())
                {
                    pcEntites = RadarFilterHelper.ResolveFilteredEntities(pcFilters, pcEntites);
                }
            }

            #region Resolve PCs

            if (Settings.Default.PCShow)
            {
                foreach (var actorEntity in pcEntites)
                {
                    sb.Clear();
                    var fsModifier = 0;
                    drawingContext.PushOpacity(1);
                    try
                    {
                        if (!actorEntity.IsValid || user == null)
                        {
                            continue;
                        }
                        if (actorEntity.ID == user.ID)
                        {
                            continue;
                        }
                        Coordinate screen;
                        if (Settings.Default.RadarCompassMode)
                        {
//.........這裏部分代碼省略.........
開發者ID:Yaguar666,項目名稱:ffxivapp-plugin-radar,代碼行數:101,代碼來源:Radar.xaml.cs

示例11: OnRender

        protected override void OnRender(DrawingContext drawingContext)
        {
            if (ChartData == null) return;

            if (GraphContents == null)
            {
                // ActualWidth and ActualHeight are NaN at initialization, need to do this here
                Viewport.Visible = new Rect(new Size(ActualWidth, ActualHeight));
                Viewport.OnViewportResized(ActualWidth, ActualHeight);
                GraphContents = new DrawingGroup();
            }

            if (FilteredPoints == null)
                Update();

            using (DrawingContext context = GraphContents.Open())
            {
                // Draw Background
                context.DrawRectangle(ChartStyle.BackgroundColor, null, Viewport.Output);

                // Draw Chart
                ChartDrawing.Draw(context, FilteredPoints, ChartStyle);

                //Draw Debug text
                context.DrawText(new FormattedText("Viewport.Visible=" + Viewport.Visible + "\n" + "Viewport.Output=" + Viewport.Output,
                    CultureInfo.InvariantCulture,
                    FlowDirection.LeftToRight,
                    new Typeface("Arial"), 12, Brushes.Red),
                    new Point(10, 10));
            }

            drawingContext.DrawDrawing(GraphContents);
        }
開發者ID:anndream,項目名稱:StockCharts-1,代碼行數:33,代碼來源:ChartPanel.cs

示例12: RenderCompass

 protected void RenderCompass(DrawingContext context)
 {
     if (baselinePen == null)
     {
         return;
     }
     compassClippingRectangle.Transform = invertedYawTransform;
     compass.Transform = yawTransform;
     compass.ClipGeometry = compassClippingRectangle;
     context.DrawDrawing(compass);
 }
開發者ID:saihv,項目名稱:EERILControlSystem,代碼行數:11,代碼來源:HeadsUpDisplay.cs

示例13: OnRender

 protected override void OnRender(DrawingContext drawingContext)
 {
     drawingContext.DrawDrawing(m_drawing);
     //base.OnRender(drawingContext);
 }
開發者ID:tomba,項目名稱:dwarrowdelf,代碼行數:5,代碼來源:MapControl3.cs

示例14: OnRender

        protected override void OnRender(DrawingContext drawingContext)
        {
            var clock = GetAnimationClock(this);
            var step = (int)Math.Floor (clock * Spokes);
            var halfWidth = ActualWidth/2;
            var halfHeight = ActualHeight/2;
            var scale = Math.Min (halfWidth, halfHeight);

            var matrix = Matrix.Identity;
            matrix.Scale (scale, scale);
            var angle = -(step*360.0)/Spokes;
            matrix.Rotate (angle);
            matrix.Translate (halfWidth, halfHeight);

            drawingContext.PushTransform(new MatrixTransform (matrix));

            drawingContext.DrawDrawing(s_drawing);

            drawingContext.Pop();
        }
開發者ID:mrange,項目名稱:T4Include,代碼行數:20,代碼來源:BuzyWait.cs

示例15: OnRender

        /// <summary>
        /// Renders the contents of an <see cref="T:System.Windows.Controls.Image"/> and 
        /// the SelectorDrawing.
        /// </summary>
        /// <param name="dc">An instance of <see cref="T:System.Windows.Media.DrawingContext"/> 
        /// used to render the control.</param>
        protected override void OnRender(DrawingContext dc)
        {
            base.OnRender(dc);

            if (ActualWidth == 0 || ActualHeight == 0)
                return;

            // Render the SelectorDrawing
            dc.PushTransform(new TranslateTransform(Position.X, Position.Y));
            dc.DrawDrawing(Selector);
            dc.Pop();
        }
開發者ID:xtremas,項目名稱:final-bachelor-project,代碼行數:18,代碼來源:ImageColorPicker.cs


注:本文中的System.Windows.Media.DrawingContext.DrawDrawing方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。