示例#1
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);
            }
        }
示例#2
0
 public void draw(System.Drawing.Graphics g)
 {
     g.TranslateTransform(this.x, this.y);
     g.RotateTransform(rotation);
     g.DrawImage(canon, (0 - canon.Width / 2), (0 - canon.Height / 2), canon.Width, canon.Height);
     g.ResetTransform();
 }
示例#3
0
        /// <summary>
        /// Renders a point to the map.
        /// </summary>
        /// <param name="g">Graphics reference</param>
        /// <param name="point">Point to render</param>
        /// <param name="symbol">Symbol to place over point</param>
        /// <param name="symbolscale">The amount that the symbol should be scaled. A scale of '1' equals to no scaling</param>
        /// <param name="offset">Symbol offset af scale=1</param>
        /// <param name="rotation">Symbol rotation in degrees</param>
        /// <param name="map">Map reference</param>
        public static void DrawPoint(System.Drawing.Graphics g, SharpMap.Geometries.Point point, System.Drawing.Bitmap symbol, float symbolscale, System.Drawing.PointF offset, float rotation, SharpMap.Map map)
        {
            if (point == null)
                return;
            if (symbol == null) //We have no point style - Use a default symbol
                symbol = defaultsymbol;
            System.Drawing.PointF pp = SharpMap.Utilities.Transform.WorldtoMap(point, map);

            if (rotation != 0 && rotation != float.NaN)
            {
                g.TranslateTransform(pp.X, pp.Y);
                g.RotateTransform(rotation);
                g.TranslateTransform(-symbol.Width / 2, -symbol.Height / 2);
                if (symbolscale == 1f)
                    g.DrawImageUnscaled(symbol, (int)(pp.X - symbol.Width / 2 + offset.X), (int)(pp.Y - symbol.Height / 2 + offset.Y));
                else
                {
                    float width = symbol.Width * symbolscale;
                    float height = symbol.Height * symbolscale;
                    g.DrawImage(symbol, (int)pp.X - width / 2 + offset.X * symbolscale, (int)pp.Y - height / 2 + offset.Y * symbolscale, width, height);
                }
                g.Transform = map.MapTransform;
            }
            else
            {
                if (symbolscale == 1f)
                    g.DrawImageUnscaled(symbol, (int)(pp.X - symbol.Width / 2 + offset.X), (int)(pp.Y - symbol.Height / 2 + offset.Y));
                else
                {
                    float width = symbol.Width * symbolscale;
                    float height = symbol.Height * symbolscale;
                    g.DrawImage(symbol, (int)pp.X - width / 2 + offset.X * symbolscale, (int)pp.Y - height / 2 + offset.Y * symbolscale, width, height);
                }
            }
        }
        public override void PrintLabel(System.Drawing.Graphics g, Invoice temp_invoice, Parcel p)
        {
            Font font1 = new Font("Verdana", 18, FontStyle.Bold);
            Font font2 = new Font("Verdana", 10, FontStyle.Regular);
            Font font3 = new Font("3 of 9 Barcode", 22, FontStyle.Regular);
            Font font4 = new Font("Verdana", 8, FontStyle.Regular);
            Pen pen1 = new Pen(Brushes.Black);

            int x = 55;//10
            int y = -350;//-290
            int x1;
            int x2;
            int y1;
            int y2;

            g.RotateTransform(90);

            //company name
            g.DrawString(temp_invoice.CompanyName, font1, Brushes.Black, x, y);

            //company information
            x = x + 5;//15
            g.DrawString("ABN   " + temp_invoice.CompanyABN, font4, Brushes.Black, x, y + 30);
            g.DrawString("Return Address:", font4, Brushes.Black, x, y + 45);
            g.DrawString(temp_invoice.CompanyAddress, font4, Brushes.Black, x, y + 60);

            //order information
            g.DrawString("Inv. No.: " + temp_invoice.InvoiceNo, font2, Brushes.Black, x, y + 80);
            //g.DrawString("Run: " + temp_state + " " + "", font2, Brushes.Black, x + 220, y + 80);

            //order barcode
            g.DrawString("*" + temp_invoice.InvoiceNo + "*", font3, Brushes.Black, x, y + 100);

            //draw box of customer information
            g.DrawString("DELIVERED TO:", font2, Brushes.Black, x, y + 140);
            x = x + 10;//25
            x1 = x - 5;
            x2 = x1 + 460;//315
            y1 = y + 165;
            y2 = y1 + 110;
            //top
            g.DrawLine(pen1, x1, y1, x2, y1);
            //left
            g.DrawLine(pen1, x1, y1, x1, y2);
            //right
            g.DrawLine(pen1, x2, y1, x2, y2);
            //buttom
            g.DrawLine(pen1, x1, y2, x2, y2);
            //customer name
            g.DrawString(temp_invoice.InvoiceCustomer.Greeting, font2, Brushes.Black, x, y + 170);
            //customer address
            g.DrawString(temp_invoice.InvoiceCustomer.Address1, font2, Brushes.Black, x, y + 195);//190
            g.DrawString(temp_invoice.InvoiceCustomer.Address2, font2, Brushes.Black, x, y + 220);//210
            //g.DrawString(temp_address3, font2, Brushes.Black, x, y + 230);//230
            g.DrawString(temp_invoice.InvoiceCustomer.City, font2, Brushes.Black, x, y + 250);

            x = x + 210;//235
            x = x + 135;//430
            //state symbol
            g.DrawString("", font2, Brushes.Black, x + 5, y + 220);
            g.DrawString(temp_invoice.InvoiceCustomer.State, font2, Brushes.Black, x, y + 245);

            x = x + 50;//285 ->430
            //postcode
            g.DrawString(temp_invoice.InvoiceCustomer.Postcode, font2, Brushes.Black, x, y + 245);
            x = x - 135;

            x = x + 70;//355
            //barcode of postcode
            g.DrawString("*" + temp_invoice.InvoiceCustomer.Postcode + "*", font3, Brushes.Black, x + 5, y + 5);

            //draw POSTAGE PAID AUSTRALIA
            //g.DrawImage(global::BL_AU_PrintingLabelSystem.Properties.Resources.postage_paid_australia, x, 60);
            x1 = x + 13;
            x2 = x1 + 100;
            y1 = y + 40;//70
            y2 = y1 + 100;
            //top
            g.DrawLine(pen1, x1, y1, x2, y1);
            //left
            g.DrawLine(pen1, x1, y1, x1, y2);
            //right
            g.DrawLine(pen1, x2, y1, x2, y2);
            //buttom
            g.DrawLine(pen1, x1, y2, x2, y2);
            g.DrawString("POSTAGE", font2, Brushes.Black, x + 25, y + 55);//y85
            g.DrawString("PAID", font2, Brushes.Black, x + 43, y + 80);//y110
            g.DrawString("AUSTRALIA", font2, Brushes.Black, x + 20, y + 105);//y135
        }
示例#5
0
        internal static void RenderVerticalText(
            System.Drawing.Graphics g,
            string text,
            Rectangle textRect,
            Font textFont,
            Color foreColor,
            StringFormat format,
            bool left)
        {
            if (string.IsNullOrEmpty(text))
            {
                return;
            }

            if (left)
            {
                g.TranslateTransform(textRect.X, textRect.Bottom);
                g.RotateTransform(270F);
            }
            else
            {
                g.TranslateTransform(textRect.Right, textRect.Y);
                g.RotateTransform(90F);
            }

            Rectangle transformRect = new Rectangle(
                0, 0, textRect.Height, textRect.Width);

            try
            {
                using (Brush brush = new SolidBrush(foreColor))
                {
                    g.DrawString(
                        text,
                        textFont,
                        brush,
                        transformRect,
                        format);
                }
            }
            finally
            {
                g.ResetTransform();
            }
        }
        /// <summary>
        /// Draw an arc on the canvas
        /// </summary>
        /// <param name="canvas">The canvas on which the arc is drawn</param>
        public void Draw(System.Drawing.Graphics canvas)
        {
            System.Drawing.Drawing2D.Matrix	matrix;
            double	startAngle, endAngle;

            matrix = canvas.Transform;

            canvas.TranslateTransform((m_points[0].x + m_points[1].x) / 2, (m_points[0].y + m_points[1].y) / 2);
            canvas.RotateTransform((float)(m_rotateAngle / System.Math.PI * 180));

            if (m_points[2].Equals(m_points[3]))
            {
                canvas.DrawEllipse(m_style.drawingStyle, -(m_points[1].x - m_points[0].x) / 2, -(m_points[1].y - m_points[0].y) / 2, m_points[1].x - m_points[0].x, m_points[1].y - m_points[0].y);
            }
            else
            {
                startAngle = System.Math.Atan2(m_points[2].y - (m_points[1].y + m_points[0].y) / 2, m_points[2].x - (m_points[1].x + m_points[0].x) / 2);
                if (startAngle < 0)
                {
                    startAngle += System.Math.PI * 2;
                }
                startAngle = (startAngle / Math.PI) * 180;

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

                endAngle -= startAngle;
                if (endAngle < 0)
                {
                    endAngle += 360;
                }

                canvas.DrawArc(m_style.drawingStyle, -(m_points[1].x - m_points[0].x) / 2, -(m_points[1].y - m_points[0].y) / 2, m_points[1].x - m_points[0].x, m_points[1].y - m_points[0].y, (float)startAngle, (float)endAngle);
            }

            canvas.Transform = matrix;
        }
        public void DrawSelected(System.Drawing.Graphics canvas, System.Drawing.Pen BoundingBoxPen, System.Drawing.Pen ResizeBoxPen, System.Drawing.Pen ConnectBoxPen, System.Drawing.Pen ControlBoxPen)
        {
            System.Drawing.Drawing2D.Matrix	orgTrans = canvas.Transform;
            System.Drawing.RectangleF		rc;

            rc = this.BoundingBox;

            canvas.TranslateTransform(this.xOffset, this.yOffset);
            canvas.TranslateTransform((rc.Left + rc.Right) / 2, (rc.Top + rc.Bottom) / 2);
            canvas.RotateTransform(this.rotation);
            canvas.TranslateTransform(-(rc.Left + rc.Right) / 2, -(rc.Top + rc.Bottom) / 2);

            for (int i = 0; i < rgObjects.Count; i++)
            {
                rgObjects[i].Draw(canvas, false);
            }

            canvas.DrawRectangle(BoundingBoxPen, rc.X - 3, rc.Y - 3, rc.Width + 6, rc.Height + 6);

            canvas.DrawRectangle(ResizeBoxPen, rc.X - 5, rc.Y - 5, 4, 4);
            canvas.DrawRectangle(ResizeBoxPen, rc.X - 5, rc.Bottom + 1, 4, 4);
            canvas.DrawRectangle(ResizeBoxPen, rc.Right + 1, rc.Y - 5, 4, 4);
            canvas.DrawRectangle(ResizeBoxPen, rc.Right + 1, rc.Bottom + 1, 4, 4);

            canvas.DrawEllipse(ControlBoxPen, (rc.Left + rc.Right) / 2 - 3, rc.Y - 30, 6, 6);
            canvas.DrawLine(ControlBoxPen, (rc.Left + rc.Right) / 2, rc.Y - 5, (rc.Left + rc.Right) / 2, rc.Y - 24);

            canvas.DrawRectangle(ConnectBoxPen, rc.X - 5, (rc.Top + rc.Bottom) / 2 - 2, 4, 4);
            canvas.DrawRectangle(ConnectBoxPen, (rc.Left + rc.Right) / 2 - 2, rc.Bottom + 1, 4, 4);
            canvas.DrawRectangle(ConnectBoxPen, (rc.Left + rc.Right) / 2 - 2, rc.Y - 5, 4, 4);
            canvas.DrawRectangle(ConnectBoxPen, rc.Right + 1, (rc.Top + rc.Bottom) / 2 - 2, 4, 4);

            canvas.Transform = orgTrans;
        }
        public void Draw(System.Drawing.Graphics canvas, bool ShowConnectPoint)
        {
            System.Drawing.Drawing2D.Matrix	orgTrans	= canvas.Transform;
            System.Drawing.RectangleF		rc			= this.BoundingBox;

            canvas.TranslateTransform(this.xOffset, this.yOffset);
            canvas.TranslateTransform((rc.Left + rc.Right) / 2, (rc.Top + rc.Bottom) / 2);
            canvas.RotateTransform(this.rotation);
            canvas.TranslateTransform(-(rc.Left + rc.Right) / 2, -(rc.Top + rc.Bottom) / 2);

            for (int i = 0; i < rgObjects.Count; i++)
            {
                rgObjects[i].Draw(canvas, false);
            }

            if (ShowConnectPoint)
            {
                System.Drawing.Pen ConnectBoxPen;

                ConnectBoxPen = new System.Drawing.Pen(System.Drawing.Color.Gray, 1);
                ConnectBoxPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;

                canvas.DrawRectangle(ConnectBoxPen, rc.X - 5, (rc.Top + rc.Bottom) / 2 - 2, 4, 4);
                canvas.DrawRectangle(ConnectBoxPen, (rc.Left + rc.Right) / 2 - 2, rc.Bottom + 1, 4, 4);
                canvas.DrawRectangle(ConnectBoxPen, (rc.Left + rc.Right) / 2 - 2, rc.Y - 5, 4, 4);
                canvas.DrawRectangle(ConnectBoxPen, rc.Right + 1, (rc.Top + rc.Bottom) / 2 - 2, 4, 4);
            }

            canvas.Transform = orgTrans;
        }
        public void DrawSelected(System.Drawing.Graphics canvas, System.Drawing.Pen BoundingBoxPen, System.Drawing.Pen ResizeBoxPen, System.Drawing.Pen ConnectBoxPen, System.Drawing.Pen ControlBoxPen)
        {
            System.Drawing.Drawing2D.Matrix	orgTrans	= canvas.Transform;
            System.Drawing.RectangleF		rc			= this.BoundingBox;

            canvas.TranslateTransform(this.xOffset, this.yOffset);
            canvas.TranslateTransform((rc.Left + rc.Right) / 2, (rc.Top + rc.Bottom) / 2);
            canvas.RotateTransform(this.rotation);
            canvas.TranslateTransform(-(rc.Left + rc.Right) / 2, -(rc.Top + rc.Bottom) / 2);

            System.Drawing.Brush brush = new System.Drawing.SolidBrush(System.Drawing.Color.Blue);
            canvas.FillEllipse(brush, m_point.x - 3, m_point.y - 3, 6, 6);

            canvas.Transform = orgTrans;
        }
        public void Draw(System.Drawing.Graphics canvas, bool ShowConnectPoint)
        {
            System.Drawing.Drawing2D.Matrix	orgTrans	= canvas.Transform;
            System.Drawing.RectangleF		rc			= this.BoundingBox;

            canvas.TranslateTransform(this.xOffset, this.yOffset);
            canvas.TranslateTransform((rc.Left + rc.Right) / 2, (rc.Top + rc.Bottom) / 2);
            canvas.RotateTransform(this.rotation);
            canvas.TranslateTransform(-(rc.Left + rc.Right) / 2, -(rc.Top + rc.Bottom) / 2);

            System.Drawing.Brush brush = new System.Drawing.SolidBrush(System.Drawing.Color.Gray);
            canvas.FillEllipse(brush, m_point.x - 3, m_point.y - 3, 6, 6);

            canvas.Transform = orgTrans;
        }
示例#11
0
        /// <summary>
        /// Draws link's terminal ponit.
        /// </summary>
        /// <param name="canvas"></param>
        /// <param name="style"></param>
        /// <param name="pt1"></param>
        /// <param name="pt2"></param>
        private void DrawTerminal(System.Drawing.Graphics canvas, GOM_Terminal_Style style, System.Drawing.PointF pt1, System.Drawing.PointF pt2)
        {
            System.Drawing.Drawing2D.Matrix	matrix;
            float angle;

            angle	= (float)(System.Math.Atan2(pt2.Y - pt1.Y, pt2.X - pt1.X) / System.Math.PI) * 180;
            matrix	= canvas.Transform;

            canvas.TranslateTransform(pt1.X, pt1.Y);
            canvas.RotateTransform(angle);
            switch (style)
            {
                case GOM_Terminal_Style.Circle:
                {
                    canvas.FillEllipse(new System.Drawing.SolidBrush(m_drawingStyle.drawingStyle.Color), -5, -5, 10, 10);
                    break;
                }
                case GOM_Terminal_Style.Arrow:
                {
                    canvas.DrawLine(m_drawingStyle.drawingStyle, 0, 0, 10, 5);
                    canvas.DrawLine(m_drawingStyle.drawingStyle, 0, 0, 10, -5);
                    break;
                }
                case GOM_Terminal_Style.Triangle:
                {
                    System.Drawing.Point[] rgPts;

                    rgPts = new System.Drawing.Point[3];
                    rgPts[0].X = 0;
                    rgPts[0].Y = 0;
                    rgPts[1].X = 10;
                    rgPts[1].Y = 5;
                    rgPts[2].X = 10;
                    rgPts[2].Y = -5;

                    canvas.FillPolygon(new System.Drawing.SolidBrush(m_drawingStyle.drawingStyle.Color), rgPts);
                    break;
                }
                case GOM_Terminal_Style.Diamond:
                {
                    System.Drawing.Point[] rgPts;

                    rgPts = new System.Drawing.Point[4];
                    rgPts[0].X = 0;
                    rgPts[0].Y = 0;
                    rgPts[1].X = 5;
                    rgPts[1].Y = 5;
                    rgPts[2].X = 10;
                    rgPts[2].Y = 0;
                    rgPts[3].X = 5;
                    rgPts[3].Y = -5;

                    canvas.FillPolygon(new System.Drawing.SolidBrush(m_drawingStyle.drawingStyle.Color), rgPts);
                    break;
                }
            }
            canvas.Transform = matrix;
        }