Imports System.Collections.Generic
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinSchedule
Imports System.Diagnostics
AddHandler Me.dayView.MouseDown, AddressOf dayView_MouseDown
Private Sub dayView_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs)
Dim dayView As UltraDayView = sender
' Use the OwnerFromPoint method to hit test for an Owner
Dim ownerAtPoint As Owner = dayView.OwnerFromPoint(e.Location)
' Use the DateTimeFromPoint method to hit test for the date and TimeSlot
Dim timeSlot As TimeSlot = Nothing
Dim dateAtPoint As Nullable(Of DateTime) = dayView.DateTimeFromPoint(e.Location, timeSlot)
Dim isInWorkingHours As Boolean = False
If Not timeSlot Is Nothing Then
If Not ownerAtPoint Is Nothing Then
isInWorkingHours = ownerAtPoint.IsInWorkingHours(timeSlot, dateAtPoint.Value)
Else
' Create a TimeRange from the WorkDayStartTime and WorkDayEndTime, and then
' use it to determine whether the TimeSlot is within that range
Dim dayOfWeek As DayOfWeek = dayView.CalendarInfo.DaysOfWeek(dateAtPoint.Value.DayOfWeek)
Dim TimeRange As TimeRange = New TimeRange(dayOfWeek.WorkDayStartTime.TimeOfDay, dayOfWeek.WorkDayEndTime.TimeOfDay)
Dim intersects As Boolean = TimeRange.IsInRange(timeSlot)
isInWorkingHours = dayOfWeek.IsWorkDay AndAlso intersects
End If
Dim timeSlotRange As TimeRange = TimeRange.FromTimeSlot(timeSlot, False)
Dim notString As String = IIf(isInWorkingHours = False, "not ", String.Empty)
Console.WriteLine(String.Format("The {0} time range is {1}within the working hour range.", timeSlotRange.ToString(True), notString))
End If
End Sub