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


C# System.FillPath方法代码示例

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


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

示例1: DrawString

        public override bool DrawString(
            System.Drawing.Graphics graphics,
            System.Drawing.FontFamily fontFamily,
            System.Drawing.FontStyle fontStyle,
            int fontSize,
            string strText,
            System.Drawing.Point ptDraw,
            System.Drawing.StringFormat strFormat)
        {
            using (GraphicsPath path = new GraphicsPath())
            {
                path.AddString(strText, fontFamily, (int)fontStyle, fontSize, ptDraw, strFormat);

                if (m_bClrText)
                {
                    using (SolidBrush brush = new SolidBrush(m_clrText))
                    {
                        graphics.FillPath(brush, path);
                    }
                }
                else
                    graphics.FillPath(m_brushText, path);
            }
            return true;
        }
开发者ID:shaovoon,项目名称:outline-text,代码行数:25,代码来源:TextNoOutlineStrategy.cs

示例2: DrawString

        public override bool DrawString(
            System.Drawing.Graphics graphics,
            System.Drawing.FontFamily fontFamily,
            System.Drawing.FontStyle fontStyle,
            int fontSize,
            string strText,
            System.Drawing.Point ptDraw,
            System.Drawing.StringFormat strFormat)
        {
            using (GraphicsPath path = new GraphicsPath())
            {
                path.AddString(strText, fontFamily, (int)fontStyle, fontSize, ptDraw, strFormat);

                using (Pen pen = new Pen(m_clrOutline, m_nThickness))
                {
                    pen.LineJoin = LineJoin.Round;
                    graphics.DrawPath(pen, path);
                }

                if (m_bClrText)
                {
                    using (SolidBrush brush = new SolidBrush(m_clrText))
                    {
                        graphics.FillPath(brush, path);
                    }
                }
                else
                    graphics.FillPath(m_brushText, path);
            }
            return true;
        }
开发者ID:shaovoon,项目名称:outline-text,代码行数:31,代码来源:TextOutlineStrategy.cs

示例3: RenderCell

		protected override void RenderCell(IMapTile tile, System.Drawing.Graphics g, int x, int y)
		{
			XCMapTile mapTile = (XCMapTile)tile;
			if (!blank)
			{
				if (mapTile.Ground != null && this.g.Checked)
					g.FillPath(Brushes["GroundColor"], UpperPath(x,y));

				if (mapTile.North != null && n.Checked)
					g.DrawLine(Pens["NorthColor"], x, y, x + hWidth, y + hHeight);

				if (mapTile.West != null && w.Checked)
					g.DrawLine(Pens["WestColor"], x, y, x - hWidth, y + hHeight);

				if (mapTile.Content != null && c.Checked)
					g.FillPath(Brushes["ContentColor"], LowerPath(x,y));
			}
			else
			{
				if (!mapTile.DrawAbove)
				{
					g.FillPath(System.Drawing.Brushes.DarkGray, UpperPath(x, y));
					g.FillPath(System.Drawing.Brushes.DarkGray, LowerPath(x, y));
				}
			}
		}
开发者ID:pmprog,项目名称:OpenXCOM.Tools,代码行数:26,代码来源:TopViewPanel.cs

示例4: DrawLabel

        /// <summary>
        /// Renders a label to the map.
        /// </summary>
        /// <param name="g">Graphics reference</param>
        /// <param name="LabelPoint">Label placement</param>
        /// <param name="Offset">Offset of label in screen coordinates</param>
        /// <param name="font">Font used for rendering</param>
        /// <param name="forecolor">Font forecolor</param>
        /// <param name="backcolor">Background color</param>
        /// <param name="halo">Color of halo</param>
        /// <param name="rotation">Text rotation in degrees</param>
        /// <param name="text">Text to render</param>
        /// <param name="map">Map reference</param>
        public static void DrawLabel(System.Drawing.Graphics g, System.Drawing.PointF LabelPoint, System.Drawing.PointF Offset, System.Drawing.Font font, System.Drawing.Color forecolor, System.Drawing.Brush backcolor, System.Drawing.Pen halo, float rotation, string text, SharpMap.Map map)
        {
            System.Drawing.SizeF fontSize = g.MeasureString(text, font); //Calculate the size of the text
            LabelPoint.X += Offset.X; LabelPoint.Y += Offset.Y; //add label offset
            if (rotation != 0 && rotation != float.NaN)
            {
                g.TranslateTransform(LabelPoint.X, LabelPoint.Y);
                g.RotateTransform(rotation);
                g.TranslateTransform(-fontSize.Width / 2, -fontSize.Height / 2);
                if (backcolor != null && backcolor != System.Drawing.Brushes.Transparent)
                    g.FillRectangle(backcolor, 0, 0, fontSize.Width * 0.74f + 1f, fontSize.Height * 0.74f);
                System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
                path.AddString(text, font.FontFamily, (int)font.Style, font.Size, new System.Drawing.Point(0, 0), null);
                if (halo != null)
                    g.DrawPath(halo, path);
                g.FillPath(new System.Drawing.SolidBrush(forecolor), path);
                //g.DrawString(text, font, new System.Drawing.SolidBrush(forecolor), 0, 0);
                g.Transform = map.MapTransform;
            }
            else
            {
                if (backcolor != null && backcolor != System.Drawing.Brushes.Transparent)
                    g.FillRectangle(backcolor, LabelPoint.X, LabelPoint.Y, fontSize.Width * 0.74f + 1, fontSize.Height * 0.74f);

                System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();

                path.AddString(text, font.FontFamily, (int)font.Style, font.Size, LabelPoint, null);
                if (halo != null)
                    g.DrawPath(halo, path);
                g.FillPath(new System.Drawing.SolidBrush(forecolor), path);
                //g.DrawString(text, font, new System.Drawing.SolidBrush(forecolor), LabelPoint.X, LabelPoint.Y);
            }
        }
开发者ID:jumpinjackie,项目名称:fdotoolbox,代码行数:46,代码来源:VectorRenderer.cs

示例5: Draw

        public override void Draw(System.Drawing.Graphics gc, Render.RenderParameter r, Render.RenderHint editState, Render.IDrawVisitor drawMethods, PointD mousePosition)
        {
            if (m_Param.Path != null)
            {
                /*if (editState.GetAttributes() == States.StateAttributes.Start)
                {
                    if (r.StrokeFill != null)
                        gc.FillPath(r.StrokeFill, (Tools.Model.VectorPath) m_Param.Path);
                    gc.DrawPath(r.StrokeOutline, (Tools.Model.VectorPath)m_Param.Path);
                }
                else*/ if (editState == Render.RenderHint.Start)
                {
                    Pen dashPen = (Pen)r.StrokeOutline.Clone();
                    dashPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
                    if (m_Param.Path.PointCount > 0)
                    {
                        PointD firstPoint = (PointD)m_Param.Path.GetFirstPoint();
                        gc.DrawEllipse(dashPen, (float)firstPoint.X - Tools.Render.DrawHelper.TARGET_SIZE / 2.0f, (float)firstPoint.Y - Tools.Render.DrawHelper.TARGET_SIZE / 2.0f, (float)Tools.Render.DrawHelper.TARGET_SIZE, (float)Tools.Render.DrawHelper.TARGET_SIZE);

                        if (r.StrokeFill != null)
                            gc.FillPath(r.StrokeFill, (Tools.Model.VectorPath)m_Param.Path);
                        gc.DrawPath(r.StrokeOutline, (Tools.Model.VectorPath)m_Param.Path);

                        DrawRegionRepresentation(gc, r, drawMethods, mousePosition);
                    }
                }
                /*else if (editState.GetAttributes() == States.StateAttributes.Change)
                {
                    drawMethods.DrawNegativeSpace(gc, m_Param, r);
                    drawMethods.DrawPositiveSpace(gc, m_Param, r);
                    if (editState is States.RegionChange)
                    {
                        DrawRegionRepresentation(gc, r, mousePosition);

                        ((States.RegionChange)editState).Handles.DrawHandles(gc, m_Param, r);
                    }
                }*/
                else if (editState == Render.RenderHint.Feedback)
                {
                    drawMethods.DrawNegativeSpace(gc, m_Param.Path.InternalPath, r);
                    drawMethods.DrawPositiveSpace(gc, m_Param.Path.InternalPath, r);
                    if (!(this is ConveyorBeltFilter))
                        DrawRegionRepresentation(gc, r,drawMethods, mousePosition);

                }
                else
                {
                    drawMethods.DrawNegativeSpace(gc, m_Param.Path.InternalPath, r);
                    drawMethods.DrawPositiveSpace(gc, m_Param.Path.InternalPath, r);
                    DrawRegionRepresentation(gc, r, drawMethods, mousePosition);

                        // TODO ((States.IFilterHandles)editState).Handles.DrawHandles(gc, m_Param, r);

                }
                drawMethods.DrawHandles(gc, this, r);
            }
        }
开发者ID:rhfung,项目名称:KinematicTemplates,代码行数:57,代码来源:RegionToolPathFilter.cs

示例6: Render

		public void Render(Character character, System.Drawing.Graphics g, int width, int height)
		{
			//MinimumX = -1000; MaximumX = 1000; GranularityX = 2;

			Width = width - 16; Height = height - 24;
			MinimumY = MaximumY = 0f;
			string[] rotations;
			float[] graphData = BuildGraphData(character, out MinimumY, out MaximumY, out rotations);
			MinimumY = 0f;//(float)Math.Floor(MinimumY / 10f) * 10f;
			MaximumY = 5f;//(float)Math.Ceiling(MaximumY / 10f) * 10f;
			//RangeX = MaximumX - MinimumX;
			//RangeY = MaximumY - MinimumY;
			ConversionX = (width - 16f) / (MaximumX - MinimumX);
			ConversionY = (height - 24f) / (MaximumY - MinimumY);

			PointF[] points = new PointF[graphData.Length + 2];
			points[0] = GetScreenPoint(MinimumX, 0);
			points[points.Length - 1] = GetScreenPoint(MaximumX, 0);
			byte[] types = new byte[points.Length];
			types[0] = (byte)PathPointType.Start;
			types[types.Length - 1] = (byte)PathPointType.Line;
			float x = 0, integralY = 0f; 
			for (int i = 1; i <= graphData.Length; i++)
			{
				x = MinimumX + (float)(i - 1) / (float)GranularityX;
				integralY = 0f;
				if (i < graphData.Length - 1) integralY = (graphData[i] - graphData[i - 1]);
				points[i] = GetScreenPoint(x, integralY);
				types[i] = (byte)PathPointType.Line;
			}

			GraphicsPath pathData = new GraphicsPath(points, types, FillMode.Winding);

			g.FillPath(BrushStat, pathData);
			g.DrawPath(PenStat, pathData);
		}
开发者ID:LucasPeacecraft,项目名称:rawr,代码行数:36,代码来源:StatGraphRenderer.cs

示例7: DrawGradientRoundRect

        internal static void DrawGradientRoundRect(
            System.Drawing.Graphics g,
            Rectangle rect,
            Color begin,
            Color end,
            Color border,
            Color innerBorder,
            Blend blend,
            LinearGradientMode mode,
            int radios,
            RoundStyle roundStyle,
            bool drawBorder,
            bool drawInnderBorder)
        {
            using (GraphicsPath path = GraphicsPathHelper.CreatePath(
                rect, radios, roundStyle, true))
            {
                using (LinearGradientBrush brush = new LinearGradientBrush(
                      rect, begin, end, mode))
                {
                    brush.Blend = blend;
                    g.FillPath(brush, path);
                }

                if (drawBorder)
                {
                    using (Pen pen = new Pen(border))
                    {
                        g.DrawPath(pen, path);
                    }
                }
            }

            if (drawInnderBorder)
            {
                rect.Inflate(-1, -1);
                using (GraphicsPath path = GraphicsPathHelper.CreatePath(
                    rect, radios, roundStyle, true))
                {
                    using (Pen pen = new Pen(innerBorder))
                    {
                        g.DrawPath(pen, path);
                    }
                }
            }
        }
开发者ID:songques,项目名称:CSSIM_Solution,代码行数:46,代码来源:ControlPaintEx.cs

示例8: DrawGlass

 public static void DrawGlass(
    System.Drawing.Graphics g,
     RectangleF glassRect,
     Color glassColor,
     int alphaCenter,
     int alphaSurround)
 {
     using (GraphicsPath path = new GraphicsPath())
     {
         path.AddEllipse(glassRect);
         using (PathGradientBrush brush = new PathGradientBrush(path))
         {
             brush.CenterColor = Color.FromArgb(alphaCenter, glassColor);
             brush.SurroundColors = new Color[] {
                 Color.FromArgb(alphaSurround, glassColor) };
             brush.CenterPoint = new PointF(
                 glassRect.X + glassRect.Width / 2,
                 glassRect.Y + glassRect.Height / 2);
             g.FillPath(brush, path);
         }
     }
 }
开发者ID:songques,项目名称:CSSIM_Solution,代码行数:22,代码来源:ControlPaintEx.cs

示例9: PaintBack

		/// <summary>This method will paint the control.</summary>
		/// <param name="g">The paint event graphics object.</param>
		private void PaintBack(System.Drawing.Graphics g)
		{
			//Set Graphics smoothing mode to Anit-Alias-- 
			g.SmoothingMode = SmoothingMode.AntiAlias;
			//-------------------------------------------

			//Declare Variables------------------
			int ArcWidth = this.RoundCorners * 2;
			int ArcHeight = this.RoundCorners * 2;
			int ArcX1 = 0;
			int ArcX2 = (this.ShadowControl) ? (this.Width - (ArcWidth + 1))-this.ShadowThickness : this.Width - (ArcWidth + 1);
			int ArcY1 = 10;
			int ArcY2 = (this.ShadowControl) ? (this.Height - (ArcHeight + 1))-this.ShadowThickness : this.Height - (ArcHeight + 1);
			System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
			System.Drawing.Brush BorderBrush = new SolidBrush(this.BorderColor);
			System.Drawing.Pen BorderPen = new Pen(BorderBrush, this.BorderThickness);
			System.Drawing.Drawing2D.LinearGradientBrush BackgroundGradientBrush = null;
			System.Drawing.Brush BackgroundBrush = new SolidBrush(this.BackgroundColor);
			System.Drawing.SolidBrush ShadowBrush = null;
			System.Drawing.Drawing2D.GraphicsPath ShadowPath  = null;
			//-----------------------------------

			//Check if shadow is needed----------
			if(this.ShadowControl)
			{
				ShadowBrush = new SolidBrush(this.ShadowColor);
				ShadowPath = new System.Drawing.Drawing2D.GraphicsPath();
                ShadowPath.AddArc(ArcX1 + this.ShadowThickness, ArcY1 + this.ShadowThickness, ArcWidth, ArcHeight, 180, Tools.GroupBoxConstants.SweepAngle); // Top Left
                ShadowPath.AddArc(ArcX2 + this.ShadowThickness, ArcY1 + this.ShadowThickness, ArcWidth, ArcHeight, 270, Tools.GroupBoxConstants.SweepAngle); //Top Right
                ShadowPath.AddArc(ArcX2 + this.ShadowThickness, ArcY2 + this.ShadowThickness, ArcWidth, ArcHeight, 360, Tools.GroupBoxConstants.SweepAngle); //Bottom Right
                ShadowPath.AddArc(ArcX1 + this.ShadowThickness, ArcY2 + this.ShadowThickness, ArcWidth, ArcHeight, 90, Tools.GroupBoxConstants.SweepAngle); //Bottom Left
				ShadowPath.CloseAllFigures();

				//Paint Rounded Rectangle------------
				g.FillPath(ShadowBrush, ShadowPath);
				//-----------------------------------
			}
			//-----------------------------------

			//Create Rounded Rectangle Path------
            path.AddArc(ArcX1, ArcY1, ArcWidth, ArcHeight, 180, Tools.GroupBoxConstants.SweepAngle); // Top Left
            path.AddArc(ArcX2, ArcY1, ArcWidth, ArcHeight, 270, Tools.GroupBoxConstants.SweepAngle); //Top Right
            path.AddArc(ArcX2, ArcY2, ArcWidth, ArcHeight, 360, Tools.GroupBoxConstants.SweepAngle); //Bottom Right
            path.AddArc(ArcX1, ArcY2, ArcWidth, ArcHeight, 90, Tools.GroupBoxConstants.SweepAngle); //Bottom Left
			path.CloseAllFigures(); 
			//-----------------------------------

			//Check if Gradient Mode is enabled--
			if(this.BackgroundGradientMode==GroupBoxGradientMode.None)
			{
				//Paint Rounded Rectangle------------
				g.FillPath(BackgroundBrush, path);
				//-----------------------------------
			}
			else
			{
				BackgroundGradientBrush = new LinearGradientBrush(new Rectangle(0,0,this.Width,this.Height), this.BackgroundColor, this.BackgroundGradientColor, (LinearGradientMode)this.BackgroundGradientMode);
				
				//Paint Rounded Rectangle------------
				g.FillPath(BackgroundGradientBrush, path);
				//-----------------------------------
			}
			//-----------------------------------

			//Paint Borded-----------------------
			g.DrawPath(BorderPen, path);
			//-----------------------------------

			//Destroy Graphic Objects------------
			if(path!=null){path.Dispose();}
			if(BorderBrush!=null){BorderBrush.Dispose();}
			if(BorderPen!=null){BorderPen.Dispose();}
			if(BackgroundGradientBrush!=null){BackgroundGradientBrush.Dispose();}
			if(BackgroundBrush!=null){BackgroundBrush.Dispose();}
			if(ShadowBrush!=null){ShadowBrush.Dispose();}
			if(ShadowPath!=null){ShadowPath.Dispose();}
			//-----------------------------------
		}
开发者ID:BruceNielsen,项目名称:_V4.7-Proxy,代码行数:80,代码来源:Grouper.cs

示例10: DrawPolygon

		/// <summary>
		/// Renders a polygon to the map.
		/// </summary>
		/// <param name="g">Graphics reference</param>
		/// <param name="pol">Polygon to render</param>
		/// <param name="brush">Brush used for filling (null or transparent for no filling)</param>
		/// <param name="pen">Outline pen style (null if no outline)</param>
		/// <param name="clip">Specifies whether polygon clipping should be applied</param>
		/// <param name="map">Map reference</param>
		public static void DrawPolygon(System.Drawing.Graphics g, IPolygon pol, System.Drawing.Brush brush, System.Drawing.Pen pen, bool clip, SharpMap.Map map)
		{
            try
            {
                
			if (pol.Shell == null)
				return;
			if (pol.Shell.Coordinates.Length > 2)
			{
				//Use a graphics path instead of DrawPolygon. DrawPolygon has a problem with several interior holes
				System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();

				//Add the exterior polygon
				if (!clip)
                    gp.AddPolygon(Transform.TransformToImage(pol.Shell, map));
                    //gp.AddPolygon(LimitValues(Transform.TransformToImage(pol.Shell, map), extremeValueLimit));
				else
					gp.AddPolygon(clipPolygon(Transform.TransformToImage(pol.Shell, map), map.Size.Width, map.Size.Height));

				//Add the interior polygons (holes)
				for (int i = 0; i < pol.Holes.Length; i++)
					if (!clip)
                        gp.AddPolygon(Transform.TransformToImage(pol.Holes[i], map));
						//gp.AddPolygon(LimitValues(Transform.TransformToImage(pol.Holes[i], map), extremeValueLimit));
					else
						gp.AddPolygon(clipPolygon(Transform.TransformToImage(pol.Holes[i], map), map.Size.Width, map.Size.Height));

				// Only render inside of polygon if the brush isn't null or isn't transparent
				if (brush != null && brush != System.Drawing.Brushes.Transparent)
					g.FillPath(brush, gp);
				// Create an outline if a pen style is available
				if (pen != null)
					g.DrawPath(pen, gp);
			}
            }
            catch(InvalidOperationException e)
            {
                string str = e.Message;
            }
		}
开发者ID:lishxi,项目名称:_SharpMap,代码行数:49,代码来源:VectorRenderingHelper.cs

示例11: DrawRegionRepresentation

        public override void DrawRegionRepresentation(System.Drawing.Graphics gc, Render.RenderParameter r, Render.IDrawVisitor drawMethods, PointD mousePosition)
        {
            if (m_Param.Path is Tools.Model.BitmapPath)
            {
                gc.DrawImage((Tools.Model.BitmapPath)m_Param.Path, new Point(0, 0));
            }
            else if (m_Param.Path is Tools.Model.VectorPath)
            {
                gc.FillPath(GetBrush(r), (Tools.Model.VectorPath)m_Param.Path);
            }

            if (HitTest(mousePosition))
            {
                gc.DrawString(ToString(), r.FontType, new SolidBrush(r.RegionGuides.Color), new PointF((float)mousePosition.X, (float)mousePosition.Y - 15));
            }
        }
开发者ID:rhfung,项目名称:KinematicTemplates,代码行数:16,代码来源:RegionToolRegionFilter.cs

示例12: DrawString

        public override bool DrawString(
            System.Drawing.Graphics graphics,
            System.Drawing.FontFamily fontFamily,
            System.Drawing.FontStyle fontStyle,
            int fontSize,
            string strText,
            System.Drawing.Point ptDraw,
            System.Drawing.StringFormat strFormat)
        {
            using (GraphicsPath path = new GraphicsPath())
            {
                path.AddString(strText, fontFamily, (int)fontStyle, fontSize, ptDraw, strFormat);

                List<Color> list = new List<Color>();
                CalculateGradient(
                    m_clrOutline1,
                    m_clrOutline2,
                    m_nThickness,
                    list);

                for (int i = m_nThickness; i >= 1; --i)
                {
                    using (Pen pen1 = new Pen(list[i - 1], i))
                    {
                        pen1.LineJoin = LineJoin.Round;
                        graphics.DrawPath(pen1, path);
                    }
                }

                if (m_bClrText)
                {
                    using (SolidBrush brush = new SolidBrush(m_clrText))
                    {
                        graphics.FillPath(brush, path);
                    }
                }
                else
                    graphics.FillPath(m_brushText, path);
            }
            return true;
        }
开发者ID:shaovoon,项目名称:outline-text,代码行数:41,代码来源:TextGradOutlineStrategy.cs

示例13: GdiDrawString

        public override bool GdiDrawString(
            System.Drawing.Graphics pGraphics,
            LOGFONT pLogFont,
            string pszText,
            System.Drawing.Rectangle rtDraw)
        {
            using (GraphicsPath pPath = new GraphicsPath(System.Drawing.Drawing2D.FillMode.Winding))
            {
                bool b = GDIPath.GetStringPath(
                    pGraphics,
                    pPath,
                    pszText,
                    pLogFont,
                    rtDraw);

                if (false == b)
                {
                    return false;
                }

                List<Color> list = new List<Color>();
                CalculateGradient(
                    m_clrOutline1,
                    m_clrOutline2,
                    m_nThickness,
                    list);
                for (int i = m_nThickness; i >= 1; --i)
                {
                    System.Drawing.Color clr = list[i - 1];
                    using (Pen pen = new Pen(clr, i))
                    {
                        pen.LineJoin = LineJoin.Round;
                        pGraphics.DrawPath(pen, pPath);
                    }
                }

                if (m_bClrText)
                {
                    using (SolidBrush brush = new SolidBrush(m_clrText))
                    {
                        pGraphics.FillPath(brush, pPath);
                    }
                }
                else
                {
                    pGraphics.FillPath(m_brushText, pPath);
                }
            }
            return true;
        }
开发者ID:shaovoon,项目名称:outline-text,代码行数:50,代码来源:TextGradOutlineStrategy.cs

示例14: Draw

        /// <summary>
        /// 绘制
        /// </summary>
        /// <param name="g"></param>
        /// <param name="center"></param>
        /// <param name="zoom"></param>
        /// <param name="screen_size"></param>
        public override void Draw(System.Drawing.Graphics g, LatLngPoint center, int zoom, System.Drawing.Size screen_size)
        {
            //不同路线绘制不一样 数据源结构也不一样
            if (DataSource != null)
            {
                g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; //质量优先
                
                LatLngPoint first, second;
                Point s_first = new Point(), s_second = new Point();
                if (Type == RouteType.Transit) //公交
                {
                    using (Pen p = new Pen(Color.FromArgb(250, Color.Blue),6))  //蓝色
                    {
                        p.StartCap = System.Drawing.Drawing2D.LineCap.Round; //连接圆滑
                        p.EndCap = System.Drawing.Drawing2D.LineCap.Round;
                        p.LineJoin = System.Drawing.Drawing2D.LineJoin.Round;
                        JToken route = DataSource["scheme"][0];
                        foreach (JArray array in route["steps"])
                        {
                            if ((string)array[0]["type"] == "5") //步行
                            {
                                using (Pen p2 = new Pen(Color.FromArgb(250, Color.Gray), 6))
                                {
                                    p2.StartCap = System.Drawing.Drawing2D.LineCap.Round; //连接圆滑
                                    p2.EndCap = System.Drawing.Drawing2D.LineCap.Round;
                                    p2.LineJoin = System.Drawing.Drawing2D.LineJoin.Round;

                                    string[] points = ((string)array[0]["path"]).Split(';'); //每一步骤中的点

                                    for (int i = points.Length - 1; i > 0; --i)
                                    {
                                        first = new LatLngPoint(double.Parse(points[i - 1].Split(',')[0]), double.Parse(points[i - 1].Split(',')[1]));
                                        second = new LatLngPoint(double.Parse(points[i].Split(',')[0]), double.Parse(points[i].Split(',')[1]));
                                        s_first = MapHelper.GetScreenLocationByLatLng(first, center, zoom, screen_size);
                                        s_second = MapHelper.GetScreenLocationByLatLng(second, center, zoom, screen_size);
                                        if (new Rectangle(new Point(0, 0), screen_size).Contains(s_first) || new Rectangle(new Point(0, 0), screen_size).Contains(s_second)) //在屏幕范围内
                                            g.DrawLine(p2, s_first, s_second);
                                    }
                                }
                            }
                            else //公交 地铁
                            {
                                string transits = "";
                                double duration = 0;
                                int type = 0;  //公交 还是 地铁
                                string start_name = "";
                                duration = double.Parse((string)array[0]["duration"]);
                                type = int.Parse((string)array[0]["vehicle"]["type"]);
                                start_name = (string)array[0]["vehicle"]["start_name"];
                                foreach (JObject jo in array) //多种方案
                                {
                                    transits += ((string)jo["vehicle"]["name"] + "/");
                                }
                                transits = transits.TrimEnd(new char[] { '/'});
                                //只绘制一个方案即可

                                string[] points = ((string)array[0]["path"]).Split(';'); //每一步骤中的点

                                for (int i = points.Length - 1; i > 0; --i)
                                {
                                    first = new LatLngPoint(double.Parse(points[i - 1].Split(',')[0]), double.Parse(points[i - 1].Split(',')[1]));
                                    second = new LatLngPoint(double.Parse(points[i].Split(',')[0]), double.Parse(points[i].Split(',')[1]));
                                    s_first = MapHelper.GetScreenLocationByLatLng(first, center, zoom, screen_size);
                                    s_second = MapHelper.GetScreenLocationByLatLng(second, center, zoom, screen_size);
                                    if (new Rectangle(new Point(0, 0), screen_size).Contains(s_first) || new Rectangle(new Point(0, 0), screen_size).Contains(s_second)) //在屏幕范围内
                                        g.DrawLine(p, s_first, s_second);

                                    if (i == 1) //起点
                                    {
                                        using (Font f = new Font("微软雅黑", 8))
                                        {
                                            string info = start_name + " 上车\n乘坐" + transits + " \n车程约" + Math.Round(duration / 60, 0) + "分钟";
                                            Size info_size = TextRenderer.MeasureText(info, f);

                                            GraphicsPath pt = new GraphicsPath();

                                            pt.AddPolygon(new Point[] { new Point(s_first.X - info_size.Width / 2 - 5, s_first.Y - 25), 
                                                new Point(s_first.X - info_size.Width / 2 - 5, s_first.Y - 25 - info_size.Height - 10),
                                                new Point(s_first.X + info_size.Width / 2 + 5, s_first.Y - 25 - info_size.Height - 10),
                                                new Point(s_first.X + info_size.Width / 2 + 5,s_first.Y - 25),
                                                    new Point(s_first.X + 8,s_first.Y - 25),
                                                    new Point(s_first.X,s_first.Y-15),
                                                new Point(s_first.X - 8,s_first.Y-25)});
                                            g.FillPath(Brushes.Wheat, pt);
                                            g.DrawPath(Pens.LightGray, pt);
                                            g.DrawString(info, new Font("微软雅黑", 9), Brushes.Black, new PointF(s_first.X - info_size.Width/2, s_first.Y - info_size.Height - 25 - 5));

                                            Bitmap b = type == 0 ? Properties.BMap.ico_bybus : Properties.BMap.ico_bysubway; //0公交 1地铁轻轨

                                            g.DrawImage(b, new Rectangle(s_first.X - b.Width / 2, s_first.Y - b.Height / 2, b.Width, b.Height));
                                        }
                                    }
                                    if (i == points.Length - 1) //终点
//.........这里部分代码省略.........
开发者ID:huaan011,项目名称:BMap.NET,代码行数:101,代码来源:BRoute.cs

示例15: PaintSymbol

		public RectangleF PaintSymbol(System.Drawing.Graphics g, System.Drawing.RectangleF bounds)
		{
			if (_scatterSymbol is NoSymbol)
				return bounds;

			var cachedPathData = new CachedPathData();
			var cachedBrushData = new CachedBrushData();
			var scatterSymbol = CalculateOverriddenScatterSymbol();
			CalculatePaths(scatterSymbol, _symbolSize, ref cachedPathData);
			CalculateBrushes(scatterSymbol, _color, cachedPathData, ref cachedBrushData);

			GraphicsState gs = g.Save();
			g.TranslateTransform(bounds.X + 0.5f * bounds.Width, bounds.Y + 0.5f * bounds.Height);

			if (null != cachedPathData.InsetPath)
				g.FillPath(cachedBrushData.InsetBrush, cachedPathData.InsetPath);

			if (null != cachedPathData.FillPath)
				g.FillPath(cachedBrushData.FillBrush, cachedPathData.FillPath);

			if (null != cachedPathData.FramePath)
				g.FillPath(cachedBrushData.FrameBrush, cachedPathData.FramePath);

			cachedBrushData.Clear();
			cachedPathData.Clear();

			g.Restore(gs);

			if (this.SymbolSize > bounds.Height)
				bounds.Inflate(0, (float)(this.SymbolSize - bounds.Height));

			return bounds;
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:33,代码来源:ScatterPlotStyle.cs


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