示例#1
0
        private void tspNewLayer_Click(object sender, EventArgs e)
        {
            HookHelper   mHook   = HookHelper.Instance();
            IMapControl2 mapCtrl = mHook.MapControl as IMapControl2;

            RGeos.Carto.IMap   map        = mapCtrl.Map;
            FrmNewFeatureClass newFeatCls = new FrmNewFeatureClass();

            if (newFeatCls.ShowDialog() == DialogResult.OK)
            {
                RGeos.Carto.ILayer layer = new RGeos.Carto.FetureLayer();
                layer.Name = newFeatCls.FeatureName;
                (layer as RGeos.Carto.FetureLayer).ShapeType = newFeatCls.ShapeType;
                map.AddLayer(layer);
                mapCtrl.Refresh();
            }
        }
示例#2
0
        private void tspNewLayer_Click(object sender, EventArgs e)
        {
            HookHelper   mHook   = HookHelper.Instance();
            IMapControl2 mapCtrl = mHook.MapControl as IMapControl2;

            RGeos.Carto.IMap   map        = mapCtrl.Map;
            frmNewFeatureClass newFeatCls = new frmNewFeatureClass();

            if (newFeatCls.ShowDialog() == DialogResult.OK)
            {
                RGeos.Carto.ILayer layer = new RGeos.Carto.FetureLayer();
                layer.Name = newFeatCls.FeatureName;
                (layer as RGeos.Carto.FetureLayer).ShapeType = newFeatCls.ShapeType;
                map.AddLayer(layer);
                mapCtrl.Refresh();
            }
            //RGeos.Carto.ILayer layer = new RGeos.Carto.FetureLayer();
            //(layer as RGeos.Carto.FetureLayer).ShapeType = RgEnumShapeType.RgLineString;
            //LineString line = new LineString();
            //RgPoint pt = new RgPoint(0, 0);
            //RgPoint pt1 = new RgPoint(10 / MillmeteresPerInch, 0);
            //line.Vertices.Add(pt);
            //line.Vertices.Add(pt1);
            //(layer as RGeos.Carto.FetureLayer).mGeometries.Add(line);
            //LineString line1 = new LineString();
            //RgPoint pt11 = new RgPoint(0, 10 / MillmeteresPerInch);
            //RgPoint pt12 = new RgPoint(0, 0);
            //line1.Vertices.Add(pt11);
            //line1.Vertices.Add(pt12);
            //(layer as RGeos.Carto.FetureLayer).mGeometries.Add(line1);
            //map.AddLayer(layer);

            //RGeos.Carto.ILayer layerPolygon = new RGeos.Carto.FetureLayer();
            //(layerPolygon as RGeos.Carto.FetureLayer).ShapeType = RgEnumShapeType.RgPolygon;
            //map.AddLayer(layerPolygon);

            //RGeos.Carto.ILayer layerPolygon = new RGeos.Carto.FetureLayer();
            //(layerPolygon as RGeos.Carto.FetureLayer).ShapeType = RgEnumShapeType.RgPoint;
            //map.AddLayer(layerPolygon);
            //mapCtrl.Refresh();
        }
示例#3
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            int  row   = 0;
            bool flag  = int.TryParse(txtRows.Text, out row);
            int  col   = 0;
            bool flag1 = int.TryParse(txtCols.Text, out col);

            double rheight, rwidth;
            bool   flag3 = double.TryParse(txtRowHeight.Text, out rheight);
            bool   flag4 = double.TryParse(txtRowWidth.Text, out rwidth);

            if (!flag)
            {
                MessageBox.Show("请输入正确的行数", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtRows.Focus();
                return;
            }
            if (!flag1)
            {
                MessageBox.Show("请输入正确的列数", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtCols.Focus();
                return;
            }
            if (!flag3)
            {
                MessageBox.Show("请输入正确的行高", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtRowHeight.Focus();
                return;
            }
            if (!flag4)
            {
                MessageBox.Show("请输入正确的行宽", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtRowWidth.Focus();
                return;
            }
            IMapControl2 mapCtrl = mMapCtrl as IMapControl2;

            RGeos.Carto.IMap map = mapCtrl.Map;

            if (chkGridPoint.Checked)
            {
                RGeos.Carto.FetureLayer layer = new RGeos.Carto.FetureLayer();
                layer.Name      = "GridPoint";
                layer.ShapeType = RgEnumShapeType.RgPoint;
                map.AddLayer(layer);

                double baseX;
                bool   flag5 = double.TryParse(txtX.Text, out baseX);
                double baseY;
                bool   flag6 = double.TryParse(txtY.Text, out baseY);

                for (int i = 0; i < row; i++)
                {
                    for (int j = 0; j < col; j++)
                    {
                        RgPoint pt = new RgPoint();
                        pt.X = baseX + i * rwidth;
                        pt.Y = baseY + j * rheight;
                        layer.AddFeature(pt);
                    }
                }
            }
            if (chkGridLine.Checked)
            {
                RGeos.Carto.FetureLayer layer = new RGeos.Carto.FetureLayer();
                layer.Name      = "GridLine";
                layer.ShapeType = RgEnumShapeType.RgLineString;
                map.AddLayer(layer);

                double baseX;
                bool   flag5 = double.TryParse(txtX.Text, out baseX);
                double baseY;
                bool   flag6 = double.TryParse(txtY.Text, out baseY);

                RgPoint ptLowerLeft = new RgPoint();
                ptLowerLeft.X = baseX;
                ptLowerLeft.Y = baseY;
                RgPoint ptLowerRight = new RgPoint();
                ptLowerRight.X = baseX + col * rwidth;
                ptLowerRight.Y = baseY;

                RgPoint ptTopRight = new RgPoint();
                ptTopRight.X = baseX + col * rwidth;
                ptTopRight.Y = baseY + row * rheight;
                RgPoint ptTopLeft = new RgPoint();
                ptTopLeft.X = baseX;
                ptTopLeft.Y = baseY + row * rheight;


                List <RgPoint> ptBounds = new List <RgPoint>();
                ptBounds.Add(ptLowerLeft);
                ptBounds.Add(ptLowerRight);
                ptBounds.Add(ptTopRight);
                ptBounds.Add(ptTopLeft);
                ptBounds.Add(ptLowerLeft);
                LineString lineBounds = new LineString(ptBounds);
                layer.AddFeature(lineBounds);

                for (int i = 1; i < row; i++)
                {
                    RgPoint ptStart = new RgPoint();
                    ptStart.X = baseX;
                    ptStart.Y = baseY + i * rheight;
                    RgPoint ptEnd = new RgPoint();
                    ptEnd.X = baseX + col * rwidth;
                    ptEnd.Y = baseY + i * rheight;
                    List <RgPoint> pts = new List <RgPoint>();
                    pts.Add(ptStart);
                    pts.Add(ptEnd);
                    LineString line = new LineString(pts);
                    layer.AddFeature(line);
                }
                for (int j = 1; j < col; j++)
                {
                    RgPoint ptStart = new RgPoint();
                    ptStart.X = baseX + j * rwidth;
                    ptStart.Y = baseY;
                    RgPoint ptEnd = new RgPoint();
                    ptEnd.X = baseX + j * rwidth;
                    ptEnd.Y = baseY + row * rheight;
                    List <RgPoint> pts = new List <RgPoint>();
                    pts.Add(ptStart);
                    pts.Add(ptEnd);
                    LineString line = new LineString(pts);
                    layer.AddFeature(line);
                }
            }
            mapCtrl.Refresh();
        }