Example #1
0
        /// <summary>
        /// Returns a polygon with a centroid at the given x and y exactly 1 acre in size
        /// </summary>
        /// <param name="X"></param>
        /// <param name="Y"></param>
        /// <returns></returns>
        private IPolygon CreateHomesitePolygon(int X, int Y)
        {
            try
            {
                ESRI.ArcGIS.Display.IScreenDisplay screenDisplay = (_application.Document as IMxDocument).ActiveView.ScreenDisplay;
                ESRI.ArcGIS.Geometry.IPoint        point         = screenDisplay.DisplayTransformation.ToMapPoint(X, Y);
                ITopologicalOperator topologicalOperator         = point as ITopologicalOperator;
                IGeometry            geometry = topologicalOperator.Buffer(104.3551628); // radius of circle --> envelope is 1 square acre :)
                IPolygon             polygon  = geometry as IPolygon;

                // Might be able to skip this
                ISegmentCollection segmentcollection = polygon as ISegmentCollection;
                segmentcollection.SetRectangle(polygon.Envelope);

                return(segmentcollection as IPolygon);
            } catch (Exception ex)
            {
                RS_Tools.Utilities.Utilities_MessageBox.ErrorBox(ex.Message, MB_TITLE);
            }
            return(null);
        }
Example #2
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;
        }
        /// <summary>
        /// Flashes the given feature on the hook's active view
        /// </summary>
        /// <param name="msPause">Pause between flashes</param>
        /// <param name="times">Number of times to flash</param>
        /// <param name="feature">Feature to flash</param>
        public void FlashFeature(ESRI.ArcGIS.Geodatabase.IFeature feature, int times, int msPause)
        {
            if (null == feature)
            {
                throw new ArgumentNullException("feature");
            }

            if (null != this.ActiveView)
            {
                ESRI.ArcGIS.Display.IScreenDisplay screenDisplay = this.ActiveView.ScreenDisplay;
                if (null != screenDisplay)
                {
                    ESRI.ArcGIS.Carto.IIdentifyObj obj = new FeatureIdentifyObjectClass();
                    ((ESRI.ArcGIS.Carto.IFeatureIdentifyObj)obj).Feature = feature;

                    for (int i = 0; i < times; i++)
                    {
                        obj.Flash(screenDisplay);
                        System.Threading.Thread.Sleep(msPause);
                    }
                }
            }
        }