Exemple #1
0
        private void buttonItem22_Click(object sender, EventArgs e)
        {
            //删除所选要素(单选):
            m_sketchshape        = "featuredelete";
            m_NewPolygonFeedback = null;
            IFeatureLayer     iCheckLayer      = m_MapCtrls.ActiveView.FocusMap.get_Layer(0) as IFeatureLayer;
            IFeatureSelection CurrentSelection = iCheckLayer as IFeatureSelection;
            int OID = 0;

            if (CurrentSelection.SelectionSet.Count == 1)
            {
                OID = CurrentSelection.SelectionSet.IDs.Next();
            }
            if (OID > 0)
            {
                IFeatureWorkspace checkWorkspace    = m_GlobalWorkspace as IFeatureWorkspace;
                IFeatureClass     checkFeatureClass = checkWorkspace.OpenFeatureClass("CheckArea");
                if (!(m_EditWorkspace.IsBeingEdited()))
                {
                    m_EditWorkspace.StartEditing(false);
                }

                m_EditWorkspace.StartEditOperation();
                CheckFeatueEditor.DeleteCheckArea(OID, checkFeatureClass);
                m_EditWorkspace.StopEditOperation();

                MessageBox.Show("删除成功!");
                //清除选择要素:
                CurrentSelection.Clear();
                m_MapCtrls.ActiveView.Refresh();
            }
        }
Exemple #2
0
        private void buttonX1_Click(object sender, EventArgs e)
        {
            //提交注释:
            if (this.textBoxX1.Text.Trim() == "")
            {
                return;
            }

            string textinput = this.textBoxX1.Text;
            //根据当前所选要素进行更新注释;
            IFeatureLayer     iCheckLayer     = m_MapCtrls.Map.get_Layer(0) as IFeatureLayer;
            IFeatureSelection iCheckSelection = iCheckLayer as IFeatureSelection;
            int CheckFeatureOID = 0;

            if (iCheckSelection.SelectionSet.Count == 1)
            {
                CheckFeatureOID = iCheckSelection.SelectionSet.IDs.Next();
            }

            if (CheckFeatureOID > 0)
            {
                IVersionedWorkspace3 versionWorkspace  = m_GlobalWorkspace as IVersionedWorkspace3;
                IFeatureWorkspace    checkWorkspace    = versionWorkspace as IFeatureWorkspace;
                IFeatureClass        checkFeatureClass = checkWorkspace.OpenFeatureClass("CheckArea");
                if (checkFeatureClass != null)
                {
                    if (!(m_EditWorkspace.IsBeingEdited()))
                    {
                        m_EditWorkspace.StartEditing(false);
                    }

                    m_EditWorkspace.StartEditOperation();
                    int res = CheckFeatueEditor.UpdateComment(CheckFeatureOID, checkFeatureClass, textinput);
                    m_EditWorkspace.StopEditOperation();

                    if (res > 0)
                    {
                        MessageBox.Show("提交成功!");
                        m_MapCtrls.ActiveView.Refresh();
                    }
                    else
                    {
                        MessageBox.Show("提交失败!");
                    }
                }
            }
        }
Exemple #3
0
        private void buttonItem8_Click_1(object sender, EventArgs e)
        {
            //弹出保存shp框:
            ExportSHPDlg dlg = new ExportSHPDlg();

            if (dlg.getDLG().ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string strSHPPath = dlg.getDLG().FileName;
                bool   res        = CheckFeatueEditor.ExportSHP(strSHPPath, m_GlobalWorkspace);
                if (res == true)
                {
                    MessageBox.Show("导出成功!");
                }
                else
                {
                    MessageBox.Show("导出失败!");
                }
            }
        }
Exemple #4
0
        private void axMapControl1_OnSelectionChanged(object sender, EventArgs e)
        {
            this.textBoxX1.Clear();

            IFeatureLayer     iCheckLayer      = m_MapCtrls.ActiveView.FocusMap.get_Layer(0) as IFeatureLayer;
            IFeatureSelection CurrentSelection = iCheckLayer as IFeatureSelection;
            int OID = 0;

            if (CurrentSelection.SelectionSet.Count == 1)
            {
                OID = CurrentSelection.SelectionSet.IDs.Next();
            }
            if (OID > 0)
            {
                IFeatureWorkspace checkWorkspace    = m_GlobalWorkspace as IFeatureWorkspace;
                IFeatureClass     checkFeatureClass = checkWorkspace.OpenFeatureClass("CheckArea");
                this.textBoxX1.Text = CheckFeatueEditor.GetComment(OID, checkFeatureClass);
                //this.textBoxX1.Text = checkFeatureClass.GetFeature(OID).get_Value(5).ToString();
            }
        }
Exemple #5
0
        private void LoadAllCheckedItems(string pFeatureClassName)
        {
            //遍历更新的图层要素:
            IFeatureWorkspace checkWorkspace    = m_GlobalWorkspace as IFeatureWorkspace;
            IFeatureClass     checkFeatureClass = checkWorkspace.OpenFeatureClass(pFeatureClassName);
            IFeatureCursor    cursor            = CheckFeatueEditor.CheckFeaturesGDB(checkFeatureClass, AppManager.GetInstance().TaskName);

            //IFeatureCursor cursor = CheckFeatueEditor.CheckFeaturesGDB(checkFeatureClass);
            if (cursor != null)
            {
                IFeature feature = cursor.NextFeature();
                while (feature != null)
                {
                    int    namefieldindex = feature.Fields.FindFieldByAliasName("ObjectClass");
                    int    fidfieldindex  = feature.Fields.FindFieldByAliasName("FeatureID");
                    string text           = feature.get_Value(fidfieldindex).ToString() + "." + feature.get_Value(namefieldindex).ToString();
                    //string text = feature.OID.ToString() + "." + feature.Class.AliasName;
                    ButtonItem buttonitem = new ButtonItem(text, text);
                    buttonitem.Tooltip = feature.OID.ToString() + "." + feature.Class.AliasName;
                    this.itemPanel2.Items.Add(buttonitem as BaseItem);
                    feature = cursor.NextFeature();
                }
            }
        }
Exemple #6
0
        private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            #region 处理各种交互情况
            switch (m_sketchshape)
            {
            case "polygon":
            {
                IScreenDisplay iSDisplay = m_MapCtrls.ActiveView.ScreenDisplay;

                IPoint newPoint = new PointClass();
                newPoint = iSDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);

                if (e.button == 1)
                {
                    //左单击画多边形添加点:
                    if (m_NewPolygonFeedback == null)
                    {
                        m_NewPolygonFeedback = new NewPolygonFeedbackClass();

                        m_NewPolygonFeedback.Display = iSDisplay;
                        m_NewPolygonFeedback.Start(newPoint);
                    }
                    else
                    {
                        m_NewPolygonFeedback.AddPoint(newPoint);
                    }
                }
                if (e.button == 2)
                {
                    if (m_NewPolygonFeedback == null)
                    {
                        return;
                    }
                    //右键结束绘制:
                    m_NewPolygonFeedback.AddPoint(newPoint);
                    m_NewPolygon = m_NewPolygonFeedback.Stop();

                    //若是逆时针创建,反转一下,变为顺时针:
                    IArea feedBackArea = m_NewPolygon as IArea;
                    if (feedBackArea.Area < 0)
                    {
                        m_NewPolygon.ReverseOrientation();
                    }

                    IGeometry         newGeometry       = m_NewPolygon as IGeometry;
                    IFeatureWorkspace checkWorkspace    = m_GlobalWorkspace as IFeatureWorkspace;
                    IFeatureClass     checkFeatureClass = checkWorkspace.OpenFeatureClass("CheckArea");


                    if (!(m_EditWorkspace.IsBeingEdited()))
                    {
                        m_EditWorkspace.StartEditing(false);
                    }

                    m_EditWorkspace.StartEditOperation();
                    int OID = CheckFeatueEditor.InsertNewFeature(newGeometry, checkFeatureClass, AppManager.GetInstance().TaskName);
                    m_EditWorkspace.StopEditOperation();
                    //ISelectionEnvironment selectionEnv = new SelectionEnvironmentClass();
                    //selectionEnv.AreaSelectionMethod = esriSpatialRelEnum.esriSpatialRelOverlaps;
                    //selectionEnv.CombinationMethod = esriSelectionResultEnum.esriSelectionResultNew;
                    //this.m_MapCtrls.ActiveView.FocusMap.SelectByShape(feature.Shape, null, true);
                    //this.m_MapCtrls.ActiveView.FocusMap.SelectByShape(feature.Shape, selectionEnv, true);
                    //m_MapCtrls.Map.SelectByShape(m_NewPolygon, null, true);
                    ILayer   iLayer   = m_MapCtrls.Layer[0];
                    IFeature iFeature = checkFeatureClass.GetFeature(OID);

                    clearFeatureSelection();

                    m_MapCtrls.Map.SelectFeature(iLayer, iFeature);
                    m_NewPolygonFeedback = null;
                    m_MapCtrls.ActiveView.Refresh();
                }
                break;
            }

            case "rectangle":
            {
                IScreenDisplay iSDisplay = m_MapCtrls.ActiveView.ScreenDisplay;

                IPoint newPoint = new PointClass();
                newPoint = iSDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);
                if (e.button == 1)
                {
                    if (m_RecFeedback == null)
                    {
                        m_RecFeedback         = new NewRectangleFeedbackClass();
                        m_RecFeedback.Display = iSDisplay;
                        m_RecFeedback.Angle   = 90;
                        m_RecFeedback.Start(newPoint);

                        newPoint.Y = newPoint.Y + 20;

                        m_RecFeedback.SetPoint(newPoint);
                    }
                    else
                    {
                        m_RecFeedback.SetPoint(newPoint);
                    }
                }
                if (e.button == 2)
                {
                    if (m_RecFeedback != null)
                    {
                        m_NewPolygon = m_RecFeedback.Stop(newPoint) as IPolygon;

                        //若是逆时针创建,反转一下,变为顺时针:
                        IArea feedBackArea = m_NewPolygon as IArea;
                        if (feedBackArea.Area < 0)
                        {
                            m_NewPolygon.ReverseOrientation();
                        }

                        IGeometry         newGeometry       = m_NewPolygon as IGeometry;
                        IFeatureWorkspace checkWorkspace    = m_GlobalWorkspace as IFeatureWorkspace;
                        IFeatureClass     checkFeatureClass = checkWorkspace.OpenFeatureClass("CheckArea");


                        if (!(m_EditWorkspace.IsBeingEdited()))
                        {
                            m_EditWorkspace.StartEditing(false);
                        }

                        m_EditWorkspace.StartEditOperation();
                        int OID = CheckFeatueEditor.InsertNewFeature(newGeometry, checkFeatureClass, AppManager.GetInstance().TaskName);
                        m_EditWorkspace.StopEditOperation();

                        ILayer   iLayer   = m_MapCtrls.Layer[0];
                        IFeature iFeature = checkFeatureClass.GetFeature(OID);

                        clearFeatureSelection();

                        m_MapCtrls.Map.SelectFeature(iLayer, iFeature);
                        m_MapCtrls.ActiveView.Refresh();
                        m_RecFeedback = null;
                    }
                }

                break;
            }
            }
            #endregion
        }