Example #1
0
        //fill the marker background
        public override void RenderElement(IRenderable element, Graphics graphics, Render render)
        {
            MarkerBase markerBase = element as MarkerBase;

            graphics.SmoothingMode = markerBase.SmoothingMode;
            if (markerBase.DrawBackground)
            {
                SolidBrush brush;
                brush = new SolidBrush(render.AdjustColor(markerBase.BackColor, 0, markerBase.Opacity));
                graphics.FillPath(brush, markerBase.GetPath());
            }

            base.RenderElement(element, graphics, render);

            //Draw any images and annotations
            if (markerBase.Image != null)
            {
                IFormsRenderer renderer = render.GetRenderer(markerBase.Image);
                renderer.RenderElement(markerBase.Image, graphics, render);
            }
            if (markerBase.Label != null)
            {
                IFormsRenderer renderer = render.GetRenderer(markerBase.Image);
                renderer.RenderElement(markerBase.Label, graphics, render);
            }
        }
Example #2
0
        //fill the marker background
        public override void RenderShadow(IRenderable element, Graphics graphics, Render render)
        {
            MarkerBase markerBase  = element as MarkerBase;
            Layer      layer       = render.CurrentLayer;
            Color      shadowColor = render.AdjustColor(layer.ShadowColor, markerBase.BorderWidth, markerBase.Opacity);

            if (markerBase.DrawBackground)
            {
                SolidBrush brush = new SolidBrush(shadowColor);

                //Draw soft shadows
                if (layer.SoftShadows)
                {
                    shadowColor = Color.FromArgb(10, shadowColor);
                    graphics.CompositingQuality = CompositingQuality.HighQuality;
                    graphics.SmoothingMode      = SmoothingMode.HighQuality;
                }

                graphics.FillPath(brush, markerBase.GetPath());

                if (layer.SoftShadows)
                {
                    graphics.CompositingQuality = render.CompositingQuality;
                    graphics.SmoothingMode      = markerBase.SmoothingMode;
                }
            }

            base.RenderShadow(element, graphics, render);
        }
Example #3
0
        private string ExtractMarkerImplementation(MarkerBase marker, float rotation, bool invert)
        {
            GraphicsPath path = marker.GetPath();

            Matrix     translateMatrix = new Matrix();
            RectangleF rectF           = new RectangleF();

            rectF = path.GetBounds();

            translateMatrix.Translate(-rectF.X, -rectF.Y);
            path.Transform(translateMatrix);
            translateMatrix.Dispose();

            StringBuilder def = new StringBuilder();

            def.Append("<marker id=\"\" viewbox=\"0 0 ");

            //Add viewbox data
            def.Append(XmlConvert.ToString(Math.Round(rectF.Width, 2)));
            def.Append(" ");
            def.Append(XmlConvert.ToString(Math.Round(rectF.Height, 2)));
            def.Append("\" ");

            //Add ref x and y
            if (!invert)
            {
                def.Append("refX=\"");
                def.Append(XmlConvert.ToString(Math.Round(rectF.Width, 2)));
                def.Append("\" ");
            }
            def.Append("refY=\"");
            def.Append(XmlConvert.ToString(Math.Round(rectF.Height / 2, 2)));
            def.Append("\" ");

            //Units
            def.Append("markerUnits=\"strokeWidth\" ");

            //markerWidth and Height
            def.Append("markerWidth=\"");
            def.Append(XmlConvert.ToString(Math.Round(rectF.Width, 2)));
            def.Append("\" ");
            def.Append("markerHeight=\"");
            def.Append(XmlConvert.ToString(Math.Round(rectF.Height, 2)));
            def.Append("\" ");

            //Orient
            def.Append("orient=\"auto\" ");

            //Stroke-width
            def.Append("stroke=\"");
            def.Append(Style.GetCompatibleColor(marker.BorderColor));
            def.Append("\" ");

            //Stroke-width
            def.Append("stroke-width=\"");
            def.Append(XmlConvert.ToString(Math.Round(marker.BorderWidth, 2)));
            def.Append("\" ");

            //Fill
            def.Append("fill=\"");

            if (marker.DrawBackground)
            {
                def.Append(Style.GetCompatibleColor(marker.BackColor));
            }
            else
            {
                def.Append("white");
            }
            def.Append("\" ");

            def.Append(">");

            //Append path
            if (mDefinition == null)
            {
                mDefinition           = new Definition(marker.GetPath());
                mDefinition.IncludeId = false;
            }
            else
            {
                mDefinition.Path = marker.GetPath();
            }

            mDefinition.Rotate(rotation);
            def.Append(mDefinition.ExtractPath());

            //Close tag
            def.Append("</marker>");

            return(def.ToString());
        }
Example #4
0
		private string ExtractMarkerImplementation(MarkerBase marker, float rotation, bool invert)
		{
			GraphicsPath path = marker.GetPath();

			Matrix translateMatrix = new Matrix();
			RectangleF rectF = new RectangleF();

			rectF = path.GetBounds();

			translateMatrix.Translate(-rectF.X, -rectF.Y);
			path.Transform(translateMatrix);
			translateMatrix.Dispose();

			StringBuilder def = new StringBuilder();

			def.Append("<marker id=\"\" viewbox=\"0 0 ");

			//Add viewbox data
			def.Append(XmlConvert.ToString(Math.Round(rectF.Width, 2)));
			def.Append(" ");
			def.Append(XmlConvert.ToString(Math.Round(rectF.Height, 2)));
			def.Append("\" ");
			
			//Add ref x and y
			if (!invert)
			{
				def.Append("refX=\"");
				def.Append(XmlConvert.ToString(Math.Round(rectF.Width, 2)));
				def.Append("\" ");
			}
			def.Append("refY=\"");
			def.Append(XmlConvert.ToString(Math.Round(rectF.Height/2, 2)));
			def.Append("\" ");
			
			//Units
			def.Append("markerUnits=\"strokeWidth\" ");

			//markerWidth and Height
			def.Append("markerWidth=\"");
			def.Append(XmlConvert.ToString(Math.Round(rectF.Width, 2)));
			def.Append("\" ");
			def.Append("markerHeight=\"");
			def.Append(XmlConvert.ToString(Math.Round(rectF.Height, 2)));
			def.Append("\" ");

			//Orient
			def.Append("orient=\"auto\" ");

			//Stroke-width
			def.Append("stroke=\"");
			def.Append(Style.GetCompatibleColor(marker.BorderColor));
			def.Append("\" ");

			//Stroke-width
			def.Append("stroke-width=\"");
			def.Append(XmlConvert.ToString(Math.Round(marker.BorderWidth, 2)));
			def.Append("\" ");

			//Fill
			def.Append("fill=\"");
			
			if (marker.DrawBackground)
			{
				def.Append(Style.GetCompatibleColor(marker.BackColor));
			}
			else
			{
				def.Append("white");
			}
			def.Append("\" ");
			
			def.Append(">");

			//Append path
			if (mDefinition == null)
			{
				mDefinition = new Definition(marker.GetPath());
				mDefinition.IncludeId = false;
			}
			else
			{
				mDefinition.Path = marker.GetPath();
			}

			mDefinition.Rotate(rotation);
			def.Append(mDefinition.ExtractPath());

			//Close tag
			def.Append("</marker>");

			return def.ToString();
		}