AppointmentActionオブジェクトは、アクションに引き渡すコマンドとパラメーターだけでなく実行するアクションのタイプに関する情報を含みます。
Imports Infragistics.Win Imports Infragistics.Win.UltraWinSchedule Private Sub SetupAppointment() ' Create a new Appointment object. Make its start time five minutes from now, and ' make its end time a half an hour later Dim appointment As Appointment = New Appointment(DateTime.Now.AddMinutes(5.0F), DateTime.Now.AddMinutes(35.0F)) ' Set the subject of the appointment appointment.Subject = "Appointment subject" ' Set the location of the appointment appointment.Location = "Appointment location" ' Set the description of the appointment appointment.Description = "Appointment description" ' Set up a reminder for the appointment, set to activate 5 minutes before ' the appointment's start time Me.SetReminder(appointment, 5) ' Set the AllDayEvent property to false appointment.AllDayEvent = False ' Set the bar color to red...note that this will only be ' displayed by the UltraDayView control. appointment.BarColor = Color.Red ' Set the Tag property to the form on which the component is sited appointment.Tag = Me ' Now that the appointment has been configured, add it to ' the UltraCalendarInfo object's Appointments collection Me.ultraCalendarInfo1.Appointments.Add(appointment) ' See if the day that corresponds to the appointment's StartDateTime ' is Selected, if it is, make the appointment selected as well If appointment.Day.Selected Then appointment.Selected = True ' Set up an action to be performed when the appointment activates Me.SetAction(appointment) End Sub Private Sub SetAction(ByVal appointment As Appointment) '-------------------------------------------------------------------------------- ' Demonstrates how to use an appointment's Action object property '-------------------------------------------------------------------------------- ' Make sure the appointment is useable before continuing If appointment Is Nothing Or appointment.Disposed Then Return ' Create a new AppointmentAction object Dim action As AppointmentAction = New AppointmentAction() ' Set the action's command string to launch Notepad action.Command = "Notepad.exe" ' Create a simple text file, and write the appointment's ' description out to it Dim fileName As String = Application.CommonAppDataPath + "\action.txt" Dim output As TextWriter = File.AppendText(fileName) output.WriteLine(appointment.Description) output.Close() ' Set the action's Parameters property to the text file ' we created, so that it will be opened when the action ' is launched action.Parameters = fileName ' Set the Action type to 'Execute Program' action.Type = AppointmentActionType.ExecuteProgram ' Set the Tag property to the form on which the component is sited action.Tag = Me ' Assign the AppointmentAction object to the ' specified Appointment's Action property appointment.Action = action ' Enable the action appointment.Action.Enabled = True End Sub Private Sub SetReminder(ByVal appointment As Appointment, ByVal minutes As Integer) '-------------------------------------------------------------------------------- ' Sets a reminder for the specified appointment '-------------------------------------------------------------------------------- ' Make sure the appointment is useable before continuing If appointment Is Nothing Or appointment.Disposed Then Return ' Make sure the value of the minutes parameter is valid If minutes < 0 Then Return ' Create a new reminder and assign it to the Appointment Dim reminder As Reminder = New Reminder() ' Set the reminder's Enabled property to false until we are ' finished configuring it reminder.Enabled = False ' Since this method specifies the time to wait in minutes, set ' the reminder's DisplayIntervalUnits property to Minutes reminder.DisplayIntervalUnits = DisplayIntervalUnits.Minutes ' Set the DisplayInterval property to the value of the 'minutes' parameter reminder.DisplayInterval = minutes ' Set the DialogText property reminder.DialogText = "My Reminder" ' Set the Tag property to the form on which the component is sited reminder.Tag = Me ' Set the appointment's Reminder property to the ' Reminder object we just created appointment.Reminder = reminder ' Now that it has been configured, set the reminder's ' Enabled property to true. This will start the timer. reminder.Enabled = True End Sub
using System.Diagnostics; using Infragistics.Win; using Infragistics.Win.UltraWinSchedule; private void SetupAppointment() { // Create a new Appointment object. Make its start time five minutes from now and // make its end time a half an hour later Appointment appointment = new Appointment( DateTime.Now.AddMinutes( 5.0F ), DateTime.Now.AddMinutes( 35.0F ) ); // Set the subject of the appointment appointment.Subject = "Appointment subject"; // Set the location of the appointment appointment.Location = "Appointment location"; // Set the description of the appointment appointment.Description = "Appointment description"; // Set up a reminder for the appointment, set to activate 5 minutes before // the appointment's start time this.SetReminder( appointment, 5 ); // Set the AllDayEvent property to false appointment.AllDayEvent = false; // Set the bar color to red...note that this will only be // displayed by the UltraDayView control. appointment.BarColor = Color.Red; // Set the Tag property to the form on which the component is sited appointment.Tag = this; // Now that the appointment has been configured, add it to // the UltraCalendarInfo object's Appointments collection this.ultraCalendarInfo1.Appointments.Add( appointment ); // See if the day that corresponds to the appointment's StartDateTime // is Selected; if it is, make the appointment selected as well if ( appointment.Day.Selected ) appointment.Selected = true; // Set up an action to be performed when the appointment activates this.SetAction( appointment ); } private void SetAction( Appointment appointment ) { //-------------------------------------------------------------------------------- // Demonstrates how to use an appointment's Action object property //-------------------------------------------------------------------------------- // Make sure the appointment is useable before continuing if ( appointment == null || appointment.Disposed ) return; // Create a new AppointmentAction object AppointmentAction action = new AppointmentAction(); // Set the action's command string to launch Notepad action.Command = "Notepad.exe"; // Create a simple text file, and write the appointment's // description out to it string fileName = Application.CommonAppDataPath + @"\action.txt"; TextWriter output = File.AppendText( fileName ); output.WriteLine( appointment.Description ); output.Close(); // Set the action's Parameters property to the text file // we created, so that it will be opened when the action // is launched action.Parameters = fileName; // Set the Action type to 'Execute Program' action.Type = AppointmentActionType.ExecuteProgram; // Set the Tag property to the form on which the component is sited action.Tag = this; // Assign the AppointmentAction object to the // specified Appointment's Action property appointment.Action = action; // Enable the action appointment.Action.Enabled = true; } private void SetReminder( Appointment appointment, int minutes ) { //-------------------------------------------------------------------------------- // Sets a reminder for the specified appointment //-------------------------------------------------------------------------------- // Make sure the appointment is useable before continuing if ( appointment == null || appointment.Disposed ) return; // Make sure the value of the minutes parameter is valid if ( minutes < 0 ) return; // Create a new reminder and assign it to the Appointment Reminder reminder = new Reminder(); // Set the reminder's Enabled property to false until we are // finished configuring it reminder.Enabled = false; // Since this method specifies the time to wait in minutes, set // the reminder's DisplayIntervalUnits property to Minutes reminder.DisplayIntervalUnits = DisplayIntervalUnits.Minutes; // Set the DisplayInterval property to the value of the 'minutes' parameter reminder.DisplayInterval = minutes; // Set the DialogText property reminder.DialogText = "My Reminder"; // Set the Tag property to the form on which the component is sited reminder.Tag = this; // Set the appointment's Reminder property to the // Reminder object we just created appointment.Reminder = reminder; // Now that it has been configured, set the reminder's // Enabled property to true. This will start the timer. reminder.Enabled = true; }