'宣言 Public ReadOnly Property DayOfTheWeek As DayOfWeekEnum
public DayOfWeekEnum DayOfTheWeek {get;}
Imports Infragistics.Win Imports Infragistics.Win.UltraWinSchedule Imports System.IO Imports System.Globalization Private Sub SetupDayOfWeek() ' Get the DayOfWeek object corresponding to the current day ' of the week. Note that we can index into the component's DaysOfWeek ' collection using the DateTime structure's DayOfWeek property. Dim dayOfWeek As Infragistics.Win.UltraWinSchedule.DayOfWeek dayOfWeek = Me.ultraCalendarInfo1.DaysOfWeek(DateTime.Today.DayOfWeek) ' Get the current culture's long name for the day of the week Dim longName As String = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(DateTime.Today.DayOfWeek) ' Get the current culture's short name for the day of the week Dim shortName As String = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedDayName(DateTime.Today.DayOfWeek) ' Set the LongDescription property to the current culture's long name for the ' day of the week, and append an asterisk to it dayOfWeek.LongDescription = longName + "*" ' Set the LongDescription property to the current culture's short name for the ' day of the week, and append an asterisk to it dayOfWeek.ShortDescription = shortName + "*" ' If the current day of the week is a work day, set the WorkDayStartTime ' to 10AM, and the WorkDayEndTime to 6PM If (dayOfWeek.IsWorkDay) Then dayOfWeek.WorkDayStartTime = DateTime.Today.Date.AddHours(10.0F) dayOfWeek.WorkDayEndTime = DateTime.Today.Date.AddHours(18.0F) End If ' Iterate the component's DaysOfWeek collection and display information ' on each day of the week and prompt the end user to make sure they ' want to make the changes Dim info As String = String.Empty Dim dow As Infragistics.Win.UltraWinSchedule.DayOfWeek For Each dow In Me.ultraCalendarInfo1.DaysOfWeek info += "DaysOfWeek(" + dow.DayOfTheWeek.ToString() + "):" + vbCrLf ' Use the LongDescriptionResolved property, which will return the value ' of the LongDescription property if it was explicitly set otherwise it will ' return the current culture's name for the day of the week. info += Chr(9) + "The display name is " + dow.LongDescriptionResolved + vbCrLf ' Use the ShortDescriptionResolved property, which will return the value ' of the ShortDescription property if it was explicitly set otherwise it will ' return the current culture's abbreviated name for the day of the week. info += Chr(9) + "The abbreviated display name is " + dow.ShortDescriptionResolved + vbCrLf ' Display the WorkDayStartTime and WorkDayEndTime info += Chr(9) + "The work day begins at " + dow.WorkDayStartTime.ToLongTimeString() info += " and ends at " + dow.WorkDayEndTime.ToLongTimeString() + vbCrLf ' Display whether the day of the week is enabled If (dow.Enabled) Then info += Chr(9) + "The day of the week is enabled." + vbCrLf Else info += Chr(9) + "The day of the week is disabled." + vbCrLf End If ' Display whether the day of the week is visible If (dow.Visible) Then info += Chr(9) + "The day of the week is visible." + vbCrLf Else info += Chr(9) + "The day of the week is hidden." + vbCrLf End If info += vbCrLf Next ' Display the information in a message box, and prompt the user to see ' if they want to make the changes Dim result As DialogResult info += "Save changes?" + vbCrLf result = MessageBox.Show(info, "SetupDayOfWeek", MessageBoxButtons.YesNo) ' Reverse the changes by calling the appropriate Reset methods If (result = DialogResult.No) Then dayOfWeek.ResetLongDescription() dayOfWeek.ResetShortDescription() If (dayOfWeek.IsWorkDay) Then dayOfWeek.ResetWorkDayStartTime() dayOfWeek.ResetWorkDayEndTime() End If End If End Sub
using Infragistics.Win; using Infragistics.Win.UltraWinSchedule; using System.IO; using System.Globalization; private void SetupDayOfWeek() { // Get the DayOfWeek object corresponding to the current day // of the week. Note that we can index into the component's DaysOfWeek // collection using the DateTime structure's DayOfWeek property. Infragistics.Win.UltraWinSchedule.DayOfWeek dayOfWeek = this.ultraCalendarInfo1.DaysOfWeek[ DateTime.Today.DayOfWeek ]; // Get the current culture's long name for the day of the week string longName = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetDayName( DateTime.Today.DayOfWeek ); // Get the current culture's short name for the day of the week string shortName = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedDayName( DateTime.Today.DayOfWeek ); // Set the LongDescription property to the current culture's long name for the // day of the week, and append an asterisk to it dayOfWeek.LongDescription = longName + "*"; // Set the LongDescription property to the current culture's short name for the // day of the week, and append an asterisk to it dayOfWeek.ShortDescription = shortName + "*"; // If the current day of the week is a work day, set the WorkDayStartTime // to 10AM, and the WorkDayEndTime to 6PM if ( dayOfWeek.IsWorkDay ) { dayOfWeek.WorkDayStartTime = DateTime.Today.Date.AddHours( 10.0F ); dayOfWeek.WorkDayEndTime = DateTime.Today.Date.AddHours( 18.0F ); } // Iterate the component's DaysOfWeek collection and display information // on each day of the week and prompt the end user to make sure they // want to make the changes string info = string.Empty; foreach ( Infragistics.Win.UltraWinSchedule.DayOfWeek dow in this.ultraCalendarInfo1.DaysOfWeek ) { info += "DaysOfWeek[" + dow.DayOfTheWeek.ToString() + "]:" + "\n"; // Use the LongDescriptionResolved property, which will return the value // of the LongDescription property if it was explicitly set; otherwise it will // return the current culture's name for the day of the week. info += ((char)(9)).ToString() + "The display name is " + dow.LongDescriptionResolved + "\n"; // Use the ShortDescriptionResolved property, which will return the value // of the ShortDescription property if it was explicitly set; otherwise it will // return the current culture's abbreviated name for the day of the week. info += ((char)(9)).ToString() + "The abbreviated display name is " + dow.ShortDescriptionResolved + "\n"; // Display the WorkDayStartTime and WorkDayEndTime info += ((char)(9)).ToString() + "The work day begins at " + dow.WorkDayStartTime.ToLongTimeString(); info += " and ends at " + dow.WorkDayEndTime.ToLongTimeString() + "\n"; // Display whether the day of the week is enabled if ( dow.Enabled ) info += ((char)(9)).ToString() + "The day of the week is enabled." + "\n"; else info += ((char)(9)).ToString() + "The day of the week is disabled." + "\n"; // Display whether the day of the week is visible if ( dow.Visible ) info += ((char)(9)).ToString() + "The day of the week is visible." + "\n"; else info += ((char)(9)).ToString() + "The day of the week is hidden." + "\n"; info += "\n"; } // Display the information in a message box, and prompt the user to see // if they want to make the changes DialogResult result; info += "Save changes?" + "\n"; result = MessageBox.Show( info, "SetupDayOfWeek", MessageBoxButtons.YesNo ); // Reverse the changes by calling the appropriate Reset methods if ( result == DialogResult.No ) { dayOfWeek.ResetLongDescription(); dayOfWeek.ResetShortDescription(); if ( dayOfWeek.IsWorkDay ) { dayOfWeek.ResetWorkDayStartTime(); dayOfWeek.ResetWorkDayEndTime(); } } }