SchedulerHitInfo.HitTest Property
Gets a value identifying the type of the visual element located under the test point.
Namespace: DevExpress.XtraScheduler.Drawing
Assembly: DevExpress.XtraScheduler.v24.2.dll
Declaration
Property Value
Type | Description |
---|---|
SchedulerHitTest | A SchedulerHitTest enumeration value which identifies the type of the visual element that contains the test point. |
Available values:
Name | Description |
---|---|
None | The test point does not belong to any visual element or is outside the scheduler. |
Cell | The test point belongs to a time cell. |
ResourceHeader | The test point belongs to a resource header. |
DayHeader | The test point belongs to a day header. |
AllDayArea | The test point belongs to the all-day area. |
AppointmentResizingLeftEdge | The test point belongs to the left resizable edge of an appointment. |
AppointmentResizingRightEdge | The test point belongs to the right resizable edge of an appointment. |
AppointmentResizingTopEdge | The test point belongs to the top resizable edge of an appointment. |
AppointmentResizingBottomEdge | The test point belongs to the bottom resizable edge of an appointment. |
AppointmentMoveEdge | The test point belongs to the movable edge of an appointment. |
AppointmentContent | The test point belongs to contents of an appointment. |
MoreButton | The test point belongs to a MoreButton. |
DayOfWeekHeader | The test point belongs to a day of week header. |
GroupSeparator | The test point belongs to the group separator, which separates one group from another. |
UpperLeftCorner | The test point belongs to the top-left corner in the Day View. |
DayViewColumn | The test point belongs to a column in a Day View. |
SingleWeek | The test point belongs to a single week. |
Timeline | The test point belongs to the timeline bar. |
SelectionBar | The test point belongs to the selection bar in the Timeline View. |
SelectionBarCell | The test point belongs to a single cell of the selection bar in the Timeline View. |
TimeScaleHeader | The test point belongs to the time scale header in the Timeline View. |
Ruler | The test point belongs to a time ruler. |
NavigationButton | The test point belongs to the navigation button. |
ScrollMoreButton | The test point belongs to a Scroll MoreButton. |
AppointmentDependency | The test point belongs to the Dependency |
Undefined | An object under the test point cannot be determined. |
TimeIndicator | The test point belongs to the Time Indicator element. |
ContextButtons | Reserved for future use. |
GridElement | A test point belongs to the element of the Agenda view grid. |
HeaderTab | |
TabArea | |
HeaderButton | |
MonthHeader | |
Hyperlink |
Example
The following examples demonstrate how to handle the SchedulerControl.MouseMove event and calculate the hit information for the point which the mouse pointer is currently hovering over. The information on the element located under the mouse pointer is shown within the form caption.
The second parameter of the SchedulerViewInfoBase.CalcHitInfo method enables you to specify whether you need information on an appointment being clicked, or on a scheduler element located underneath.
When you drag an appointment over the scheduler, you can use the SchedulerViewInfoBase.CalcHitInfo method to determine the scheduler area below. If you drag appointment to the All-Day Area, you can cancel the action.
using DevExpress.XtraScheduler;
using DevExpress.XtraScheduler.Drawing;
using System;
using System.Drawing;
using System.Windows.Forms;
private void schedulerControl1_MouseMove(object sender, MouseEventArgs e)
{
SchedulerControl scheduler = sender as SchedulerControl;
if (scheduler == null) return;
Point pos = new Point(e.X, e.Y);
SchedulerViewInfoBase viewInfo = schedulerControl1.ActiveView.ViewInfo;
SchedulerHitInfo hitInfo = viewInfo.CalcHitInfo(pos, false);
if (hitInfo.HitTest == SchedulerHitTest.AppointmentContent)
{
Appointment apt = ((AppointmentViewInfo)hitInfo.ViewInfo).Appointment;
Text = apt.Subject;
}
else if (scheduler.ActiveView.Type == SchedulerViewType.Day && hitInfo.HitTest == SchedulerHitTest.Cell)
{
int diff = pos.Y - hitInfo.ViewInfo.Bounds.Y;
long ticksPerPixel = hitInfo.ViewInfo.Interval.Duration.Ticks /
hitInfo.ViewInfo.Bounds.Height;
long ticksCount = ticksPerPixel * diff;
DateTime actualTime = hitInfo.ViewInfo.Interval.Start.AddTicks(ticksCount);
Text = actualTime.ToString();
}
else if (hitInfo.HitTest == SchedulerHitTest.None)
{
Text = Application.ProductName;
}
else Text = string.Empty;
}
private void schedulerControl1_DragOver(object sender, DragEventArgs e)
{
SchedulerControl scheduler = sender as SchedulerControl;
if (scheduler == null) return;
Point p = scheduler.PointToClient(new Point(e.X, e.Y));
SchedulerHitInfo info = scheduler.DayView.ViewInfo.CalcHitInfo(p, true);
if (info.HitTest == SchedulerHitTest.AllDayArea)
e.Effect = DragDropEffects.None;
}
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the HitTest property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.