コード例 #1
0
ファイル: MapEditorUtil.cs プロジェクト: bnitelf/ArcObjectX
        public static void StartEdit(string layerName)
        {
            // If an edit session has already been started, exit.
            if (engineEditor.EditState != esriEngineEditState.esriEngineStateNotEditing)
            {
                return;
            }

            IMap          map          = Map;
            IFeatureLayer featureLayer = GetLayerFromTOC(layerName) as IFeatureLayer;
            IDataset      dataset      = (IDataset)featureLayer.FeatureClass;
            IWorkspace    workspace    = dataset.Workspace;

            engineEditor.StartEditing(workspace, map);
        }
コード例 #2
0
        public void OnClick()
        {
            m_Map          = m_hookHelper.FocusMap;
            m_activeView   = m_Map as IActiveView;
            m_EngineEditor = MapManager.EngineEditor;
            if (m_EngineEditor == null)
            {
                return;
            }
            if (m_EngineEditor.EditState != esriEngineEditState.esriEngineStateEditing)
            {
                return;
            }
            IWorkspace pWs      = m_EngineEditor.EditWorkspace;
            Boolean    bHasEdit = m_EngineEditor.HasEdits();

            if (bHasEdit)
            {
                //if (MessageBox.Show("是否保存所做的编辑?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    m_EngineEditor.StopEditing(true);
                    m_EngineEditor.StartEditing(pWs, m_Map);
                    m_activeView.Refresh();
                }
            }
        }
コード例 #3
0
        private void cmdEdit_Click(object sender, EventArgs e)
        {
            if (cmdEdit.Text == "Edit")
            {
                IFeatureLayer featlayer = FindFeatureLayer("usa_major_highways");

                if (featlayer != null)
                {
                    m_engineEditor.StartEditing(((IDataset)featlayer.FeatureClass).Workspace, m_mapControl.Map);
                    IEngineEditLayers editLayer = (IEngineEditLayers)m_engineEditor;
                    editLayer.SetTargetLayer(featlayer, 0);
                    EnableButtons();

                    cmdEdit.Text = "Finish";
                    Color color = Color.Red;
                    cmdEdit.BackColor = color;
                    cmdCreate_Click(cmdCreate, null);
                }
            }
            else
            {
                SaveEdits();
                DisableButtons();
                cmdEdit.Text = "Edit";
                Color color = Color.White;
                cmdEdit.BackColor = color;
                SetErrorLabel("");
            }
        }
コード例 #4
0
        private void save_attribute()
        {
            //判断属性有没有改变
            if (mDataGridTableChanged.Count == 0)
            {
                XtraMessageBox.Show("未进行修改", "提示信息", MessageBoxButtons.OK);
                return;
            }

            DataTable dt = dataGridView1.DataSource as DataTable;

            IFeatureLayer pFeatureLayer = mLayer as IFeatureLayer;
            IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;

            //启动编辑
            //todo
            //workspace maybe null
            IWorkspace    workspace     = pFeatureClass.FeatureDataset.Workspace;
            IEngineEditor mEngineEditor = mEngineEditor = new EngineEditorClass();

            //mEngineEditor.EditSessionMode = esriEngineEditSessionMode.esriEngineEditSessionModeNonVersioned;
            mEngineEditor.EditSessionMode = esriEngineEditSessionMode.esriEngineEditSessionModeVersioned;

            mEngineEditor.StartEditing(workspace, mAxMapControl1.Map);
            ((IEngineEditLayers)mEngineEditor).SetTargetLayer(pFeatureLayer, -1);
            mEngineEditor.StartOperation();

            UpdateFTOnDV(mLayer, dt, mDataGridTableChanged.ToArray <int>());
            mEngineEditor.StopEditing(true);
            mDataGridTableChanged.Clear();
        }
コード例 #5
0
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            double offsetValue = -1;

            try
            {
                offsetValue = Convert.ToDouble(textEdit1.Text);
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("请输入数值类型", "提示信息", MessageBoxButtons.OK);
                return;
            }
            try
            {
                //启动编辑
                IFeatureLayer featureLayer  = mLayer as IFeatureLayer;
                IFeatureClass pFeatureClass = featureLayer.FeatureClass;

                IWorkspace    workspace     = null;
                IEngineEditor mEngineEditor = mEngineEditor = new EngineEditorClass();
                if (pFeatureClass.FeatureDataset != null)
                {
                    workspace = pFeatureClass.FeatureDataset.Workspace;
                    mEngineEditor.EditSessionMode = esriEngineEditSessionMode.esriEngineEditSessionModeVersioned;
                    mEngineEditor.StartEditing(workspace, mMap);
                    ((IEngineEditLayers)mEngineEditor).SetTargetLayer(featureLayer, -1);
                    mEngineEditor.StartOperation();
                }



                ISelectionSet mSelectionSet = (mLayer as IFeatureSelection).SelectionSet;
                ICursor       mCursor;
                mSelectionSet.Search(null, false, out mCursor);

                IFeature mFeature = mCursor.NextRow() as IFeature;
                while (mFeature != null)
                {
                    IGeometry  geometry  = mFeature.ShapeCopy;
                    IPolycurve polycurve = geometry as IPolycurve;
                    polycurve.Smooth(offsetValue);
                    mFeature.Shape = polycurve as IGeometry;
                    mFeature.Store();
                    mFeature = mCursor.NextRow() as IFeature;
                }
                if (workspace != null)
                {
                    mEngineEditor.StopEditing(true);
                }

                this.Dispose();
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("平滑失败", "提示信息", MessageBoxButtons.OK);
            }
        }
コード例 #6
0
        /// <summary>
        /// 开始编辑按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnStartEdit_Click(object sender, EventArgs e)
        {
            try
            {
                mEngineEditor     = new EngineEditorClass();
                mEngineEditTask   = mEngineEditor as IEngineEditTask;
                mEngineEditLayers = mEngineEditor as IEngineEditLayers;
                mMap        = MainMapControl.Map;
                mActiveView = mMap as IActiveView;
                mlistLayers = MapOperation.GetLayers(mMap);

                if (mlistLayers == null || mlistLayers.Count == 0)
                {
                    MessageBox.Show("请加载编辑图层!", "提示",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                mMap.ClearSelection();
                mActiveView.Refresh();
                InitComboBox(mlistLayers);
                ChangeButtonState(true);

                // 如果编辑已经开始,则直接退出
                if (mEngineEditor.EditState != esriEngineEditState.esriEngineStateNotEditing)
                {
                    return;
                }
                if (mCurrentLyr == null)
                {
                    return;
                }
                // 获取当前编辑图层工作空间
                IDataset   dataset   = mCurrentLyr.FeatureClass as IDataset;
                IWorkspace workspace = dataset.Workspace;
                // 设置编辑模式,如果是ArcSDE采用版本模式
                if (workspace.Type == esriWorkspaceType.esriRemoteDatabaseWorkspace)
                {
                    mEngineEditor.EditSessionMode = esriEngineEditSessionMode.esriEngineEditSessionModeVersioned;
                }
                else
                {
                    mEngineEditor.EditSessionMode = esriEngineEditSessionMode.esriEngineEditSessionModeNonVersioned;
                }
                // 设置编辑任务
                mEngineEditTask           = mEngineEditor.GetTaskByUniqueName("ControlToolsEditing_CreateNewFeatureTask");
                mEngineEditor.CurrentTask = mEngineEditTask;
                //是否可以进行撤销、恢复操作
                mEngineEditor.EnableUndoRedo(true);
                //开始编辑操作
                mEngineEditor.StartEditing(workspace, mMap);
            }
            catch (Exception ex)
            {
            }
        }
コード例 #7
0
        //开始编辑
        private void btnStartEdit_Click(object sender, EventArgs e)
        {
            label1.Visible      = true;
            cmbSelLayer.Visible = true;
            button1.Visible     = true;
            ChangeButtonState(true);
            plstLayers = MapManager.GetLayers(axMap.Map);
            for (int i = 0; i < plstLayers.Count; i++)
            {
                cmbSelLayer.Items.Add(plstLayers[i].Name);
            }

            try
            {
                if (plstLayers == null || plstLayers.Count == 0)
                {
                    MessageBox.Show("请加载编辑图层!", "提示",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                pMap.ClearSelection();
                pActiveView.Refresh();
                InitComboBox(plstLayers);
                ChangeButtonState(true);
                //如果编辑已经开始,则直接退出
                if (pEngineEditor.EditState != esriEngineEditState.esriEngineStateNotEditing)
                {
                    return;
                }
                if (pCurrentLyr == null)
                {
                    return;
                }
                //获取当前编辑图层工作空间
                IDataset   pDataSet = pCurrentLyr.FeatureClass as IDataset;
                IWorkspace pWs      = pDataSet.Workspace;
                //设置编辑模式,如果是ArcSDE采用版本模式
                if (pWs.Type == esriWorkspaceType.esriRemoteDatabaseWorkspace)
                {
                    pEngineEditor.EditSessionMode = esriEngineEditSessionMode.esriEngineEditSessionModeVersioned;
                }
                else
                {
                    pEngineEditor.EditSessionMode = esriEngineEditSessionMode.esriEngineEditSessionModeNonVersioned;
                }
                //设置编辑任务
                pEngineEditTask           = pEngineEditor.GetTaskByUniqueName("ControlToolsEditing_CreateNewFeatureTask");
                pEngineEditor.CurrentTask = pEngineEditTask; // 设置编辑任务
                pEngineEditor.EnableUndoRedo(true);          //是否可以进行撤销、恢复操作
                pEngineEditor.StartEditing(pWs, pMap);       //开始编辑操作
            }
            catch (Exception ex)
            {
            }
        }
コード例 #8
0
        //开始编辑
        private void btnStart_Click(object sender, EventArgs e)
        {
            try
            {
                if (pCurrentLyr == null)
                {
                    MessageBox.Show("请选择编辑图层!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                setEditToolEnable(true);
                //如果编辑已经开始,则直接退出
                if (pEngineEditor.EditState != esriEngineEditState.esriEngineStateNotEditing)
                {
                    return;
                }
                if (pCurrentLyr == null)
                {
                    return;
                }
                //获取当前编辑图层工作空间
                pDataSet                  = pCurrentLyr.FeatureClass as IDataset;
                pWs                       = pDataSet.Workspace;
                pEngineEditTask           = pEngineEditor.GetTaskByUniqueName("ControlToolsEditing_CreateNewFeatureTask");
                pEngineEditor.CurrentTask = pEngineEditTask; // 设置编辑任务
                pEngineEditor.EnableUndoRedo(true);          //是否可以进行撤销、恢复操作
                //设置编辑模式,如果是ArcSDE采用版本模式
                if (pWs.Type == esriWorkspaceType.esriRemoteDatabaseWorkspace)
                {
                    IVersionedObject3 versionedObject = pDataSet as IVersionedObject3;
                    //注册版本
                    if (versionedObject != null && !versionedObject.IsRegisteredAsVersioned)
                    {
                        versionedObject.RegisterAsVersioned(true);
                    }
                    pEngineEditor.EditSessionMode = esriEngineEditSessionMode.esriEngineEditSessionModeVersioned;
                }
                //else
                //{
                //    pEngineEditor.EditSessionMode = esriEngineEditSessionMode.esriEngineEditSessionModeNonVersioned;
                //}
                //设置编辑任务
                pEngineEditor.StartEditing(pWs, pMap);
                isEditing = true;
                //SysLogHelper.WriteOperationLog("数据编辑", "开始编辑", "数据管理");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                PS.Plot.Common.LogHelper.WriteLog(typeof(Form_Editor), ex, "开始编辑");
            }
        }
コード例 #9
0
        private void menuStartEdit_Click(object sender, EventArgs e)
        {
            map        = axMapControl1.Map;
            activeView = map as IActiveView;
            if (axMapControl1.Map.LayerCount == 0)
            {
                MessageBox.Show("请加载编辑图层", "提示", MessageBoxButtons.OK);
                return;
            }
            map.ClearSelection();
            activeView.Refresh();
            //调用操作函数,将“开始编辑”设置为非激活状态,其他子菜单项设置为激活状态
            ChangeButtonState(false);
            //初始化“图层选择”
            menuSelectLayer.Items.Clear();
            for (int i = 0; i < axMapControl1.LayerCount; i++)
            {
                menuSelectLayer.Items.Add(axMapControl1.Map.get_Layer(i).Name);
            }
            //默认选择顶层图层
            if (menuSelectLayer.Items.Count != 0)
            {
                menuSelectLayer.SelectedIndex = 0;
            }
            //获取当前编辑图层工作空间
            IDataset   dataSet   = currentLayer.FeatureClass as IDataset;
            IWorkspace workspace = dataSet.Workspace;

            //设置编辑模式,如果是ArcSDE采用版本模式
            if (workspace.Type == esriWorkspaceType.esriRemoteDatabaseWorkspace)
            {
                engineEditor.EditSessionMode = esriEngineEditSessionMode.esriEngineEditSessionModeVersioned;
            }
            else
            {
                engineEditor.EditSessionMode = esriEngineEditSessionMode.esriEngineEditSessionModeNonVersioned;
            }
            //设置编辑任务
            engineEditTask           = engineEditor.GetTaskByUniqueName("ControlToolsEditing_CreateNewFeatureTask");
            engineEditor.CurrentTask = engineEditTask;
            engineEditor.EnableUndoRedo(true);         //是否可以进行撤销、恢复操作
            engineEditor.StartEditing(workspace, map); //开始编辑操作
        }
コード例 #10
0
        private void startEdit_ToolbarItem_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            IBasicMap          map           = null;
            ILayer             selectedLayer = null;
            object             unk           = null;
            object             data          = null;
            esriTOCControlItem item          = esriTOCControlItem.esriTOCControlItemNone;

            m_tocControl.GetSelectedItem(ref item, ref map, ref selectedLayer, ref unk, ref data);

            if (item == esriTOCControlItem.esriTOCControlItemLayer)
            {
                // 启动编辑
                if (pEngineEditor.EditState != esriEngineEditState.esriEngineStateNotEditing)
                {
                    return;
                }

                IFeatureLayer featurelayer = selectedLayer as IFeatureLayer;
                IDataset      dataset      = featurelayer.FeatureClass as IDataset;
                IWorkspace    workspace    = dataset.Workspace;

                pEngineEditor.StartEditing(workspace, m_mapControl.Map);
                ((IEngineEditLayers)pEngineEditor).SetTargetLayer(featurelayer, -1);

                pEngineEditor.StartOperation();

                // 设置目标图层
                IEngineEditLayers pEditLayer = pEngineEditor as IEngineEditLayers;
                pEditLayer.SetTargetLayer(featurelayer, 0);
                targetLayer_ToolbarText.Caption += " " + featurelayer.Name;

                featureEditor_ToolbarItem_ItemClick(null, null);

                featureEditToolbar.Visible = true;
            }
            ICommand pcommand = new ControlsEditingStartCommand();

            pcommand.OnCreate(m_mapControl.Object);
            pcommand.OnClick();
        }
コード例 #11
0
ファイル: MainForm.cs プロジェクト: hengyu123/AE_Dev
        /// <summary>
        /// 编辑所选图层
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void editLayer_ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            pEngineEditor = new EngineEditorClass();
            IBasicMap          map           = null;
            ILayer             selectedLayer = null;
            object             unk           = null;
            object             data          = null;
            esriTOCControlItem item          = esriTOCControlItem.esriTOCControlItemNone;

            m_tocControl.GetSelectedItem(ref item, ref map, ref selectedLayer, ref unk, ref data);

            if (item == esriTOCControlItem.esriTOCControlItemLayer)
            {
                //启动编辑
                if (pEngineEditor.EditState != esriEngineEditState.esriEngineStateNotEditing)
                {
                    return;
                }
                IFeatureLayer featurelayer = selectedLayer as IFeatureLayer;
                IDataset      dataset      = featurelayer.FeatureClass as IDataset;
                IWorkspace    workspace    = dataset.Workspace;

                pEngineEditor.StartEditing(workspace, m_mapControl.Map);
                ((IEngineEditLayers)pEngineEditor).SetTargetLayer(featurelayer, -1);

                pEngineEditor.StartOperation();

                //设置目标图层
                IEngineEditLayers pEditLayer = pEngineEditor as IEngineEditLayers;
                pEditLayer.SetTargetLayer(featurelayer, 0);
                m_editinglayer.Caption += " " + featurelayer.Name;

                ICommand t_editcommand = new ESRI.ArcGIS.Controls.ControlsEditingEditToolClass();
                t_editcommand.OnCreate(m_mapControl.Object);
                m_mapControl.CurrentTool = t_editcommand as ITool;
                t_editcommand.OnClick();

                map_edittools.Visible = true;
            }
        }
        private void barButtonItem8_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            pEngineEditor = new EngineEditorClass();
            MapManagement.EngineEditor = pEngineEditor;
            pEngineEditTask            = pEngineEditor as IEngineEditTask;
            pEngineEditLayers          = pEngineEditor as IEngineEditLayers;

            pMap        = Variable.pMapFrm.mainMapControl.Map;
            pActiveView = pMap as IActiveView;
            pLayerlist  = MapManagement.GetMapLayers(pMap);
            try
            {
                if (pLayerlist == null || pLayerlist.Count == 0)
                {
                    MessageBox.Show("请在主视图中加载编辑图层!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                for (int i = 0; i < pLayerlist.Count; i++)
                {
                    ((DevExpress.XtraEditors.Repository.RepositoryItemComboBox) this.barEditItem1.Edit).Items.Add(pLayerlist[i].Name);
                }
                this.barEditItem1.EditValue = ((DevExpress.XtraEditors.Repository.RepositoryItemComboBox) this.barEditItem1.Edit).Items[0];

                pMap.ClearSelection();
                pActiveView.Refresh();
                //设置数据管理中要素管理未开始编辑状态,图层选择、添加要素、选择编辑要素、要素属性编辑、结束编辑等功能变成正常状态,使得可以操作。
                barEditItem1.Enabled    = true;
                barButtonItem12.Enabled = true;
                barButtonItem14.Enabled = true;
                barButtonItem13.Enabled = true;
                barButtonItem15.Enabled = true;
                barButtonItem4.Enabled  = true;
                barButtonItem20.Enabled = true;
                barButtonItem22.Enabled = true;
                barButtonItem21.Enabled = true;
                barButtonItem23.Enabled = true;
                if (pEngineEditor.EditState != esriEngineEditState.esriEngineStateNotEditing)
                {
                    return;
                }
                if (pCurrentLayer == null)
                {
                    return;
                }

                IDataset   pDataSet   = pCurrentLayer.FeatureClass as IDataset;
                IWorkspace pWorkspace = pDataSet.Workspace;
                if (pWorkspace.Type == esriWorkspaceType.esriRemoteDatabaseWorkspace)
                {
                    pEngineEditor.EditSessionMode = esriEngineEditSessionMode.esriEngineEditSessionModeVersioned;
                }
                else
                {
                    pEngineEditor.EditSessionMode = esriEngineEditSessionMode.esriEngineEditSessionModeVersioned;
                }
                pEngineEditTask           = pEngineEditor.GetTaskByUniqueName("ControlToolsEditing_CreateNewFeatureTask");
                pEngineEditor.CurrentTask = pEngineEditTask;
                pEngineEditor.EnableUndoRedo(true);
                pEngineEditor.StartEditing(pWorkspace, pMap);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n" + ex.ToString(), "异常");
            }
        }
コード例 #13
0
ファイル: MergeForm.cs プロジェクト: voyagexiang/ArcObjects
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                string saveString = comboBox1.Text;
                // 属性过滤
                IQueryFilter pQueryFilter = new QueryFilter();
                if (pItems.Count > 0)
                {
                    pQueryFilter.WhereClause = saveString;
                }
                else
                {
                    pQueryFilter.WhereClause = null;
                }



                // 要素游标

                //启动编辑
                IFeatureLayer pFeatureLayer = mLayer as IFeatureLayer;
                IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;

                IWorkspace workspace = null;
                IEngineEditor mEngineEditor = mEngineEditor = new EngineEditorClass();
                if (pFeatureClass.FeatureDataset != null)
                {

                    workspace = pFeatureClass.FeatureDataset.Workspace;
                    IMap mMap = mAxMapControl1.Map;
                    mEngineEditor.EditSessionMode = esriEngineEditSessionMode.esriEngineEditSessionModeVersioned;
                    mEngineEditor.StartEditing(workspace, mMap);
                    ((IEngineEditLayers)mEngineEditor).SetTargetLayer(pFeatureLayer, -1);
                    mEngineEditor.StartOperation();

                }



                IFeatureCursor pFCursor = pFeatureClass.Search(pQueryFilter, false);
                IFeature pFeature = pFCursor.NextFeature();
                //todo
                string str = getQueryString();
                pFeature.Shape = GetMergeGeometry(str);

                pFeature.Store();
                //pFCursor.Flush();

                //删除语句
                pItems.Remove(saveString);
                for (int i = 0; i < pItems.Count; i++)
                {
                    delectSelectedCells(pItems[i]);
                }


                this.Close();
                if (workspace != null)
                {
                    mEngineEditor.StopEditing(true);
                }

                XtraMessageBox.Show("合并成功", "提示信息", MessageBoxButtons.OK);
                mAxMapControl1.Refresh();
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message, "合并失败", MessageBoxButtons.OK);
            }

        }
コード例 #14
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (Button != 1)
            {
                return;
            }

            IWorkspace workspace = null;

            #region……分割面

            //根据已选择的要分割的要素的类型绘制分割线

            if (((IFeatureLayer)mLayer).FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon)

            {//分割线的样式
                IScreenDisplay pScreenDisplay = pMapControl.ActiveView.ScreenDisplay;

                ISimpleLineSymbol pLineSymbol = new SimpleLineSymbolClass();

                IRgbColor pRgbColor = new RgbColorClass();

                pRgbColor.Red = 255;

                pLineSymbol.Color = pRgbColor;

                IRubberBand pRubberBand = new RubberLineClass();

                IPolyline pPolyline = (IPolyline)pRubberBand.TrackNew(pScreenDisplay, (ISymbol)pLineSymbol);

                pScreenDisplay.StartDrawing(pScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);

                pScreenDisplay.SetSymbol((ISymbol)pLineSymbol);

                pScreenDisplay.DrawPolyline(pPolyline);

                pScreenDisplay.FinishDrawing();



                //清理将被分割的要素

                ITopologicalOperator pTopoOpo;

                pTopoOpo = pPolyline as ITopologicalOperator;

                pTopoOpo.Simplify();//确保几何体的拓扑正确

                //开始编辑

                IFeatureLayer featureLayer  = mLayer as IFeatureLayer;
                IFeatureClass pFeatureClass = featureLayer.FeatureClass;


                IEngineEditor mEngineEditor = mEngineEditor = new EngineEditorClass();
                if (pFeatureClass.FeatureDataset != null)
                {
                    workspace = pFeatureClass.FeatureDataset.Workspace;
                    mEngineEditor.EditSessionMode = esriEngineEditSessionMode.esriEngineEditSessionModeVersioned;
                    mEngineEditor.StartEditing(workspace, mMap);
                    ((IEngineEditLayers)mEngineEditor).SetTargetLayer(featureLayer, -1);
                    mEngineEditor.StartOperation();
                }



                //分割方法


                SplitPolygon(pFeatureClass, pPolyline);

                ReBackStates();//刷新返回修改工具

                pMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, pMapControl.ActiveView.Extent);
                //  mEngineEditor.StopEditing(true);
            }

            #endregion



            #region……鼠标画线分割线

            //根据分割要素的类型绘制分割线

            if (((IFeatureLayer)mLayer).FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline)

            {
                IScreenDisplay pScreenDisplay = pMapControl.ActiveView.ScreenDisplay;

                ISimpleLineSymbol pLineSymbol = new SimpleLineSymbolClass();

                IRgbColor pRgbColor = new RgbColorClass();

                pRgbColor.Red = 255;

                pLineSymbol.Color = pRgbColor;

                IRubberBand pRubberBand = new RubberLineClass();

                IPolyline pPolyline = (IPolyline)pRubberBand.TrackNew(pScreenDisplay, (ISymbol)pLineSymbol);

                pScreenDisplay.StartDrawing(pScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);

                pScreenDisplay.SetSymbol((ISymbol)pLineSymbol);

                pScreenDisplay.DrawPolyline(pPolyline);

                pScreenDisplay.FinishDrawing();



                // mEngineEditor.StartOperation();//开启编辑

                IFeatureLayer featureLayer  = mLayer as IFeatureLayer;
                IFeatureClass pFeatureClass = featureLayer.FeatureClass;

                IEngineEditor mEngineEditor = mEngineEditor = new EngineEditorClass();
                if (pFeatureClass.FeatureDataset != null)
                {
                    workspace = pFeatureClass.FeatureDataset.Workspace;
                    mEngineEditor.EditSessionMode = esriEngineEditSessionMode.esriEngineEditSessionModeVersioned;
                    mEngineEditor.StartEditing(workspace, mMap);
                    ((IEngineEditLayers)mEngineEditor).SetTargetLayer(featureLayer, -1);
                    mEngineEditor.StartOperation();
                }

                ISelectionSet pSelectionSet = pFeatureClass.Select(null, esriSelectionType.esriSelectionTypeIDSet, esriSelectionOption.esriSelectionOptionNormal, workspace);

                //分割方法

                SplitPolyline(pSelectionSet, pPolyline);



                ReBackStates();

                pMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, pMapControl.ActiveView.Extent);
            }

            #endregion
            if (workspace != null)
            {
                mEngineEditor.StopEditing(true);
            }

            //mEngineEditor.StopOperation("ControlToolsEditing_CreateNewFeatureTask");
        }
コード例 #15
0
        private void simpleButton3_Click(object sender, EventArgs e)
        {
            if (mEngineEditor.EditState == esriEngineEditState.esriEngineStateNotEditing)
            {
                AxMapControl mMap = this.axMapControl1;
                currentLayer = GetTocSelectedLayer();
                if (currentLayer is IFeatureLayer)
                {
                    IFeatureLayer featureLayer = currentLayer as IFeatureLayer;
                    mLayerType = featureLayer.FeatureClass.ShapeType;

                    IDataset dataset = featureLayer.FeatureClass as IDataset;



                    IVersionedObject verObj = dataset as IVersionedObject;
                    if (verObj != null)
                    {
                        try
                        {
                            verObj.RegisterAsVersioned(true);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                    }
                    //if (verObj != null)
                    //{

                    //    MessageBox.Show("数据集未注册为版本!");
                    //    return;
                    //}
                    IWorkspace workspace;
                    try
                    {
                        mEngineEditor.EditSessionMode = esriEngineEditSessionMode.esriEngineEditSessionModeVersioned;


                        workspace = dataset.Workspace;
                        mEngineEditor.StartEditing(workspace, mMap.Map);
                    }
                    catch (Exception ex)
                    {
                        try
                        {
                            mEngineEditor.EditSessionMode = esriEngineEditSessionMode.esriEngineEditSessionModeNonVersioned;


                            workspace = dataset.Workspace;
                            mEngineEditor.StartEditing(workspace, mMap.Map);
                        }
                        catch (Exception ex1)
                        {
                            XtraMessageBox.Show(ex1.Message, "提示信息", MessageBoxButtons.OK);
                        }
                    }

                    ((IEngineEditLayers)mEngineEditor).SetTargetLayer(featureLayer, 0);
                }
            }
        }