protected override void OnMouseDown(MouseEventArgs arg) { base.OnMouseDown(arg); if (Painter.ActiveLayer != null && arg.Button == MouseButtons.Left) { try { ValueSymbolForm valueSymbolForm = AddIn.FromID <ValueSymbolForm.AddinImpl>(ThisAddIn.IDs.ValueSymbolForm).UI; selectedValue = valueSymbolForm.SelectedValue; selectedColor = valueSymbolForm.SelectedColor; IPoint startCoor = Raster.ScreenCoor2MapCoor(arg.X, arg.Y); if (!isDrawing) { newLineFeedback = new NewLineFeedback(); newLineFeedback.Display = ArcMap.Document.ActiveView.ScreenDisplay; newLineFeedback.Symbol = (ISymbol)Display.GetDefaultSelectLineSymbol(); newLineFeedback.Start(startCoor); } newLineFeedback.AddPoint(startCoor); } 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"); } } }
protected override void OnMouseMove(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg) { base.OnMouseMove(arg); if (arg.Button == MouseButtons.Left && activeLayer != null) { IPoint moveCoor = Raster.ScreenCoor2MapCoor(arg.X, arg.Y); newEnvelopeFeedback.MoveTo(moveCoor); } }
protected override void OnMouseMove(MouseEventArgs arg) { base.OnMouseMove(arg); if (isDrawing && arg.Button == MouseButtons.Left && Editor.ActiveLayer != null) { IPoint moveCoor = Raster.ScreenCoor2MapCoor(arg.X, arg.Y); newLineFeedback.MoveTo(moveCoor); } }
/// <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 = Raster.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"); } } }
protected override void OnMouseDown(MouseEventArgs arg) { base.OnMouseDown(arg); if (Editor.ActiveLayer != null) { try { Display.ClearElement(Editor.Selections.GetAllGraphicElements()); Editor.Selections.Clear(); IPoint startCoor = Raster.ScreenCoor2MapCoor(arg.X, arg.Y); newEnvelopeFeedback = new NewEnvelopeFeedbackClass(); newEnvelopeFeedback.Display = ArcMap.Document.ActiveView.ScreenDisplay; newEnvelopeFeedback.Symbol = (ISymbol)Display.GetDefaultSelectLineSymbol(); newEnvelopeFeedback.Start(startCoor); } 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"); } } }
protected override void OnDoubleClick() { base.OnDoubleClick(); if (isDrawing && Editor.ActiveLayer != null) { IPoint startCoor = Raster.ScreenCoor2MapCoor(Control.MousePosition.X, Control.MousePosition.Y); newLineFeedback.AddPoint(startCoor); IPointCollection pointCollection = (IPointCollection)newLineFeedback.Stop(); List <Position> pointList = new List <Position>(); for (int i = 0; i < pointCollection.PointCount - 1; i++) { Position startPos = Raster.MapCoor2RasterCoor(pointCollection.get_Point(i), Painter.ActiveLayer); Position endPos = Raster.MapCoor2RasterCoor(pointCollection.get_Point(i + 1), Painter.ActiveLayer); pointList.AddRange(Display.GetPolyline(startPos, endPos, layerExetent)); } isDrawing = false; } }