Version

FromTimeSlot Method

Returns a TimeRange instance whose start and end time is obtained from the specified TimeSlot, optionally adjusting the end time.
Syntax
'Declaration
 
Public Shared Function FromTimeSlot( _
   ByVal timeSlot As TimeSlot, _
   ByVal adjustEndTime As Boolean _
) As TimeRange
public static TimeRange FromTimeSlot( 
   TimeSlot timeSlot,
   bool adjustEndTime
)

Parameters

timeSlot
The TimeSlot instance from which the times are obtained.
adjustEndTime
Specifies whether the end time is adjusted by one minute later than the value obtained from the TimeSlot. For example, if the TimeSlot spans from 08:00 through 08:14, specifying true will result in a return value of "8AM - 8:15AM".
Remarks

The end time of a TimeSlot object returns a value that is one minute earlier than the start time of the next TimeSlot. This is to avoid intersection between adjacent TimeSlots. The adjustEndTime provides an easy way to create a TimeRange instance that can be used in a WorkingHours or TimeRangeAppearances collection.

Example
The following code sample demonstrates how to use the OwnerFromPoint and DateTimeFromPoint methods to hit test for an Owner, date, and TimeSlot in the UltraDayView control:

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

        Dim ownerAtPoint = dayView.OwnerFromPoint(e.Location)

        Dim timeSlot As TimeSlot = Nothing
        Dim dateAtPoint As Nullable(Of DateTime) = dayView.DateTimeFromPoint(e.Location, timeSlot)

        If Not ownerAtPoint Is Nothing AndAlso dateAtPoint.HasValue Then

            Dim timeRange As TimeRange = Nothing
            If Not timeSlot Is Nothing Then timeRange = Infragistics.Win.UltraWinSchedule.TimeRange.FromTimeSlot(timeSlot, False)
            Dim timeRangeString As String = String.Empty
            If Not timeRange Is Nothing Then timeRangeString = String.Format(", TimeSlot = {0}", timeRange.ToString(True))

            Console.WriteLine(String.Format("Owner = '{0}', Date = {1}{2}", ownerAtPoint.Key, dateAtPoint.Value.ToShortDateString(), timeRangeString))
        End If
    End Sub
using System.Collections.Generic;
using Infragistics.Win;
using Infragistics.Win.UltraWinSchedule;
using System.Diagnostics;

    this.dayView.MouseDown += new MouseEventHandler(dayView_MouseDown);

    void dayView_MouseDown(object sender, MouseEventArgs e)
    {
        UltraDayView dayView = sender as UltraDayView;

        Owner ownerAtPoint = dayView.OwnerFromPoint( e.Location );

        TimeSlot timeSlot = null;
        Nullable<DateTime> dateAtPoint = dayView.DateTimeFromPoint( e.Location, out timeSlot );

        if ( ownerAtPoint != null && dateAtPoint.HasValue )
        {
            TimeRange timeRange = timeSlot != null ? TimeRange.FromTimeSlot( timeSlot, false ) : null;
            string timeRangeString = timeSlot != null ? string.Format(", TimeSlot = {0}", timeRange.ToString(true)) : string.Empty;
            Console.WriteLine( string.Format( "Owner = '{0}', Date = {1}{2}", ownerAtPoint.Key, dateAtPoint.Value.ToShortDateString(), timeRangeString) );
        }
    }
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also