コード例 #1
0
ファイル: moMapDrawingTools.cs プロジェクト: IRAN96/MiniTerra
        //采用简单填充符号绘制矩形
        private static void DrawRectangleBySimpleFill(Graphics g, moRectangle extent, double mapScale, double dpm,
                                                      double mpu, moRectangle rectangle, moSimpleFillSymbol symbol)
        {
            double sOffsetX = extent.MinX, sOffsetY = extent.MaxY;  //获取投影坐标系相对屏幕坐标系的平移量
            //(1)转换为屏幕坐标并生成矩形
            Point sTopLeftPoint = new Point(), sBottomRightPoint = new Point();

            sTopLeftPoint.X     = (Int32)((rectangle.MinX - sOffsetX) * mpu / mapScale * dpm);
            sTopLeftPoint.Y     = (Int32)((sOffsetY - rectangle.MaxY) * mpu / mapScale * dpm);
            sBottomRightPoint.X = (Int32)((rectangle.MaxX - sOffsetX) * mpu / mapScale * dpm);
            sBottomRightPoint.Y = (Int32)((sOffsetY - rectangle.MinY) * mpu / mapScale * dpm);
            Int32     sWidth  = sBottomRightPoint.X - sTopLeftPoint.X;
            Int32     sHeight = sBottomRightPoint.Y - sTopLeftPoint.Y;
            Rectangle sRect   = new Rectangle(sTopLeftPoint.X, sTopLeftPoint.Y, sWidth, sHeight);

            //(2)填充
            if (symbol.Color != Color.Transparent)
            {
                SolidBrush sBrush = new SolidBrush(symbol.Color);
                g.FillRectangle(sBrush, sRect);
                sBrush.Dispose();
            }
            //(3)绘制边界
            if (symbol.Outline.SymbolType == moSymbolTypeConstant.SimpleLineSymbol)
            {
                moSimpleLineSymbol sOutline = symbol.Outline;
                if (sOutline.Visible == true)
                {
                    Pen sPen = new Pen(sOutline.Color, (float)(sOutline.Size / 1000 * dpm));
                    sPen.DashStyle = (DashStyle)sOutline.Style;
                    g.DrawRectangle(sPen, sRect);
                    sPen.Dispose();
                }
            }
        }
コード例 #2
0
 //初始化符号
 private void InitializeSymbols()
 {
     //选择点符号
     mSelectedPointSymbol       = new moSimpleMarkerSymbol();
     mSelectedPointSymbol.Color = _SelectionColor;
     mSelectedPointSymbol.Size  = 3;
     //选择线符号
     mSelectedLineSymbol       = new moSimpleLineSymbol();
     mSelectedLineSymbol.Color = _SelectionColor;
     mSelectedLineSymbol.Size  = 3000 / mMapDrawingReference.dpm;
     //选择面符号
     mSelectedFillSymbol               = new moSimpleFillSymbol();
     mSelectedFillSymbol.Color         = Color.Transparent;
     mSelectedFillSymbol.Outline.Color = _SelectionColor;
     mSelectedFillSymbol.Outline.Size  = 3000 / mMapDrawingReference.dpm;
     //闪烁点符号
     mFlashPointSymbol       = new moSimpleMarkerSymbol();
     mFlashPointSymbol.Color = _FlashColor;
     mFlashPointSymbol.Style = moSimpleMarkerSymbolStyleConstant.SolidCircle;
     mFlashPointSymbol.Size  = 3;
     //闪烁线符号
     mFlashLineSymbol       = new moSimpleLineSymbol();
     mFlashLineSymbol.Color = _FlashColor;
     mFlashLineSymbol.Size  = 1.5;
     //闪烁面符号
     mFlashFillSymbol               = new moSimpleFillSymbol();
     mFlashFillSymbol.Color         = _FlashColor;
     mFlashFillSymbol.Outline.Color = Color.Black;
     mFlashFillSymbol.Outline.Size  = 0.35;
 }
コード例 #3
0
ファイル: moMapDrawingTools.cs プロジェクト: IRAN96/MiniTerra
        //采用简单线符号绘制简单折线
        private static void DrawPolylineBySimpleLine(Graphics g, moRectangle extent, double mapScale, double dpm,
                                                     double mpu, moPoints points, moSimpleLineSymbol symbol)
        {
            double sOffsetX = extent.MinX, sOffsetY = extent.MaxY; //获取投影坐标系相对屏幕坐标系的平移量
            //(1)转换为屏幕坐标
            GraphicsPath sGraphicPath = new GraphicsPath();        //用于屏幕绘制
            Int32        sPointCount  = points.Count;              //顶点数目

            PointF[] sScreenPoints = new PointF[sPointCount];
            for (Int32 j = 0; j <= sPointCount - 1; j++)
            {
                PointF  sScreenPoint = new PointF();
                moPoint sCurPoint    = points.GetItem(j);
                sScreenPoint.X   = (float)((sCurPoint.X - sOffsetX) * mpu / mapScale * dpm);
                sScreenPoint.Y   = (float)((sOffsetY - sCurPoint.Y) * mpu / mapScale * dpm);
                sScreenPoints[j] = sScreenPoint;
            }
            sGraphicPath.AddLines(sScreenPoints);
            //(2)绘制
            Pen sPen = new Pen(symbol.Color, (float)(symbol.Size / 1000 * dpm));

            sPen.DashStyle = (DashStyle)symbol.Style;
            g.DrawPath(sPen, sGraphicPath);
            sPen.Dispose();
        }
コード例 #4
0
        /// <summary>
        /// 为所有符号生成渐变色
        /// </summary>
        /// <param name="startColor"></param>
        /// <param name="endColor"></param>
        public void RampColor(Color startColor, Color endColor)
        {
            Int32 sBreakCount = _BreakValues.Count;

            if (sBreakCount <= 0)
            {
                return;
            }
            Int32  A1 = startColor.A, R1 = startColor.R, G1 = startColor.G, B1 = startColor.B;
            Int32  A2 = endColor.A, R2 = endColor.R, G2 = endColor.G, B2 = endColor.B;
            Int32  A, R, G, B;
            double H, S, V;

            Color[] sColors = new Color[sBreakCount];
            if (sBreakCount == 1)
            {
                sColors[0] = startColor;
            }
            else
            {
                //将起始和终止颜色转换为HSV
                double[] sStartHSV = RGBToHSV(startColor.R, startColor.G, startColor.B);
                double[] sEndHSV   = RGBToHSV(endColor.R, endColor.G, endColor.B);
                sColors[0] = startColor;
                sColors[sBreakCount - 1] = endColor;
                for (Int32 i = 1; i <= sBreakCount - 2; i++)
                {
                    H = sStartHSV[0] + i * (sEndHSV[0] - sStartHSV[0]) / sBreakCount;
                    S = sStartHSV[1] + i * (sEndHSV[1] - sStartHSV[1]) / sBreakCount;
                    V = sStartHSV[2] + i * (sEndHSV[2] - sStartHSV[2]) / sBreakCount;
                    byte[] sRGB = HSVToRGB(H, S, V);
                    A          = A1 + i * (A2 - A1) / sBreakCount;
                    R          = sRGB[0];
                    G          = sRGB[1];
                    B          = sRGB[2];
                    sColors[i] = Color.FromArgb(A, R, G, B);
                }
            }
            for (Int32 i = 0; i <= sBreakCount - 1; i++)
            {
                if (_Symbols[i] != null)
                {
                    if (_Symbols[i].SymbolType == moSymbolTypeConstant.SimpleMarkerSymbol)
                    {
                        moSimpleMarkerSymbol sSymbol = (moSimpleMarkerSymbol)_Symbols[i];
                        sSymbol.Color = sColors[i];
                    }
                    else if (_Symbols[i].SymbolType == moSymbolTypeConstant.SimpleLineSymbol)
                    {
                        moSimpleLineSymbol sSymbol = (moSimpleLineSymbol)_Symbols[i];
                        sSymbol.Color = sColors[i];
                    }
                    else if (_Symbols[i].SymbolType == moSymbolTypeConstant.SimpleFillSymbol)
                    {
                        moSimpleFillSymbol sSymbol = (moSimpleFillSymbol)_Symbols[i];
                        sSymbol.Color = sColors[i];
                    }
                }
            }
        }
コード例 #5
0
ファイル: moMapDrawingTools.cs プロジェクト: IRAN96/MiniTerra
 //绘制线段
 internal static void DrawLine(Graphics g, moRectangle extent, double mapScale, double dpm, double mpu, moPoint point1, moPoint point2, moSymbol symbol)
 {
     if (symbol.SymbolType == moSymbolTypeConstant.SimpleLineSymbol)
     {
         moSimpleLineSymbol sSymbol = (moSimpleLineSymbol)symbol;
         if (sSymbol.Visible == true)
         {
             DrawLineBySimpleLine(g, extent, mapScale, dpm, mpu, point1, point2, sSymbol);
         }
     }
 }
コード例 #6
0
        /// <summary>
        /// 复制
        /// </summary>
        public override moSymbol Clone()
        {
            moSimpleLineSymbol sSymbol = new moSimpleLineSymbol();

            sSymbol._Label   = _Label;
            sSymbol._Visible = _Visible;
            sSymbol._Style   = _Style;
            sSymbol._Color   = _Color;
            sSymbol._Size    = _Size;
            return(sSymbol);
        }
コード例 #7
0
ファイル: moMapDrawingTools.cs プロジェクト: IRAN96/MiniTerra
        //采用简单填充符号绘制复合多边形
        private static void DrawMultiPolygonBySimpleFill(Graphics g, moRectangle extent, double mapScale, double dpm,
                                                         double mpu, moMultiPolygon multiPolygon, moSimpleFillSymbol symbol)
        {
            double sOffsetX = extent.MinX, sOffsetY = extent.MaxY; //获取投影坐标系相对屏幕坐标系的平移量
            //(1)转换为屏幕坐标
            Int32        sPartCount   = multiPolygon.Parts.Count;  //简单多边形的数目
            GraphicsPath sGraphicPath = new GraphicsPath();        //定义复合多边形,用于屏幕绘制

            for (Int32 i = 0; i <= sPartCount - 1; i++)
            {
                Int32    sPointCount   = multiPolygon.Parts.GetItem(i).Count; //当前简单多边形的顶点数目
                PointF[] sScreenPoints = new PointF[sPointCount];
                for (Int32 j = 0; j <= sPointCount - 1; j++)
                {
                    PointF  sScreenPoint = new PointF();
                    moPoint sCurPoint    = multiPolygon.Parts.GetItem(i).GetItem(j);
                    sScreenPoint.X   = (float)((sCurPoint.X - sOffsetX) * mpu / mapScale * dpm);
                    sScreenPoint.Y   = (float)((sOffsetY - sCurPoint.Y) * mpu / mapScale * dpm);
                    sScreenPoints[j] = sScreenPoint;
                }
                sGraphicPath.AddPolygon(sScreenPoints);
            }
            //(2)填充
            SolidBrush sBrush = new SolidBrush(symbol.Color);

            g.FillPath(sBrush, sGraphicPath);
            sBrush.Dispose();
            //(3)绘制边界
            if (symbol.Outline.SymbolType == moSymbolTypeConstant.SimpleLineSymbol)
            {
                moSimpleLineSymbol sOutline = symbol.Outline;
                if (sOutline.Visible == true)
                {
                    Pen sPen = new Pen(sOutline.Color, (float)(sOutline.Size / 1000 * dpm));
                    sPen.DashStyle = (DashStyle)sOutline.Style;
                    g.DrawPath(sPen, sGraphicPath);
                    sPen.Dispose();
                }
            }
        }
コード例 #8
0
ファイル: moMapLayer.cs プロジェクト: IRAN96/MiniTerra
        //要素的符号是否可见
        private bool IsFeatureSymbolVisible(moFeature feature)
        {
            moSymbol sSymbol = feature.Symbol;

            if (sSymbol.SymbolType == moSymbolTypeConstant.SimpleMarkerSymbol)
            {
                moSimpleMarkerSymbol sMarkerSymbol = (moSimpleMarkerSymbol)sSymbol;
                return(sMarkerSymbol.Visible);
            }
            else if (sSymbol.SymbolType == moSymbolTypeConstant.SimpleLineSymbol)
            {
                moSimpleLineSymbol sLineSymbol = (moSimpleLineSymbol)sSymbol;
                return(sLineSymbol.Visible);
            }
            else if (sSymbol.SymbolType == moSymbolTypeConstant.SimpleFillSymbol)
            {
                moSimpleFillSymbol sFillSymbol = (moSimpleFillSymbol)sSymbol;
                return(sFillSymbol.Visible);
            }
            else
            {
                throw new Exception("Invalid symbol type!");
            }
        }
コード例 #9
0
ファイル: moMapDrawingTools.cs プロジェクト: IRAN96/MiniTerra
        //采用简单线符号绘制线段
        private static void DrawLineBySimpleLine(Graphics g, moRectangle extent, double mapScale, double dpm,
                                                 double mpu, moPoint point1, moPoint point2, moSimpleLineSymbol symbol)
        {
            double sOffsetX = extent.MinX, sOffsetY = extent.MaxY;  //获取投影坐标系相对屏幕坐标系的平移量
            //(1)转换为屏幕坐标
            PointF sScreenPoint1 = new PointF();
            PointF sScreenPoint2 = new PointF();

            sScreenPoint1.X = (float)((point1.X - sOffsetX) * mpu / mapScale * dpm);
            sScreenPoint1.Y = (float)((sOffsetY - point1.Y) * mpu / mapScale * dpm);
            sScreenPoint2.X = (float)((point2.X - sOffsetX) * mpu / mapScale * dpm);
            sScreenPoint2.Y = (float)((sOffsetY - point2.Y) * mpu / mapScale * dpm);
            //(2)绘制
            Pen sPen = new Pen(symbol.Color, (float)(symbol.Size / 1000 * dpm));

            sPen.DashStyle = (DashStyle)symbol.Style;
            g.DrawLine(sPen, sScreenPoint1, sScreenPoint2);
            sPen.Dispose();
        }
コード例 #10
0
 //初始化边界符号
 private void InitializeOutline()
 {
     _Outline       = new moSimpleLineSymbol();
     _Outline.Color = Color.DarkGray;
 }