Last active
August 29, 2015 14:16
-
-
Save alamsal/9fc1d54cdb3bf5650a99 to your computer and use it in GitHub Desktop.
Draw features in ArcMap using ArcGIS Addin tool (Arcobject's IRubberband Interface)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected override void OnMouseDown(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg) | |
{ | |
//create geometery | |
if (ArcMap.Document != null) | |
{ | |
IScreenDisplay screenDisplay = ArcMap.Document.ActiveView.ScreenDisplay; | |
// Constants | |
screenDisplay.StartDrawing(screenDisplay.hDC, (System.Int16)esriScreenCache.esriNoScreenCache); | |
// Explicit Cast | |
IRgbColor rgbColor = new RgbColorClass(); | |
rgbColor.Red = 255; | |
rgbColor.Transparency = 75; | |
IColor color = rgbColor; // Implicit Cast | |
ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass(); | |
simpleFillSymbol.Color = color; | |
//Draw geometry | |
ISymbol symbol = simpleFillSymbol as ISymbol; // Dynamic Cast | |
IRubberBand rubberBand = new RubberPolygonClass(); | |
IGeometry geometry = rubberBand.TrackNew(screenDisplay, symbol); | |
//check for valid geometery | |
if (geometry != null) | |
{ | |
screenDisplay.SetSymbol(symbol); | |
screenDisplay.DrawPolygon(geometry); | |
screenDisplay.FinishDrawing(); | |
//Open addattributes wpf form | |
AddAtrributesView addAtrributesView = new AddAtrributesView(geometry); | |
addAtrributesView.ShowInTaskbar = false; | |
addAtrributesView.ShowDialog(); | |
ArcMap.Document.ActivatedView.Refresh(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment