protected override void OnMouseDown(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
        {
            if (arg.Button == MouseButtons.Left)
            {
                GeographicCoordinates geographicCoordinates = new GeographicCoordinates(ArcGlobe.Globe, arg.X, arg.Y);

                SpatialReferenceFactory spatialReferenceFactory = new SpatialReferenceFactory((int)GeographicCoordinateSystem);

                PointGeometry pointGeometry = new PointGeometry(geographicCoordinates.Longitude, geographicCoordinates.Latitude, geographicCoordinates.AltitudeInKilometers, spatialReferenceFactory.SpatialReference);

                TextForm textForm = new TextForm();

                DialogResult dialogResult = textForm.ShowDialog();

                if (textForm.InputText.Length > 0)
                {
                    TextElement textElement = new TextElement(pointGeometry.Geometry, textForm.InputText, TextElementSize);

                    TableOfContents tableOfContents = new TableOfContents(ArcGlobe.Globe);

                    if (!tableOfContents.LayerExists(GraphicsLayerName))
                    {
                        tableOfContents.ConstructLayer(GraphicsLayerName);
                    }

                    Layer layer = new Layer(tableOfContents[GraphicsLayerName]);

                    layer.AddElement(textElement.Element, textElement.ElementProperties);

                    ArcGlobe.Globe.GlobeDisplay.RefreshViewers();
                }
            }
        }
示例#2
0
        protected override void OnMouseUp(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
        {
            if (arg.Button == MouseButtons.Left || arg.Button == MouseButtons.Right)
            {
                if (!inUse)
                {
                    mouseX = arg.X;
                    mouseY = arg.Y;

                    if (speed == 0)
                    {
                        StartFlight(arg.X, arg.Y);
                    }
                }
                else
                {
                    //Set the speed
                    if (arg.Button == MouseButtons.Left)
                    {
                        speed = speed + 1;
                    }
                    else if (arg.Button == MouseButtons.Right)
                    {
                        speed = speed - 1;
                    }
                }
            }
            else
            {
                //EndFlight();
                inUse   = false;
                bCancel = true;
            }
        }
示例#3
0
        protected override void OnMouseUp(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
        {
            IMxDocument pMxDoc = ArcMap.Application.Document as IMxDocument;

            //get point cordinate from map point
            // IPoint pPoint = pMxDoc.ActivatedView.ScreenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y);


            //get point from hard coded
            IPoint pPoint = new Point();

            pPoint.X = -126.165462;
            pPoint.Y = 136.960535;

            IFeatureLayer pFLayer = pMxDoc.FocusMap.Layer[0] as IFeatureLayer;

            IWorkspaceEdit pWorkspaceEdit = ((IDataset)(pFLayer.FeatureClass)).Workspace as IWorkspaceEdit;

            pWorkspaceEdit.StartEditing(false);

            pWorkspaceEdit.StartEditOperation();

            IFeature pFeature = pFLayer.FeatureClass.CreateFeature();

            pFeature.Shape = pPoint;
            pFeature.Store();

            pWorkspaceEdit.StopEditOperation();
            pWorkspaceEdit.StopEditing(true);


            //for refresh mxd doc
            pMxDoc.ActivatedView.Refresh();
        }
        protected override void OnMouseDown(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
        {
            if (arg.Button != System.Windows.Forms.MouseButtons.Left)
            {
                return;
            }

            try
            {
                //Get the active view from the ArcMap static class.
                IActiveView activeView = ArcMap.Document.FocusMap as IActiveView;

                var             point      = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y) as IPoint;
                ISnappingResult snapResult = null;
                //Try to snap the current position
                snapResult = m_Snapper.Snap(point);
                m_SnappingFeedback.Update(null, 0);
                if (snapResult != null && snapResult.Location != null)
                {
                    point = snapResult.Location;
                }

                Mediator.NotifyColleagues(Constants.NEW_MAP_POINT, point);
            }
            catch (Exception ex) { Console.WriteLine(ex.Message); }
        }
        protected override void OnMouseUp(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
        {
            if (arg.Button == MouseButtons.Left)
            {
                GeographicCoordinates geographicCoordinates = new GeographicCoordinates(ArcGlobe.Globe, arg.X, arg.Y);

                SpatialReferenceFactory spatialReferenceFactory = new SpatialReferenceFactory((int)GeographicCoordinateSystem);

                PointGeometry pointGeometry = new PointGeometry(geographicCoordinates.Longitude, geographicCoordinates.Latitude, geographicCoordinates.AltitudeInKilometers, spatialReferenceFactory.SpatialReference);

                IStyleGalleryItem styleGalleryItem = StyleGallerySelection.GetStyleGalleryItem();

                if (styleGalleryItem != null)
                {
                    StyleElement styleElement = new StyleElement(pointGeometry.Geometry, StyleElementSize, styleGalleryItem);

                    TableOfContents tableOfContents = new TableOfContents(ArcGlobe.Globe);

                    if (!tableOfContents.LayerExists(GraphicsLayerName))
                    {
                        tableOfContents.ConstructLayer(GraphicsLayerName);
                    }

                    Layer layer = new Layer(tableOfContents[GraphicsLayerName]);

                    layer.AddElement(styleElement.Element, styleElement.ElementProperties);

                    ArcGlobe.Globe.GlobeDisplay.RefreshViewers();
                }
            }
        }
        protected override void OnMouseDown(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
        {
            if (arg.Button != System.Windows.Forms.MouseButtons.Left)
            {
                return;
            }
            try
            {
                //Get the active view from the ArcMap static class.
                IActiveView activeView = ArcMap.Document.FocusMap as IActiveView;

                var point = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y) as IPoint;

                // always use WGS84
                var sr = GetSR();

                if (sr != null)
                {
                    point.Project(sr);
                }

                var doc = AddIn.FromID <ArcMapAddinCoordinateTool.DockableWindowCoordinateTool.AddinImpl>(ThisAddIn.IDs.DockableWindowCoordinateTool);

                if (doc != null)
                {
                    doc.SetInput(point.X, point.Y);
                }
            }
            catch { }
        }
示例#7
0
        protected override void OnMouseUp(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
        {
            base.OnMouseUp(arg);

            int x = arg.X;
            int y = arg.Y;

            IMxDocument pMxdoc = (IMxDocument)ArcMap.Application.Document;

            IFeatureLayer  pfeaturelayer = (IFeatureLayer)pMxdoc.ActiveView.FocusMap.Layer[0];
            IPoint         pPoint        = pMxdoc.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
            OpenFileDialog of            = new OpenFileDialog();

            if (of.ShowDialog() == DialogResult.OK)
            {
                string [] devicepoints = System.IO.File.ReadAllLines(of.FileName);
                foreach (string dpoint in devicepoints)
                {
                    double dx = double.Parse(dpoint.Split(',')[0]);
                    double dy = double.Parse(dpoint.Split(',')[1]);

                    IPoint pDevicePoint = new Point();
                    pDevicePoint.X = dx;
                    pDevicePoint.Y = dy;

                    setDeviceLocation("d02", pDevicePoint, ((IDataset)pfeaturelayer.FeatureClass).Workspace);
                    wait(2);
                }
            }


            //setDeviceLocation("D01",pPoint, ((IDataset)pfeaturelayer.FeatureClass).Workspace);
        }
        protected override void OnMouseDown(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
        {
            IMxDocument pMxDoc = ArcMap.Application.Document as IMxDocument;

            IRubberBand pRabber = new RubberPolygon();

            //get polygon from screen
            IPolygon pPolygon = pRabber.TrackNew(pMxDoc.ActiveView.ScreenDisplay, null) as IPolygon;

            //get cordinate from hard coded
            //IPolygon pPolygon ;

            //IPoint pPoint1 = new Point();
            //pPoint1.X = -120.730273;
            //pPoint1.Y = 224.928212;

            //IPoint pPoint2 = new Point();
            //pPoint2.X = -25.280158;
            //pPoint2.Y = 27942068.023;

            //IPoint pPoint3 = new Point();
            //pPoint3.X = -117.895121;
            //pPoint3.Y = 150.269211;



            //IPointCollection pPointCollection = new Polygon();
            //pPointCollection.AddPoint(pPoint1);
            //pPointCollection.AddPoint(pPoint2);
            //pPointCollection.AddPoint(pPoint3);
            //pPointCollection.AddPoint(pPoint1);

            //pPolygon = pPointCollection as IPolygon;


            ////fix when draw wrong draw
            //IArea pArea = pPolygon as IArea;
            //if (pArea.Area < 0)
            //{
            //    pPolygon.ReverseOrientation();
            //}


            IFeatureLayer  pFlayer = pMxDoc.FocusMap.Layer[0] as IFeatureLayer;
            IDataset       pDS     = pFlayer.FeatureClass as IDataset;
            IWorkspaceEdit pWSE    = pDS.Workspace as IWorkspaceEdit;

            pWSE.StartEditing(false);
            pWSE.StartEditOperation();

            IFeature pFeature = pFlayer.FeatureClass.CreateFeature();

            pFeature.Shape = pPolygon;
            pFeature.Store();

            pWSE.StopEditOperation();
            pWSE.StopEditing(true);

            pMxDoc.ActiveView.Refresh();
        }
示例#9
0
        protected override void OnMouseUp(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
        {
            base.OnMouseDown(arg);

            try
            {
                if ((Painter.ActiveLayer == null) ||
                    (arg.Button != MouseButtons.Left) ||
                    (selectedValue == null))
                {
                    return;
                }
                else
                {
                    // If the mouse does not move, paint at the clicked pixel
                    Position mousePos = Raster.ScreenCoor2RasterCoor(arg.X, arg.Y, Painter.ActiveLayer);
                    if (layerExetent.Contains(mousePos) && iniMousePos.Equals(mousePos))
                    {
                        PaintPixel(mousePos);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Unfortunately, the application meets an error.\n\nSource: {0}\nSite: {1}\nMessage: {2}", ex.Source, ex.TargetSite, ex.Message), "Error");
            }

            iniMousePos = null;
            preMousePos = null;
        }
示例#10
0
        protected override void  OnMouseDown(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
        {
            try
            {
                dlg = gpExtension.elevationDlg;
                if (dlg == null)
                {
                    return;
                }

                IDisplayTransformation displayTransformation = view.ScreenDisplay.DisplayTransformation;
                //the clicked point in map crs:
                IPoint mapPoint = displayTransformation.ToMapPoint(arg.X, arg.Y);

                //Get the polyline object from the users mouse clicks
                polyline = geopuntHelper.GetPolylineFromMouseClicks(view);

                dlg.getData(polyline);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + " : " + ex.StackTrace);
            }
            finally
            {
                base.OnMouseDown(arg);
            }
        }
示例#11
0
        protected override void OnMouseMove(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
        {
            if (!inUse)
            {
                return;
            }

            mouseX = arg.X;
            mouseY = arg.Y;
        }
示例#12
0
        protected override void OnMouseMove(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
        {
            base.OnMouseMove(arg);

            if (arg.Button == MouseButtons.Left && Editor.ActiveLayer != null)
            {
                IPoint moveCoor = Editor.ScreenCoor2MapCoor(arg.X, arg.Y);
                newEnvelopeFeedback.MoveTo(moveCoor);
            }
        }
示例#13
0
        protected override void OnMouseDown(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
        {
            IMxDocument pMxDoc = ArcMap.Application.Document as IMxDocument;

            //get line from drawing
            IRubberBand pRubber = new RubberLine();
            //IPolyline pPloyline = pRubber.TrackNew(pMxDoc.ActivatedView.ScreenDisplay, null) as IPolyline;

            //get lines from hard coded
            IPolyline pPloyline;

            //create points
            IPoint pPoint1 = new Point();

            pPoint1.X = -92.675984;
            pPoint1.Y = 194.232396;

            IPoint pPoint2 = new Point();

            pPoint2.X = -78.115341;
            pPoint2.Y = 133.077697;

            IPoint pPoint3 = new Point();

            pPoint3.X = 13.616707;
            pPoint3.Y = 0.090495;

            IPointCollection pPointCollection = new Polyline();

            pPointCollection.AddPoint(pPoint1);
            pPointCollection.AddPoint(pPoint2);
            pPointCollection.AddPoint(pPoint3);


            IFeatureLayer pFLayer = pMxDoc.FocusMap.Layer[0] as IFeatureLayer;

            IDataset       pDS  = pFLayer.FeatureClass as IDataset;
            IWorkspaceEdit pWSE = pDS.Workspace as IWorkspaceEdit;

            pWSE.StartEditing(false);
            pWSE.StartEditOperation();

            IFeature pFeature = pFLayer.FeatureClass.CreateFeature();

            pFeature.Shape = pPointCollection as IGeometry;
            pFeature.Store();

            pWSE.StopEditOperation();
            pWSE.StopEditing(true);

            pMxDoc.ActivatedView.Refresh();
        }
        protected override void OnMouseDown(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
        {
            IScreenDisplay         screenDisplay         = view.ScreenDisplay;
            batchGeocodeForm       batchDlg              = gpExtension.batchGeocodeDlg;
            IDisplayTransformation displayTransformation = view.ScreenDisplay.DisplayTransformation;

            if (batchDlg != null)
            {
                IPoint mapPoint   = displayTransformation.ToMapPoint(arg.X, arg.Y);
                IPoint lam72Point = geopuntHelper.Transform2Lam72(mapPoint) as IPoint;
                batchDlg.getXYasValidAdres(lam72Point.X, lam72Point.Y);
            }
            base.OnMouseDown(arg);
        }
示例#15
0
        protected override void OnMouseDown(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
        {
            IPoint Point = getCursorLocation(arg);

            if (m_Feedback == null)
            {
                m_Feedback         = new NewEnvelopeFeedbackClass();
                m_Feedback.Display = ArcMap.Document.ActiveView.ScreenDisplay;
                m_Feedback.Start(Point);
            }
            m_isMouseDown = true;

            base.OnMouseDown(arg);
        }
示例#16
0
        protected override void OnMouseDown(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
        {
            m_bDrawPoint = true;

            //move the light-source according to the mouse coordinate
            double lat, lon, alt;

            lat = lon = alt = 0;

            m_globeViewUtil.WindowToGeographic(m_globeDisplay, m_sceneViewer, arg.X, arg.Y, false, out lon, out lat, out alt);

            m_globeDisplayRendering.SetSunPosition(lat, lon);

            //Refresh the display so that the AfterDraw will get called
            m_sceneViewer.Redraw(false);
        }
示例#17
0
        protected override void OnMouseDown(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
        {
            if (arg.Button != System.Windows.Forms.MouseButtons.Left)
            {
                return;
            }

            try
            {
                var point = GetMapPoint(arg.X, arg.Y);
                if (point == null)
                {
                    return;
                }

                ISnappingResult snapResult = null;
                //Try to snap the current position
                if (m_Snapper != null)
                {
                    snapResult = m_Snapper.Snap(point);
                }

                if (m_SnappingFeedback != null)
                {
                    m_SnappingFeedback.Update(null, 0);
                }

                if (snapResult != null && snapResult.Location != null)
                {
                    point = snapResult.Location;
                }

                if (!SelectFeatureEnable)
                {
                    Mediator.NotifyColleagues(CoordinateConversionLibrary.Constants.VALIDATE_MAP_POINT, point);
                }
                else
                {
                    Mediator.NotifyColleagues(CoordinateConversionLibrary.Constants.SELECT_MAP_POINT, point);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }
        protected override void OnMouseMove(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
        {
            base.OnMouseMove(arg);

            try
            {
                if (LineFeedBack != null)
                {
                    IDisplay display = mDoc.ActiveView.ScreenDisplay;
                    IPoint   p       = mDoc.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y);
                    LineFeedBack.MoveTo(p);
                }

                CurrentPos = mDoc.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y);
            }
            catch { }
        }
示例#19
0
        protected override void OnMouseDown(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
        {
            if (arg.Button == MouseButtons.Left)
            {
                GeographicCoordinates geographicCoordinates = new GeographicCoordinates(ArcGlobe.Globe, arg.X, arg.Y);

                SpatialReferenceFactory spatialReferenceFactory = new SpatialReferenceFactory((int)GeographicCoordinateSystem);

                PointGeometry pointGeometry = new PointGeometry(geographicCoordinates.Longitude, geographicCoordinates.Latitude, geographicCoordinates.AltitudeInKilometers, spatialReferenceFactory.SpatialReference);

                if (_polygonGeometry == null)
                {
                    _polygonGeometry = new PolygonGeometry(spatialReferenceFactory.SpatialReference);
                }

                _polygonGeometry.AddPoint(pointGeometry.Geometry as IPoint);

                TableOfContents tableOfContents = new TableOfContents(ArcGlobe.Globe);

                if (!tableOfContents.LayerExists(GraphicsLayerName))
                {
                    tableOfContents.ConstructLayer(GraphicsLayerName);
                }

                Layer layer = new Layer(tableOfContents[GraphicsLayerName]);

                if (_polygonGeometry.PointCount == 1)
                {
                    PointElement pointElement = new PointElement(pointGeometry.Geometry, PointElementSize, PointElementStyle);

                    layer.AddElement(pointElement.Element, pointElement.ElementProperties);
                }
                else
                {
                    layer.RemoveElement(layer.ElementCount - 1);

                    PolylineGeometry polylineGeometry = new PolylineGeometry(_polygonGeometry.Geometry);

                    PolylineElement polylineElement = new PolylineElement(polylineGeometry.Geometry, PolylineElementWidth, PolylineElementStyle);

                    layer.AddElement(polylineElement.Element, polylineElement.ElementProperties);
                }

                ArcGlobe.Globe.GlobeDisplay.RefreshViewers();
            }
        }
        protected override void OnMouseDown(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
        {
            if (arg.Button != System.Windows.Forms.MouseButtons.Left)
            {
                return;
            }

            try
            {
                //Get the active view from the ArcMap static class.
                IActiveView activeView = ArcMap.Document.FocusMap as IActiveView;

                var point = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y) as IPoint;

                Mediator.NotifyColleagues(Constants.NEW_MAP_POINT, point);
            }
            catch (Exception ex) { Console.WriteLine(ex.Message); }
        }
示例#21
0
        protected override void OnMouseUp(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
        {
            int x = arg.X;
            int y = arg.Y;

            IMxDocument pMxdoc = (IMxDocument)ArcMap.Application.Document;
            ////IWorkspace pWorkspace

            IFeatureLayer pFeatureLayer = (IFeatureLayer)pMxdoc.ActiveView.FocusMap.Layer[0];
            IDataset      pDS           = (IDataset)pFeatureLayer.FeatureClass;

            IPoint pPoint = pMxdoc.ActivatedView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);

            DeviceManager dm = new DeviceManager(pDS.Workspace);

            dm.AddDevice("D01", pPoint);

            pMxdoc.ActivatedView.Refresh();
        }
        protected override void OnMouseMove(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
        {
            try
            {
                if (m_schematicFeature1 != null)
                {
                    ESRI.ArcGIS.ArcMapUI.IMxApplication mxApp = (ESRI.ArcGIS.ArcMapUI.IMxApplication)m_app;

                    if (mxApp == null)
                    {
                        return;
                    }

                    ESRI.ArcGIS.Display.IAppDisplay appDisplay = mxApp.Display;

                    if (appDisplay == null)
                    {
                        return;
                    }

                    IScreenDisplay screenDisplay = appDisplay.FocusScreen;

                    if (screenDisplay == null)
                    {
                        return;
                    }

                    //Move the Feedback to the current mouse location
                    IPoint pnt = screenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y);

                    if (pnt != null && m_linkFbk != null)
                    {
                        m_linkFbk.MoveTo(pnt);
                    }
                }
            }
            catch (System.Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.Message);
            }
            return;
        }
示例#23
0
        protected override void OnMouseUp(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
        {
            int x = arg.X;
            int y = arg.Y;



            IMxDocument pMxdoc = (IMxDocument)ArcMap.Application.Document;
            ////IWorkspace pWorkspace

            IFeatureLayer pFeatureLayer = (IFeatureLayer)pMxdoc.ActiveView.FocusMap.Layer[0];
            IDataset      pDS           = (IDataset)pFeatureLayer.FeatureClass;

            IPoint pPoint = pMxdoc.ActivatedView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);

            TowerManager tm = new TowerManager(pDS.Workspace);

            DeviceManager dm = new DeviceManager(pDS.Workspace);

            dm.AddDevice("D01", pPoint);



            Tower tower = tm.GetNearestTower(pPoint);

            if (tower == null)
            {
                MessageBox.Show("No towers were found within the area.");
                return;
            }

            pMxdoc.ActivatedView.Refresh();

            MessageBox.Show("Tower ID: " + tower.ID + Environment.NewLine + "Type: " + tower.towerType + Environment.NewLine + "NetworkBand: " + tower.networkBand);

            //IPoint pPoint = (IPoint) pMxdoc.ActivatedView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);

            //MessageBox.Show("Mouse point is x: " + x + Environment.NewLine + "y: " + y + Environment.NewLine + "Mapx: " + pPoint.X + Environment.NewLine + "mapy: " + pPoint.Y);
            ///base.OnMouseUp(arg);
        }
示例#24
0
        protected override void OnMouseDown(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
        {
            if (arg.Button != System.Windows.Forms.MouseButtons.Left)
            {
                return;
            }
            try
            {
                var point = GetMapPoint(arg.X, arg.Y);

                var doc = AddIn.FromID <ArcMapAddinCoordinateConversion.DockableWindowCoordinateConversion.AddinImpl>(ThisAddIn.IDs.DockableWindowCoordinateConversion);

                if (doc != null && point != null)
                {
                    doc.GetMainVM().IsToolGenerated = true;
                    doc.SetInput(point.X, point.Y);
                }

                doc.GetMainVM().IsToolActive = false;
            }
            catch { }
        }
示例#25
0
        protected override void OnMouseDown(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
        {
            if (oCoords != null)
            {
                try
                {
                    oCoords.Close();
                    oCoords.Dispose();
                }
                catch
                {
                    string s = "continue on";
                    s += " -- ok, thanks";
                }
            }

            if ((arg.X > 0) && (arg.Y > 0))
            {
                oCoords = new fmCoords();
                oCoords.LoadValues(arg.X, arg.Y);
            }
        }
示例#26
0
        /// <summary>
        /// Start to track the rectangle when mouse down.
        /// </summary>
        /// <param name="arg"></param>
        protected override void OnMouseDown(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
        {
            base.OnMouseDown(arg);

            activeLayer = ArcMapApp.GetRasterLayer();

            if (activeLayer != null)
            {
                try
                {
                    Display.ClearElement(Editor.Selections.GetAllGraphicElements());
                    Editor.Selections.Clear();

                    // Define the selection symbol.
                    IRgbColor color = new RgbColorClass();
                    color.Red   = 255;
                    color.Green = 255;
                    color.Blue  = 255;

                    ISimpleLineSymbol lineSymbol = new SimpleLineSymbolClass();
                    lineSymbol.Width = 1;
                    lineSymbol.Color = (IColor)color;

                    IPoint startCoor = Editor.ScreenCoor2MapCoor(arg.X, arg.Y);
                    newEnvelopeFeedback         = new NewEnvelopeFeedbackClass();
                    newEnvelopeFeedback.Display = ArcMap.Document.ActiveView.ScreenDisplay;
                    newEnvelopeFeedback.Symbol  = (ISymbol)lineSymbol;
                    newEnvelopeFeedback.Start(startCoor);

                    // Get the maximum extent of the active layer.
                    IRasterProps rasterProps = (IRasterProps)activeLayer.Raster;
                    maxExtent = new Position(rasterProps.Width, rasterProps.Height);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(string.Format("Unfortunately, the application meets an error.\n\nSource: {0}\nSite: {1}\nMessage: {2}", ex.Source, ex.TargetSite, ex.Message), "Error");
                }
            }
        }
示例#27
0
        protected override void OnMouseDown(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs e)
        {
            IScreenDisplay screenDisplay = ArcMap.Document.ActiveView.ScreenDisplay;

            //创建选取多边形
            IRubberBand pRubberPolygon = new RubberPolygonClass();
            IPolygon    pPolygon       = pRubberPolygon.TrackNew(screenDisplay, null) as IPolygon;

            //构建选取环境;选取对象颜色为红色;选取方法为累加
            SelectionEnvironment se = new SelectionEnvironmentClass();

            se.DefaultColor      = getRGB(255, 0, 0);
            se.CombinationMethod = esriSelectionResultEnum.esriSelectionResultAdd;

            //选取要素
            IMap map = ArcMap.Document.FocusMap;

            map.SelectByShape(pPolygon, se, false);

            //刷新屏幕
            ArcMap.Document.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
        }
示例#28
0
        protected override void OnMouseDown(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
        {
            int    intx    = arg.X;
            int    inty    = arg.Y;
            IPoint pPoints = new PointClass();

            pPoints.PutCoords(intx, inty);



            IActiveView activeView = ArcMap.Document.ActiveView;

            pPoints = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(-100, 40);//x,y为屏幕坐标


            ESRI.ArcGIS.Display.IScreenDisplay         screenDisplay         = activeView.ScreenDisplay;
            ESRI.ArcGIS.Display.IDisplayTransformation displayTransformation = screenDisplay.DisplayTransformation;
            pPoints = displayTransformation.ToMapPoint(-120, 40);


            IMxDocument doc = ArcMap.Document;
            IMap        map = doc.FocusMap;

            pPoints = doc.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(-100, 40);

            AlterForm frm = null;

            if (frm == null || frm.IsDisposed)
            {
                frm = new AlterForm(intx, inty);
            }

            frm.Show();
            frm.TopMost = true;
            frm.Width   = 400;
            frm.Height  = 300;
            frm.Left    = 500;
        }
        protected override void OnMouseUp(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
        {
            base.OnMouseUp(arg);

            try
            {
                IPoint p = ArcMap.Document.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y);

                ITopologicalOperator to   = (ITopologicalOperator)p;
                IGeometry            poly = to.Buffer(20.0d);

                ISpatialFilter sp = new SpatialFilterClass();
                sp.Geometry      = poly;
                sp.GeometryField = Globals.CenterlineLayer.FeatureClass.ShapeFieldName;
                sp.SpatialRel    = esriSpatialRelEnum.esriSpatialRelIntersects;
                sp.SearchOrder   = esriSearchOrder.esriSearchOrderSpatial;

                ArcMap.Document.FocusMap.ClearSelection();

                IFeatureSelection fsel = (IFeatureSelection)Globals.CenterlineLayer;
                fsel.SelectFeatures(sp, esriSelectionResultEnum.esriSelectionResultNew, true);

                ISelectionSet selset = fsel.SelectionSet;
                if (selset.Count > 0)
                {
                    IEnumIDs pEnumIDs = selset.IDs;
                    pEnumIDs.Reset();
                    int oid = pEnumIDs.Next();

                    if (oid > -1)
                    {
                        Globals.SelectedCenterlineID = oid;
                        ArcMap.Document.ActiveView.Refresh();
                    }
                }
            }
            catch (Exception ex) { log.WriteError(ex, TAG, System.Security.Principal.WindowsIdentity.GetCurrent().Name, null); }
        }
        protected override void OnMouseDown(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
        {
            if (arg.Button != System.Windows.Forms.MouseButtons.Left)
            {
                return;
            }

            try
            {
                var             point      = GetMapPoint(arg.X, arg.Y);
                ISnappingResult snapResult = null;
                //Try to snap the current position
                snapResult = m_Snapper.Snap(point);
                m_SnappingFeedback.Update(null, 0);
                if (snapResult != null && snapResult.Location != null)
                {
                    point = snapResult.Location;
                }

                Mediator.NotifyColleagues(CoordinateConversionLibrary.Constants.NEW_MAP_POINT, point);
            }
            catch { }
        }