예제 #1
0
 //删除
 private void button3_Click(object sender, EventArgs e)
 {
     try
     {
         double min = double.Parse(textBox1.Text);
         double max = double.Parse(textBox2.Text);
         for (int i = 0; i < treeView1.Nodes.Count; i++)
         {
             if (treeView1.Nodes[i].Checked)
             {
                 GSOLayer    layer = treeView1.Nodes[i].Tag as GSOLayer;
                 GSOFeatures fs    = layer.GetAllFeatures();
                 for (int j = fs.Length - 1; j >= 0; j--)
                 {
                     GSOFeature f = fs[j];
                     double     z = f.Geometry.GeoCenterPoint.Z;
                     if (z >= min && z <= max)
                     {
                         layer.RemoveAt(j);
                     }
                 }
             }
         }
     }
     catch (Exception exp)
     {
         exp.GetType();
     }
 }
        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();
        }