示例#1
0
        public override void OnCreate(object hook)
        {
            if (hook == null)
            {
                return;
            }

            m_application = hook as IApplication;

            //Disable if it is not ArcMap
            if (hook is IMxApplication)
            {
                base.m_enabled = true;
            }
            else
            {
                base.m_enabled = false;
            }

            //get the editor
            UID editorUid = new UID();

            editorUid.Value = "esriEditor.Editor";
            m_editor        = m_application.FindExtensionByCLSID(editorUid) as IEditor;
            m_edSketch      = m_editor as IEditSketch3;
        }
        protected override void OnActivate()
        {
            //get the cadastral editor and target fabric
            m_pCadEd  = (ICadastralEditor)ArcMap.Application.FindExtensionByName("esriCadastralUI.CadastralEditorExtension");
            m_pCadFab = m_pCadEd.CadastralFabric;

            if (m_pCadFab == null)
            {
                MessageBox.Show("No target fabric found. Please add a fabric to the map start editing, and try again.");
                return;
            }

            m_pFabricLines = (IFeatureClass)m_pCadFab.get_CadastralTable(esriCadastralFabricTable.esriCFTLines);

            m_editor.CurrentTask    = null;
            m_edSketch              = m_editor as IEditSketch3;
            m_edSketch.GeometryType = esriGeometryType.esriGeometryPolyline;
            m_csc = new TraceConstructorClass();
            m_csc.Initialize(m_editor);
            m_edSketch.ShapeConstructor = m_csc;
            m_csc.Activate();

            // Setup events
            m_editEvents.OnSketchModified           += OnSketchModified;
            m_editEvents5.OnShapeConstructorChanged += OnShapeConstructorChanged;
            m_editEvents.OnSketchFinished           += OnSketchFinished;
        }
        protected override void OnActivate()
        {
            m_edSketch           = m_editor as IEditSketch3;
            m_editor.CurrentTask = null;

            if (m_editor.EditState == esriEditState.esriStateNotEditing)
            {
                return;
            }

            m_edSketch.GeometryType = esriGeometryType.esriGeometryPolyline;

            IEditProperties4 pEdProps = m_editor as IEditProperties4;

            m_bsnap2sketch        = pEdProps.SnapToSketch;
            pEdProps.SnapToSketch = true;

            m_csc = new StraightConstructorClass();
//      m_csc = new SketchConstructorClass();

            m_csc.Initialize(m_editor);
            m_edSketch.ShapeConstructor = m_csc;
            m_csc.Activate();

            // Setup events
            m_editEvents.OnSketchModified           += OnSketchModified;
            m_editEvents.OnSketchFinished           += OnSketchFinished;
            m_editEvents5.OnShapeConstructorChanged += OnShapeConstructorChanged;
        }
        public override void OnClick()
        {
            m_edSketch = m_editor as IEditSketch3;

            //Restrict to line constructors (for this tool)
            m_edSketch.GeometryType = esriGeometryType.esriGeometryPolyline;

            //Activate a constructor based on the current sketch geometry
            if (m_edSketch.GeometryType == esriGeometryType.esriGeometryPoint)
            {
                m_csc = new PointConstructorClass();
            }
            else
            {
                m_csc = new StraightConstructorClass();
            }
            m_csc.Initialize(m_editor);
            m_edSketch.ShapeConstructor = m_csc;
            m_csc.Activate();

            //set the current task to null
            m_editor.CurrentTask = null;

            //setup events
            m_editEvents.OnSketchModified           += new IEditEvents_OnSketchModifiedEventHandler(m_editEvents_OnSketchModified);
            m_editEvents5.OnShapeConstructorChanged += new IEditEvents5_OnShapeConstructorChangedEventHandler(m_editEvents5_OnShapeConstructorChanged);
            m_editEvents.OnSketchFinished           += new IEditEvents_OnSketchFinishedEventHandler(m_editEvents_OnSketchFinished);

            //Create form and pass initialization parameters
            m_form = new ViperPinForm(m_editor);

            base.OnClick();
        }
        protected override void OnActivate()
        {
            m_edSketch = m_editor as IEditSketch3;

            m_editor.CurrentTask    = null;
            m_edSketch.GeometryType = esriGeometryType.esriGeometryPoint;

            //IEditTaskSearch editTaskSearch = m_editor as IEditTaskSearch;
            //IEditTask editTask = editTaskSearch.get_TaskByUniqueName("GarciaUI_CreateNewFeatureTask");
            //m_editor.CurrentTask = editTask;

            // Activate a shape constructor based on the current sketch geometry
            if (m_edSketch.GeometryType == esriGeometryType.esriGeometryPoint | m_edSketch.GeometryType == esriGeometryType.esriGeometryMultipoint)
            {
                m_csc = new PointConstructorClass();
            }
            else
            {
                m_csc = new StraightConstructorClass();
            }

            m_csc.Initialize(m_editor);
            m_edSketch.ShapeConstructor = m_csc;
            m_csc.Activate();


            // Setup events
            m_editEvents.OnSketchModified           += OnSketchModified;
            m_editEvents5.OnShapeConstructorChanged += OnShapeConstructorChanged;
            m_editEvents.OnSketchFinished           += OnSketchFinished;
        }
        protected override void OnActivate()
        {
            ConfigUtil.type = "gas";
            m_edSketch = m_editor as IEditSketch3;

            m_editor.CurrentTask = null;
            m_edSketch.GeometryType = esriGeometryType.esriGeometryPoint;

            //IEditTaskSearch editTaskSearch = m_editor as IEditTaskSearch;
            //IEditTask editTask = editTaskSearch.get_TaskByUniqueName("GarciaUI_CreateNewFeatureTask");
            //m_editor.CurrentTask = editTask;

            // Activate a shape constructor based on the current sketch geometry
            if (m_edSketch.GeometryType == esriGeometryType.esriGeometryPoint | m_edSketch.GeometryType == esriGeometryType.esriGeometryMultipoint)
                m_csc = new PointConstructorClass();
            else
                m_csc = new StraightConstructorClass();

            m_csc.Initialize(m_editor);
            m_edSketch.ShapeConstructor = m_csc;
            m_csc.Activate();

            // Setup events
            m_editEvents.OnSketchModified += OnSketchModified;
            m_editEvents5.OnShapeConstructorChanged += OnShapeConstructorChanged;
            m_editEvents.OnSketchFinished += OnSketchFinished;
        }
        protected override void OnActivate()
        {
            //get the cadastral editor and target fabric
              m_pCadEd = (ICadastralEditor)ArcMap.Application.FindExtensionByName("esriCadastralUI.CadastralEditorExtension");
              m_pCadFab = m_pCadEd.CadastralFabric;

              if (m_pCadFab == null)
              {
            MessageBox.Show("No target fabric found. Please add a fabric to the map start editing, and try again.");
            return;
              }

              m_pFabricLines = (IFeatureClass)m_pCadFab.get_CadastralTable(esriCadastralFabricTable.esriCFTLines);

              m_editor.CurrentTask = null;
              m_edSketch = m_editor as IEditSketch3;
              m_edSketch.GeometryType = esriGeometryType.esriGeometryPolyline;
              m_csc = new TraceConstructorClass();
              m_csc.Initialize(m_editor);
              m_edSketch.ShapeConstructor = m_csc;
              m_csc.Activate();

              // Setup events
              m_editEvents.OnSketchModified += OnSketchModified;
              m_editEvents5.OnShapeConstructorChanged += OnShapeConstructorChanged;
              m_editEvents.OnSketchFinished += OnSketchFinished;
        }
        protected override void OnActivate()
        {
            ConfigUtil.type      = "address";
            m_editor.CurrentTask = null;
            m_targetLayer        = ((IFeatureLayer)m_editor.CurrentTemplate.Layer);
            m_className          = Globals.getClassName(m_targetLayer);

            m_edSketch = m_editor as IEditSketch3;
            m_edSketch.GeometryType = esriGeometryType.esriGeometryMultipoint;
            // Activate a shape constructor based on the current sketch geometry
            if (m_edSketch.GeometryType == esriGeometryType.esriGeometryPoint | m_edSketch.GeometryType == esriGeometryType.esriGeometryMultipoint)
            {
                m_csc = new PointConstructorClass();
            }
            else
            {
                m_csc = new StraightConstructorClass();
            }

            m_csc.Initialize(m_editor);
            m_edSketch.ShapeConstructor = m_csc;
            m_csc.Activate();

            // Setup events
            m_editEvents.OnSketchModified           += OnSketchModified;
            m_editEvents5.OnShapeConstructorChanged += OnShapeConstructorChanged;
            m_editEvents.OnSketchFinished           += OnSketchFinished;

            // Initialize address map tip
            m_addressMaptip = new AddressMapTip();
            var mxPtr = new IntPtr(ArcMap.Application.hWnd);

            m_addressMaptip.Show(Control.FromHandle(mxPtr));
            m_addressMaptip.Visible = false;
        }
        protected override void OnActivate()
        {
            m_editor.CurrentTask = null;

            m_edSketch = m_editor as IEditSketch3;
            m_edSketch.GeometryType = esriGeometryType.esriGeometryPolyline;
            // Activate a shape constructor based on the current sketch geometry
            if (m_edSketch.GeometryType == esriGeometryType.esriGeometryPoint | m_edSketch.GeometryType == esriGeometryType.esriGeometryMultipoint)
            {
                m_csc = new PointConstructorClass();
            }
            else
            {
                m_csc = new StraightConstructorClass();
            }

            m_csc.Initialize(m_editor);
            m_edSketch.ShapeConstructor = m_csc;
            m_csc.Activate();

            // Setup events
            m_editEvents.OnSketchModified           += OnSketchModified;
            m_editEvents5.OnShapeConstructorChanged += OnShapeConstructorChanged;
            m_editEvents.OnSketchFinished           += OnSketchFinished;
        }
示例#10
0
        public override void OnClick()
        {
            // Create the constructor, pass the editor and set as current constructor
            m_edSketch = m_editor as IEditSketch3;
            AngleAngleCstr aac = new AngleAngleCstr();

            aac.Initialize(m_editor);
            m_edSketch.ShapeConstructor = aac;
        }
        public void AddZToSketch(IEditSketch3 sketch)
        {
            var    editor  = ArcUtils.Editor;
            var    editorZ = editor as IEditorZ;
            IPoint point   = sketch.LastPoint;

            if ((editorZ != null) && (point != null) && sketch.ZAware)
            {
                double z = GetHeight(point.X, point.Y);
                editorZ.UseZOffset = true;
                editorZ.ZOffset    = z;

                IGeometry         geometry = sketch.Geometry;
                var               ptColl   = geometry as IPointCollection4;
                ISketchOperation2 sketchOp = new SketchOperationClass();
                sketchOp.Start(editor);
                IPoint pointc = null;

                if ((!geometry.IsEmpty) && (geometry is IPoint) && (ptColl == null))
                {
                    pointc = geometry as IPoint;
                    ptColl = new MultipointClass();
                    ptColl.AddPoint(pointc);
                }

                if (ptColl != null)
                {
                    int nrPoints = ptColl.PointCount;

                    for (int i = 0; i < nrPoints; i++)
                    {
                        IPoint pointC = ptColl.Point[i];
                        // ReSharper disable CompareOfFloatsByEqualityOperator

                        if (pointC.Z == 0)
                        {
                            IPoint newPoint = new PointClass {
                                X = pointC.X, Y = pointC.Y, Z = z
                            };
                            ptColl.UpdatePoint(i, newPoint);
                        }

                        // ReSharper restore CompareOfFloatsByEqualityOperator
                    }
                }

                sketch.Geometry = pointc ?? (ptColl as IGeometry);
                geometry        = sketch.Geometry;

                if (geometry != null)
                {
                    sketchOp.Finish(geometry.Envelope, esriSketchOperationType.esriSketchOperationGeneral, geometry);
                }
            }
        }
        public ViperPinForm(IEditor3 editor)
        {
            InitializeComponent();

            m_editor     = editor;
            m_edSketch   = m_editor as IEditSketch3;
            m_editLayers = m_editor as IEditLayers;

            lblEditLayer.Text = m_editLayers.CurrentLayer.Name;

            //Load field combo box with field names
            IFields pFields = m_editLayers.CurrentLayer.FeatureClass.Fields;

            for (int i = 0; i < pFields.FieldCount; i++)
            {
                cmbPINField.Items.Add(pFields.get_Field(i).Name);
            }

            //get pinfield from registry
            string      pinField = null;
            RegistryKey pRegKey  = Registry.CurrentUser.OpenSubKey("Software\\ESRI\\ViperPin");

            if (pRegKey != null)
            {
                pinField = pRegKey.GetValue("Pinfield").ToString();
            }

            //set the combo box to the pinfield
            for (int i = 0; i < pFields.FieldCount; i++)
            {
                if (pinField == pFields.get_Field(i).Name)
                {
                    cmbPINField.Text = pinField;
                    break;
                }
                else
                {
                    cmbPINField.Text = "None";
                }
            }

            //cmbPINField.SelectedIndex = 0;
            cmbPINField.Refresh();
            m_lotNum    = 1;
            txtlot.Text = "1";

            //Set center right of form to center right of screen
            this.StartPosition = FormStartPosition.Manual;
            this.Left          = 0;
            this.Top           = (Screen.PrimaryScreen.Bounds.Height / 2) - (this.Height / 2);
        }
    public ViperPinForm(IEditor3 editor)
    {
      InitializeComponent();

      m_editor = editor;
      m_edSketch = m_editor as IEditSketch3;
      m_editLayers = m_editor as IEditLayers;

      lblEditLayer.Text = m_editLayers.CurrentLayer.Name;

      //Load field combo box with field names
      IFields pFields = m_editLayers.CurrentLayer.FeatureClass.Fields;
		  for (int i=0; i < pFields.FieldCount; i++)
      {
        cmbPINField.Items.Add(pFields.get_Field(i).Name);
      }

      //get pinfield from registry
      string pinField = null;
      RegistryKey pRegKey = Registry.CurrentUser.OpenSubKey("Software\\ESRI\\ViperPin");
      if (pRegKey != null)
      {
        pinField = pRegKey.GetValue("Pinfield").ToString();
      }

      //set the combo box to the pinfield
      for (int i = 0; i < pFields.FieldCount; i++)
      {
        if (pinField == pFields.get_Field(i).Name)
        {
          cmbPINField.Text = pinField;
          break;
        }
        else
        {
          cmbPINField.Text = "None";
        }
      }

      //cmbPINField.SelectedIndex = 0;
      cmbPINField.Refresh();
      m_lotNum = 1;
      txtlot.Text = "1";

      //Set center right of form to center right of screen
      this.StartPosition = FormStartPosition.Manual;
      this.Left = 0;
      this.Top = (Screen.PrimaryScreen.Bounds.Height / 2) - (this.Height / 2);
    }
        public PointsAlongLineForm(IEditor3 editor)
        {
            InitializeComponent();

            m_editor   = editor;
            m_edSketch = m_editor as IEditSketch3;

            m_polyline        = m_edSketch.Geometry as IPolyline;
            tbLineLength.Text = (m_polyline.Length.ToString("F"));

            //get the template
            m_editTemplate = m_editor.CurrentTemplate;
            m_featureLayer = m_editTemplate.Layer as IFeatureLayer;
            m_featureClass = m_featureLayer.FeatureClass;
        }
        public PointsAlongLineForm(IEditor3 editor)
        {
            InitializeComponent();

              m_editor = editor;
              m_edSketch = m_editor as IEditSketch3;

              m_polyline = m_edSketch.Geometry as IPolyline;
              tbLineLength.Text = (m_polyline.Length.ToString("F"));

              //get the template
              m_editTemplate = m_editor.CurrentTemplate;
              m_featureLayer = m_editTemplate.Layer as IFeatureLayer;
              m_featureClass = m_featureLayer.FeatureClass;
        }
示例#16
0
        public void Initialize(IEditor pEditor)
        {
            // Initialize the constructor
            m_editor   = pEditor as IEditor;
            m_edSketch = pEditor as IEditSketch3;

            //Get the snap environment
            m_snappingEnv      = m_editor.Parent.FindExtensionByName("ESRI Snapping") as ISnappingEnvironment;
            m_snapper          = m_snappingEnv.PointSnapper;
            m_snappingFeedback = new SnappingFeedbackClass();
            m_snappingFeedback.Initialize(m_editor.Parent, m_snappingEnv, true);

            m_firstPoint  = new PointClass();
            m_secondPoint = new PointClass();
            m_activePoint = new PointClass();

            // Set the phase to inactive so we start at the beginning
            m_etoolPhase = ToolPhase.Inactive;
        }
        protected override void OnActivate()
        {
            m_editor.CurrentTask = null;

            m_edSketch = m_editor as IEditSketch3;
            m_edSketch.GeometryType = esriGeometryType.esriGeometryPoint;
            // Activate a shape constructor based on the current sketch geometry
            if (m_edSketch.GeometryType == esriGeometryType.esriGeometryPoint | m_edSketch.GeometryType == esriGeometryType.esriGeometryMultipoint)
                m_csc = new PointConstructorClass();
            else
                m_csc = new StraightConstructorClass();

            m_csc.Initialize(m_editor);
            m_edSketch.ShapeConstructor = m_csc;
            m_csc.Activate();

            // Setup events
            m_editEvents.OnSketchModified += OnSketchModified;
            m_editEvents5.OnShapeConstructorChanged += OnShapeConstructorChanged;
            m_editEvents.OnSketchFinished += OnSketchFinished;
        }
    public void Initialize(IEditor pEditor)
    {
      // Initialize the constructor
      m_editor = pEditor as IEditor;
      m_edSketch = pEditor as IEditSketch3;

      //Get the snap environment
      m_snappingEnv = m_editor.Parent.FindExtensionByName("ESRI Snapping") as ISnappingEnvironment;
      m_snapper = m_snappingEnv.PointSnapper;
      m_snappingFeedback = new SnappingFeedbackClass();
      m_snappingFeedback.Initialize(m_editor.Parent, m_snappingEnv, true);

      m_firstPoint = new PointClass();
      m_secondPoint = new PointClass();
      m_activePoint = new PointClass();

      // Set the phase to inactive so we start at the beginning 
      m_etoolPhase = ToolPhase.Inactive;
    }
 public override void OnClick()
 {
   // Create the constructor, pass the editor and set as current constructor
   m_edSketch = m_editor as IEditSketch3;
   AngleAngleCstr aac = new AngleAngleCstr();
   aac.Initialize(m_editor);
   m_edSketch.ShapeConstructor = aac;
 }
示例#20
0
        /// <summary>
        /// Occurs when this tool is clicked
        /// </summary>
        public override void OnClick()
        {
            m_edSketch = m_editor as IEditSketch3;

            // Activate a shape constructor based on the current sketch geometry
            // Sketch geometry can be set either by the user selecting a template or the developer setting a current layer
            // and/or sketch geometry
            if (m_edSketch.GeometryType == esriGeometryType.esriGeometryPoint)
                m_csc = new PointConstructorClass();
            else
                m_csc = new StraightConstructorClass();
            m_csc.Initialize(m_editor);
            m_edSketch.ShapeConstructor = m_csc;
            m_csc.Activate();

            // Set the current task to null
            m_editor.CurrentTask = null;

            // Setup events
            m_editEvents.OnSketchModified += new IEditEvents_OnSketchModifiedEventHandler(m_editEvents_OnSketchModified);
            m_editEvents5.OnShapeConstructorChanged += new IEditEvents5_OnShapeConstructorChangedEventHandler(m_editEvents5_OnShapeConstructorChanged);
            m_editEvents.OnSketchFinished += new IEditEvents_OnSketchFinishedEventHandler(m_editEvents_OnSketchFinished);
        }
    /// <summary>
    /// Occurs when this tool is clicked
    /// </summary>
    public override void OnClick()
    {
      m_edSketch = m_editor as IEditSketch3;

      //Restrict to line constructors (for this tool)
      m_edSketch.GeometryType = esriGeometryType.esriGeometryPolyline;

      //Activate a shape constructor based on the current sketch geometry
      if (m_edSketch.GeometryType == esriGeometryType.esriGeometryPoint)
        m_csc = new PointConstructorClass();
      else
        m_csc = new StraightConstructorClass();
      m_csc.Initialize(m_editor);
      m_edSketch.ShapeConstructor = m_csc;
      m_csc.Activate();

      //set the current task to null
      m_editor.CurrentTask = null;

      //setup events
      m_editEvents.OnSketchModified += new IEditEvents_OnSketchModifiedEventHandler(m_editEvents_OnSketchModified);
      m_editEvents5.OnShapeConstructorChanged += new IEditEvents5_OnShapeConstructorChangedEventHandler(m_editEvents5_OnShapeConstructorChanged);
      m_editEvents.OnSketchFinished += new IEditEvents_OnSketchFinishedEventHandler(m_editEvents_OnSketchFinished);
    }
示例#22
0
 public override void Initialize(IEditor pEditor)
 {
     m_editor   = pEditor;
     m_EdSketch = m_editor as IEditSketch3;
     base.Initialize(pEditor);
 }