Пример #1
0
        /// <summary>
        /// 图例
        /// </summary>
        public void DrawLegendColorBar()
        {
            if (TableValue == null)
            {
                return;
            }
            int cellWidth  = 12;
            int cellHeight = 1;

            LineCoordConverter pixeToInputValConverter = new LineCoordConverter(SizeOfLegendColorBar.Height, this.TableValue.ValueSpan.Span);

            for (int i = 0; i < SizeOfLegendColorBar.Height; i++)
            {
                var val   = pixeToInputValConverter.GetNew(i) + this.TableValue.ValueSpan.Start; //像素,转换到原始数据,以获取颜色
                var color = ColorBuilder.Build(val);
                //转回平面坐标
                var pt    = OriginOfLengendColorBar + new Size(0, i);
                var scrPt = UserToScreenCoordConverter.GetScreenCoord(pt);

                ChartGraphics.DrawColorPoint(scrPt, cellWidth, cellHeight, color);
            }
            //绘制文字
            ChartGraphics.DrawLabel(Geo.Utils.StringUtil.FillSpaceLeft(this.TableValue.ValueSpan.Start.ToString("0.00"), 6), OriginOfLengendColorBar - new Size(30, 20), 0);
            ChartGraphics.DrawLabel(Geo.Utils.StringUtil.FillSpaceLeft(this.TableValue.ValueSpan.End.ToString("0.00"), 6),
                                    OriginOfLengendColorBar + new Size(-30, SizeOfLegendColorBar.Height + 20), 0);
        }
Пример #2
0
        /// <summary>
        /// 输入原始数据转换为屏幕坐标
        /// </summary>
        /// <param name="xy"></param>
        /// <returns></returns>
        private Point InputToScreenPt(XY xy)
        {
            var userCoord = InputToUserCoord(xy);
            var scrPt     = UserToScreenCoordConverter.GetScreenCoord(userCoord);

            return(scrPt);
        }
Пример #3
0
        /// <summary>
        /// 绘制带
        /// </summary>
        /// <param name="pen"></param>
        /// <param name="yCoord"></param>
        /// <param name="xCoords"></param>
        /// <param name="height"></param>
        public void DarwBelt(Pen pen, int yCoord, int[] xCoords, int height = 5)
        {
            var y     = UserToScreenCoordConverter.GetScreenY(yCoord);
            var xList = new List <int>();

            foreach (var item in xCoords)
            {
                var x = UserToScreenCoordConverter.GetScreenX(item);
                xList.Add(x);
            }
            int halfHeight = height / 2;

            foreach (var item in xCoords)
            {
                var pt  = new Point(item, yCoord - halfHeight);
                var pt2 = new Point(item, yCoord + halfHeight);
                DrawLine(pen, pt, pt2);
            }
        }
Пример #4
0
        /// <summary>
        /// 通过鼠标滚轮实现图的缩放
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void pictureBox1_MouseWheel(object sender, MouseEventArgs e)
        {
            var location          = UserToScreenCoordConverter.GetUserCoord(e.Location);
            int userX             = location.X;
            var epoch             = GetEpcohNumber(userX);
            int toStartEpochCount = epoch - MinEpoch;
            int toEndEpochCount   = MaxEpoch - epoch;

            if (e.Delta > 0)
            {
                toStartEpochCount = toStartEpochCount / 2;
                toEndEpochCount   = toEndEpochCount / 2;
            }
            else
            {
                toStartEpochCount = toStartEpochCount * 2;
                toEndEpochCount   = toEndEpochCount * 2;
            }


            this.MinEpoch = epoch - toStartEpochCount;
            this.MaxEpoch = epoch + toEndEpochCount;
            //合法性设置
            if (this.MinEpoch < 0)
            {
                this.MinEpoch = 0;
            }
            if (this.MaxEpoch > this.DataTable.Rows.Count)
            {
                this.MaxEpoch = this.DataTable.Rows.Count;
            }
            if (this.MaxEpoch == 0)
            {
                this.MaxEpoch = 1;
            }
            if (this.MinEpoch >= MaxEpoch)
            {
                this.MinEpoch = MaxEpoch - 1;
            }

            Draw();
        }
Пример #5
0
        /// <summary>
        /// 绘制标签
        /// </summary>
        /// <param name="label"></param>
        /// <param name="pt"></param>
        /// <param name="font"></param>
        /// <param name="brush"></param>
        /// <param name="format"></param>
        /// <param name="degree"></param>
        public void DrawLabel(string label, Point pt, Font font = null, Brush brush = null, StringFormat format = null, float degree = 0)
        {
            if (font == null)
            {
                font = DefaultFont;
            }
            if (brush == null)
            {
                brush = DefaultBrush;
            }

            var screenPt = UserToScreenCoordConverter.GetScreenCoord(pt);

            //  g.DrawString(label, font, brush, screenPt);
            // 绘制围绕点旋转的文本
            if (format == null)
            {
                format = DefaultStringFormat;
            }
            GraphicsText.Graphics = Graphics;
            GraphicsText.DrawString(label, font, brush, screenPt, format, degree);
        }
Пример #6
0
        /// <summary>
        /// 绘制线条。连续绘制
        /// </summary>
        /// <param name="pen"></param>
        /// <param name="pts"></param>
        public void DrawLine(Pen pen, params Point[] pts)
        {
            List <Point> screentPts = new List <Point>();

            foreach (var item in pts)
            {
                screentPts.Add(UserToScreenCoordConverter.GetScreenCoord(item));
            }

            Point current = Point.Empty;

            foreach (var p in screentPts)
            {
                if (current == Point.Empty)
                {
                    current = p;
                    continue;
                }

                g.DrawLine(pen, current, p);
                current = p;
            }
        }
Пример #7
0
        /// <summary>
        /// 绘图
        /// </summary>
        /// <param name="geoCoords"></param>
        public Bitmap Draw(List <GeoCoord> geoCoords)
        {
            if (ChartSize.Width == 0 || ChartSize.Height == 0)
            {
                return(null);
            }

            Bitmap   bmp = new Bitmap(ChartSize.Width, ChartSize.Height);;
            Graphics g   = Graphics.FromImage(bmp);

            g.Clear(Color.White);

            this.UserToScreenCoordConverter = new ScreenCoordConverter(this.ChartSize);
            this.GeoCoords     = new GeoCoords(geoCoords);
            this.ChartGraphics = new Geo.Draw.UserChartGraphics(UserToScreenCoordConverter, g);

            InputToContentCoordConverter = new PlainCoordConverter(this.GeoCoords.Size, this.ChartSize, GeoCoords.CoordFrom);
            //var ColorBuilder = new TwoStepColorBuilder(this.GeoCoords.HeightSpan, Color.Blue, Color.Yellow, Color.Red);
            var ColorBuilder = new ThreeStepColorBuilder(this.GeoCoords.HeightSpan, Color.Blue, Color.Cyan, Color.Yellow, Color.Red);
            int cellWidth    = (int)Math.Ceiling(InputToContentCoordConverter.XConverter.Factor * GeoCoords.LonInterval);

            cellWidth = cellWidth < 1 ? 1 : cellWidth;
            int cellHeight = (int)Math.Ceiling(InputToContentCoordConverter.YConverter.Factor * GeoCoords.LatInterval);

            cellHeight = cellHeight < 1 ? 1 : cellHeight;
            foreach (var geoCoord in geoCoords)
            {
                var xy    = new XY(geoCoord.Lon, geoCoord.Lat);
                var pt    = InputToContentCoordConverter.GetNewPoint(xy);
                var scrPt = UserToScreenCoordConverter.GetScreenCoord(pt);

                var color = ColorBuilder.Build(geoCoord.Height);
                ChartGraphics.DrawColorPoint(scrPt, cellWidth, cellHeight, color);
            }
            return(bmp);
            //    UserChartGraphics.DrawGrid(new Pen(new SolidBrush(Color.FromArgb(100, 100, 100))), 10, 10, Origin, this.ScreenCoordArea.RightTop);
        }
Пример #8
0
        /// <summary>
        /// 内容坐标转换为屏幕坐标。
        /// </summary>
        /// <param name="xy"></param>
        /// <returns></returns>
        private Envelope ContentToScreenCoord(Envelope contentCoord)
        {
            var userCoord = ContentToUserCoordConverter.GetNew(contentCoord);

            return(UserToScreenCoordConverter.ToScreenCoord(userCoord));
        }
Пример #9
0
        /// <summary>
        /// 内容坐标转换为屏幕坐标。
        /// </summary>
        /// <param name="xy"></param>
        /// <returns></returns>
        private Point ContentToScreenCoord(XY contentCoord)
        {
            var userCoord = ContentToUserCoordConverter.GetNewPoint(contentCoord);

            return(UserToScreenCoordConverter.GetScreenCoord(userCoord));
        }