Is there button in ArcObjects "draw rectangle" such as in openlayers?
Update
Well, I use this code for drawing:
ESRI.ArcGIS.Display.IScreenDisplay screenDisplay = Map1.ActiveView.ScreenDisplay;
screenDisplay.StartDrawing(screenDisplay.hDC, (System.Int16)
ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache);
ESRI.ArcGIS.Display.IRgbColor rgbColor = new ESRI.ArcGIS.Display.RgbColor();
rgbColor.Red = 255;
ESRI.ArcGIS.Display.IColor color = rgbColor;
ESRI.ArcGIS.Display.ISimpleFillSymbol simpleFillSymbol = new
ESRI.ArcGIS.Display.SimpleFillSymbol();
simpleFillSymbol.Color = color;
ESRI.ArcGIS.Display.ISymbol symbol = simpleFillSymbol as
ESRI.ArcGIS.Display.ISymbol;
ESRI.ArcGIS.Display.IRubberBand rubberBand = new
ESRI.ArcGIS.Display.RubberEnvelope();
ESRI.ArcGIS.Geometry.IGeometry geometry = rubberBand.TrackNew(screenDisplay,
symbol);
screenDisplay.SetSymbol(symbol);
screenDisplay.DrawRectangle(geometry as ESRI.ArcGIS.Geometry.IEnvelope);
screenDisplay.FinishDrawing();
...
ArcGisToolbar.CurrentTool.Deactivate();
ArcGisToolbar.CurrentTool = null;
ICommand command = this.ArcGisToolbar.CommandPool.get_Command(3); // button "pan"
Map1.CurrentTool = (ITool)command;
But there is a problem. When I activate this instrument (button "select") again, I already start selecting the area (from the point, where I begin drawing the polygon)
Best Answer
First of all I would use:
instead of using the RubberEnvelope method
then later do:
instead of screenDisplay.DrawRectangle(...)
see if that gets you further.
When getting Feedback for the rectangle via mouse Events I'd do the following: In OnMouseDown use:
assign the envFb to a IDisplayfeedback df
In OnMouseMove do:
In OnMouseUp do:
pt is always the position of your mouse cursor.