コード例 #1
0
 public static MoveNodesDlg GetInstance()
 {
     if (_defaultIntance == null)
     {
         _defaultIntance = new MoveNodesDlg();
     }
     return(_defaultIntance);
 }
コード例 #2
0
 public MoveNodesDlg()
 {
     InitializeComponent();
     this.btnStartEditNode.IsEnabled = false;
     this.Owner       = MainWindow.m_MainWindow;
     this.DataContext = this;
     _defaultIntance  = this;
     //获取视图中图层列表
     m_FeaLyrList = MainWindow.m_DotMap.GetFeatureLayers();
     foreach (ILayer layer in m_FeaLyrList)
     {
         if (layer is IFeatureLayer)
         {
             this.cboLayer.Items.Add((layer as FeatureLayer).Name);
         }
     }
     if (this.cboLayer.Items.Count > 0)
     {
         this.cboLayer.SelectedIndex = 0;
     }
 }
コード例 #3
0
        private void M_DotMap_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (m_AddFeaType != FeaType.None)
            {
                Coordinate coord = m_DotMap.PixelToProj(e.Location);//点击的屏幕未知转换成坐标系中的点
                switch (m_AddFeaType)
                {
                case FeaType.Point:
                {
                    CreatePointDlg f = UCVectorDataEditing.m_CreatePointDlg;
                    if (f == null)
                    {
                        return;
                    }
                    var         layer  = f.m_PointLayer;
                    IFeatureSet PointF = (layer as FeatureLayer).FeatureSet;
                    GeoAPI.Geometries.IPoint pPoint = new NetTopologySuite.Geometries.Point(coord);
                    IFeature currentFeature         = PointF.AddFeature(pPoint);
                    PointF.InitializeVertices();
                    m_DotMap.ResetBuffer();
                }
                break;

                case FeaType.Polyline:
                {
                    CreatePolylineDlg f = UCVectorDataEditing.m_CreatePolylineDlg;
                    if (f == null)
                    {
                        return;
                    }
                    var         layer = f.m_PolylineLayer;
                    IFeatureSet LineF = (layer as FeatureLayer).FeatureSet;
                    if (e.Button == System.Windows.Forms.MouseButtons.Left)
                    {
                        if (f.IsFirstPoint)
                        {
                            //一开始就要加入至少两个点
                            f.CoordList.Add(coord);
                            f.CoordList.Add(coord);
                            LineString line        = new LineString(f.CoordList.ToArray());
                            IFeature   lineFeature = LineF.AddFeature(line);
                            f.IsFirstPoint = false;
                        }
                        else
                        {
                            LineF.Features.RemoveAt(LineF.Features.Count - 1);
                            if (f.CoordList[0] == f.CoordList[1])
                            {
                                f.CoordList.RemoveAt(1);
                            }
                            f.CoordList.Add(coord);
                            LineString line        = new LineString(f.CoordList.ToArray());
                            IFeature   lineFeature = LineF.AddFeature(line);
                            m_DotMap.ResetBuffer();
                        }
                    }
                    else if (e.Button == System.Windows.Forms.MouseButtons.Right)
                    {
                        LineF.InitializeVertices();
                        f.IsFirstPoint = true;
                        f.CoordList.Clear();
                        m_DotMap.ResetBuffer();
                    }
                }
                break;

                case FeaType.Polygon:
                {
                    CreatePolygonDlg f = UCVectorDataEditing.m_CreatePolygonDlg;
                    if (f == null)
                    {
                        return;
                    }
                    var         layer    = f.m_PolygonLayer;
                    IFeatureSet PolygonF = (layer as FeatureLayer).FeatureSet;
                    if (e.Button == System.Windows.Forms.MouseButtons.Left)
                    {
                        if (f.IsFirstPoint)
                        {
                            for (int i = 0; i < 4; i++)
                            {
                                f.CoordList.Add(coord);
                            }
                            ILinearRing LineRing = new LinearRing(f.CoordList.ToArray());
                            NetTopologySuite.Geometries.Polygon pPolygon = new NetTopologySuite.Geometries.Polygon(LineRing);
                            IFeature polygonFeature = PolygonF.AddFeature(pPolygon);
                            f.IsFirstPoint = false;
                        }
                        else
                        {
                            PolygonF.Features.RemoveAt(PolygonF.Features.Count - 1);
                            if (f.CoordList[0] == f.CoordList[1])
                            {
                                f.CoordList.RemoveAt(1);
                            }
                            //组成面的点必须形成一个闭环 因此要先把最新加入的点去掉,加入绘制点之后再加入第一个点
                            f.CoordList.RemoveAt(f.CoordList.Count - 1);
                            f.CoordList.Add(coord);
                            f.CoordList.Add(f.CoordList[0]);
                            ILinearRing LineRing = new LinearRing(f.CoordList.ToArray());
                            NetTopologySuite.Geometries.Polygon pPolygon = new NetTopologySuite.Geometries.Polygon(LineRing);
                            IFeature lineFeature = PolygonF.AddFeature(pPolygon);
                            m_DotMap.ResetBuffer();
                        }
                    }
                    else if (e.Button == System.Windows.Forms.MouseButtons.Right)
                    {
                        PolygonF.InitializeVertices();
                        f.IsFirstPoint = true;
                        f.CoordList.Clear();
                        m_DotMap.ResetBuffer();
                    }
                }
                break;

                case FeaType.UCPoint:
                {
                    bool ShouldAdd        = true;
                    UCTopologyAnalysis uc = UCTopologyAnalysis.GetIntance();
                    if (uc.ClickIndex >= 1)
                    {
                        m_AddFeaType    = FeaType.None;
                        uc.ClickIndex   = 0;
                        ShouldAdd       = false;
                        m_DotMap.Cursor = System.Windows.Forms.Cursors.Default;
                    }
                    var         layer  = uc.m_PointLayer;
                    IFeatureSet PointF = (layer as FeatureLayer).FeatureSet;
                    GeoAPI.Geometries.IPoint pPoint = new NetTopologySuite.Geometries.Point(coord);
                    IFeature currentFeature         = PointF.AddFeature(pPoint);
                    m_DotMap.ResetBuffer();
                    if (ShouldAdd)
                    {
                        uc.ClickIndex++;
                    }
                }
                break;

                case FeaType.MovePoint:
                {
                    if (e.Button == System.Windows.Forms.MouseButtons.Right)
                    {
                        var defaultIntance = MoveNodesDlg.GetInstance();
                        if (defaultIntance != null)
                        {
                            defaultIntance.MoveNode(coord);
                        }
                    }
                }
                break;

                case FeaType.MoveFeature:
                {
                    if (e.Button == System.Windows.Forms.MouseButtons.Right)
                    {
                        var defaultIntance = MoveFeatureDlg.GetInstance();
                        if (defaultIntance != null)
                        {
                            defaultIntance.MoveFeature(coord);
                        }
                    }
                }
                break;

                case FeaType.RotateFeature:
                {
                    if (e.Button == System.Windows.Forms.MouseButtons.Right)
                    {
                        var defaultIntance = RotateFeatureDlg.GetInstance();
                        if (defaultIntance != null)
                        {
                            defaultIntance.RotateFeature(coord);
                        }
                    }
                    break;
                }
                }
            }
        }