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;
        }
Exemplo n.º 2
0
        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;
        }
Exemplo n.º 3
0
		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));
				}
			}
		}
Exemplo n.º 4
0
        /// <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);
            }
        }
        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);
            }
        }
Exemplo n.º 6
0
		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);
		}
Exemplo n.º 7
0
        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);
                    }
                }
            }
        }
Exemplo n.º 8
0
 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);
         }
     }
 }
Exemplo n.º 9
0
		/// <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();}
			//-----------------------------------
		}
Exemplo n.º 10
0
		/// <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;
            }
		}
        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));
            }
        }
        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;
        }
        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;
        }
Exemplo n.º 14
0
        /// <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) //终点
                                    {
                                        Bitmap b = type == 0 ? Properties.BMap.ico_bybus : Properties.BMap.ico_bysubway; //0公交 1地铁轻轨

                                        g.DrawImage(b, new Rectangle(s_second.X - b.Width / 2, s_second.Y - b.Height / 2, b.Width, b.Height));
                                    }

                                }
                            }
                        }
                    }
                }
                else if (Type == RouteType.Driving) //驾车
                {
                    using (Pen p = new Pen(Color.FromArgb(250, Color.Green), 6)) //绿色 
                    {
                        p.StartCap = System.Drawing.Drawing2D.LineCap.Round; //连接圆滑
                        p.EndCap = System.Drawing.Drawing2D.LineCap.Round;
                        p.LineJoin = System.Drawing.Drawing2D.LineJoin.Round;
                        foreach (JObject step in DataSource["steps"])
                        {
                            first = new LatLngPoint(double.Parse((string)step["stepOriginLocation"]["lng"]), double.Parse((string)step["stepOriginLocation"]["lat"]));
                            s_first = MapHelper.GetScreenLocationByLatLng(first, center, zoom, screen_size); //第一点

                            string[] points = ((string)step["path"]).Split(';'); //每一步骤中的点
                            for (int i = 0; i < points.Length; ++i)
                            {
                                if (i == 0) //与前一点连接
                                {
                                    second = new LatLngPoint(double.Parse(points[i].Split(',')[0]), double.Parse(points[i].Split(',')[1]));
                                    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);
                                }
                                else
                                {
                                    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);
                                }
                            }
                            s_first = s_second;

                            second = new LatLngPoint(double.Parse((string)step["stepDestinationLocation"]["lng"]), double.Parse((string)step["stepDestinationLocation"]["lat"]));
                            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);  //最后一点
                        }
                    }
                }
                else //步行
                {
                    using (Pen p = new Pen(Color.FromArgb(250, Color.Gray), 6)) //灰色 
                    {
                        p.StartCap = System.Drawing.Drawing2D.LineCap.Round; //连接圆滑
                        p.EndCap = System.Drawing.Drawing2D.LineCap.Round;
                        p.LineJoin = System.Drawing.Drawing2D.LineJoin.Round;
                        foreach (JObject step in DataSource["steps"])
                        {
                            first = new LatLngPoint(double.Parse((string)step["stepOriginLocation"]["lng"]), double.Parse((string)step["stepOriginLocation"]["lat"]));
                            s_first = MapHelper.GetScreenLocationByLatLng(first, center, zoom, screen_size); //第一点

                            string[] points = ((string)step["path"]).Split(';'); //每一步骤中的点
                            for (int i = 0; i < points.Length; ++i)
                            {
                                if (i == 0) //与前一点连接
                                {
                                    second = new LatLngPoint(double.Parse(points[i].Split(',')[0]), double.Parse(points[i].Split(',')[1]));
                                    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);
                                }
                                else
                                {
                                    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);
                                }
                            }
                            s_first = s_second;

                            second = new LatLngPoint(double.Parse((string)step["stepDestinationLocation"]["lng"]), double.Parse((string)step["stepDestinationLocation"]["lat"]));
                            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 (HighlightPath != null)
                {
                    using (Pen p3 = new Pen(Color.FromArgb(250, Color.Red), 6))
                    {
                        p3.StartCap = System.Drawing.Drawing2D.LineCap.Round; //连接圆滑
                        p3.EndCap = System.Drawing.Drawing2D.LineCap.Round;
                        p3.LineJoin = System.Drawing.Drawing2D.LineJoin.Round;
                        string[] points = HighlightPath.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(p3, s_first, s_second);
                        }
                    }
                }
            }
        }
Exemplo n.º 15
0
		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;
		}
Exemplo n.º 16
0
        public override bool GdiDrawString(
            System.Drawing.Graphics pGraphics,
            LOGFONT pLogFont,
            string pszText,
            System.Drawing.Point ptDraw)
        {
            using (GraphicsPath pPath = new GraphicsPath(System.Drawing.Drawing2D.FillMode.Winding))
            {
                bool b = GDIPath.GetStringPath(
                    pGraphics,
                    pPath,
                    pszText,
                    pLogFont,
                    ptDraw);

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

                for (int i = 1; i <= m_nThickness; ++i)
                {
                    using (Pen pen = new Pen(m_clrOutline, 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;
        }
 internal static void DrawDropShadow(System.Drawing.Graphics graphics, System.Drawing.Rectangle bounds, int radius, System.Drawing.Color color)
 {
     graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
     using (System.Drawing.Brush brush = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(color.A / 4, color.R, color.G, color.B)))
     {
         for (int i = 0; i < 4; i++)
         {
             bounds.Inflate(-1, -1);
             using (System.Drawing.Drawing2D.GraphicsPath graphicsPath = Skybound.VisualTips.Rendering.VisualTipRenderer.CreateRoundRectPath(bounds, radius, Skybound.VisualTips.Rendering.VisualTipRenderer.BorderCorners.All))
             {
                 graphics.FillPath(brush, graphicsPath);
             }
         }
     }
     graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;
 }
Exemplo n.º 18
0
        /// <summary>
        /// Fill a closed path composed of several drawing operations
        /// </summary>
        /// <param name="canvas"></param>
        public void Fill(System.Drawing.Graphics canvas)
        {
            System.Drawing.Drawing2D.GraphicsPath path;

            path = new System.Drawing.Drawing2D.GraphicsPath();
            for (int i = 0; i < m_drawings.Count; i++)
            {
                switch (m_drawings[i].Type)
                {
                    case DrawingType.Line:
                    {
                        path.AddLine(m_drawings[i].Points[0].x, m_drawings[i].Points[0].y, m_drawings[i].Points[1].x, m_drawings[i].Points[1].y);
                        break;
                    }
                    case DrawingType.Arc:
                    {
                        double	startAngle, endAngle;

                        startAngle = System.Math.Atan2(m_drawings[i].Points[2].y - (m_drawings[i].Points[1].y + m_drawings[i].Points[0].y) / 2, m_drawings[i].Points[2].x - (m_drawings[i].Points[1].x + m_drawings[i].Points[0].x) / 2);
                        if (startAngle < 0)
                        {
                            startAngle += System.Math.PI * 2;
                        }
                        startAngle = (startAngle / Math.PI) * 180;

                        endAngle = System.Math.Atan2(m_drawings[i].Points[3].y - (m_drawings[i].Points[1].y + m_drawings[i].Points[0].y) / 2, m_drawings[i].Points[3].x - (m_drawings[i].Points[1].x + m_drawings[i].Points[0].x) / 2);
                        if (endAngle < 0)
                        {
                            endAngle += System.Math.PI * 2;
                        }
                        endAngle = (endAngle / Math.PI) * 180;

                        path.AddArc(m_drawings[i].Points[0].x, m_drawings[i].Points[0].y, m_drawings[i].Points[1].x - m_drawings[i].Points[0].x, m_drawings[i].Points[1].y - m_drawings[i].Points[0].y, (float)startAngle, Math.Abs((float)(endAngle - startAngle)));
                        break;
                    }
                    case DrawingType.Bezier:
                    {
                        path.AddBezier(m_drawings[i].Points[0].x, m_drawings[i].Points[0].y, m_drawings[i].Points[2].x, m_drawings[i].Points[2].y, m_drawings[i].Points[3].x, m_drawings[i].Points[3].y, m_drawings[i].Points[1].x, m_drawings[i].Points[1].y);
                        break;
                    }
                }
            }

            canvas.FillPath(m_style.fillingStyle, path);
        }
Exemplo n.º 19
0
        public void Draw(System.Drawing.Graphics gc, Render.RenderParameter r, Render.RenderHint editState, Render.IDrawVisitor drawMethods, PointD mousePosition)
        {
            if (m_Param.Path != null && m_Param.Path.PointCount >= 2)
            {
                try
                {
                    if (m_visibleThickPath != null)
                    {
                        if (r.RegionInsideFill != null)
                            gc.FillPath(r.RegionInsideFill, m_visibleThickPath);
                        gc.DrawPath(r.RegionOutline, m_visibleThickPath);
                    }
                    gc.DrawPath(r.RegionOutline, (Tools.Model.VectorPath)m_Param.Path);
                }
                catch
                {
                    // don't know what happened here
                }

                if (editState ==  Render.RenderHint.Start)
                {
                    Pen dashPen = (Pen)r.RegionOutline.Clone();
                    dashPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
                    if (m_Param.Path.PointCount > 0)
                    {
                        PointD firstPoint = mousePosition; // TODO ((States.LineHover)editState).FirstPoint;
                        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);
                    }

                    /*
                    PointD normal;
                    double radius;
                    NormalOfPoint(mousePosition, out normal, out radius);
                    gc.DrawLine(r.ActivePen, (Point)mousePosition, (Point)(mousePosition - normal * radius));
                     */

                }
                else
                {
                    DrawArrowForces(gc, r, drawMethods);
                }

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

            }
        }
Exemplo n.º 20
0
        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;
                }

                if (m_bClrText)
                {
                    using (SolidBrush brush = new SolidBrush(m_clrText))
                    {
                        pGraphics.FillPath(brush, pPath);
                    }
                }
                else
                {
                    pGraphics.FillPath(m_brushText, pPath);
                }
            }
            return true;
        }
Exemplo n.º 21
0
        /// <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, SharpMap.Geometries.Polygon pol, System.Drawing.Brush brush, System.Drawing.Pen pen, bool clip, SharpMap.Map map)
        {
            if (pol.ExteriorRing == null)
                return;
            if (pol.ExteriorRing.Vertices.Count > 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(pol.ExteriorRing.TransformToImage(map));
                else
                    gp.AddPolygon(clipPolygon(pol.ExteriorRing.TransformToImage(map), map.Size.Width, map.Size.Height));

                //Add the interior polygons (holes)
                for (int i = 0; i < pol.InteriorRings.Count; i++)
                    if (!clip)
                        gp.AddPolygon(pol.InteriorRings[i].TransformToImage(map));
                    else
                        gp.AddPolygon(clipPolygon(pol.InteriorRings[i].TransformToImage(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);
            }
        }
Exemplo n.º 22
0
        void DrawTab(System.Drawing.Graphics g, TabVS2005 tab)
        {
            var rectTabOrigin = GetTabRectangle(tab);
            if (rectTabOrigin.IsEmpty)
                return;

            var dockState = tab.Content.DockHandler.DockState;
            var content = tab.Content;

            var path = GetTabOutline(tab, false, true);

            var startColor = DockPanel.Skin.AutoHideStripSkin.TabGradient.StartColor;
            var endColor = DockPanel.Skin.AutoHideStripSkin.TabGradient.EndColor;
            var gradientMode = DockPanel.Skin.AutoHideStripSkin.TabGradient.LinearGradientMode;
            g.FillPath(new LinearGradientBrush(rectTabOrigin, startColor, endColor, gradientMode), path);
            g.DrawPath(PenTabBorder, path);

            // Set no rotate for drawing icon and text
            var matrixRotate = g.Transform;
            g.Transform = MatrixIdentity;

            // Draw the icon
            var rectImage = rectTabOrigin;
            rectImage.X += ImageGapLeft;
            rectImage.Y += ImageGapTop;
            var imageHeight = rectTabOrigin.Height - ImageGapTop - ImageGapBottom;
            var imageWidth = ImageWidth;
            if (imageHeight > ImageHeight)
                imageWidth = ImageWidth * (imageHeight / ImageHeight);
            rectImage.Height = imageHeight;
            rectImage.Width = imageWidth;
            rectImage = GetTransformedRectangle(dockState, rectImage);
            g.DrawIcon(((Form)content).Icon, RtlTransform(rectImage, dockState));

            // Draw the text
            var rectText = rectTabOrigin;
            rectText.X += ImageGapLeft + imageWidth + ImageGapRight + TextGapLeft;
            rectText.Width -= ImageGapLeft + imageWidth + ImageGapRight + TextGapLeft;
            rectText = RtlTransform(GetTransformedRectangle(dockState, rectText), dockState);

            var textColor = DockPanel.Skin.AutoHideStripSkin.TabGradient.TextColor;

            if (dockState == DockState.DockLeftAutoHide || dockState == DockState.DockRightAutoHide)
                g.DrawString(content.DockHandler.TabText, TextFont, new SolidBrush(textColor), rectText, StringFormatTabVertical);
            else
                g.DrawString(content.DockHandler.TabText, TextFont, new SolidBrush(textColor), rectText, StringFormatTabHorizontal);

            // Set rotate back
            g.Transform = matrixRotate;
        }
 protected override void Draw(System.Drawing.Graphics dc, string title, string text, Rectangle rect, Rectangle titleRect, Rectangle bodyRect, Image img, int iconWidth)
 {
     Rectangle borderRect = new Rectangle(rect.X + borderThickness / 2, rect.Y + borderThickness / 2, rect.Width - borderThickness, rect.Height - borderThickness);
     dc.FillPath(backBrush, GetCapsule(borderRect, CornerRadius));
     dc.DrawPath(borderPen, GetCapsule(borderRect, CornerRadius));
     StringFormat format = new StringFormat(StringFormatFlags.NoWrap);
     format.Trimming = StringTrimming.EllipsisCharacter;
     dc.DrawString(title, titleFont, titleForeBrush,
         new RectangleF(Padding.Left + iconWidth, Padding.Top, Math.Min(titleRect.Width, bodyRect.Width), titleRect.Height), format);
     dc.DrawString(text, font, foreBrush,
         new RectangleF(Padding.Left + iconWidth, Padding.Top + titleRect.Height, bodyRect.Width, bodyRect.Height),
         new StringFormat());
 }
        /// <summary>
        /// Replaces the drawing code so that the polygon characteristics are more evident.
        /// </summary>
        /// <param name="g"></param>
        /// <param name="target"></param>
        public override void Draw(System.Drawing.Graphics g, System.Drawing.Rectangle target)
        {
            GraphicsPath gp = new GraphicsPath();
            gp.AddRectangle(target);
            g.FillPath(FillBrush, gp);

            if (_borderIsVisible)
            {
                g.SmoothingMode = _borderSymbolizer.Smoothing ? SmoothingMode.AntiAlias : SmoothingMode.None;
                const double width = 1;
                if (_borderSymbolizer.ScaleMode == ScaleModes.Geographic)
                {
                    // TO DO: Geographic Scaling
                }
                foreach (IStroke stroke in _borderSymbolizer.Strokes)
                {
                    stroke.DrawPath(g, gp, width);
                }
               
            }
           
            gp.Dispose();
           
            
        }
Exemplo n.º 25
0
        private void PaintTabBackground(System.Drawing.Graphics graph, int index, System.Drawing.Drawing2D.GraphicsPath path)
        {
            Rectangle rect = this.GetTabRect(index);

            if (rect.Height > 1 && rect.Width > 1)
            {
                System.Drawing.Brush buttonBrush = new System.Drawing.Drawing2D.LinearGradientBrush(rect, SystemColors.ControlLightLight, SystemColors.ControlLight, System.Drawing.Drawing2D.LinearGradientMode.Vertical);

                if (index == this.SelectedIndex)
                {
                    buttonBrush = new System.Drawing.SolidBrush(SystemColors.ControlLightLight);
                }

                graph.FillPath(buttonBrush, path);
                buttonBrush.Dispose();
            }
        }
Exemplo n.º 26
0
		private static System.Object mutex_TabRect_DrawTabRect = new System.Object[0];						// 1.0.003
		internal static void TabRect_DrawTabRect(															// 1.0.003
			TdhTabCtl theTabCtl, 																	// 1.0.003
			System.Drawing.Point ptMouse, 																	// 1.0.003
			System.Windows.Forms.TabPage theTabPage, int idxTabPage, bool asActive, 						// 1.0.010
			System.Drawing.Graphics gfx, System.Drawing.RectangleF tabRectDraw 								// 1.0.003
		)																									// 1.0.003
		{																									// 1.0.003
			lock (mutex_TabRect_DrawTabRect)								// Just-in-case					// 1.0.003
			{																								// 1.0.003
				#region Draw the TabRect Background and Buttons
				System.Drawing.Drawing2D.GraphicsPath _Path = new System.Drawing.Drawing2D.GraphicsPath();
				_Path.AddRectangle(tabRectDraw);
				using (
					System.Drawing.Drawing2D.LinearGradientBrush _Brush = 
						new System.Drawing.Drawing2D.LinearGradientBrush(
						tabRectDraw, 
						System.Drawing.SystemColors.Control, 
						System.Drawing.SystemColors.ControlLight, 
						System.Drawing.Drawing2D.LinearGradientMode.Vertical) 
						)
				{
					if (asActive)							// Is this the active TabPage?					// 1.0.003
					{																						// 1.0.003						
						#region Draw the TabRect background (active TabPage)
						System.Drawing.Drawing2D.ColorBlend _ColorBlend = new System.Drawing.Drawing2D.ColorBlend(3);
						_ColorBlend.Colors = new System.Drawing.Color[]
							{
								//System.Drawing.SystemColors.ControlLightLight, 
								//System.Drawing.Color.FromArgb(255, System.Drawing.SystemColors.Control), 
								//System.Drawing.SystemColors.ControlLight, 
								//System.Drawing.SystemColors.Control

//								System.Drawing.SystemColors.ControlLightLight,								// 1.0.001
//								//System.Drawing.Color.FromArgb(255, System.Drawing.SystemColors.ControlLight),// 1.0.001
//								System.Drawing.SystemColors.ControlLight,									// 1.0.001
//								System.Drawing.SystemColors.ControlDark,									// 1.0.001
//								System.Drawing.SystemColors.ControlLightLight								// 1.0.001

								System.Drawing.Color.FromArgb(255, 170, 213, 243),							// 1.0.001
								System.Drawing.Color.FromArgb(255, 170, 213, 243),							// 1.0.001
								System.Drawing.Color.FromArgb(255, 170, 213, 243),							// 1.0.001
								//System.Drawing.Color.FromArgb(255, 44, 137, 191),							// 1.0.001
								System.Drawing.Color.FromArgb(255, 44, 137, 191)							// 1.0.001
							};
						_ColorBlend.Positions = new float[] { 0f, .4f, 0.5f, 1f };
						_Brush.InterpolationColors = _ColorBlend;
						gfx.FillPath(_Brush, _Path);														// 1.0.003
						using (Pen pen = new Pen(SystemColors.ActiveBorder))
						{
							gfx.DrawPath(pen, _Path);														// 1.0.003
						}
						#endregion 
					}																						// 1.0.003
					else																					// 1.0.003
					{																						// 1.0.003
						#region Draw the TabRect background (inactive TabPage)
						ColorBlend _ColorBlend = new ColorBlend(3);
						_ColorBlend.Colors = new System.Drawing.Color[]
							{
								//System.Drawing.SystemColors.ControlLightLight, 
								//System.Drawing.Color.FromArgb(255, System.Drawing.SystemColors.ControlLight), 
								//System.Drawing.SystemColors.ControlDark, 
								//System.Drawing.SystemColors.ControlLightLight 

//								System.Drawing.SystemColors.ControlDarkDark,								// 1.0.001
//								System.Drawing.SystemColors.ControlLightLight,								// 1.0.001
//								System.Drawing.SystemColors.ControlLightLight,								// 1.0.001
//								System.Drawing.SystemColors.ControlLight									// 1.0.001

								System.Drawing.SystemColors.ControlLightLight,								// 1.0.001
								System.Drawing.Color.FromArgb(255, System.Drawing.SystemColors.ControlLight), // 1.0.001
								//System.Drawing.SystemColors.ControlLightLight,							 // 1.0.001
								System.Drawing.SystemColors.ControlLight,									// 1.0.001
								System.Drawing.SystemColors.ControlDark										// 1.0.001
							};
						_ColorBlend.Positions = new float[] { 0f, .4f, 0.5f, 1f };
						_Brush.InterpolationColors = _ColorBlend;
						gfx.FillPath(_Brush, _Path);														// 1.0.003
						using (System.Drawing.Pen pen = new System.Drawing.Pen(System.Drawing.SystemColors.ActiveBorder))
						{
							gfx.DrawPath(pen, _Path);														// 1.0.003
						}
						#endregion 
					}																						// 1.0.003

					#region Draw Buttons this TabRect
					if( (theTabPage.GetType() == typeof(TdhTabPage))								// 1.0.010
						|| theTabPage.GetType().IsSubclassOf(typeof(TdhTabPage))					// 1.0.010
					)																						// 1.0.010
					{																						// 1.0.010
						TabRect_DrawButtons(																// 1.0.001
							theTabCtl, ptMouse,																// 1.0.003
							gfx, 																			// 1.0.003
							tabRectDraw, idxTabPage, asActive, !asActive									// 1.0.003
							);																				// 1.0.001
					}																						// 1.0.010
					#endregion 
				}
				_Path.Dispose();
				#endregion 

				#region Draw [theTabPage.Text] on the TabRect
				int textOffset = 0;																			// 1.0.001
				if (theTabCtl.Font.Size <= 8.25f)		// Size: 8											// 1.0.003
				{																							// 1.0.001
					textOffset = 5;																			// 1.0.001
				}																							// 1.0.001
				else																						// 1.0.001
				if (theTabCtl.Font.Size <= 9f)			// Size: 9											// 1.0.003
				{																							// 1.0.001
					textOffset = 4;																			// 1.0.001
				}																							// 1.0.001
				else																						// 1.0.001
				if (theTabCtl.Font.Size <= 9.75f)		// Size: 10											// 1.0.003
				{																							// 1.0.001
					textOffset = 3;																			// 1.0.001
				}																							// 1.0.001
				else																						// 1.0.001
				if (theTabCtl.Font.Size < 11.25f)		// Size: 11											// 1.0.003
				{																							// 1.0.001
					textOffset = 2;																			// 1.0.001
				}																							// 1.0.001
				else																						// 1.0.001
				if (theTabCtl.Font.Size < 12f)			// Size: 12											// 1.0.003
				{																							// 1.0.001
					textOffset = 1;																			// 1.0.001
				}																							// 1.0.001
				System.Drawing.RectangleF textRect = new System.Drawing.RectangleF(							// 1.0.001
					tabRectDraw.X,																			// 1.0.001
					tabRectDraw.Y + textOffset,																// 1.0.001
					tabRectDraw.Width,																		// 1.0.001
					tabRectDraw.Height - textOffset);														// 1.0.001

				string str = " "+ theTabPage.Text.Trim();													// 1.0.010
				System.Drawing.StringFormat stringFormat = new System.Drawing.StringFormat();
				stringFormat.Alignment = System.Drawing.StringAlignment.Near;								// 1.0.001
				gfx.DrawString(																				// 1.0.003
					str, 
					theTabCtl.Font,																			// 1.0.003
					new System.Drawing.SolidBrush(theTabPage.ForeColor),									// 1.0.010
					textRect,																				// 1.0.001
					stringFormat);
				#endregion 
			}																								// 1.0.003
		}																									// 1.0.003
Exemplo n.º 27
0
		/// <summary>This method will paint the group title.</summary>
		/// <param name="g">The paint event graphics object.</param>
		private void PaintGroupText(System.Drawing.Graphics g)
		{
			//Check if string has something-------------
			if(this.GroupTitle==string.Empty){return;}
			//------------------------------------------

			//Set Graphics smoothing mode to Anit-Alias-- 
			g.SmoothingMode = SmoothingMode.AntiAlias;
			//-------------------------------------------

			//Declare Variables------------------
			SizeF StringSize = g.MeasureString(this.GroupTitle, this.Font);
			Size StringSize2 = StringSize.ToSize();
			if(this.GroupImage!=null){StringSize2.Width+=18;}
			int ArcWidth = this.RoundCorners;
			int ArcHeight = this.RoundCorners;
			int ArcX1 = 20;
			int ArcX2 = (StringSize2.Width+34) - (ArcWidth + 1);
			int ArcY1 = 0;
			int ArcY2 = 24 - (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 = (this.PaintGroupBox) ? new SolidBrush(this.CustomGroupBoxColor) : new SolidBrush(this.BackgroundColor);
			System.Drawing.SolidBrush TextColorBrush = new SolidBrush(this.ForeColor);
			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-1), ArcY1+(this.ShadowThickness-1), ArcWidth, ArcHeight, 180, Tools.GroupBoxConstants.SweepAngle); // Top Left
                ShadowPath.AddArc(ArcX2 + (this.ShadowThickness - 1), ArcY1 + (this.ShadowThickness - 1), ArcWidth, ArcHeight, 270, Tools.GroupBoxConstants.SweepAngle); //Top Right
                ShadowPath.AddArc(ArcX2 + (this.ShadowThickness - 1), ArcY2 + (this.ShadowThickness - 1), ArcWidth, ArcHeight, 360, Tools.GroupBoxConstants.SweepAngle); //Bottom Right
                ShadowPath.AddArc(ArcX1 + (this.ShadowThickness - 1), ArcY2 + (this.ShadowThickness - 1), 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.PaintGroupBox)
			{
				//Paint Rounded Rectangle------------
				g.FillPath(BackgroundBrush, path);
				//-----------------------------------
			}
			else
			{
				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);
			//-----------------------------------

			//Paint Text-------------------------
			int CustomStringWidth = (this.GroupImage!=null) ? 44 : 28;
			g.DrawString(this.GroupTitle, this.Font, TextColorBrush, CustomStringWidth, 5);
			//-----------------------------------

			//Draw GroupImage if there is one----
			if(this.GroupImage!=null)
			{
				g.DrawImage(this.GroupImage, 28,4, 16, 16);
			}
			//-----------------------------------

			//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(TextColorBrush!=null){TextColorBrush .Dispose();}
			if(ShadowBrush!=null){ShadowBrush.Dispose();}
			if(ShadowPath!=null){ShadowPath.Dispose();}
			//-----------------------------------
		}
Exemplo n.º 28
0
 /// <summary>
 /// Fills the interior of a rounded rectangle.
 /// </summary>
 public static void FillRoundedRectangle(System.Drawing.Graphics graphics, Brush brush, int x, int y, int width, int height, int radius)
 {
     using (GraphicsPath path = GetRoundedRectanglePath(x, y, width, height, radius))
     {
         graphics.FillPath(brush, path);
     }
 }
Exemplo n.º 29
0
		protected internal void DrawInsertMarker(System.Drawing.Graphics g)
		{
            IOwner owner = GetOwner() as IOwner;
            if (m_DesignInsertMarker == eDesignInsertPosition.None || !this.Visible || !this.Displayed || !(owner != null && owner.DragInProgress || this.DesignMode))
                return;

            Color lineColor = ColorScheme.GetColor("834DD5");
            Color fillColor = ColorScheme.GetColor("CCCFF8");

            int size = 4;
            int lineThickness = 1;
            int padding = 2;

			if(IsDesignMarkHorizontal)
			{
                Point start = new Point(m_Rect.X, m_Rect.Y + padding), end = new Point(m_Rect.X, m_Rect.Bottom - (padding + 1));
                if (m_DesignInsertMarker == eDesignInsertPosition.After)
                {
                    start = new Point(m_Rect.Right - size * 2, m_Rect.Y + padding);
                    end = new Point(m_Rect.Right - size * 2, m_Rect.Bottom - (padding+1));
                }

                using (SolidBrush fillBrush = new SolidBrush(fillColor))
                {
                    using (Pen pen = new Pen(lineColor, 1))
                    {
                        using (GraphicsPath path = new GraphicsPath())
                        {
                            path.AddLine(start.X, start.Y + size, start.X + size, start.Y);
                            path.AddLine(start.X + size * 2, start.Y + size, start.X + (size * 2 - (size - lineThickness)), start.Y + size);
                            path.AddLine(end.X + (size * 2 - (size - lineThickness)), end.Y - size, end.X + size * 2, end.Y - size);
                            path.AddLine(end.X + size, end.Y, end.X, end.Y - size);
                            path.AddLine(end.X + (size - lineThickness), end.Y - size, start.X + (size - lineThickness), start.Y + size);
                            path.CloseAllFigures();

                            g.FillPath(fillBrush, path);
                            g.DrawPath(pen, path);
                        }
                    }
                }
			}
			else
			{
                Point start = new Point(m_Rect.X + padding, m_Rect.Y), end = new Point(m_Rect.Right - (padding+1), m_Rect.Y);
                if (m_DesignInsertMarker == eDesignInsertPosition.After)
                {
                    start = new Point(m_Rect.X + padding, m_Rect.Bottom - (size * 2 + 1));
                    end = new Point(m_Rect.Right - (padding + 1), m_Rect.Bottom - (size * 2 + 1));
                }

                using (SolidBrush fillBrush = new SolidBrush(fillColor))
                {
                    using (Pen pen = new Pen(lineColor, 1))
                    {
                        using (GraphicsPath path = new GraphicsPath())
                        {
                            path.AddLine(start.X, start.Y + size, start.X + size, start.Y);
                            path.AddLine(start.X + size, start.Y + (size - lineThickness), end.X - size, end.Y + (size - lineThickness));
                            path.AddLine(end.X - size, end.Y, end.X, end.Y + size);
                            path.AddLine(end.X - size, end.Y + size * 2, end.X - size, end.Y + (size*2 - (size-padding)));
                            path.AddLine(start.X + size, start.Y + (size * 2 - (size - padding)), start.X + size, start.Y + size * 2);

                            path.CloseAllFigures();

                            g.FillPath(fillBrush, path);
                            g.DrawPath(pen, path);
                        }
                    }
                }
                //if(m_DesignInsertMarker==eDesignInsertPosition.Before)
                //{
                //    p[0].X=m_Rect.Left+1;
                //    p[0].Y=m_Rect.Top;
                //    p[1].X=m_Rect.Left+1;
                //    p[1].Y=m_Rect.Top+4;
                //    g.DrawLines(pen,p);

                //    p[0].X=m_Rect.Left+1;
                //    p[0].Y=m_Rect.Top+2;
                //    p[1].X=m_Rect.Right-1;
                //    p[1].Y=m_Rect.Top+2;
                //    g.DrawLines(pen,p);

                //    p[0].X=m_Rect.Right-1;
                //    p[0].Y=m_Rect.Top;
                //    p[1].X=m_Rect.Right-1;
                //    p[1].Y=m_Rect.Top+4;
                //    g.DrawLines(pen,p);
                //}
                //else
                //{
                //    p[0].X=m_Rect.Left+1;
                //    p[0].Y=m_Rect.Bottom-4;
                //    p[1].X=m_Rect.Left+1;
                //    p[1].Y=m_Rect.Bottom;
                //    g.DrawLines(pen,p);

                //    p[0].X=m_Rect.Left+1;
                //    p[0].Y=m_Rect.Bottom-2;
                //    p[1].X=m_Rect.Right-1;
                //    p[1].Y=m_Rect.Bottom-2;
                //    g.DrawLines(pen,p);

                //    p[0].X=m_Rect.Right-1;
                //    p[0].Y=m_Rect.Bottom-4;
                //    p[1].X=m_Rect.Right-1;
                //    p[1].Y=m_Rect.Bottom;
                //    g.DrawLines(pen,p);
                //}
			}
            //g.SmoothingMode = sm;
		}
Exemplo n.º 30
0
        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;
                }

                using (Pen pen2 = new Pen(m_clrOutline2, m_nThickness1 + m_nThickness2))
                {
                    pen2.LineJoin = LineJoin.Round;
                    pGraphics.DrawPath(pen2, pPath);
                }
                using (Pen pen1 = new Pen(m_clrOutline1, m_nThickness1))
                {
                    pen1.LineJoin = LineJoin.Round;
                    pGraphics.DrawPath(pen1, pPath);
                }

                if (m_bClrText)
                {
                    using (SolidBrush brush = new SolidBrush(m_clrText))
                    {
                        pGraphics.FillPath(brush, pPath);
                    }
                }
                else
                {
                    pGraphics.FillPath(m_brushText, pPath);
                }
            }
            return true;
        }