public void Activate(ESRI.ArcGIS.Controls.IEngineEditor pEditor, ESRI.ArcGIS.Controls.IEngineEditTask pOldTask)
        {
            if (pEditor == null)
                return;

            pEngineEditor = pEditor;
            pEditSketch = pEngineEditor as IEngineEditSketch;
            pEditSketch.GeometryType = esriGeometryType.esriGeometryPolyline;
            pEditLayer = pEditSketch as IEngineEditLayers;

            //Listen to engine editor events
            ((IEngineEditEvents_Event)pEditSketch).OnTargetLayerChanged += new IEngineEditEvents_OnTargetLayerChangedEventHandler(OnTargetLayerChanged);

            ((IEngineEditEvents_Event)pEditSketch).OnCurrentTaskChanged += new IEngineEditEvents_OnCurrentTaskChangedEventHandler(OnCurrentTaskChanged);
        }
Esempio n. 2
0
        public void OnClick()
        {
            m_Map = m_hookHelper.FocusMap;
            m_activeView = m_Map as IActiveView;
            m_EngineEditor = MapManager.EngineEditor;
            m_EngineEditLayers = MapManager.EngineEditor as IEngineEditLayers;

            EditVertexClass.m_activeView = m_activeView;
            EditVertexClass.m_Map = m_Map;

            EditVertexClass.ClearResource();

            if (m_EngineEditor == null) return;
            if (m_EngineEditor.EditState != esriEngineEditState.esriEngineStateEditing) return;
            if (m_EngineEditLayers == null) return;

            IFeatureLayer pFeatLyr = m_EngineEditLayers.TargetLayer;
            if (pFeatLyr == null) return;
            IFeatureCursor pFeatCur = MapManager.GetSelectedFeatures(pFeatLyr);
            if (pFeatCur == null)
            {
                MessageBox.Show("请选择要删除节点的要素!", "提示",
                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            EditVertexClass.ShowAllVertex(pFeatLyr);

            ((IActiveViewEvents_Event)m_Map).AfterDraw += new IActiveViewEvents_AfterDrawEventHandler(map_AfterDraw);

        }
Esempio n. 3
0
        /// <summary>
        /// Load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Form1_Load(object sender, EventArgs e)
        {
            m_controlsSynchronizer = new ControlsSynchronizer(m_mapControl, m_pageLayoutControl);
            //把 MapControl 和 PageLayoutControl 绑定起来(两个都指向同一个 Map),然后设置 MapControl 为活动的 Control
            m_controlsSynchronizer.BindControls(true);
            //为了在切换 MapControl 和 PageLayoutControl 视图同步,要添加 Framework Control
            m_controlsSynchronizer.AddFrameworkControl(axToolbarControl1.Object);
            m_controlsSynchronizer.AddFrameworkControl(axTOCControl1.Object);


            axToolbarControl1.AddItem(new DotDensitySymbolsCmd(), -1, -1, false, -1, esriCommandStyles.esriCommandStyleIconAndText);//点密度
            axTOCControl1.SetBuddyControl(axMapControl1);

            axToolbarControl1.SetBuddyControl(axMapControl1);
            //定制菜单
            chkCustomize.Checked      = false;
            chkCustomize.CheckOnClick = true;
            //调用非模态定制对话框
            this.presenter.CreateCustomizeDialog();
            //初始化自定义命令
            axToolbarControl1.AddItem(new ClearCurrentActiveToolCmd(), -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconAndText);
            axToolbarControl1.AddItem(new AddDateTool(axToolbarControl1, axPageLayoutControl1), -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconAndText);
            //设置编辑菜单的状态
            saveEdit.Enabled    = false;
            endEdit.Enabled     = false;
            selectLayer.Enabled = false;
            addLayer.Enabled    = false;
            //编辑
            pEngineEditor           = new EngineEditorClass();
            MapManager.EngineEditor = pEngineEditor;
            pEngineEditTask         = pEngineEditor as IEngineEditTask;
            pEngineEditLayers       = pEngineEditor as IEngineEditLayers;
        }
Esempio n. 4
0
 public void OnClick()
 {
     map              = hookHelper.FocusMap;
     activeView       = map as IActiveView;
     engineEditor     = MapManager.EngineEditor;
     engineEditLayers = MapManager.EngineEditor as IEngineEditLayers;
 }
        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();
                }
            }
        }
Esempio n. 6
0
 public void OnDblClick()
 {
     this._bStarted  = false;
     this._bFinished = true;
     this._bMouse    = true;
     try
     {
         this._lineFeedback.Stop();
         this._lineFeedback.Refresh(this._hookHelper.ActiveView.ScreenDisplay.hDC);
         this._lineFeedback = null;
         IEngineEditor     engineEditor = Editor.UniqueInstance.EngineEditor;
         IEngineEditSketch sketch       = Editor.UniqueInstance.EngineEditor as IEngineEditSketch;
         IGeometry         pGeo         = sketch.Geometry;
         if (pGeo == null)
         {
             return;
         }
         if ((Editor.UniqueInstance.CheckOverlap && !Editor.UniqueInstance.CheckFeatureOverlap(pGeo, false)) && (XtraMessageBox.Show("要素与其他要素重叠!是否保留此要素?", "", MessageBoxButtons.YesNo) == DialogResult.No))
         {
             Editor.UniqueInstance.CancleSketch();
             this._hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection | esriViewDrawPhase.esriViewGeography, null, this._hookHelper.ActiveView.Extent);
             return;
         }
         Editor.UniqueInstance.AddAttribute = true;
         this._tool.OnDblClick();
     }
     catch (Exception exception)
     {
         this.mErrOpt.ErrorOperate(this.mSubSysName, "ShapeEdit.SnapEx", "OnDblClick", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
     }
     this._bMouse = false;
 }
 public void OnClick()
 {
     m_Map              = m_hookHelper.FocusMap;
     m_activeView       = m_Map as IActiveView;
     m_EngineEditor     = MapManager.EngineEditor;
     m_EngineEditLayers = MapManager.EngineEditor as IEngineEditLayers;
 }
Esempio n. 8
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();
        }
        //关闭窗体
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            if (btnStop.Enabled == true)
            {
                DialogResult dialogResult = MessageBox.Show("是否保存并停止编辑?", "提示", MessageBoxButtons.YesNoCancel);
                switch (dialogResult)
                {
                case DialogResult.Yes:
                    btnSave_Click(sender, e);
                    break;

                case DialogResult.No:
                    IEngineEditor m_EngineEditor = MapManager.EngineEditor;
                    m_EngineEditor.StopEditing(false);
                    break;

                case DialogResult.Cancel:
                    return;

                default:
                    break;
                }
            }
            this.Close();
        }
Esempio n. 10
0
 public void OnClick()
 {
     try
     {
         m_Map          = m_hookHelper.FocusMap;
         m_activeView   = m_Map as IActiveView;
         m_EngineEditor = MapManager.EngineEditor;
         EditVertexClass.ClearResource();
         if (m_EngineEditor == null)
         {
             return;
         }
         if (m_EngineEditor.EditState != esriEngineEditState.esriEngineStateEditing)
         {
             return;
         }
         IWorkspaceEdit2 pWSEdit = m_EngineEditor.EditWorkspace as IWorkspaceEdit2;
         if (pWSEdit == null)
         {
             return;
         }
         Boolean bHasUndo = false;
         pWSEdit.HasUndos(ref bHasUndo);
         if (bHasUndo)
         {
             pWSEdit.UndoEditOperation();
         }
         m_activeView.Refresh();
     }
     catch (Exception ex)
     {
     }
 }
Esempio n. 11
0
 public SelectLayer(AxMapControl mMap, IEngineEditor mEngineEditor, esriGeometryType mLayerType)
 {
     InitializeComponent();
     this.mMap          = mMap;
     this.mEngineEditor = mEngineEditor;
     this.mLayerType    = mLayerType;
 }
Esempio n. 12
0
        public void OnDblClick()
        {
            this.ps = 0;
            IEngineEditor engineEditor = Editor.UniqueInstance.EngineEditor;

            this._tool.OnDblClick();
        }
 /// <summary>
 /// 编辑工具初始化
 /// </summary>
 private void EditorInit()
 {
     pEngineEditor           = new EngineEditorClass();
     MapManager.EngineEditor = pEngineEditor;
     pEngineEditTask         = pEngineEditor as IEngineEditTask;
     pEngineEditLayers       = pEngineEditor as IEngineEditLayers;
     pActiveView             = pMap as IActiveView;
 }
Esempio n. 14
0
 public void OnClick()
 {
     m_Map              = m_hookHelper.FocusMap;
     m_activeView       = m_Map as IActiveView;
     m_EngineEditor     = MapManager.EngineEditor;
     m_EngineEditLayers = MapManager.EngineEditor as IEngineEditLayers;
     EditVertexClass.ClearResource();
 }
Esempio n. 15
0
 public EventListener(IEngineEditor editor)
 {
     if (editor == null)
     {
         throw new ArgumentNullException();
     }
     m_editor = editor;
 }
Esempio n. 16
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            this.KeyPreview = true;

            m_globalSetting = new GlobalSettings();

            pEngineEditor = new EngineEditorClass(); // 初始化编辑器对象
        }
Esempio n. 17
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);
            }
        }
 public void OnClick()
 {
     try
     {
         m_Map              = m_hookHelper.FocusMap;
         m_activeView       = m_Map as IActiveView;
         m_EngineEditor     = MapManager.EngineEditor;
         m_EngineEditLayers = MapManager.EngineEditor as IEngineEditLayers;
         if (m_EngineEditor == null)
         {
             return;
         }
         if (m_EngineEditor.EditState != esriEngineEditState.esriEngineStateEditing)
         {
             return;
         }
         if (m_EngineEditLayers == null)
         {
             return;
         }
         IFeatureLayer pFeatLyr = m_EngineEditLayers.TargetLayer;
         if (pFeatLyr == null)
         {
             return;
         }
         IFeatureClass pFeatCls = pFeatLyr.FeatureClass;
         if (pFeatCls == null)
         {
             return;
         }
         IFeatureCursor pFeatCur = MapManager.GetSelectedFeatures(pFeatLyr);
         if (pFeatCur == null)
         {
             MessageBox.Show("请选择要删除的要素!", "提示",
                             MessageBoxButtons.OK, MessageBoxIcon.Information);
             return;
         }
         m_EngineEditor.StartOperation();
         IFeature pFeature = pFeatCur.NextFeature();
         if (MessageBox.Show("是否删除所选要素?", "提示", MessageBoxButtons.YesNo,
                             MessageBoxIcon.Information) == DialogResult.Yes)
         {
             while (pFeature != null)
             {
                 pFeature.Delete();
                 pFeature = pFeatCur.NextFeature();
             }
         }
         System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatCur);
         m_EngineEditor.StopOperation("DelFeatureCommand");
         m_activeView.Refresh();
     }
     catch (Exception ex)
     {
         //SysLogHelper.WriteOperationLog("要素删除错误", ex.Source, "数据编辑");
     }
 }
        public void Startup(ref object initializationData)
        {
            if (initializationData != null && initializationData is IEngineEditor)
            {
                m_engineeditor = (IEngineEditor)initializationData;
            }

            #endregion
        }
        /// <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)
            {
            }
        }
        /// <summary>
        /// Inspects the properties of the features.
        /// </summary>
        /// <param name="objects"></param>
        /// <param name="Editor"></param>
        public void Inspect(IEngineEnumRow objects, IEngineEditor Editor)
        {
            try
            {
                SetParent(m_inspector.hWnd, stabHwnd);
                SetParent(stabHwnd, picHwnd);

                ShowWindow(m_inspector.hWnd, SW_SHOW);
                m_inspector.Inspect(objects, Editor);

                IEngineEnumRow enumRow     = objects;
                IRow           row         = enumRow.Next();
                IFeature       inspFeature = (IFeature)row;

                //user selected the layer name instead of a feature.
                if (objects.Count > 1)
                {
                    return;
                }

                switch (inspFeature.Shape.GeometryType)
                {
                case esriGeometryType.esriGeometryPolygon:
                {
                    //do this for polygons.
                    customListBox.Items.Clear();
                    ReportPolygons(inspFeature);
                    break;
                }

                case esriGeometryType.esriGeometryPolyline:
                {
                    //do this for lines.
                    customListBox.Items.Clear();
                    ReportPolylines(inspFeature);
                    break;
                }

                case esriGeometryType.esriGeometryPoint:
                {
                    //do this for points.
                    customListBox.Items.Clear();
                    ReportPoints(inspFeature);
                    break;
                }

                default:
                    break;
                } //End switch.
            }
            catch (Exception ex)
            {
                MessageBox.Show("IObjectInspector_Inspect: " + ex.Message);
            }
        }
        public void Deactivate()
        {
            //Stop listening for editor events.
            ((IEngineEditEvents_Event)m_engineEditor).OnTargetLayerChanged -= OnTargetLayerChanged;
            ((IEngineEditEvents_Event)m_engineEditor).OnCurrentTaskChanged -= OnCurrentTaskChanged;

            //Release object references.
            m_engineEditor = null;
            m_editSketch   = null;
            m_editLayer    = null;
        }
Esempio n. 23
0
        public void Deactivate()
        {
            // throw new NotImplementedException();
            pEditSketch.RefreshSketch();
            ((IEngineEditEvents_Event)pEditSketch).OnTargetLayerChanged -= new IEngineEditEvents_OnTargetLayerChangedEventHandler(OnTargetLayerChanged);

            ((IEngineEditEvents_Event)pEditSketch).OnCurrentTaskChanged -= new IEngineEditEvents_OnCurrentTaskChangedEventHandler(OnCurrentTaskChanged);
            pEngineEditor = null;
            pEditSketch   = null;
            pEditLayer    = null;
        }
Esempio n. 24
0
        public SnapEditor()
        {
            InitializeComponent();

            //get the snapEnvironment
            editor          = new EngineEditorClass();
            editLayers      = editor as IEngineEditLayers;
            snapEnvironment = editor as IEngineSnapEnvironment;

            //Update this form with the snap environment and snap tips
            //Note: from here on we expect all snap changes to be made via this form, so it is not updated after direct changes to the snapping
            //environment or the Arc Engine Snap Window.
            RefreshDisplay();
        }
    public SnapEditor()
    {
      InitializeComponent();

      //get the snapEnvironment
      editor = new EngineEditorClass();
      editLayers = editor as IEngineEditLayers;
      snapEnvironment = editor as IEngineSnapEnvironment;    
  
      //Update this form with the snap environment and snap tips
      //Note: from here on we expect all snap changes to be made via this form, so it is not updated after direct changes to the snapping 
      //environment or the Arc Engine Snap Window. 
      RefreshDisplay();
    }
Esempio n. 26
0
        public void Deactivate()
        {
            m_editSketch.RefreshSketch();

            //Stop listening to engine editor events.
            ((IEngineEditEvents_Event)m_editSketch).OnTargetLayerChanged -= OnTargetLayerChanged;
            ((IEngineEditEvents_Event)m_editSketch).OnSelectionChanged   -= OnSelectionChanged;
            ((IEngineEditEvents_Event)m_editSketch).OnCurrentTaskChanged -= OnCurrentTaskChanged;

            //Release object references.
            m_engineEditor = null;
            m_editSketch   = null;
            m_editLayer    = null;
        }
Esempio n. 27
0
 /// <summary>
 /// Occurs when this tool is created
 /// </summary>
 /// <param name="hook">Instance of the application</param>
 public override void OnCreate(object hook)
 {
     try
     {
         m_hookHelper      = new HookHelperClass();
         m_hookHelper.Hook = hook;
         m_engineEditor    = new EngineEditorClass(); //this class is a singleton
         m_editLayer       = m_engineEditor as IEngineEditLayers;
     }
     catch
     {
         m_hookHelper = null;
     }
 }
Esempio n. 28
0
        public MapViewerForm()
        {
            InitializeComponent();

            _mainUnitOfWork   = ContainerManager.GetContainer(ContainerNames.Main).Resolve <IUnitOfWork>();
            _componentBuilder = ContainerManager.GetContainer(ContainerNames.Main).Resolve <IComponentBuilder>();
            IServiceProvider serviceProvider = new DelegateServiceLocator(GetServiceByTypeAndName, GetAllServicesByType);

            _componentContext = new ComponentContext(serviceProvider, components);

            BindToMap();
            _engineEditor    = new EngineEditorClass();
            _eventAggregator = ContainerManager.GetContainer().Resolve <IEventAggregator>();
            InitEvent();//订阅事件
        }
Esempio n. 29
0
        /// <summary>
        /// Return the cursor to be used by the tool
        /// </summary>
        //public override int Cursor
        //{
        //    get
        //    {
        //        int iHandle = 0;

        //        iHandle = m_InsertVertexCursor.Handle.ToInt32();
        //        //switch (m_lSubType)
        //        //{
        //        //    case 1:
        //        //        iHandle = m_InsertVertexCursor.Handle.ToInt32();
        //        //        break;

        //        //    case 2:
        //        //        iHandle = m_DeleteVertexCursor.Handle.ToInt32();
        //        //        break;
        //        //}

        //        return (iHandle);
        //    }
        //}

        /// <summary>
        /// Occurs when this tool is created
        /// </summary>
        /// <param name="hook">Instance of the application</param>
        public override void OnCreate(object hook)
        {
            try
            {
                m_hookHelper      = new HookHelperClass();
                m_hookHelper.Hook = hook;
                m_engineEditor    = new EngineEditorClass(); //this class is a singleton
                m_editLayer       = m_engineEditor as IEngineEditLayers;
            }
            catch
            {
                m_hookHelper = null;
            }

            // TODO:  Add ToolSplitLine.OnCreate implementation
        }
        /// <summary>
        /// Occurs when this command is created
        /// </summary>
        /// <param name="hook">Instance of the application</param>
        public override void OnCreate(object hook)
        {
            try
            {
                m_hookHelper      = new HookHelperClass();
                m_hookHelper.Hook = hook;
                m_engineEditor    = new EngineEditorClass(); //this class is a singleton
                // m_editLayer = m_engineEditor as IEngineEditLayers;
            }
            catch
            {
                m_hookHelper = null;
            }

            // TODO:  Add other initialization code
        }
        public void Activate(ESRI.ArcGIS.Controls.IEngineEditor editor, ESRI.ArcGIS.Controls.IEngineEditTask oldTask)
        {
            if (editor == null)
            {
                return;
            }

            //Initialize class member variables.
            m_engineEditor            = editor;
            m_editSketch              = editor as IEngineEditSketch;
            m_editSketch.GeometryType = esriGeometryType.esriGeometryPolyline;
            m_editLayer = m_editSketch as IEngineEditLayers;

            //Wire editor events.
            ((IEngineEditEvents_Event)m_editSketch).OnTargetLayerChanged += new IEngineEditEvents_OnTargetLayerChangedEventHandler(OnTargetLayerChanged);
            ((IEngineEditEvents_Event)m_editSketch).OnCurrentTaskChanged += new IEngineEditEvents_OnCurrentTaskChangedEventHandler(OnCurrentTaskChanged);
        }
Esempio n. 32
0
        public void Activate(ESRI.ArcGIS.Controls.IEngineEditor editor, ESRI.ArcGIS.Controls.IEngineEditTask oldTask)
        {
            if (editor == null)
            {
                return;
            }

            m_engineEditor            = editor;
            m_editSketch              = m_engineEditor as IEngineEditSketch;
            m_editSketch.GeometryType = esriGeometryType.esriGeometryPolyline;
            m_editLayer = m_editSketch as IEngineEditLayers;

            //Listen to engine editor events
            ((IEngineEditEvents_Event)m_editSketch).OnTargetLayerChanged += new IEngineEditEvents_OnTargetLayerChangedEventHandler(OnTargetLayerChanged);
            ((IEngineEditEvents_Event)m_editSketch).OnSelectionChanged   += new IEngineEditEvents_OnSelectionChangedEventHandler(OnSelectionChanged);
            ((IEngineEditEvents_Event)m_editSketch).OnCurrentTaskChanged += new IEngineEditEvents_OnCurrentTaskChangedEventHandler(OnCurrentTaskChanged);
        }
Esempio n. 33
0
 public TrimLineTool()
 {
     base.m_category = "�ü�"; //localizable text
     base.m_caption = "�ü�";  //localizable text
     base.m_message = "����ѡ�񹤾�ѡ��ο��ߣ����ñ�����ѡ�д��ü���Ҫ�أ����ɲü�";  //localizable text
     base.m_toolTip = "�ü���";  //localizable text
     base.m_name = "TrimLineTool";   //unique id, non-localizable (e.g. "MyCategory_MyTool")
     try
     {
         m_engineEditor = Activator.CreateInstance<EngineEditorClass>();
         //m_engineEditor = GIS.Common.DataEditCommon.g_engineEditor;
         base.m_bitmap = Properties.Resources.EditingTrimTool16;
         base.m_cursor = new System.Windows.Forms.Cursor(GetType().Assembly.GetManifestResourceStream(GetType(), "Resources.Cross.cur"));
     }
     catch (Exception ex)
     {
         System.Diagnostics.Trace.WriteLine(ex.Message, "Invalid Bitmap");
     }
 }
Esempio n. 34
0
        public ExtendTool()
        {
            base.m_category = "GraphicModify"; //localizable text
            base.m_caption = "������";  //localizable text
            base.m_message = "��ѡ�вο��ߣ���ѡ�д�������Ҫ�أ����ɽ����������������ο���";  //localizable text
            base.m_toolTip = "������";  //localizable text
            base.m_name = "ExtendTool";   //unique id, non-localizable (e.g. "MyCategory_MyTool")
            try
            {
                base.m_bitmap = Properties.Resources.EditingExtendTool16;
                base.m_cursor = new System.Windows.Forms.Cursor(GetType().Assembly.GetManifestResourceStream(GetType(), "Resources.Cross.cur"));

                m_engineEditor = Activator.CreateInstance<EngineEditorClass>();
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message, "Invalid Bitmap");
            }
        }
Esempio n. 35
0
        private IRotateTracker m_rotateTracker; //��ת�켣

        #endregion Fields

        #region Constructors

        public RotateTool()
        {
            //�������Զ���
            m_category = "��ת";
            m_caption = "��תͼԪ";
            m_message = "ѡ��ͼԪ��������ת";
            m_toolTip = "��תͼԪ";
            m_name = "RotateTool";
            try
            {
                m_bitmap = Resources.RotateTool;
                m_cursor = new Cursor(GetType().Assembly.GetManifestResourceStream(GetType(), "Resources.RotateTool.cur"));

                m_engineEditor = Activator.CreateInstance<EngineEditorClass>();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message, "Invalid Bitmap");
            }
        }
    public void Activate(ESRI.ArcGIS.Controls.IEngineEditor editor, ESRI.ArcGIS.Controls.IEngineEditTask oldTask)
    {      
        if (editor == null)
          return;

        //Initialize class member variables.
        m_engineEditor = editor;
        m_editSketch = editor as IEngineEditSketch;
        m_editSketch.GeometryType = esriGeometryType.esriGeometryPolyline;
        m_editLayer = m_editSketch as IEngineEditLayers;

        //Wire editor events.        
        ((IEngineEditEvents_Event)m_editSketch).OnTargetLayerChanged += new IEngineEditEvents_OnTargetLayerChangedEventHandler(OnTargetLayerChanged);
        ((IEngineEditEvents_Event)m_editSketch).OnCurrentTaskChanged += new IEngineEditEvents_OnCurrentTaskChangedEventHandler(OnCurrentTaskChanged);
    }
    public void Startup(ref object initializationData)
    {
      if (initializationData != null && initializationData is IEngineEditor)
      {
        m_engineeditor = (IEngineEditor)initializationData;
      }

    #endregion
    }
 public void Shutdown()
 {
   m_engineeditor = null;
   m_featureCache = null;
 }
    /// <summary>
    /// Inspects the properties of the features.
    /// </summary>
    /// <param name="objects"></param>
    /// <param name="Editor"></param>
    public void Inspect(IEngineEnumRow objects, IEngineEditor Editor)
    {
      try
      {
        SetParent(m_inspector.hWnd, stabHwnd);
        SetParent(stabHwnd, picHwnd);

        ShowWindow(m_inspector.hWnd, SW_SHOW);
        m_inspector.Inspect(objects, Editor);

        IEngineEnumRow enumRow = objects;
        IRow row = enumRow.Next();
        IFeature inspFeature = (IFeature) row;

        //user selected the layer name instead of a feature.
        if (objects.Count > 1)
          return;

        switch (inspFeature.Shape.GeometryType)
        {
          case esriGeometryType.esriGeometryPolygon:
            {
              //do this for polygons.
              customListBox.Items.Clear();
              ReportPolygons(inspFeature);
              break;
            }
          case esriGeometryType.esriGeometryPolyline:
            {
              //do this for lines.
              customListBox.Items.Clear();
              ReportPolylines(inspFeature);
              break;
            }
          case esriGeometryType.esriGeometryPoint:
            {
              //do this for points.
              customListBox.Items.Clear();
              ReportPoints(inspFeature);
              break;
            }
          default:
            break;
        } //End switch.
      }
      catch (Exception ex)
      {
        MessageBox.Show("IObjectInspector_Inspect: " + ex.Message);
      }
    }
    public void Deactivate()
    {
      //Stop listening for editor events.
      ((IEngineEditEvents_Event)m_engineEditor).OnTargetLayerChanged -= OnTargetLayerChanged;
      ((IEngineEditEvents_Event)m_engineEditor).OnCurrentTaskChanged -= OnCurrentTaskChanged;

      //Release object references.
      m_engineEditor = null;
      m_editSketch = null;
      m_editLayer = null;
    }
Esempio n. 41
0
        private void EditorForm_Load(object sender, EventArgs e)
        {
            //*********  Important *************
            //Obtain a reference to the MainForm using the EditHelper class
            m_mainForm = EditHelper.TheMainForm;
            m_mapControl = m_mainForm.MapControl;

            //buddy the toolbars with the MapControl
            axBlankToolBar.SetBuddyControl(m_mapControl);
            axModifyToolbar.SetBuddyControl(m_mapControl);
            axReshapeToolbar.SetBuddyControl(m_mapControl);
            axUndoRedoToolbar.SetBuddyControl(m_mapControl);
            axCreateToolbar.SetBuddyControl(m_mapControl);

            //Create and share command pool
            m_pool = new CommandPoolClass();
            axCreateToolbar.CommandPool = m_pool;
            axBlankToolBar.CommandPool = m_pool;
            axModifyToolbar.CommandPool = m_pool;
            axReshapeToolbar.CommandPool = m_pool;
            axUndoRedoToolbar.CommandPool = m_pool;

            //Create and share operation stack
            m_operationStack = new ControlsOperationStackClass();
            axModifyToolbar.OperationStack = m_operationStack;
            axReshapeToolbar.OperationStack = m_operationStack;
            axUndoRedoToolbar.OperationStack = m_operationStack;
            axCreateToolbar.OperationStack = m_operationStack;

            //load items for the axModifyToolbar
            axModifyToolbar.AddItem("esriControls.ControlsEditingEditTool", 0, 0, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axModifyToolbar.AddItem("VertexCommands_CS.CustomVertexCommands", 1, 1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axModifyToolbar.AddItem("VertexCommands_CS.CustomVertexCommands", 2, 2, false, 0, esriCommandStyles.esriCommandStyleIconOnly);

            //load items for the axReshapeToolbar
            axReshapeToolbar.AddItem("esriControls.ControlsEditingEditTool", 0, 0, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axReshapeToolbar.AddItem("esriControls.ControlsEditingSketchTool", 0, 1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);

            //load items for the axCreateToolbar
            axCreateToolbar.AddItem("esriControls.ControlsEditingSketchTool", 0, 0, false, 0, esriCommandStyles.esriCommandStyleIconOnly);

            //set up the EngineEditor
            m_engineEditor = new EngineEditorClass();
            m_engineEditor.EnableUndoRedo(true);
            ((IEngineEditProperties2)m_engineEditor).StickyMoveTolerance = 10000;
            object tbr = (object)axCreateToolbar.Object;
            IExtension engineEditorExt = m_engineEditor as IExtension;
            engineEditorExt.Startup(ref tbr); //ensures that the operationStack will function correctly

            //Listen to OnSketchModified engine editor event
            ((IEngineEditEvents_Event)m_engineEditor).OnSketchModified += new IEngineEditEvents_OnSketchModifiedEventHandler(OnSketchModified);
            //listen to MainForm events in case application is closed while editing
            EditHelper.TheMainForm.FormClosing += new FormClosingEventHandler(TheMainForm_FormClosing);

            #region Form Management
            m_commands = new ArrayList();
            m_commands.Add(cmdModify);
            m_commands.Add(cmdReshape);
            m_commands.Add(cmdCreate);

            DisableButtons();
            txtInfo.Text = "";
            this.Size = new Size(242, 208);
            this.FormBorderStyle = FormBorderStyle.FixedSingle;
            SetErrorLabel("");
            EditHelper.IsEditorFormOpen = true;
            #endregion
        }
        private void EngineEditingForm_Load(object sender, EventArgs e)
        {
            m_editor = new EngineEditorClass();
           
            //Set buddy controls
            axTOCControl1.SetBuddyControl(axMapControl1);
            axEditorToolbar.SetBuddyControl(axMapControl1);
            axToolbarControl1.SetBuddyControl(axMapControl1);

            //Add items to the ToolbarControl
            axToolbarControl1.AddItem("esriControls.ControlsOpenDocCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axToolbarControl1.AddItem("esriControls.ControlsSaveAsDocCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axToolbarControl1.AddItem("esriControls.ControlsAddDataCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);            
            axToolbarControl1.AddItem("esriControls.ControlsMapZoomInTool", 0, -1, true, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axToolbarControl1.AddItem("esriControls.ControlsMapZoomOutTool", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axToolbarControl1.AddItem("esriControls.ControlsMapPanTool", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axToolbarControl1.AddItem("esriControls.ControlsMapFullExtentCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axToolbarControl1.AddItem("esriControls.ControlsMapZoomToLastExtentBackCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axToolbarControl1.AddItem("esriControls.ControlsMapZoomToLastExtentForwardCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
           
            //Add items to the custom editor toolbar          
            axEditorToolbar.AddItem("esriControls.ControlsEditingEditorMenu", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axEditorToolbar.AddItem("esriControls.ControlsEditingEditTool", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axEditorToolbar.AddItem("esriControls.ControlsEditingSketchTool", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axEditorToolbar.AddItem("esriControls.ControlsUndoCommand", 0, -1, true, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axEditorToolbar.AddItem("esriControls.ControlsRedoCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axEditorToolbar.AddItem("esriControls.ControlsEditingTargetToolControl", 0, -1, true, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axEditorToolbar.AddItem("esriControls.ControlsEditingTaskToolControl", 0, -1, true, 0, esriCommandStyles.esriCommandStyleIconOnly);
                       
            //Create a popup menu
            m_toolbarMenu = new ToolbarMenuClass();
            m_toolbarMenu.AddItem("esriControls.ControlsEditingSketchContextMenu", 0, 0, false, esriCommandStyles.esriCommandStyleTextOnly);

            //share the command pool          
            axToolbarControl1.CommandPool = axEditorToolbar.CommandPool;
            m_toolbarMenu.CommandPool = axEditorToolbar.CommandPool;

            //Create an operation stack for the undo and redo commands to use
            IOperationStack operationStack = new ControlsOperationStackClass();
            axEditorToolbar.OperationStack = operationStack;

            // Fill the Check List of Events for Selection
            TabControl tabControl = eventTabControl as TabControl;
            System.Collections.IEnumerator enumTabs = tabControl.TabPages.GetEnumerator();
            enumTabs.MoveNext();
            m_listenTab = enumTabs.Current as TabPage;
            enumTabs.MoveNext();
            m_selectTab = enumTabs.Current as TabPage;

            CheckedListBox editEventList = m_selectTab.GetNextControl(m_selectTab, true) as CheckedListBox;
            editEventList.ItemCheck += new ItemCheckEventHandler(editEventList_ItemCheck);

            ListBox listEvent = m_listenTab.GetNextControl(m_listenTab, true) as ListBox;
            listEvent.MouseDown += new MouseEventHandler(listEvent_MouseDown);

            eventListener = new Events.EventListener(m_editor);

            eventListener.Changed += new Events.ChangedEventHandler(eventListener_Changed);

            //populate the editor events            
            editEventList.Items.AddRange(Enum.GetNames(typeof(Events.EventListener.EditorEvent)));

            //add some sample line data to the map
            IWorkspaceFactory workspaceFactory = new AccessWorkspaceFactoryClass();
            //relative file path to the sample data from EXE location
            string filePath = @"..\..\..\data\StreamflowDateTime\Streamflow.mdb";
            
            IFeatureWorkspace workspace = (IFeatureWorkspace)workspaceFactory.OpenFromFile(filePath, axMapControl1.hWnd);

            //Add the various layers
            IFeatureLayer featureLayer1 = new FeatureLayerClass();
            featureLayer1.Name = "Watershed";
            featureLayer1.Visible = true;
            featureLayer1.FeatureClass = workspace.OpenFeatureClass("Watershed");
            axMapControl1.Map.AddLayer((ILayer)featureLayer1);

            IFeatureLayer featureLayer2 = new FeatureLayerClass();
            featureLayer2.Name = "TimSerTool";
            featureLayer2.Visible = true;
            featureLayer2.FeatureClass = workspace.OpenFeatureClass("TimSerTool");
            axMapControl1.Map.AddLayer((ILayer)featureLayer2);

        }
Esempio n. 43
0
        public static void InitEditEnvironment()
        {
            g_operationStack = new ControlsOperationStackClass();
            g_tbCtlEdit.OperationStack = g_operationStack;
            g_engineEditor = new EngineEditorClass();
            g_engineEditLayers = (IEngineEditLayers)g_engineEditor;

            System.Object tbr = g_tbCtlEdit.Object;
            IExtension engineEditorExt = (IExtension)g_engineEditor;
            engineEditorExt.Startup(tbr);
            g_EngineEditEvents = (IEngineEditEvents_Event)g_engineEditor;
        }
 /// <summary>
 /// Occurs when this tool is created
 /// </summary>
 /// <param name="hook">Instance of the application</param>
 public override void OnCreate(object hook)
 {
     try
     {
         m_hookHelper = new HookHelperClass();
         m_hookHelper.Hook = hook;
         m_engineEditor = new EngineEditorClass(); //this class is a singleton
         m_editLayer = m_engineEditor as IEngineEditLayers;
     }
     catch
     {
         m_hookHelper = null;
     }
 }
Esempio n. 45
0
        public void Deactivate()
        {
            pEditSketch.RefreshSketch();

            //Stop listening to engine editor events.
            ((IEngineEditEvents_Event)pEditSketch).OnTargetLayerChanged -= OnTargetLayerChanged;

            ((IEngineEditEvents_Event)pEditSketch).OnCurrentTaskChanged -= OnCurrentTaskChanged;

            //Release object references.
            pEngineEditor = null;
            pEditSketch = null;
            pEditLayer = null;
        }