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


C# PathGeometry.GetOutlinedPathGeometry方法代码示例

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


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

示例1: DrawScenes

        //private void DrawNavNode(DrawingContext dc, CanvasData canvas, GridNode node)
        //{
        //    SolidColorBrush nodeBrush;
        //    if (node.Flags.HasFlag(NavCellFlags.RoundedCorner0) || node.Flags.HasFlag(NavCellFlags.RoundedCorner1) || node.Flags.HasFlag(NavCellFlags.RoundedCorner2) || node.Flags.HasFlag(NavCellFlags.RoundedCorner3))
        //    {
        //        nodeBrush = Brushes.SaddleBrown;
        //    }
        //    else if (node.Flags.HasFlag(NavCellFlags.AllowWalk))
        //    {
        //        nodeBrush = Brushes.Green;
        //    }
        //    else if (node.Flags.HasFlag(NavCellFlags.AllowProjectile))
        //    {
        //        nodeBrush = Brushes.DarkGray;
        //    }
        //    else
        //    {
        //        nodeBrush = Brushes.Black;
        //    }

        //    dc.DrawEllipse(nodeBrush, RadarResources.GridPen, node.NavigableCenter.ToCanvasPoint(), GridSize, GridSize);
        //}

        //private void DrawNodesInRadius(DrawingContext dc, CanvasData canvas)
        //{
        //    try
        //    {
        //        var nearestNode = MainGrid.Instance.GetNearestNodeToPosition(AdvDia.MyPosition);
        //        if (nearestNode == null) return;
        //        var nodes = MainGrid.Instance.GetNeighbors(nearestNode, 5);
        //        foreach (var node in nodes)
        //        {
        //            DrawNavNode(dc, canvas, node);
        //        }

        //    }
        //    catch (Exception ex)
        //    {
        //        Logger.Debug("Exception in RadarUI.DrawNodesInRadius(). {0} {1} {2}", ex.Message, ex.InnerException, ex);
        //    }
        //}

        /// <summary>
        /// Draw a Scene
        /// </summary>
        private void DrawScenes(DrawingContext dc, CanvasData canvas)
        {
            try
            {
                if (Math.Abs(CenterActor.Point.X) < 0.01f && Math.Abs(CenterActor.Point.Y) < 0.01f)
                    return;

                var worldId = AdvDia.CurrentWorldDynamicId;
                foreach (var adventurerScene in ScenesStorage.CurrentWorldScenes.Where(s => s.DynamicWorldId == worldId).ToList())
                {
                    //var scene = adventurerScene.TrinityScene;

                    // Combine navcells into one drawing and store it; because they don't change relative to each other
                    // And because translating geometry for every navcell on every frame is waaaaay too slow.
                    if (Drawings.Relative.ContainsKey(adventurerScene.HashName)) continue;

                    var drawing = new DrawingGroup();

                    using (var groupdc = drawing.Open())
                    {
                        #region Terrain
                        if (adventurerScene.Cells != null)
                        {
                            var figures = new List<PathFigure>();
                            foreach (var navCell in adventurerScene.Cells.Where(nc => nc.IsWalkable))
                            {
                                var topLeft = new Vector3(navCell.MinX, navCell.MinY, 0);
                                var topRight = new Vector3(navCell.MaxX, navCell.MinY, 0);
                                var bottomLeft = new Vector3(navCell.MinX, navCell.MaxY, 0);
                                var bottomRight = new Vector3(navCell.MaxX, navCell.MaxY, 0);
                                var segments = new[]
                                               {
                                                   new LineSegment(topLeft.ToCanvasPoint(), true),
                                                   new LineSegment(topRight.ToCanvasPoint(), true),
                                                   new LineSegment(bottomRight.ToCanvasPoint(), true)
                                               };

                                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()));
//.........这里部分代码省略.........
开发者ID:mythsya,项目名称:db-plugins,代码行数:101,代码来源:RadarCanvas.cs

示例2: GetMarkerGeometry

		/// <summary>
		/// </summary>
		/// <exception cref="ArgumentNullException">
		/// <para><paramref name="span"/> is <see langword="null"/>.</para>
		/// </exception>
		/// <exception cref="ArgumentOutOfRangeException">
		/// <para><paramref name="span"/> is less than zero or greater than the buffer length for the associated <see cref="ISourceEditorView"/>.</para>
		/// </exception>
		public Geometry GetMarkerGeometry(Span span)
		{
			if (span == null)
			{
				throw new ArgumentNullException("span");
			}
			if ((span.Start < 0) || (span.End > _editorView.TextBuffer.Length))
			{
				throw new ArgumentOutOfRangeException("span");
			}
			if (span.IsEmpty)
			{
				return null;
			}
			PathGeometry geometry = new PathGeometry();
			geometry.FillRule = FillRule.Nonzero;
			IList<ITextLine> textLines = _editorView.TextLines;
			if (textLines.Count == 0)
			{
				return null;
			}
			if ((span.Start > base.LastRenderedCharacter) || (span.End < base.FirstRenderedCharacter))
			{
				return null;
			}
			ITextLine item = null;
			ITextLine textLineClosestTo = null;
			if (span.Start < base.FirstRenderedCharacter)
			{
				item = textLines[0];
			}
			if (span.End > base.LastRenderedCharacter)
			{
				textLineClosestTo = textLines[textLines.Count - 1];
			}
			if (item == null)
			{
				item = base.GetTextLineClosestTo(span.Start);
			}
			if (textLineClosestTo == null)
			{
				textLineClosestTo = base.GetTextLineClosestTo(span.End);
			}
			if (item == textLineClosestTo)
			{
				foreach (TextBounds bounds in item.GetTextBounds(span))
				{
					RectangleGeometry geometry2 = new RectangleGeometry(new Rect(bounds.Left - 0.2, bounds.Top - 1, bounds.Width + 0.4, bounds.Height + 1), 0.6, 0.6);
					geometry2.Freeze();
					geometry.AddGeometry(geometry2);
				}
			}
			else
			{
				foreach (TextBounds bounds2 in item.GetTextBounds(span))
				{
					RectangleGeometry geometry3 = new RectangleGeometry(new Rect(bounds2.Left - 0.2, bounds2.Top - 1, bounds2.Width + 0.4, bounds2.Height + 1), 0.6, 0.6);
					geometry3.Freeze();
					geometry.AddGeometry(geometry3);
				}
				Int32 num = textLines.IndexOf(item) + 1;
				Int32 index = textLines.IndexOf(textLineClosestTo);
				for (Int32 i = num; i < index; i++)
				{
					ITextLine line3 = textLines[i];
					RectangleGeometry geometry4 = new RectangleGeometry(new Rect(-0.2, line3.VerticalOffset - 0.2, line3.Width, line3.Height + 0.4), 0.6, 0.6);
					geometry4.Freeze();
					geometry.AddGeometry(geometry4);
				}
				foreach (TextBounds bounds3 in textLineClosestTo.GetTextBounds(span))
				{
					RectangleGeometry geometry5 = new RectangleGeometry(new Rect(bounds3.Left - 0.2, bounds3.Top - 1, bounds3.Width + 0.4, bounds3.Height + 1), 0.6, 0.6);
					geometry5.Freeze();
					geometry.AddGeometry(geometry5);
				}
			}
			geometry.Freeze();
			return geometry.GetOutlinedPathGeometry();
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:87,代码来源:SourceEditorViewHelper.cs

示例3: DrawScenes

        /// <summary>
        /// Mind = Blown
        /// </summary>
        private void DrawScenes(DrawingContext dc, CanvasData canvas)
        {
            try
            {
                if (CenterActor.Point.X == 0 && CenterActor.Point.Y == 0)
                    return;

                foreach (var pair in CacheManager.CachedScenes)
                {                    
                    var scene = pair.Value;

                    // Combine navcells into one drawing and store it; because they don't change relative to each other
                    // And because translating geometry for every navcell on every frame is waaaaay too slow.
                    if (!Drawings.Relative.ContainsKey(scene.SceneHash) && scene.WalkableNavCellBounds.Any() && scene.IsCurrentWorld)
                    {
                        var drawing = new DrawingGroup();

                        using (var groupdc = drawing.Open())
                        {
                            var figures = new List<PathFigure>();
                            
                            foreach (var navCellBounds in scene.WalkableNavCellBounds)
                            {
                                var cellSouthWest = new Vector3(navCellBounds.Max.X, navCellBounds.Min.Y, 0).ToCanvasPoint();
                                var cellSouthEast = new Vector3(navCellBounds.Max.X, navCellBounds.Max.Y, 0).ToCanvasPoint();
                                var cellNorthWest = new Vector3(navCellBounds.Min.X, navCellBounds.Min.Y, 0).ToCanvasPoint();
                                var cellNorthEast = new Vector3(navCellBounds.Min.X, navCellBounds.Max.Y, 0).ToCanvasPoint();

                                var segments = new[]
                                {
                                    new LineSegment(cellNorthWest, true),
                                    new LineSegment(cellNorthEast, true),
                                    new LineSegment(cellSouthEast, true)
                                };

                                figures.Add(new PathFigure(cellSouthWest, segments, true));
                            }            
                            
                            var geo = new PathGeometry(figures, FillRule.Nonzero, null);
                            geo.GetOutlinedPathGeometry();                            
                            groupdc.DrawGeometry(RadarBrushes.WalkableTerrain, null, geo);                            
                        }
   
                        // Have to use SceneHash as key because scenes can appear multiple times with the same name
                        Drawings.Relative.TryAdd(scene.SceneHash, new RelativeDrawing
                        {
                            Drawing = drawing,
                            Origin = CenterActor.Morph,
                            Center = scene.Center,
                            WorldId = scene.WorldDynamicId
                        });
                    }                  
                }

                foreach (var pair in Drawings.Relative)
                {
                    if (pair.Value.WorldId != CacheManager.WorldDynamicId)
                        continue;

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

                    dc.DrawDrawing(pair.Value.Drawing);
                }

            }
            catch (Exception ex)
            {
                Logger.Log("Exception in RadarUI.DrawScenes(). {0} {1}", ex.Message, ex.InnerException);
            }            
        }
开发者ID:artious,项目名称:unifiedTrinity-2.x.x,代码行数:74,代码来源:RadarCanvas.cs


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