Exemplo n.º 1
0
        public override void OnClick()
        {
            //Find the Modify Feature task and set it as the current task
            IEngineEditTask editTask = m_engineEditor.GetTaskByUniqueName("ControlToolsEditing_ModifyFeatureTask");

            m_engineEditor.CurrentTask = editTask;
        }
Exemplo n.º 2
0
        private void cmdCreate_Click(object sender, EventArgs e)
        {
            IEngineEditTask edittask = m_engineEditor.GetTaskByUniqueName("ControlToolsEditing_CreateNewFeatureTask");

            if (edittask != null)
            {
                m_engineEditor.CurrentTask  = edittask;
                axCreateToolbar.CurrentTool = axCreateToolbar.GetItem(0).Command as ITool;

                SetButtonColors(sender as Button);
                txtInfo.Text = "";
                label1.Text  = "";
                this.flowLayoutPanel1.Controls.Clear();
                this.flowLayoutPanel1.Controls.Add(axCreateToolbar);
                this.flowLayoutPanel2.Controls.Clear();
                this.flowLayoutPanel2.Controls.Add(axUndoRedoToolbar);
            }
        }
        /// <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)
            {
            }
        }
Exemplo n.º 4
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)
            {
            }
        }
        //开始编辑
        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, "开始编辑");
            }
        }
Exemplo n.º 6
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); //开始编辑操作
        }
Exemplo n.º 7
0
        /// <summary>
        /// Occurs when this tool is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add ToolSplitLine.OnClick implementation
            //Find the Modify Feature task and set it as the current task
            IEngineEditTask editTask = m_engineEditor.GetTaskByUniqueName("ControlToolsEditing_ModifyFeatureTask");

            m_engineEditor.CurrentTask = editTask;

            IEngineEditLayers editLayers = m_editLayer;

            snapEnvironment = m_engineEditor as IEngineSnapEnvironment;
            pt = new PointClass();
            //Check the user is editing; otherwise, there will be no snap agent loaded.
            if (editLayers.TargetLayer == null)
            {
                System.Windows.Forms.MessageBox.Show("Please start an edit session");
                return;
            }

            ////Create a feature snap agent.
            IEngineFeatureSnapAgent featureSnapAgent  = new EngineFeatureSnap();
            IFeatureClass           layerFeatureClass = editLayers.TargetLayer.FeatureClass;

            featureSnapAgent.FeatureClass = layerFeatureClass;
            featureSnapAgent.HitType      = esriGeometryHitPartType.esriGeometryPartBoundary;

            //Activate only the snap agent for the target layer.
            snapEnvironment.AddSnapAgent(featureSnapAgent);
            pMPfeedback         = new MovePointFeedbackClass();
            pMPfeedback.Display = m_hookHelper.ActiveView.ScreenDisplay;
            pMPfeedback.Start(pt, pt);

            IToolbarBuddy toolbarbuddy = (IToolbarBuddy)((IToolbarControl)m_hookHelper.Hook).Buddy;

            oldtool = toolbarbuddy.CurrentTool;
        }
        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(), "异常");
            }
        }