Beispiel #1
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add LHSBCrePoint.OnMouseDown implementation
            IRubberBand ipRubber = new RubberPointClass();
            IGeometry   ipGeo    = ipRubber.TrackNew(m_hookHelper.ActiveView.ScreenDisplay,
                                                     null);
            IFeatureLayer layer = null;

            for (int i = 0; i < m_hookHelper.FocusMap.LayerCount; i++)
            {
                layer = (IFeatureLayer)m_hookHelper.FocusMap.get_Layer(i);
                if (layer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPoint)
                {
                    break;
                }
                layer = null;
            }
            if (layer != null)
            {
                IFeature feature = layer.FeatureClass.CreateFeature();
                feature.Shape = ipGeo;
                feature.Store();
                m_hookHelper.ActiveView.Refresh();
            }
        }
Beispiel #2
0
        public override void OnClick()
        {
            IRubberBand ipRubberRec = new RubberPointClass();
            IPoint      po          = ipRubberRec.TrackNew(m_hookHelper.ActiveView.ScreenDisplay, null) as IPoint;
            object      lidan       = null;

            GetPixValue(selectLayer as IRasterLayer, po, out lidan);

            MessageBox.Show("¤ы╦пох:" + lidan.ToString());
        }
        /// <summary>
        /// 绘制点要素
        /// </summary>
        /// <param name="view">活动视图</param>
        /// <param name="symbol">点样式SimpleSymbolHelper</param>
        /// <returns></returns>
        public static IGeometry DreawPoint(IActiveView view, ISymbol symbol)
        {
            //初始rubberband
            IRubberBand band   = new RubberPointClass();
            IGeometry   newGeo = band.TrackNew(view.ScreenDisplay, symbol);

            if (newGeo == null)
            {
                return(null);
            }
            return(newGeo);
        }
        protected override void OnMouseDown(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
        {
            if (ArcMap.Document.SelectedLayer == null)
            {
                System.Windows.Forms.MessageBox.Show("Select a layer before continuing.");
                return;
            }

            IFeatureLayer ifl_active = (IFeatureLayer)ArcMap.Document.SelectedLayer;

            try
            {
                IRgbColor rgbColor = new RgbColorClass();
                rgbColor.Red = 255;

                IColor color = rgbColor; // Implicit Cast
                ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass();
                simpleMarkerSymbol.Color = rgbColor;
                simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSX;

                ISymbol symbol = simpleMarkerSymbol as ISymbol; // Dynamic Cast

                IScreenDisplay screenDisplay = ArcMap.Document.ActiveView.ScreenDisplay;
                IRubberBand2 rubberBand = new RubberPointClass();

                IGeometry geometry = rubberBand.TrackNew(screenDisplay, symbol);

                if (geometry == null) return;

                try
                {
                    screenDisplay.SetSymbol(symbol);
                    screenDisplay.DrawPoint(geometry);
                    screenDisplay.FinishDrawing();
                }
                catch (Exception iii)
                {
                }

                IGeoDataset igd_dest = (IGeoDataset)ifl_active.FeatureClass;

                geometry.SpatialReference = ArcMap.Document.FocusMap.SpatialReference;

                if (igd_dest.SpatialReference.Name != geometry.SpatialReference.Name)
                {
                    geometry.Project(igd_dest.SpatialReference);
                }

                ITopologicalOperator ito = (ITopologicalOperator)geometry;

                IMap mp = ArcMap.Document.FocusMap;
                ISpatialReference isr = igd_dest.SpatialReference;

                IProjectedCoordinateSystem ipcs = (IProjectedCoordinateSystem)isr;
                ILinearUnit ilu = ipcs.CoordinateUnit;

                string input = Microsoft.VisualBasic.Interaction.InputBox("Enter radius to use (in the units of the target NWI layer: " + ((ilu.Name.IndexOf("Foot", StringComparison.CurrentCultureIgnoreCase) > -1) ? "feet" : ilu.Name.ToLower() + "s") + ") ", "Radius for Buffered Clip", "500");
                double distance = double.Parse(input);

                IGeometry circle = ito.Buffer(distance);

                DoClip(ArcMap.Document.ActiveView, ifl_active, circle);
            }
            catch (Exception e)
            {
                //System.Windows.Forms.MessageBox.Show("Exception: " + e.Message + "\n\n" + e.StackTrace );
                SelectArrowToolOnToolbar();
            }
            finally
            {
                //System.Windows.Forms.MessageBox.Show("Return");
            }
        }