Back to Devexpress

SchedulerControl.CalcHitInfo(Point) Method

wpf-devexpress-dot-xpf-dot-scheduling-dot-schedulercontrol-dot-calchitinfo-x28-system-dot-windows-dot-point-x29.md

latest5.6 KB
Original Source

SchedulerControl.CalcHitInfo(Point) Method

Returns information on the scheduler element located at the specified point.

Namespace : DevExpress.Xpf.Scheduling

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

NuGet Package : DevExpress.Wpf.Scheduling

Declaration

csharp
public ISchedulerHitInfo CalcHitInfo(
    Point hitPoint
)
vb
Public Function CalcHitInfo(
    hitPoint As Point
) As ISchedulerHitInfo

Parameters

NameTypeDescription
hitPointPoint

A ISchedulerHitInfo object contains information about a Scheduler element located at the test point.

|

Returns

TypeDescription
ISchedulerHitInfo

A Point structure which specifies the test point coordinates relative to the top left corner.

|

Example

The following code snippet shows how to use the SchedulerControl.CalcHitInfo method in the Scheduler.MouseMove event handler to obtain the hit information for the scheduler element over which the mouse pointer is hovering. The information on the element located under the mouse pointer is shown in the top panel.

csharp
private void SchedulerControl_MouseMove(object sender, MouseEventArgs e) {
    // Obtain hit information under the test point.
    Point position = e.GetPosition(schedulerControl1);
    ISchedulerHitInfo hitInfo = schedulerControl1.CalcHitInfo(position);
    if (hitInfo != null) {
        this.hitResultsHeader.Text = "Hit Test Results";
        StringBuilder builder = new StringBuilder();
        builder.AppendLine(Enum.GetName(typeof(SchedulerHitTestType), hitInfo.HitTestType));
        switch (hitInfo.HitTestType) {
            case SchedulerHitTestType.Appointment:
                AppointmentViewModel appViewModel = hitInfo.ViewModel as AppointmentViewModel;
                if (appViewModel != null) {
                    builder.AppendLine("Subject: " + appViewModel.Appointment.Subject);
                    builder.AppendLine("Start: " + appViewModel.Appointment.Start.ToString());
                    builder.AppendLine("End: " + appViewModel.Appointment.End.ToString());
                }
                break;
            case SchedulerHitTestType.Cell:
                builder.AppendLine("Interval: " + hitInfo.ViewModel.Interval.ToString());
                builder.AppendLine("Selected: " + hitInfo.ViewModel.IsSelected.ToString());
                break;
            case SchedulerHitTestType.Ruler:
               TimeRulerCellViewModel rulerViewModel = hitInfo.ViewModel as TimeRulerCellViewModel;
                if (rulerViewModel != null) {
                    builder.AppendLine("Time: " + rulerViewModel.Time.ToString());
                    builder.AppendLine("Time Scale: " + rulerViewModel.TimeScale.ToString());
                }
                break;
        }
        this.hitResultsText.Text = builder.ToString();
    }
    else {
        ClearResults();
    }
}
vb
Private Sub SchedulerControl_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs)
    ' Obtain hit information under the test point.
    Dim position As Point = e.GetPosition(schedulerControl1)
    Dim hitInfo As ISchedulerHitInfo = schedulerControl1.CalcHitInfo(position)
    If hitInfo IsNot Nothing Then
        Me.hitResultsHeader.Text = "Hit Test Results"
        Dim builder As New StringBuilder()
        builder.AppendLine(System.Enum.GetName(GetType(SchedulerHitTestType), hitInfo.HitTestType))
        Select Case hitInfo.HitTestType
            Case SchedulerHitTestType.Appointment
                Dim appViewModel As AppointmentViewModel = TryCast(hitInfo.ViewModel, AppointmentViewModel)
                If appViewModel IsNot Nothing Then
                    builder.AppendLine("Subject: " & appViewModel.Appointment.Subject)
                    builder.AppendLine("Start: " & appViewModel.Appointment.Start.ToString())
                    builder.AppendLine("End: " & appViewModel.Appointment.End.ToString())
                End If
            Case SchedulerHitTestType.Cell
                builder.AppendLine("Interval: " & hitInfo.ViewModel.Interval.ToString())
                builder.AppendLine("Selected: " & hitInfo.ViewModel.IsSelected.ToString())
            Case SchedulerHitTestType.Ruler
               Dim rulerViewModel As TimeRulerCellViewModel = TryCast(hitInfo.ViewModel, TimeRulerCellViewModel)
                If rulerViewModel IsNot Nothing Then
                    builder.AppendLine("Time: " & rulerViewModel.Time.ToString())
                    builder.AppendLine("Time Scale: " & rulerViewModel.TimeScale.ToString())
                End If
        End Select
        Me.hitResultsText.Text = builder.ToString()
    Else
        ClearResults()
    End If
End Sub

See Also

SchedulerControl Class

SchedulerControl Members

DevExpress.Xpf.Scheduling Namespace