Back to Devexpress

Measurements.BeforeMeasurement Event

wpf-devexpress-dot-xpf-dot-map-dot-measurements-8215306f.md

latest3.4 KB
Original Source

Measurements.BeforeMeasurement Event

Occurs when a user starts ruler creation.

Namespace : DevExpress.Xpf.Map

Assembly : DevExpress.Xpf.Map.v25.2.dll

NuGet Package : DevExpress.Wpf.Map

Declaration

csharp
public event BeforeMeasurementEventHandler BeforeMeasurement
vb
Public Event BeforeMeasurement As BeforeMeasurementEventHandler

Event Data

The BeforeMeasurement event's data class is BeforeMeasurementEventArgs. The following properties provide information specific to this event:

PropertyDescription
CancelGets or sets a value indicating whether the event should be canceled. Inherited from CancelEventArgs.
RulerAppearanceSpecifies ruler appearance settings.
RulerTypeReturns the type of the new ruler.
StartPointReturns coordinates of the ruler’s start point.

Remarks

The Measurements object raises the BeforeMeasurement event after a user sets the ruler’s first point. To cancel ruler creation, use the e.Cancel property. The e.StartPoint property returns the ruler’s first point. To determine the type of ruler that a user wishes to add, use the e.RulerType property.

The example below cancels ruler creation if a ruler starts inside an ellipse. The MapControl.CalcHitInfo method returns information on the map elements located at the ruler’s first point. The e.StartPoint property returns this point.

csharp
private void Measurements_BeforeMeasurement(object sender, BeforeMeasurementEventArgs e) {

 // Convert coordinates to the screen point.
 Point startPoint = mapControl1.CoordPointToScreenPoint(e.StartPoint);

 MapHitInfo info = mapControl1.CalcHitInfo(startPoint);
 if (info.InMapEllipse) {
   e.Cancel = true;
 }
}
vb
Private Sub Measurements_BeforeMeasurement(ByVal sender As Object, ByVal e As BeforeMeasurementEventArgs)

   ' Convert coordinates to the screen point.
   Dim startPoint As Point = mapControl1.CoordPointToScreenPoint(e.StartPoint)
   Dim info As MapHitInfo = mapControl1.CalcHitInfo(startPoint)

   If info.InMapEllipse Then
       e.Cancel = True
   End If
End Sub

See Also

AfterMeasurement

Measurements Class

Measurements Members

DevExpress.Xpf.Map Namespace