Example #1
0
        /// <summary>
        /// 图像上绘制剖面图对应的直线
        /// </summary>
        /// <param name="canvas"></param>
        /// <param name="drawArgs"></param>
        private void DrawProfileLine(ICanvas canvas, IDrawArgs drawArgs)
        {
            if (_iserror)
            {
                return;
            }
            Graphics      g     = drawArgs.Graphics as Graphics;
            SmoothingMode smode = g.SmoothingMode;

            try
            {
                g.SmoothingMode = SmoothingMode.AntiAlias;
                int x, y;
                ICoordinateTransform coordTran = canvas.CoordTransform;
                coordTran.Prj2Screen(_beginPoint.PrjX, _beginPoint.PrjY, out x, out y);
                _vertices[0].X = x;
                _vertices[0].Y = y;
                if (!_endPoint.IsEmpty)
                {
                    coordTran.Prj2Screen(_endPoint.PrjX, _endPoint.PrjY, out x, out y);
                    _vertices[1].X = x;
                    _vertices[1].Y = y;
                }
                else if (!_mousePoint.IsEmpty)
                {
                    coordTran.Prj2Screen(_mousePoint.PrjX, _mousePoint.PrjY, out x, out y);
                    if (x == _vertices[0].X && y == _vertices[0].Y)
                    {
                        return;
                    }
                    if (MathHelp.DistanceLessThan(_vertices[0].X, _vertices[0].Y, x, y, 4))
                    {
                        return;
                    }
                    _vertices[1].X = x;
                    _vertices[1].Y = y;
                }
                g.DrawLines(_pofileLinePen, _vertices);
                g.FillEllipse(_profileRectangleBrush, new RectangleF(_vertices[0].X - 2, _vertices[0].Y - 2, 4, 4));    //端点
            }
            catch (Exception ex)
            {
                _iserror = true;
                SizeF      fontSize = g.MeasureString(ex.Message, _labelFont);
                RectangleF fontRect = new RectangleF(canvas.Container.Width - fontSize.Width - offsetToTopAndLeft, offsetToTopAndLeft, fontSize.Width, fontSize.Height);
                g.DrawString(ex.Message, _labelFont, _profileRectangleBrush, fontRect);
            }
            finally
            {
                g.SmoothingMode = smode;
            }
        }
Example #2
0
        public void Render(object sender, IDrawArgs drawArgs)
        {
            //左上角绘制信息列表
            if (_infoItems.Count == 0)
            {
                return;
            }
            Graphics g        = drawArgs.Graphics as Graphics;
            float    x        = 50;
            float    y        = 10;
            SizeF    fontSize = g.MeasureString("100", _font);
            int      rowStep  = (int)(fontSize.Height + 2);

            foreach (InfoItem item in _infoItems)
            {
                g.DrawString(item.ToString(), _font, Brushes.Yellow, x, y);
                y += rowStep;
            }

            ICanvas canvas = sender as ICanvas;

            if (_visible)
            {
                ICoordinateTransform coordTran = canvas.CoordTransform;
                QuickTransform       qt        = drawArgs.QuickTransformArgs;
                //绘制拐点
                foreach (InfoItem item in _infoItems)
                {
                    int    row = 0, col = 0;
                    double geoX, geoY;
                    coordTran.Geo2Prj(item.Longitude, item.Latitude, out geoX, out geoY);
                    coordTran.Prj2Screen(geoX, geoY, out col, out row);
                    g.FillEllipse(Brushes.Yellow, new RectangleF(col - 3, row - 3, 6, 6));
                }
                //绘制冰缘线
                if (_geoItems != null)
                {
                    foreach (CodeCell.AgileMap.Core.Feature items in _geoItems)
                    {
                        GraphicsPath path = ToGraphicsPath(items, canvas);
                        g.DrawPath(Pens.Red, path);
                    }
                }
            }
        }
Example #3
0
        public void Render(object sender, IDrawArgs drawArgs)
        {
            if (!_visible)
            {
                return;
            }
            ICanvas canvas = sender as ICanvas;
            ICoordinateTransform coordTran = canvas.CoordTransform;
            QuickTransform       qt        = drawArgs.QuickTransformArgs;
            Graphics             g         = drawArgs.Graphics as Graphics;

            g.SmoothingMode = SmoothingMode.AntiAlias;
            Brush blue = new SolidBrush(Color.FromArgb(60, 0, 0, 255));

            Pen bluePen = new Pen(Color.Blue, 2F);
            Pen redPen  = new Pen(Color.Red, 3F);

            redPen.DashStyle = DashStyle.Dot;
            Brush redBrush            = new SolidBrush(Color.Red);
            Brush yelloBrush          = new SolidBrush(Color.Yellow);
            Font  font                = new Font("微软雅黑", 10.0f);
            SizeF distanceFontSize    = g.MeasureString("12111.0", font);
            Brush textBackgroundBrush = new SolidBrush(Color.FromArgb(100, 250, 250, 250));
            Pen   textBackUpPen       = new Pen(Color.FromArgb(125, 125, 125));

            if (_previousParts != null && _previousParts.Count > 0)
            {
                GraphicsPath previous = new GraphicsPath();
                previous.FillMode = FillMode.Winding;
                for (int i = 0; i < _previousParts.Count; i++)
                {
                    List <PointF>     points = new List <PointF>();
                    List <CoordPoint> part   = _previousParts[i];
                    for (int j = 0; j < part.Count; j++)
                    {
                        int col = 0, row = 0;
                        coordTran.Prj2Screen(part[j].X, part[j].Y, out col, out row);
                        points.Add(new PointF(col, row));
                    }
                    g.DrawLines(bluePen, points.ToArray());
                    for (int j = 0; j < points.Count; j++)
                    {
                        g.FillEllipse(yelloBrush, new RectangleF(points[j].X - 3, points[j].Y - 3, 6, 6));
                        if (j == 0)
                        {
                            SizeF textRect = g.MeasureString("起点", font);
                            g.FillRectangle(textBackgroundBrush, points[j].X + 5, points[j].Y - distanceFontSize.Height / 2, textRect.Width, textRect.Height);
                            g.DrawRectangle(textBackUpPen, points[j].X + 5, points[j].Y - distanceFontSize.Height / 2, textRect.Width, textRect.Height);
                            g.DrawString("起点", font, redBrush, points[j].X + 5, points[j].Y - distanceFontSize.Height / 2);
                        }
                        else if (j == _previousDistances[i].Length - 1)
                        {
                            SizeF textRect = g.MeasureString("总长" + FormatDistance(_previousDistances[i][j]), font);
                            g.FillRectangle(textBackgroundBrush, points[j].X + 5, points[j].Y - distanceFontSize.Height / 2, textRect.Width, textRect.Height);
                            g.DrawRectangle(textBackUpPen, points[j].X + 5, points[j].Y - distanceFontSize.Height / 2, textRect.Width, textRect.Height);
                            g.DrawString("总长" + FormatDistance(_previousDistances[i][j]), font, redBrush, points[j].X + 5, points[j].Y - distanceFontSize.Height / 2);
                        }
                        else
                        {
                            SizeF textRect = g.MeasureString(FormatDistance(_previousDistances[i][j]), font);
                            g.FillRectangle(textBackgroundBrush, points[j].X + 5, points[j].Y - distanceFontSize.Height / 2, textRect.Width, textRect.Height);
                            g.DrawRectangle(textBackUpPen, points[j].X + 5, points[j].Y - distanceFontSize.Height / 2, textRect.Width, textRect.Height);
                            g.DrawString(FormatDistance(_previousDistances[i][j]), font, redBrush, points[j].X + 5, points[j].Y - distanceFontSize.Height / 2);
                        }
                    }
                }
            }

            List <PointF> curpoints = new List <PointF>();

            if (_coordinates != null)
            {
                int srceenX = 0, srceenY = 0;
                for (int j = 0; j < _coordinates.Count; j++)
                {
                    coordTran.Prj2Screen(_coordinates[j].X, _coordinates[j].Y, out srceenX, out srceenY);
                    curpoints.Add(new PointF(srceenX, srceenY));
                }
                if (curpoints.Count > 1)
                {
                    g.DrawLines(bluePen, curpoints.ToArray());
                    for (int j = 0; j < curpoints.Count; j++)
                    {
                        PointF pt = curpoints[j];
                        g.FillRectangle(redBrush, new RectangleF(pt.X - 2.5f, pt.Y - 2.5f, 5f, 5f));
                        if (j == 0)
                        {
                            g.DrawString("起点", font, redBrush, pt.X + 5, pt.Y - distanceFontSize.Height / 2);
                        }
                        else
                        {
                            g.DrawString(FormatDistance(_curDistances[j]), font, redBrush, pt.X + 5, pt.Y - distanceFontSize.Height / 2);
                        }
                    }
                }

                if (curpoints.Count > 0 && _mouseDistance > 0)// && _standBy == false && hasMouse)
                {
                    g.DrawLine(redPen, curpoints[curpoints.Count - 1], _mousePosition);
                    SizeF size = g.MeasureString("文字", font);
                    g.DrawString(string.Format("{0}", FormatDistance(_mouseDistance)), font, redBrush, _mousePosition.X + 2, _mousePosition.Y + size.Height);
                    g.DrawString("双击结束", font, redBrush, _mousePosition.X + 2, _mousePosition.Y + size.Height + size.Height);
                    //if (_areaMode && points.Count > 1)
                    //{
                    //    g.DrawLine(redPen, points[0], _mousePosition);
                    //}
                }
                //if (points.Count > 1 && _areaMode && (_previousParts == null || _previousParts.Count == 0))
                //{
                //    if (hasMouse && !_standBy)
                //    {
                //        points.Add(_mousePosition);
                //    }

                //    if (points.Count > 2)
                //    {
                //        g.FillPolygon(blue, points.ToArray());
                //    }
                //}
            }
            bluePen.Dispose();
            redPen.Dispose();
            redBrush.Dispose();
            yelloBrush.Dispose();
            font.Dispose();
            textBackgroundBrush.Dispose();
            textBackUpPen.Dispose();
        }