public void DrawSimpleLine(Graphics g, GSOSimpleLineStyle3D simpleLineStyle)
        {
            int nStartX = (int)(Width * 0.1);
            Pen newPen  = new Pen(simpleLineStyle.LineColor, (float)simpleLineStyle.LineWidth);

            switch (simpleLineStyle.LineType)
            {
            case EnumLineType.Solid:
                newPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
                break;

            case EnumLineType.Dash:
                newPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
                break;

            case EnumLineType.Dot:
                newPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
                break;

            case EnumLineType.DashDot:
                newPen.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDot;
                break;

            case EnumLineType.DashDotDot:
                newPen.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDotDot;
                break;
            }

            Point pt1 = new Point(nStartX, this.Height / 2);
            Point pt2 = new Point(Width - nStartX, this.Height / 2);

            g.DrawLine(newPen, pt1, pt2);
        }
Example #2
0
        private void makeBuffer(GSOFeature feature)
        {
            double radius        = (double)numericUpDownRadius.Value;  //缓冲区宽度
            double value         = (double)numericUpDownFenDuan.Value; //圆角角度
            bool   isRoundCorner = CBRoundCorner.Checked;              //拐角是否圆滑
            bool   isRoundEnds   = CBRoundEnds.Checked;                //两端是否圆滑

            GSOGeoPolygon3D buffer = null;                             //创建缓冲面

            if (feature.Geometry.Type == EnumGeometryType.GeoMarker)   //如果要素为点
            {
                GSOGeoMarker marker = feature.Geometry as GSOGeoMarker;
                buffer = marker.CreateBuffer(radius, value, false);
                //创建点的缓冲面(宽度,角度,false)
            }
            else if (feature.Geometry.Type == EnumGeometryType.GeoPolyline3D)
            {
                GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D;
                buffer = line.CreateBuffer(radius, isRoundCorner, value, isRoundEnds, false);
                //创建线的缓冲面(宽度,拐角圆滑,角度,两端圆滑,false)
            }
            else if (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D)
            {
                GSOGeoPolygon3D polygon = feature.Geometry as GSOGeoPolygon3D;
                buffer = polygon.CreateBuffer(radius, isRoundCorner, value, isRoundEnds, false);
                //创建面的缓冲面(宽度,拐角圆滑,角度,两端圆滑,false)
            }

            if (buffer != null)
            {
                //缓冲面颜色
                GSOSimplePolygonStyle3D style = new GSOSimplePolygonStyle3D();
                style.FillColor = Color.FromArgb(122, Color.Yellow);
                //缓冲线颜色
                GSOSimpleLineStyle3D outlineStyle = new GSOSimpleLineStyle3D();
                outlineStyle.LineColor = Color.Red;
                style.OutlineStyle     = outlineStyle;
                buffer.Style           = style;
                GSOFeature featureBuffer = new GSOFeature();
                featureBuffer.Geometry = buffer;
                featureBuffer.Name     = feature.Name + "_" + radius + "米_Buffer";
                globeControl1.Globe.MemoryLayer.AddFeature(featureBuffer);

                //重新创建原有要素,使得要素在缓冲面上方,可选择
                if (feature != null && feature.Dataset.Type == EnumDatasetType.Memory && feature.Dataset.Caption == "" && feature.Dataset.Name == "")
                {
                    GSOFeature featureSelectCopy = feature.Clone();
                    globeControl1.Globe.MemoryLayer.AddFeature(featureSelectCopy);
                    feature.Delete();
                }
                globeControl1.Refresh();
            }
        }
        private void RefreshGlobe(GSOSimpleLineStyle3D simpleLineStyle3D)
        {
            GSOGeoPolyline3D line = mfeature.Geometry as GSOGeoPolyline3D;

            line.Style        = simpleLineStyle3D;
            mfeature.Geometry = line;

            //mfeature.Geometry.Style = simpleLineStyle3D;
            if (m_GlobeControl != null)
            {
                m_GlobeControl.Globe.Refresh();
            }
        }
Example #4
0
        private void listViewStyle_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (listViewStyle.SelectedIndices.Count > 0)
            {
                tabControl1.TabPages.Clear();
                GSOStyle         oldStyle   = null;
                EnumAltitudeMode oldAltMode = m_Geometry.AltitudeMode;
                // 先复制一个原来的哦,以便在对话框取消的时候恢复
                if (m_Geometry.Style != null)
                {
                    oldStyle = m_Geometry.Style.Clone();
                }
                if (listViewStyle.SelectedIndices[0] == 0)
                {
                    GSOSimpleLineStyle3D simpleLineStyle = m_Geometry.Style as GSOSimpleLineStyle3D;
                    if (simpleLineStyle == null)
                    {
                        m_Geometry.Style = new GSOSimpleLineStyle3D();
                    }

                    FrmSetLineStyle dlg = new FrmSetLineStyle(m_Geometry.Style, mfeature, mlayer, m_GlobeControl);
                    if (dlg.ShowDialog(this) == DialogResult.Cancel)
                    {
                        m_Geometry.Style = oldStyle;
                    }
                }
                else if (listViewStyle.SelectedIndices[0] == 1)
                {
                    GSOPipeLineStyle3D pipeLineStyle = m_Geometry.Style as GSOPipeLineStyle3D;

                    // 管线暂不支持依地模式
                    if (m_Geometry.AltitudeMode == EnumAltitudeMode.ClampToGround)
                    {
                        m_Geometry.AltitudeMode = EnumAltitudeMode.RelativeToGround;
                    }
                    if (pipeLineStyle == null)
                    {
                        m_Geometry.Style = new GSOPipeLineStyle3D();
                    }

                    FrmSetPipelineStyle dlg = new FrmSetPipelineStyle(m_Geometry.Style, mfeature, mlayer, m_GlobeControl);

                    // 恢复一下
                    if (dlg.ShowDialog(this) == DialogResult.Cancel)
                    {
                        m_Geometry.Style        = oldStyle;
                        m_Geometry.AltitudeMode = oldAltMode;
                    }
                }
            }
        }
Example #5
0
        public FrmSetOutlineStyle(GSOLineStyle3D style, GSOGeoPolygon3D polygon, GSOFeature feature, GSOGlobeControl globeControl)
        {
            InitializeComponent();
            m_GlobeControl = globeControl;
            mfeature = feature;
            mpolygon = polygon;

            // 如果m_OldStyle不存在,先备份一个
            if (style != null)
            {
                m_OldStyle = (GSOLineStyle3D)style.Clone();
            }
            simpleLineStyle3D = (GSOSimpleLineStyle3D)style;
        }
Example #6
0
        public FrmSetOutlineStyle(GSOLineStyle3D style, GSOGeoPolygon3D polygon, GSOFeature feature, GSOGlobeControl globeControl)
        {
            InitializeComponent();
            m_GlobeControl = globeControl;
            mfeature       = feature;
            mpolygon       = polygon;

            // 如果m_OldStyle不存在,先备份一个
            if (style != null)
            {
                m_OldStyle = (GSOLineStyle3D)style.Clone();
            }
            simpleLineStyle3D = (GSOSimpleLineStyle3D)style;
        }
Example #7
0
        // 线
        private void btn_Polyline_Click(object sender, System.EventArgs e)
        {
            GSOGeoPolyline3D line = new GSOGeoPolyline3D(); //创建线对象
            GSOPoint3ds      pnts = new GSOPoint3ds();      //创建节点对象

            pnts.Add(new GSOPoint3d(120.4, 31.3, 1000));    //把各节点添加到节点对象上
            pnts.Add(new GSOPoint3d(120.41, 31.31, 3000));
            pnts.Add(new GSOPoint3d(120.42, 31.32, 2000));
            pnts.Add(new GSOPoint3d(120.43, 31.30, 2500));
            pnts.Add(new GSOPoint3d(120.44, 31.34, 4000));
            line.AddPart(pnts); //把节点添加到线上

            GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D();

            line.Style = style;
            AddNewGeoToLayer(line, "线");
        }
Example #8
0
        private void SetControlsByStyle(GSOStyle style)
        {
            if (style != null)
            {
                GSOPipeLineStyle3D pipelineStyle = style as GSOPipeLineStyle3D;
                if (pipelineStyle != null)
                {
                    AddTabPages("pipelineStyle", "管线", new CtrlPipelineStyleSetting(pipelineStyle, mfeature, mlayer, m_GlobeControl));
                }
                else
                {
                    GSOSimpleLineStyle3D simpleLineStyle = style as GSOSimpleLineStyle3D;
                    if (simpleLineStyle != null)
                    {
                        AddTabPages("simpleLineStyle", "简单线", new CtrlLineStyleSetting(simpleLineStyle, mfeature, mlayer, m_GlobeControl));
                    }
                    else
                    {
                        GSOExtendSectionLineStyle3D extentSectionLineStyle = style as GSOExtendSectionLineStyle3D;
                        if (extentSectionLineStyle != null)
                        {
                            AddTabPages("extendSectionLineStyle", "管沟", new CtrlExtentSectionlineStyleSetting(extentSectionLineStyle, mfeature, mlayer, m_GlobeControl));
                        }
                    }
                }

                checkBoxUseStyle.Checked = true;
                GSOLineStyle3D lineStyle = style as GSOLineStyle3D;
                if (lineStyle != null && lineStyle.ArrowVisible && lineStyle.ArrowStyle != null)
                {
                    checkBoxShowArrow.Checked = true;
                }
                else
                {
                    checkBoxShowArrow.Checked = false;
                }
            }
            else
            {
                checkBoxUseStyle.Checked  = false;
                checkBoxShowArrow.Checked = false;
            }

            CheckControlsEnable(checkBoxUseStyle.Checked);
        }
Example #9
0
        private void SetControlsByStyle(GSOStyle style)
        {
            simpleLineStyle3D = style as GSOSimpleLineStyle3D;
            if (simpleLineStyle3D != null)
            {
                // 这句要写到前面,不然下面Checked的时候要检查
                pictureBoxLineColor.BackColor = Color.FromArgb(255, simpleLineStyle3D.LineColor);
                numericUpDownLineOpaque.Value = simpleLineStyle3D.LineColor.A;
                textBoxLineWidth.Text         = simpleLineStyle3D.LineWidth.ToString();

                switch (simpleLineStyle3D.LineType)
                {
                case EnumLineType.Solid:
                    comboBoxLineType.SelectedIndex = 0;
                    break;

                case EnumLineType.Dash:
                    comboBoxLineType.SelectedIndex = 1;
                    break;

                case EnumLineType.Dot:
                    comboBoxLineType.SelectedIndex = 2;
                    break;

                case EnumLineType.DashDot:
                    comboBoxLineType.SelectedIndex = 3;
                    break;

                case EnumLineType.DashDotDot:
                    comboBoxLineType.SelectedIndex = 4;
                    break;
                }

                checkBoxUseStyle.Checked = true;
            }
            else
            {
                simpleLineStyle3D        = new GSOSimpleLineStyle3D();
                m_Geometry.Style         = simpleLineStyle3D;
                checkBoxUseStyle.Checked = false;
            }

            CheckControlsEnable(checkBoxUseStyle.Checked);
        }
        private void SetControlsByStyle(GSOStyle style)
        {
            if (m_Style != null)
            {
                simpleLineStyle3D = m_Style as GSOSimpleLineStyle3D;
                if (simpleLineStyle3D == null)
                {
                    simpleLineStyle3D = new GSOSimpleLineStyle3D();
                    RefreshGlobe(simpleLineStyle3D);
                }
            }
            else
            {
                simpleLineStyle3D = new GSOSimpleLineStyle3D();
                RefreshGlobe(simpleLineStyle3D);
            }
            // 这句要写到前面,不然下面Checked的时候要检查
            pictureBoxLineColor.BackColor = Color.FromArgb(255, simpleLineStyle3D.LineColor);
            numericUpDownLineOpaque.Value = simpleLineStyle3D.LineColor.A;
            textBoxLineWidth.Text         = simpleLineStyle3D.LineWidth.ToString();

            switch (simpleLineStyle3D.LineType)
            {
            case EnumLineType.Solid:
                comboBoxLineType.SelectedIndex = 0;
                break;

            case EnumLineType.Dash:
                comboBoxLineType.SelectedIndex = 1;
                break;

            case EnumLineType.Dot:
                comboBoxLineType.SelectedIndex = 2;
                break;

            case EnumLineType.DashDot:
                comboBoxLineType.SelectedIndex = 3;
                break;

            case EnumLineType.DashDotDot:
                comboBoxLineType.SelectedIndex = 4;
                break;
            }
        }
        public void CtrlLineStylePreview_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;


            /*
             * Color FColor = Color.FromArgb(255, 255, 255);
             *
             * Color TColor = Color.FromArgb(221, 221, 221);
             *
             * Brush b = new LinearGradientBrush(this.ClientRectangle, FColor, TColor, LinearGradientMode.Vertical);
             *
             * g.FillRectangle(b, this.ClientRectangle);
             */



            if (m_Style != null)
            {
                GSOSimpleLineStyle3D simpleLineStyle = m_Style as GSOSimpleLineStyle3D;
                if (simpleLineStyle != null)
                {
                    DrawSimpleLine(g, simpleLineStyle);
                }
                else
                {
                    GSOPipeLineStyle3D pipeLineStyle = m_Style as GSOPipeLineStyle3D;
                    if (pipeLineStyle != null)
                    {
                        DrawPipeLine(g, pipeLineStyle);
                    }
                }
            }
            else
            {
                StringFormat stringFormat = new StringFormat();
                stringFormat.LineAlignment = StringAlignment.Center;
                stringFormat.Alignment     = StringAlignment.Center;
                g.DrawString("无风格", new Font("宋体", 10), new SolidBrush(Color.Black), this.Bounds, stringFormat);
            }
        }
Example #12
0
        private GSOFeature makeLine()
        {
            GSOGeoPolyline3D line = new GSOGeoPolyline3D(); //创建线对象
            GSOPoint3ds      pnts = new GSOPoint3ds();      //创建节点对象

            pnts.Add(new GSOPoint3d(116.6, 39.9, 1000));    //把各节点添加到节点对象上
            pnts.Add(new GSOPoint3d(116.61, 39.91, 3000));
            pnts.Add(new GSOPoint3d(116.62, 39.92, 2000));
            pnts.Add(new GSOPoint3d(116.63, 39.90, 2500));
            pnts.Add(new GSOPoint3d(116.64, 39.94, 4000));
            line.AddPart(pnts);                                      //把节点添加到线上

            GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格

            //设置透明度及颜色,FromArgb()中的四个参数分别为alpha、red、green、blue,取值范围为0到255
            style.LineColor     = Color.FromArgb(150, 0, 255, 0);
            style.LineWidth     = 3;     //设置线的宽度为3
            style.VertexVisible = true;  //显示线的节点
            line.Style          = style; //把风格添加到线上

            //创建几何对象并设置属性
            GSOFeature f = new GSOFeature();

            f.Geometry = line;                        //把线对象添加到几何对象上
            f.Name     = "线 01";                      //设置几何对象的名称
            f.SetFieldValue("description", "这是线的属性"); //设置几何对象的字段值
            //把几何要素添加到内存图层中
            globeControl1.Globe.MemoryLayer.AddFeature(f);

            //下面不属于工程内容,只是飞到点的位置
            GSOCameraState cs = new GSOCameraState();

            cs.Longitude = 116.62;
            cs.Latitude  = 39.92;
            cs.Altitude  = 9000;
            globeControl1.Globe.FlyToCameraState(cs);

            return(f);
        }
Example #13
0
        private void AddLine()
        {
            GSOGeoPolyline3D line = new GSOGeoPolyline3D(); //创建线对象
            GSOPoint3ds      pnts = new GSOPoint3ds();      //创建节点对象

            pnts.Add(new GSOPoint3d(116.6, 39.9, 1000));    //把各节点添加到节点对象上
            pnts.Add(new GSOPoint3d(116.61, 39.91, 3000));
            pnts.Add(new GSOPoint3d(116.62, 39.92, 2000));
            pnts.Add(new GSOPoint3d(116.63, 39.90, 2500));
            pnts.Add(new GSOPoint3d(116.64, 39.94, 4000));
            line.AddPart(pnts);                                      //把节点添加到线上

            GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格

            //设置透明度及颜色,FromArgb()中的四个参数分别为alpha、red、green、blue,取值范围为0到255
            style.LineColor     = Color.FromArgb(150, 0, 255, 0);
            style.LineWidth     = 3;     //设置线的宽度为3
            style.VertexVisible = true;  //显示线的节点
            line.Style          = style; //把风格添加到线上

            //创建几何对象并设置属性
            GSOFeature lineFeature = new GSOFeature();

            lineFeature.Geometry = line;                        //把线对象添加到几何对象上
            lineFeature.Name     = "线 01";                      //设置几何对象的名称
            lineFeature.SetFieldValue("description", "这是线的属性"); //设置几何对象的字段值

            lineFeature.Description = "<html>\r\n<head>\r\n<style>\r\n#tab-list {\r\nborder-collapse:collapse;\r\nfont-size:15px;\r\nmargin:20px;\r\ntext-align:left;\r\nwidth:280px;\r\n}\r\n\r\n#tab-list th {\r\nborder-bottom:2px solid #6678B1;\r\ncolor:#003399;\r\nfont-size:14px;\r\nfont-weight:normal;\r\npadding:10px 8px;\r\n}\r\n#tab-list td {\r\nborder-bottom:1px solid #CCCCCC;\r\ncolor:#666699;\r\npadding:6px 8px;\r\n}\r\n</style>\r\n</head>\r\n<body style=\"border:none\">\r\n<center>\r\n<table id=\"tab-list\">\r\n<thead><tr><th>属性名称</th><th>属性值</th></tr></thead>\r\n<tbody>$tablecontent</tbody></table>\r\n</center>\r\n</body>\r\n</html>\r\n";
            double lineLength = line.GetSpaceLength(true, 6378137);
            Dictionary <string, string> property = new Dictionary <string, string>();

            property.Add("长度", (lineLength / 1000).ToString("0.00") + "KM");

            lineFeature.Description = lineFeature.Description.Replace("$tablecontent", maketable(property));

            //把几何要素添加到内存图层中
            globeControl1.Globe.MemoryLayer.AddFeature(lineFeature);
        }
Example #14
0
 private void buttonTailPartStyle_Click(object sender, EventArgs e)
 {
     if (m_Geometry != null)
     {
         if (m_Geometry.Type == EnumGeometryType.GeoPolyline3D)
         {
             GSOSimpleLineStyle3D geoStyle3d = m_Geometry.ExtrudeStyle.TailStyle as GSOSimpleLineStyle3D;
             if (geoStyle3d != null)
             {
                 FrmSetLineStyle dlg = new FrmSetLineStyle(geoStyle3d, m_GlobeControl);
                 dlg.Show(this);
             }
         }
         else
         {
             GSOSimplePolygonStyle3D geoStyle3d = m_Geometry.ExtrudeStyle.TailStyle as GSOSimplePolygonStyle3D;
             if (geoStyle3d != null)
             {
                 FrmSetPolygonStyle dlg = new FrmSetPolygonStyle(geoStyle3d, m_GlobeControl);
                 dlg.Show(this);
             }
         }
     }
 }
Example #15
0
        public void DrawSimpleLine(Graphics g,GSOSimpleLineStyle3D simpleLineStyle)
        {
            int nStartX = (int)(Width * 0.1);
            Pen newPen = new Pen(simpleLineStyle.LineColor,(float)simpleLineStyle.LineWidth);

            switch (simpleLineStyle.LineType)
            {
                case EnumLineType.Solid:
                    newPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
                    break;
                case EnumLineType.Dash:
                    newPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
                    break;
                case EnumLineType.Dot:
                    newPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
                    break;

                case EnumLineType.DashDot:
                    newPen.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDot;
                    break;
                case EnumLineType.DashDotDot:
                    newPen.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDotDot;
                    break;

            }

            Point pt1 = new Point(nStartX, this.Height / 2);
            Point pt2 = new Point(Width - nStartX, this.Height / 2);

            g.DrawLine(newPen, pt1, pt2);
        }
        private void buttonOK_Click(object sender, EventArgs e)
        {
            GSOFeatures features = mlayer.GetAllFeatures();

            for (int i = 0; i < features.Length; i++)
            {
                GSOFeature feature = features[i];
                switch (feature.Geometry.Type)
                {
                case EnumGeometryType.GeoPolyline3D:

                    if (checkBoxLineStyle.Checked)
                    {
                        GSOSimpleLineStyle3D polylinestyle = null;
                        if (feature.Geometry.Style == null)
                        {
                            polylinestyle           = new GSOSimpleLineStyle3D();
                            polylinestyle.LineColor = Color.FromArgb(Convert.ToByte(numericLineOpaque.Value), pictureBoxLineColor.BackColor);

                            polylinestyle.LineType = getLineType(comboBoxLineType.SelectedIndex);

                            if (textBoxLineWidth.Text != "")
                            {
                                string strwidth = textBoxLineWidth.Text;
                                double dwidth   = 0.0;
                                if (double.TryParse(strwidth, out dwidth))
                                {
                                    polylinestyle.LineWidth = dwidth;
                                }
                            }
                            feature.Geometry.Style = polylinestyle;
                        }
                        else
                        {
                            polylinestyle           = (GSOSimpleLineStyle3D)feature.Geometry.Style;
                            polylinestyle.LineColor = Color.FromArgb(Convert.ToByte(numericLineOpaque.Value), pictureBoxLineColor.BackColor);
                            polylinestyle.LineType  = getLineType(comboBoxLineType.SelectedIndex);
                            if (textBoxLineWidth.Text != "")
                            {
                                string strwidth = textBoxLineWidth.Text;
                                double dwidth   = 0.0;
                                if (double.TryParse(strwidth, out dwidth))
                                {
                                    polylinestyle.LineWidth = dwidth;
                                }
                            }
                        }
                    }
                    break;

                case EnumGeometryType.GeoPolygon3D:

                    if (checkBoxPolygonStyle.Checked)
                    {
                        GSOSimplePolygonStyle3D polygonstyle = null;
                        GSOSimpleLineStyle3D    outlinestyle = null;
                        if (checkBoxPolygonFillStyle.Checked)
                        {
                            if (feature.Geometry.Style == null)
                            {
                                polygonstyle           = new GSOSimplePolygonStyle3D();
                                polygonstyle.FillColor = Color.FromArgb(Convert.ToByte(numericPolygonFillOpaque.Value), pictureBoxPolygonFillColor.BackColor);
                                feature.Geometry.Style = polygonstyle;
                            }
                            else
                            {
                                polygonstyle           = (GSOSimplePolygonStyle3D)feature.Geometry.Style;
                                polygonstyle.FillColor = Color.FromArgb(Convert.ToByte(numericPolygonFillOpaque.Value), pictureBoxPolygonFillColor.BackColor);
                            }
                        }
                        if (checkBoxPolygonOutlineStyle.Checked)
                        {
                            if (feature.Geometry.Style == null)
                            {
                                polygonstyle           = new GSOSimplePolygonStyle3D();
                                outlinestyle           = new GSOSimpleLineStyle3D();
                                outlinestyle.LineColor = Color.FromArgb(Convert.ToByte(numericPolygonOutlineOpaque.Value), pictureBoxPolygonOutlineColor.BackColor);
                                outlinestyle.LineType  = getLineType(comboBoxPolygonOutlineType.SelectedIndex);
                                if (textBoxPolygonOutlineWidth.Text != "")
                                {
                                    string strwidth = textBoxPolygonOutlineWidth.Text;
                                    double dwidth   = 0.0;
                                    if (double.TryParse(strwidth, out dwidth))
                                    {
                                        outlinestyle.LineWidth = dwidth;
                                    }
                                }
                                polygonstyle.OutlineStyle = outlinestyle;
                                feature.Geometry.Style    = polygonstyle;
                            }
                            else
                            {
                                polygonstyle = (GSOSimplePolygonStyle3D)feature.Geometry.Style;
                                if (polygonstyle.OutlineStyle == null)
                                {
                                    outlinestyle           = new GSOSimpleLineStyle3D();
                                    outlinestyle.LineColor = Color.FromArgb(Convert.ToByte(numericPolygonOutlineOpaque.Value), pictureBoxPolygonOutlineColor.BackColor);
                                    outlinestyle.LineType  = getLineType(comboBoxPolygonOutlineType.SelectedIndex);
                                    if (textBoxPolygonOutlineWidth.Text != "")
                                    {
                                        string strwidth = textBoxPolygonOutlineWidth.Text;
                                        double dwidth   = 0.0;
                                        if (double.TryParse(strwidth, out dwidth))
                                        {
                                            outlinestyle.LineWidth = dwidth;
                                        }
                                    }
                                    polygonstyle.OutlineStyle = outlinestyle;
                                    feature.Geometry.Style    = polygonstyle;
                                }
                                else
                                {
                                    outlinestyle           = (GSOSimpleLineStyle3D)polygonstyle.OutlineStyle;
                                    outlinestyle.LineColor = Color.FromArgb(Convert.ToByte(numericPolygonOutlineOpaque.Value), pictureBoxPolygonOutlineColor.BackColor);
                                    outlinestyle.LineType  = getLineType(comboBoxPolygonOutlineType.SelectedIndex);
                                    if (textBoxPolygonOutlineWidth.Text != "")
                                    {
                                        string strwidth = textBoxPolygonOutlineWidth.Text;
                                        double dwidth   = 0.0;
                                        if (double.TryParse(strwidth, out dwidth))
                                        {
                                            outlinestyle.LineWidth = dwidth;
                                        }
                                    }
                                    feature.Geometry.Style = polygonstyle;
                                }
                            }
                        }
                    }
                    break;
                }
                mGlobeControl.Refresh();
            }
            this.Close();
        }
Example #17
0
        private void button2_Click(object sender, EventArgs e)
        {
            if(comboBoxLayers.Text == "")
            {
                MessageBox.Show("请选择一个图层!");
                return;
            }
            GSOLayer layer = mGlobeControl.Globe.Layers.GetLayerByCaption(comboBoxLayers.Text.Trim());
            if (layer == null)
            {
                MessageBox.Show("您选择的图层不存在!");
                return;
            }

            string iconPath = textBoxIconPath.Text.Trim();
            if (iconPath == "")
            {
                iconPath = Application.StartupPath + "\\Resource\\DefaultIcon.png";
            }

            Color lineColor = textBoxLineColor.BackColor;
            string strLineWidth = textBoxLineWidth.Text.Trim();
            double lineWidth = 1;
            bool blIsLineWidth = double.TryParse(strLineWidth, out lineWidth);

            Color outlineColor = textBoxOutlineColor.BackColor;
            string strOutlineWidth = textBoxOutlineWidth.Text.Trim();
            double outlineWidth = 1;
            bool blIsOutlineWidth = double.TryParse(strOutlineWidth, out outlineWidth);
            Color polygonColor = textBoxPolygonColor.BackColor;
            string strPolygonAlpha = textBoxPolygonAlpha.Text.Trim();
            int polygonAlpha = 255;
            bool blIsPolygonAlpha = int.TryParse(strPolygonAlpha, out polygonAlpha);
            polygonColor = Color.FromArgb(polygonAlpha, polygonColor);

            for (int i = 0; i < layer.GetAllFeatures().Length; i++)
            {
                GSOFeature feature = layer.GetAt(i);
                if (feature.Geometry != null)
                {
                    switch(feature.Geometry.Type)
                    {
                        case EnumGeometryType.GeoPoint3D:
                            if (panelPoints.Enabled)
                            {
                                GSOGeoPoint3D point = (GSOGeoPoint3D)feature.Geometry;
                                GSOGeoMarker marker = new GSOGeoMarker();
                                marker.Position = point.Position;
                                marker.Name = point.Name;
                                marker.CameraState = point.CameraState;
                                marker.Label = point.Label;

                                GSOFeature newFeature = new GSOFeature();
                                newFeature.Name = feature.Name;
                                newFeature.Geometry = marker;

                                layer.RemoveAt(i);
                                layer.AddFeature(newFeature);
                                i--;
                            }
                            break;
                        case EnumGeometryType.GeoMarker:
                            if (panelPoints.Enabled)
                            {
                                GSOGeoMarker marker = (GSOGeoMarker)feature.Geometry;
                                GSOMarkerStyle3D style = null;

                                if (marker.Style == null)
                                {
                                    style = new GSOMarkerStyle3D();
                                }
                                else
                                {
                                    style = (GSOMarkerStyle3D)marker.Style;
                                }

                                style.TextVisible = !checkBoxHideLabelOfMarker.Checked;
                                style.IconPath = iconPath.Trim();

                                marker.Style = style;
                            }
                            break;
                        case EnumGeometryType.GeoPolyline3D:
                            if (panelLines.Enabled)
                            {
                                GSOGeoPolyline3D line = (GSOGeoPolyline3D)feature.Geometry;
                                if (line.Label != null)
                                {
                                    line.Label.Visible = !checkBoxHideLabelOfLine.Checked;
                                }
                                if (line.Style == null)
                                {
                                    GSOSimpleLineStyle3D styleLine = new GSOSimpleLineStyle3D();
                                    styleLine.LineColor = lineColor;
                                    styleLine.LineWidth = lineWidth;
                                    line.Style = styleLine;
                                }
                                else
                                {
                                    GSOSimpleLineStyle3D styleLine = (GSOSimpleLineStyle3D)line.Style;
                                    if (styleLine == null)
                                    {
                                        GSOPipeLineStyle3D pipeStyle = (GSOPipeLineStyle3D)line.Style;
                                        if (pipeStyle != null)
                                        {
                                            pipeStyle.LineColor = lineColor;
                                            pipeStyle.Radius = lineWidth / 2;
                                            line.Style = pipeStyle;
                                        }
                                    }
                                    else
                                    {
                                        styleLine.LineColor = lineColor;
                                        styleLine.LineWidth = lineWidth;
                                        line.Style = styleLine;
                                    }
                                }
                            }
                            break;
                        case EnumGeometryType.GeoPolygon3D:
                            if (panelPolygons.Enabled)
                            {
                                GSOGeoPolygon3D polygon = (GSOGeoPolygon3D)feature.Geometry;
                                if (polygon.Label != null)
                                {
                                    polygon.Label.Visible = !checkBoxHideLabelOfPolygon.Checked;
                                }
                                GSOSimplePolygonStyle3D stylePolygon = (polygon.Style == null ? new GSOSimplePolygonStyle3D() : (GSOSimplePolygonStyle3D)polygon.Style);
                                stylePolygon.FillColor = polygonColor;
                                stylePolygon.OutLineVisible = true;
                                GSOSimpleLineStyle3D styleOutline = (GSOSimpleLineStyle3D)stylePolygon.OutlineStyle;
                                if (styleOutline == null)
                                {
                                    styleOutline = new GSOSimpleLineStyle3D();
                                }
                                styleOutline.LineWidth = outlineWidth;
                                styleOutline.LineColor = outlineColor;
                                stylePolygon.OutlineStyle = styleOutline;
                                polygon.Style = stylePolygon;
                            }
                            break;

                    }
                }
            }
            mGlobeControl.Globe.Refresh();
            this.Close();
        }
Example #18
0
        private void SetControlsByStyle()
        {
            if (simpleLineStyle3D != null)
            {
                // 这句要写到前面,不然下面Checked的时候要检查
                pictureBoxLineColor.BackColor = Color.FromArgb(255, simpleLineStyle3D.LineColor);
                numericUpDownLineOpaque.Value = simpleLineStyle3D.LineColor.A;
                textBoxLineWidth.Text = simpleLineStyle3D.LineWidth.ToString();

                switch (simpleLineStyle3D.LineType)
                {
                    case EnumLineType.Solid:
                        comboBoxLineType.SelectedIndex = 0;
                        break;
                    case EnumLineType.Dash:
                        comboBoxLineType.SelectedIndex = 1;
                        break;
                    case EnumLineType.Dot:
                        comboBoxLineType.SelectedIndex = 2;
                        break;
                    case EnumLineType.DashDot:
                        comboBoxLineType.SelectedIndex = 3;
                        break;
                    case EnumLineType.DashDotDot:
                        comboBoxLineType.SelectedIndex = 4;
                        break;
                }
            }
            else
            {
                simpleLineStyle3D = new GSOSimpleLineStyle3D();
            }
        }
        private void comboBoxLayers_TextChanged(object sender, EventArgs e)
        {
            string layerName = comboBoxLayers.Text;

            if (layerName.Trim().Equals(""))
            {
                return;
            }
            GSOLayer layer = mGlobeControl.Globe.Layers.GetLayerByCaption(layerName);

            if (layer == null)
            {
                return;
            }
            //清空上一个图层的style
            textBoxIconPath.Text = "";

            textBoxLineColor.BackColor = this.BackColor;
            textBoxLineWidth.Text      = "";

            textBoxOutlineColor.BackColor = this.BackColor;
            textBoxPolygonColor.BackColor = this.BackColor;
            textBoxOutlineWidth.Text      = "";
            textBoxPolygonAlpha.Text      = "";

            bool        markerExists  = false;
            bool        lineExists    = false;
            bool        polygonExists = false;
            GSOFeatures features      = GetAllRealFeatures(layer);

            for (int i = 0; i < features.Length; i++)
            {
                GSOFeature feature = features[i];
                if (feature == null)
                {
                    continue;
                }

                if (feature.Geometry != null)
                {
                    switch (feature.Geometry.Type)
                    {
                    case EnumGeometryType.GeoMarker:
                        if (!markerExists)
                        {
                            GSOGeoMarker marker = (GSOGeoMarker)feature.Geometry;

                            GSOMarkerStyle3D style = (GSOMarkerStyle3D)marker.Style;
                            if (style != null)
                            {
                                textBoxIconPath.Text = style.IconPath;
                                checkBoxHideLabelOfMarker.Checked = !style.TextVisible;
                                markerExists = true;
                            }
                        }
                        break;

                    case EnumGeometryType.GeoPolyline3D:
                        if (!lineExists)
                        {
                            GSOGeoPolyline3D line = (GSOGeoPolyline3D)feature.Geometry;
                            if (line.Label != null)
                            {
                                checkBoxHideLabelOfPolygon.Checked = !line.Label.Visible;
                            }
                            if (line.Style != null)
                            {
                                GSOSimpleLineStyle3D simpleLineStyle = (GSOSimpleLineStyle3D)line.Style;
                                if (simpleLineStyle != null)
                                {
                                    textBoxLineColor.BackColor = simpleLineStyle.LineColor;
                                    textBoxLineWidth.Text      = (simpleLineStyle.LineWidth == 0 ? "1".ToString() : simpleLineStyle.LineWidth.ToString());
                                    lineExists = true;
                                }
                                else
                                {
                                    GSOPipeLineStyle3D pipeLineStyle = (GSOPipeLineStyle3D)line.Style;
                                    if (pipeLineStyle != null)
                                    {
                                        textBoxLineColor.BackColor = pipeLineStyle.LineColor;
                                        textBoxLineWidth.Text      = (pipeLineStyle.Radius * 2).ToString();
                                        lineExists = true;
                                    }
                                }
                            }
                        }
                        break;

                    case EnumGeometryType.GeoPolygon3D:
                        if (!polygonExists)
                        {
                            GSOGeoPolygon3D polygon = (GSOGeoPolygon3D)feature.Geometry;
                            if (polygon.Label != null)
                            {
                                checkBoxHideLabelOfLine.Checked = !polygon.Label.Visible;
                            }
                            GSOSimplePolygonStyle3D stylePolygon = (GSOSimplePolygonStyle3D)polygon.Style;

                            if (stylePolygon != null)
                            {
                                textBoxPolygonColor.BackColor = Color.FromArgb(stylePolygon.FillColor.R, stylePolygon.FillColor.G, stylePolygon.FillColor.B);
                                textBoxPolygonAlpha.Text      = stylePolygon.FillColor.A.ToString();
                                GSOSimpleLineStyle3D styleOutline = (GSOSimpleLineStyle3D)stylePolygon.OutlineStyle;
                                if (styleOutline != null)
                                {
                                    textBoxOutlineColor.BackColor = styleOutline.LineColor;
                                    textBoxOutlineWidth.Text      = (styleOutline.LineWidth == 0 ? "1".ToString() : styleOutline.LineWidth.ToString());
                                }
                                polygonExists = true;
                            }
                        }
                        break;
                    }
                }
            }
        }
Example #20
0
        private void 管线间距分析ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (globeControl1.Globe.SelObjectCount < 2)
            {
                MessageBox.Show("请选中至少两个管线!!");
                return;
            }
            if (disFeature.ID != 0)
            {
                globeControl1.Globe.MemoryLayer.RemoveFeatureByID(disFeature.ID);
            }
            if (featureDis.ID != 0)
            {
                globeControl1.Globe.MemoryLayer.RemoveFeatureByID(featureDis.ID);
            }
            GSOLayer reslayer;
            globeControl1.Globe.GetSelectObject(0, out m_DisAnalysisFirstFeature, out reslayer);
            globeControl1.Globe.GetSelectObject(1, out m_DisAnalysisSecondFeature, out reslayer);
            if (m_DisAnalysisSecondFeature != null && m_DisAnalysisSecondFeature != null)
            {
                GSOGeoPolyline3D line1 = m_DisAnalysisFirstFeature.Geometry as GSOGeoPolyline3D;
                GSOGeoPolyline3D line2 = m_DisAnalysisSecondFeature.Geometry as GSOGeoPolyline3D;
                if (line1 == null || line2 == null)
                {
                    MessageBox.Show("请选择管线!!");
                    return;
                }
                GSOPipeLineStyle3D pipeStyle1 = line1.Style as GSOPipeLineStyle3D;
                GSOPipeLineStyle3D pipeStyle2 = line2.Style as GSOPipeLineStyle3D;
                if (pipeStyle1 == null || pipeStyle2 == null)
                {
                    MessageBox.Show("请选择管线!!");
                    return;
                }

                GSOPoint3d pntIntersect1;
                GSOPoint3d pntIntersect2;
                double dHonLen;
                double dVerLen;
                double dNoIntersectStartRatio = 0;
                // 计算两条线的距离和交点,若果失败返回-1
                // 若在同一直线上,并且有交点,返回0
                // 若不在同一平面,返回最近两点的距离,并且计算最近两点
                double dDist = globeControl1.Globe.Analysis3D.ComputeTwoGeoPolylineDistance(line1, line2, out pntIntersect1, out pntIntersect2, out dHonLen, out dVerLen, false, false, dNoIntersectStartRatio);

                if (dDist > -1)
                {
                    if (dDist == 0)
                    {
                        MessageBox.Show("管线在同一水平面,距离为0");
                        return;
                    }
                    else
                    {
                        dDist = dDist - pipeStyle1.Radius - pipeStyle2.Radius;
                        GSOGeoPolyline3D disline = new GSOGeoPolyline3D();
                        GSOPoint3ds point3ds = new GSOPoint3ds();
                        point3ds.Add(pntIntersect1);
                        point3ds.Add(pntIntersect2);
                        disline.AddPart(point3ds);

                        GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格
                        //设置透明度及颜色,FromArgb()中的四个参数分别为alpha、red、green、blue,取值范围为0到255
                        style.LineColor = Color.GreenYellow;
                        style.LineWidth = 3;          //设置线的宽度为3
                        style.VertexVisible = true; 	//显示线的节点
                        disline.Style = style;          //把风格添加到线上
                        disline.AltitudeMode = EnumAltitudeMode.Absolute;

                        disFeature.Geometry = disline;

                        GSOGeoMarker markerDis = new GSOGeoMarker();
                        markerDis.X = pntIntersect1.X;
                        markerDis.Y = pntIntersect1.Y;
                        markerDis.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2;
                        markerDis.Text = dDist.ToString().Substring(0, dDist.ToString().IndexOf(".") + 3) + "米";
                        markerDis.AltitudeMode = EnumAltitudeMode.Absolute;
                        GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D();
                        GSOTextStyle styleText = new GSOTextStyle();
                        styleText.IsSizeFixed = true;
                        styleText.ForeColor = Color.White;
                        styleText.FontSize = 20;
                        styleMarker.TextStyle = styleText;
                        markerDis.Style = styleMarker;
                        featureDis.Geometry = markerDis;
                        layerTemp = globeControl1.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData.lgd");
                        layerTemp.AddFeature(featureDis);
                        layerTemp.AddFeature(disFeature);
                        globeControl1.Refresh();
                    }
                }
                else
                {
                    MessageBox.Show("没有交点!!");
                    return;
                }
            }
        }
Example #21
0
        //创建管线要素
        public void CreatePipeLine()
        {
            //创建线要素
            GSOGeoPolyline3D line1   = new GSOGeoPolyline3D();
            GSOPoint3ds      points1 = new GSOPoint3ds();
            GSOPoint3d       point1  = new GSOPoint3d(120.27191, 31.9864637, 5);
            GSOPoint3d       point2  = new GSOPoint3d(120.271, 31.9864637, 5);

            points1.Add(point1);
            points1.Add(point2);
            line1.AddPart(points1);
            //设置线高度模式为相对地表
            line1.AltitudeMode = EnumAltitudeMode.RelativeToGround;

            //设置样式
            GSOPipeLineStyle3D style = new GSOPipeLineStyle3D();

            //管线颜色
            style.LineColor = Color.Brown;
            //管线半径, 单位:米
            style.Radius = 1;
            line1.Style  = style;
            //相对地表抬高半径的距离
            line1.MoveZ(style.Radius);
            //创建要素
            _pipeFeature1          = new GSOFeature();
            _pipeFeature1.Geometry = line1;
            //将要素添加到globe中并显示
            _glbControl.Globe.MemoryLayer.AddFeature(_pipeFeature1);

            _pipeFeature2 = new GSOFeature();
            GSOGeoPolyline3D line2 = new GSOGeoPolyline3D();

            line2.AltitudeMode = EnumAltitudeMode.RelativeToGround;
            GSOPoint3ds points2 = new GSOPoint3ds();
            GSOPoint3d  point3  = new GSOPoint3d(120.27191, 31.986, 0);
            GSOPoint3d  point4  = new GSOPoint3d(120.271, 31.986, 0);

            points2.Add(point3);
            points2.Add(point4);
            line2.AddPart(points2);
            line2.Style = style;
            line2.MoveZ(style.Radius);
            _pipeFeature2.Geometry = line2;

            _glbControl.Globe.MemoryLayer.AddFeature(_pipeFeature1);
            _glbControl.Globe.MemoryLayer.AddFeature(_pipeFeature2);
            _glbControl.Globe.FlyToFeature(_pipeFeature1);

            //添加辅助线
            GSOSimpleLineStyle3D lineStyle = new GSOSimpleLineStyle3D()
            {
                LineColor = Color.Yellow,
                LineType  = EnumLineType.Dot
            };

            //水平线
            GSOPoint3d       pointtemp = new GSOPoint3d(point4.X, point4.Y, point2.Z + _radius);
            GSOGeoPolyline3D lineHor   = new GSOGeoPolyline3D();
            GSOPoint3ds      pointsHor = new GSOPoint3ds();

            pointsHor.Add(pointtemp);
            pointsHor.Add(new GSOPoint3d(point2.X, point2.Y, point2.Z + _radius));
            lineHor.AddPart(pointsHor);
            lineHor.Style        = lineStyle;
            lineHor.AltitudeMode = EnumAltitudeMode.RelativeToGround;
            double     horLength      = Math.Round(lineHor.GetSpaceLength(true, 6378137), 3);
            GSOFeature featureHorLine = new GSOFeature()
            {
                Geometry = lineHor
            };

            featureHorLine.Label = CreateLabel(horLength.ToString());
            this._glbControl.Globe.MemoryLayer.AddFeature(featureHorLine);

            //垂直线
            GSOGeoPolyline3D lineVer   = new GSOGeoPolyline3D();
            GSOPoint3ds      pointsVer = new GSOPoint3ds();

            pointsVer.Add(pointtemp);
            pointsVer.Add(new GSOPoint3d(point4.X, point4.Y, point4.Z + _radius));
            lineVer.AddPart(pointsVer);
            lineVer.Style        = lineStyle;
            lineVer.AltitudeMode = EnumAltitudeMode.RelativeToGround;
            double verLength = Math.Round(Math.Abs(point2.Z - point4.Z));

            GSOFeature featureVerLine = new GSOFeature()
            {
                Geometry = lineVer
            };

            featureVerLine.Label = CreateLabel(verLength.ToString());
            this._glbControl.Globe.MemoryLayer.AddFeature(featureVerLine);
        }
Example #22
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            GSOFeatures features = mlayer.GetAllFeatures();
            for (int i = 0; i < features.Length; i++)
            {
                GSOFeature feature = features[i];
                switch (feature.Geometry.Type)
                {
                    case EnumGeometryType.GeoPolyline3D:

                        if (checkBoxLineStyle.Checked)
                        {
                            GSOSimpleLineStyle3D polylinestyle = null;
                            if (feature.Geometry.Style == null)
                            {
                                polylinestyle = new GSOSimpleLineStyle3D();
                                polylinestyle.LineColor = Color.FromArgb(Convert.ToByte(numericLineOpaque.Value), pictureBoxLineColor.BackColor);

                                polylinestyle.LineType = getLineType(comboBoxLineType.SelectedIndex);

                                if (textBoxLineWidth.Text != "")
                                {
                                    string strwidth = textBoxLineWidth.Text;
                                    double dwidth = 0.0;
                                    if (double.TryParse(strwidth, out dwidth))
                                    {
                                        polylinestyle.LineWidth = dwidth;
                                    }
                                }
                                feature.Geometry.Style = polylinestyle;
                            }
                            else
                            {
                                polylinestyle = (GSOSimpleLineStyle3D)feature.Geometry.Style;
                                polylinestyle.LineColor = Color.FromArgb(Convert.ToByte(numericLineOpaque.Value), pictureBoxLineColor.BackColor);
                                polylinestyle.LineType = getLineType(comboBoxLineType.SelectedIndex);
                                if (textBoxLineWidth.Text != "")
                                {
                                    string strwidth = textBoxLineWidth.Text;
                                    double dwidth = 0.0;
                                    if (double.TryParse(strwidth, out dwidth))
                                    {
                                        polylinestyle.LineWidth = dwidth;
                                    }
                                }
                            }
                        }
                        break;
                    case EnumGeometryType.GeoPolygon3D:

                        if (checkBoxPolygonStyle.Checked)
                        {
                            GSOSimplePolygonStyle3D polygonstyle = null;
                            GSOSimpleLineStyle3D outlinestyle = null;
                            if (checkBoxPolygonFillStyle.Checked)
                            {
                                if (feature.Geometry.Style == null)
                                {
                                    polygonstyle = new GSOSimplePolygonStyle3D();
                                    polygonstyle.FillColor = Color.FromArgb(Convert.ToByte(numericPolygonFillOpaque.Value), pictureBoxPolygonFillColor.BackColor);
                                    feature.Geometry.Style = polygonstyle;
                                }
                                else
                                {
                                    polygonstyle = (GSOSimplePolygonStyle3D)feature.Geometry.Style;
                                    polygonstyle.FillColor = Color.FromArgb(Convert.ToByte(numericPolygonFillOpaque.Value), pictureBoxPolygonFillColor.BackColor);
                                }
                            }
                            if (checkBoxPolygonOutlineStyle.Checked)
                            {

                                if (feature.Geometry.Style == null)
                                {
                                    polygonstyle = new GSOSimplePolygonStyle3D();
                                    outlinestyle = new GSOSimpleLineStyle3D();
                                    outlinestyle.LineColor = Color.FromArgb(Convert.ToByte(numericPolygonOutlineOpaque.Value), pictureBoxPolygonOutlineColor.BackColor);
                                    outlinestyle.LineType = getLineType(comboBoxPolygonOutlineType.SelectedIndex);
                                    if (textBoxPolygonOutlineWidth.Text != "")
                                    {
                                        string strwidth = textBoxPolygonOutlineWidth.Text;
                                        double dwidth = 0.0;
                                        if (double.TryParse(strwidth, out dwidth))
                                        {
                                            outlinestyle.LineWidth = dwidth;
                                        }
                                    }
                                    polygonstyle.OutlineStyle = outlinestyle;
                                    feature.Geometry.Style = polygonstyle;
                                }
                                else
                                {
                                    polygonstyle = (GSOSimplePolygonStyle3D)feature.Geometry.Style;
                                    if (polygonstyle.OutlineStyle == null)
                                    {
                                        outlinestyle = new GSOSimpleLineStyle3D();
                                        outlinestyle.LineColor = Color.FromArgb(Convert.ToByte(numericPolygonOutlineOpaque.Value), pictureBoxPolygonOutlineColor.BackColor);
                                        outlinestyle.LineType = getLineType(comboBoxPolygonOutlineType.SelectedIndex);
                                        if (textBoxPolygonOutlineWidth.Text != "")
                                        {
                                            string strwidth = textBoxPolygonOutlineWidth.Text;
                                            double dwidth = 0.0;
                                            if (double.TryParse(strwidth, out dwidth))
                                            {
                                                outlinestyle.LineWidth = dwidth;
                                            }
                                        }
                                        polygonstyle.OutlineStyle = outlinestyle;
                                        feature.Geometry.Style = polygonstyle;
                                    }
                                    else
                                    {
                                        outlinestyle = (GSOSimpleLineStyle3D)polygonstyle.OutlineStyle;
                                        outlinestyle.LineColor = Color.FromArgb(Convert.ToByte(numericPolygonOutlineOpaque.Value), pictureBoxPolygonOutlineColor.BackColor);
                                        outlinestyle.LineType = getLineType(comboBoxPolygonOutlineType.SelectedIndex);
                                        if (textBoxPolygonOutlineWidth.Text != "")
                                        {
                                            string strwidth = textBoxPolygonOutlineWidth.Text;
                                            double dwidth = 0.0;
                                            if (double.TryParse(strwidth, out dwidth))
                                            {
                                                outlinestyle.LineWidth = dwidth;
                                            }
                                        }
                                        feature.Geometry.Style = polygonstyle;
                                    }
                                }
                            }
                        }
                        break;
                }
                mGlobeControl.Refresh();
            }
            this.Close();
        }
        private void button2_Click(object sender, EventArgs e)
        {
            if (comboBoxLayers.Text == "")
            {
                MessageBox.Show("请选择一个图层!");
                return;
            }
            GSOLayer layer = mGlobeControl.Globe.Layers.GetLayerByCaption(comboBoxLayers.Text.Trim());

            if (layer == null)
            {
                MessageBox.Show("您选择的图层不存在!");
                return;
            }

            string iconPath = textBoxIconPath.Text.Trim();

            if (iconPath == "")
            {
                iconPath = Application.StartupPath + "\\Resource\\DefaultIcon.png";
            }

            Color  lineColor     = textBoxLineColor.BackColor;
            string strLineWidth  = textBoxLineWidth.Text.Trim();
            double lineWidth     = 1;
            bool   blIsLineWidth = double.TryParse(strLineWidth, out lineWidth);

            Color  outlineColor     = textBoxOutlineColor.BackColor;
            string strOutlineWidth  = textBoxOutlineWidth.Text.Trim();
            double outlineWidth     = 1;
            bool   blIsOutlineWidth = double.TryParse(strOutlineWidth, out outlineWidth);
            Color  polygonColor     = textBoxPolygonColor.BackColor;
            string strPolygonAlpha  = textBoxPolygonAlpha.Text.Trim();
            int    polygonAlpha     = 255;
            bool   blIsPolygonAlpha = int.TryParse(strPolygonAlpha, out polygonAlpha);

            polygonColor = Color.FromArgb(polygonAlpha, polygonColor);

            for (int i = 0; i < layer.GetAllFeatures().Length; i++)
            {
                GSOFeature feature = layer.GetAt(i);
                if (feature.Geometry != null)
                {
                    switch (feature.Geometry.Type)
                    {
                    case EnumGeometryType.GeoPoint3D:
                        if (panelPoints.Enabled)
                        {
                            GSOGeoPoint3D point  = (GSOGeoPoint3D)feature.Geometry;
                            GSOGeoMarker  marker = new GSOGeoMarker();
                            marker.Position    = point.Position;
                            marker.Name        = point.Name;
                            marker.CameraState = point.CameraState;
                            marker.Label       = point.Label;

                            GSOFeature newFeature = new GSOFeature();
                            newFeature.Name     = feature.Name;
                            newFeature.Geometry = marker;

                            layer.RemoveAt(i);
                            layer.AddFeature(newFeature);
                            i--;
                        }
                        break;

                    case EnumGeometryType.GeoMarker:
                        if (panelPoints.Enabled)
                        {
                            GSOGeoMarker     marker = (GSOGeoMarker)feature.Geometry;
                            GSOMarkerStyle3D style  = null;

                            if (marker.Style == null)
                            {
                                style = new GSOMarkerStyle3D();
                            }
                            else
                            {
                                style = (GSOMarkerStyle3D)marker.Style;
                            }

                            style.TextVisible = !checkBoxHideLabelOfMarker.Checked;
                            style.IconPath    = iconPath.Trim();

                            marker.Style = style;
                        }
                        break;

                    case EnumGeometryType.GeoPolyline3D:
                        if (panelLines.Enabled)
                        {
                            GSOGeoPolyline3D line = (GSOGeoPolyline3D)feature.Geometry;
                            if (line.Label != null)
                            {
                                line.Label.Visible = !checkBoxHideLabelOfLine.Checked;
                            }
                            if (line.Style == null)
                            {
                                GSOSimpleLineStyle3D styleLine = new GSOSimpleLineStyle3D();
                                styleLine.LineColor = lineColor;
                                styleLine.LineWidth = lineWidth;
                                line.Style          = styleLine;
                            }
                            else
                            {
                                GSOSimpleLineStyle3D styleLine = (GSOSimpleLineStyle3D)line.Style;
                                if (styleLine == null)
                                {
                                    GSOPipeLineStyle3D pipeStyle = (GSOPipeLineStyle3D)line.Style;
                                    if (pipeStyle != null)
                                    {
                                        pipeStyle.LineColor = lineColor;
                                        pipeStyle.Radius    = lineWidth / 2;
                                        line.Style          = pipeStyle;
                                    }
                                }
                                else
                                {
                                    styleLine.LineColor = lineColor;
                                    styleLine.LineWidth = lineWidth;
                                    line.Style          = styleLine;
                                }
                            }
                        }
                        break;

                    case EnumGeometryType.GeoPolygon3D:
                        if (panelPolygons.Enabled)
                        {
                            GSOGeoPolygon3D polygon = (GSOGeoPolygon3D)feature.Geometry;
                            if (polygon.Label != null)
                            {
                                polygon.Label.Visible = !checkBoxHideLabelOfPolygon.Checked;
                            }
                            GSOSimplePolygonStyle3D stylePolygon = (polygon.Style == null ? new GSOSimplePolygonStyle3D() : (GSOSimplePolygonStyle3D)polygon.Style);
                            stylePolygon.FillColor      = polygonColor;
                            stylePolygon.OutLineVisible = true;
                            GSOSimpleLineStyle3D styleOutline = (GSOSimpleLineStyle3D)stylePolygon.OutlineStyle;
                            if (styleOutline == null)
                            {
                                styleOutline = new GSOSimpleLineStyle3D();
                            }
                            styleOutline.LineWidth    = outlineWidth;
                            styleOutline.LineColor    = outlineColor;
                            stylePolygon.OutlineStyle = styleOutline;
                            polygon.Style             = stylePolygon;
                        }
                        break;
                    }
                }
            }
            mGlobeControl.Globe.Refresh();
            this.Close();
        }
        private void SetControlsByStyle(GSOStyle style)
        {
            simpleLineStyle3D = style as GSOSimpleLineStyle3D;
            if (simpleLineStyle3D != null)
            {

                // 这句要写到前面,不然下面Checked的时候要检查
                pictureBoxLineColor.BackColor = Color.FromArgb(255, simpleLineStyle3D.LineColor);
                numericUpDownLineOpaque.Value = simpleLineStyle3D.LineColor.A;
                textBoxLineWidth.Text = simpleLineStyle3D.LineWidth.ToString();

                switch (simpleLineStyle3D.LineType)
                {
                    case EnumLineType.Solid:
                        comboBoxLineType.SelectedIndex = 0;
                        break;
                    case EnumLineType.Dash:
                        comboBoxLineType.SelectedIndex = 1;
                        break;
                    case EnumLineType.Dot:
                        comboBoxLineType.SelectedIndex = 2;
                        break;
                    case EnumLineType.DashDot:
                        comboBoxLineType.SelectedIndex = 3;
                        break;
                    case EnumLineType.DashDotDot:
                        comboBoxLineType.SelectedIndex = 4;
                        break;
                }

                checkBoxUseStyle.Checked = true;
            }
            else
            {
                simpleLineStyle3D = new GSOSimpleLineStyle3D();
                m_Geometry.Style = simpleLineStyle3D;
                checkBoxUseStyle.Checked = false;
            }

            CheckControlsEnable(checkBoxUseStyle.Checked);
        }
Example #25
0
        private void RefreshGlobe(GSOSimpleLineStyle3D simpleLineStyle3D)
        {
            GSOGeoPolyline3D line = mfeature.Geometry as GSOGeoPolyline3D;
            line.Style = simpleLineStyle3D;
            mfeature.Geometry = line;

            //mfeature.Geometry.Style = simpleLineStyle3D;
            if (m_GlobeControl != null)
            {
                m_GlobeControl.Globe.Refresh();
            }
        }