Occurs when the mouse is moved when this tool is active.
Namespace:
ESRI.ArcGIS.Desktop.AddInsAssembly: ESRI.ArcGIS.Desktop.Addins (in ESRI.ArcGIS.Desktop.Addins.dll) Version: 10.0.0.0 (10.0.0.0)
Syntax
C# |
---|
protected virtual void OnMouseMove( Tool..::.MouseEventArgs arg ) |
Visual Basic (Declaration) |
---|
Protected Overridable Sub OnMouseMove ( _ arg As Tool..::.MouseEventArgs _ ) |
Visual C++ |
---|
protected: virtual void OnMouseMove( Tool..::.MouseEventArgs^ arg ) |
Parameters
- arg
- Type: ESRI.ArcGIS.Desktop.AddIns..::.Tool..::.MouseEventArgs
The Tool..::.MouseEventArgs instance containing the event data.
Remarks
When creating a custom tool, write the code that performs the action when the mouse is moved when this tool is the active tool in the OnMouseMove method.
Examples
The code below shows the implementation of select features by line tool.
CopyC#
public class SelectByLineTool : ESRI.ArcGIS.Desktop.AddIns.Tool { bool m_isMouseDown = false; ESRI.ArcGIS.Display.INewLineFeedback m_lineFeedback; public SelectByLineTool() { } protected override void OnKeyDown(ESRI.ArcGIS.Desktop.AddIns.Tool.KeyEventArgs arg) { if (arg.ModifierKeys == (System.Windows.Forms.Keys.Shift & System.Windows.Forms.Keys.Control)) System.Windows.Forms.MessageBox.Show("Shift+Control"); } protected override void OnMouseDown(MouseEventArgs arg) { IMxDocument mxDoc = ArcMap.Document; IActiveView activeView = mxDoc.FocusMap as IActiveView; IPoint point = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y) as IPoint; if (m_lineFeedback == null) { m_lineFeedback = new ESRI.ArcGIS.Display.NewLineFeedback(); m_lineFeedback.Display = activeView.ScreenDisplay; m_lineFeedback.Start(point); } else { m_lineFeedback.AddPoint(point); } m_isMouseDown = true; } protected override void OnDoubleClick() { IMxDocument mxDoc = ArcMap.Document; IActiveView activeView = mxDoc.FocusMap as IActiveView; activeView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null); IPolyline polyline; if (m_lineFeedback != null) { polyline = m_lineFeedback.Stop(); if (polyline != null) mxDoc.FocusMap.SelectByShape(polyline, null, false); } activeView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null); m_lineFeedback = null; m_isMouseDown = false; } protected override void OnMouseMove(MouseEventArgs arg) { if (!m_isMouseDown) return; IMxDocument mxDoc = ArcMap.Document; IActiveView activeView = mxDoc.FocusMap as IActiveView; IPoint point = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y) as IPoint; m_lineFeedback.MoveTo(point); } protected override void OnUpdate() { this.Enabled = SelectionExtension.IsExtensionEnabled; } }
CopyVB.NET
Public Class SelectByLineTool Inherits ESRI.ArcGIS.Desktop.AddIns.Tool Private m_isMouseDown As Boolean = False Private m_lineFeedback As ESRI.ArcGIS.Display.INewLineFeedback Public Sub New() End Sub Protected Overloads Overrides Sub OnKeyDown(ByVal arg As ESRI.ArcGIS.Desktop.AddIns.Tool.KeyEventArgs) If arg.ModifierKeys = (System.Windows.Forms.Keys.Shift And System.Windows.Forms.Keys.Control) Then System.Windows.Forms.MessageBox.Show("Shift+Control") End If End Sub Protected Overloads Overrides Sub OnMouseDown(ByVal arg As MouseEventArgs) Dim mxDoc As IMxDocument = ArcMap.Document Dim activeView As IActiveView = TryCast(mxDoc.FocusMap, IActiveView) Dim point As IPoint = TryCast(activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y), IPoint) If m_lineFeedback Is Nothing Then m_lineFeedback = New ESRI.ArcGIS.Display.NewLineFeedback() m_lineFeedback.Display = activeView.ScreenDisplay m_lineFeedback.Start(point) Else m_lineFeedback.AddPoint(point) End If m_isMouseDown = True End Sub Protected Overloads Overrides Sub OnDoubleClick() Dim mxDoc As IMxDocument = ArcMap.Document Dim activeView As IActiveView = TryCast(mxDoc.FocusMap, IActiveView) activeView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, Nothing, Nothing) Dim polyline As IPolyline If m_lineFeedback IsNot Nothing Then polyline = m_lineFeedback.[Stop]() If polyline IsNot Nothing Then mxDoc.FocusMap.SelectByShape(polyline, Nothing, False) End If End If activeView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, Nothing, Nothing) m_lineFeedback = Nothing m_isMouseDown = False End Sub Protected Overloads Overrides Sub OnMouseMove(ByVal arg As MouseEventArgs) If Not m_isMouseDown Then Exit Sub End If Dim mxDoc As IMxDocument = ArcMap.Document Dim activeView As IActiveView = TryCast(mxDoc.FocusMap, IActiveView) Dim point As IPoint = TryCast(activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y), IPoint) m_lineFeedback.MoveTo(point) End Sub Protected Overloads Overrides Sub OnUpdate() Me.Enabled = SelectionExtension.IsExtensionEnabled End Sub End Class