Imports System.Collections.Generic
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinSchedule
Imports System.Diagnostics
Public Sub ShowClocks(ByVal control As UltraTimelineView)
' Don't show any additional intervals
control.AdditionalIntervals.Clear()
' Create a new TimeInterval with 15-minute intervals
' and assign it to the PrimaryInterval property.
Dim primaryInterval As New TimeInterval(15, TimeIntervalUnits.Minutes)
control.PrimaryInterval = primaryInterval
' Set the image alignment to middle/center
control.ColumnHeaderAppearance.ImageHAlign = HAlign.Center
control.ColumnHeaderAppearance.ImageVAlign = VAlign.Middle
' Set ColumnHeaderImageSize to a size that is large
' enough to display an analog clock image set the
' ColumnWidth property to a slightly larger size.
control.ColumnHeaderImageSize = ClockSize
control.ColumnWidth = ClockSize.Width + Padding
' Handle the ColumnHeaderInitializing event so we can
' show an image on the header instead of the text, and
' the ColumnHeaderToolTipDisplaying event so we can force
' a tooltip to be displayed.
AddHandler control.ColumnHeaderInitializing, AddressOf Me.OnColumnHeaderInitializing
AddHandler control.ColumnHeaderToolTipDisplaying, AddressOf Me.OnColumnHeaderToolTipDisplaying
End Sub
Private Sub OnColumnHeaderToolTipDisplaying(ByVal sender As Object, ByVal e As ColumnHeaderToolTipDisplayingEventArgs)
' If this is a primary interval header, show the start time
' in a tooltip, since there is no text on the header.
If Not e.HeaderElement Is Nothing AndAlso e.HeaderElement.DateTimeInterval.IsPrimaryInterval Then
Dim toolTipInfo As ToolTipInfo = e.ToolTipInfo
toolTipInfo.ToolTipText = e.HeaderElement.DateTimeRange.StartDateTime.ToString(TimeInterval.ShortTimePattern)
e.ToolTipInfo = toolTipInfo
End If
End Sub
Private Sub OnColumnHeaderInitializing(ByVal sender As Object, ByVal e As ColumnHeaderInitializingEventArgs)
If (e.DateTimeInterval.IsPrimaryInterval) Then
' Create an image of an analog clock, depicting the
' start time for this header, and assign it to the
' Image property of the e.AppearanceData
Dim time As TimeSpan = e.DateTimeRange.StartDateTime.TimeOfDay
Dim bmp As Bitmap = ClockImage.GetImage(time, ClockSize, Color.Black, Color.White)
Dim appData As AppearanceData = New AppearanceData()
appData.Image = bmp
e.AppearanceData = appData
' Assign a space character to the text, so that
' nothing appears, but a tooltip can still be displayed
e.Text = " "
End If
End Sub