Imports Infragistics.Win
Imports Infragistics.Win.UltraWinSchedule
Imports System.IO
Imports System.Globalization
Private Sub GetDayInfo()
Dim info As String = String.Empty
' 現在の日付の Day オブジェクトを作成します
Dim day As Infragistics.Win.UltraWinSchedule.Day = Me.ultraCalendarInfo1.GetDay(DateTime.Today, True)
' 現在の日に予定、休日、メモを追加します
Me.ultraCalendarInfo1.Appointments.Add(day.Date, "Today's Appointment #1")
Me.ultraCalendarInfo1.Appointments.Add(day.Date, "Today's Appointment #2")
Me.ultraCalendarInfo1.Appointments.Add(day.Date, "Today's Appointment #3")
Me.ultraCalendarInfo1.Holidays.Add(day.Date, "Today's Holiday")
Me.ultraCalendarInfo1.Notes.Add(day.Date, "Today's Note #1")
Me.ultraCalendarInfo1.Notes.Add(day.Date, "Today's Note #2")
' 日の日付を取得します
info += "The date of the day is " + day.Date.ToLongDateString() + "." + vbCrLf
' 日の曜日を取得します
info += "The day falls on a " + day.DayOfWeek.DayOfTheWeek.ToString() + "." + vbCrLf
' 日の週番号を取得します
info += "The day falls in week number " + day.Week.WeekNumber.ToString() + " of the year." + vbCrLf
' 月の日数を取得し、月の名前を取得します
Dim monthName As String = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.MonthNames(day.Month.MonthNumber - 1)
info += "The day is day number " + day.DayNumber.ToString()
info += " in the month of " + monthName + "." + vbCrLf
' 月の日の位置を取得します
Dim daysInMonth As Integer = day.Month.DaysInMonth
Dim elapsed As Double = (day.DayNumber) / (daysInMonth)
elapsed *= 100
info += "The day is approximately " + elapsed.ToString("n") + "% of the way into the month." + vbCrLf
' 年数を取得します
info += "The day is in the year " + day.Month.Year.YearNumber.ToString() + "." + vbCrLf
' その年の日の位置を取得します
Dim daysInYear As Integer = 365
If day.Month.Year.IsLeapYear Then daysInYear = 366
elapsed = (day.DayOfYear) / (daysInYear)
elapsed *= 100
info += "The day is approximately " + elapsed.ToString("n") + "% of the way into the year." + vbCrLf
' アクティビティがある場合、日の Enabled プロパティは True または False であるかどうかを表示す
If (day.HasActivity) Then
Dim activity As String = String.Empty
If (day.Appointments.Count > 0) Then
activity += day.Appointments.Count.ToString() + " Appointment(s)" + vbCrLf
End If
If (day.Holidays.Count > 0) Then
activity += day.Holidays.Count.ToString() + " Holiday(s)" + vbCrLf
End If
If (day.Notes.Count > 0) Then
activity += day.Notes.Count.ToString() + " Note(s)" + vbCrLf
End If
info += "There is activity for the day :" + vbCrLf + vbCrLf
info += activity + vbCrLf
End If
' 各タイプの数を表示します
If (day.Enabled) Then
info += "The day's Enabled property is set to true." + vbCrLf
Else
info += "The day's Enabled property is set to false." + vbCrLf
End If
' 日が結果的に有効化されたかどうかを表示します
'
' EnabledResolved プロパティは、日の Enabled プロパティだけでなく
' その日を含むオブジェクト (Week、Month、Year など) の
' Enabled プロパティによっても
' 影響されます
If (day.EnabledResolved) Then
info += "The day is enabled." + vbCrLf
Else
info += "The day is disabled." + vbCrLf
End If
' 日が ActiveDay であるかどうかを表示します
If Not Me.ultraCalendarInfo1.ActiveDay Is Nothing And Me.ultraCalendarInfo1.ActiveDay Is day Then
info += "The day is the ActiveDay." + vbCrLf
End If
' 日が選択されたかどうかを表示します
If (day.Selected) Then
info += "The day is selected." + vbCrLf
End If
' 日がアクティブ化されているかを表示します
If (day.Activated) Then
info += "The day has been activated." + vbCrLf
' 情報を表示します
MessageBox.Show(info, "GetDayInfo")
End If
End Sub