Пример #1
0
        /// <summary>
        /// 停止编辑所选图层
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void m_stoptool_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (pEngineEditor != null && pEngineEditor.HasEdits() == false)
            {
                pEngineEditor.StopEditing(false);
            }
            else
            {
                if (MessageBox.Show("Save Edits?", "Save Prompt", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    pEngineEditor.StopEditing(true);
                }
                else
                {
                    pEngineEditor.StopEditing(false);
                }
            }
            //恢复光标
            ICommand t_editcommand = new ESRI.ArcGIS.Controls.ControlsEditingEditToolClass();

            t_editcommand.OnCreate(m_mapControl.Object);
            m_mapControl.CurrentTool = t_editcommand as ITool;
            t_editcommand.OnClick();

            m_editinglayer.Caption = "当前图层:";
            map_edittools.Visible  = false;
        }
Пример #2
0
 /// <summary>
 /// 矢量“编辑”工具
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void m_edittool_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     if (pEngineEditor.EditState == esriEngineEditState.esriEngineStateEditing)
     {
         ICommand t_editcommand = new ESRI.ArcGIS.Controls.ControlsEditingEditToolClass();
         t_editcommand.OnCreate(m_mapControl.Object);
         m_mapControl.CurrentTool = t_editcommand as ITool;
         t_editcommand.OnClick();
     }
 }
Пример #3
0
        /// <summary>
        /// 关闭主窗口
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            //try
            //{

            //检查编辑状态
            if (pEngineEditor != null && pEngineEditor.HasEdits() == false)
            {
                pEngineEditor.StopEditing(false);
            }
            else
            {
                if (pEngineEditor != null)
                {
                    if (MessageBox.Show("Save Edits?", "Save Prompt", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        pEngineEditor.StopEditing(true);
                    }
                    else
                    {
                        pEngineEditor.StopEditing(false);
                    }
                }
            }
            //恢复光标
            ICommand t_editcommand = new ESRI.ArcGIS.Controls.ControlsEditingEditToolClass();

            t_editcommand.OnCreate(m_mapControl.Object);
            m_mapControl.CurrentTool = t_editcommand as ITool;
            t_editcommand.OnClick();

            m_editinglayer.Caption = "当前图层:";
            map_edittools.Visible  = false;

            //移除图层并解除图层锁
            for (int i = m_mapControl.Map.LayerCount - 1; i >= 0; i--)
            {
                IDataLayer2 datalayer = m_mapControl.get_Layer(i) as IDataLayer2;
                if (datalayer.DataSourceName.NameString != "")
                {
                    datalayer.Disconnect();
                }
                m_mapControl.DeleteLayer(i);
            }
            //}
            //catch (Exception err)
            //{

            //    MessageBox.Show(err.Message);
            //}
        }
Пример #4
0
        /// <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;
            }
        }