'宣言 Public ReadOnly Property Phase As AppointmentDragPhase
public AppointmentDragPhase Phase {get;}
「Beginning」の戻り値は、関連付けられた操作のイベントが初めて発生していることを示します。「Moving」値は、操作が現在実行中であることを示し、前回のイベントが発生した後でユーザーが別の day または TimeSlot にカーソルを移動したことを示します。「CopyStatusChanging」の戻り値は、ユーザーが Control キーを押しているか放していて、ドラッグ操作のコピー ステータスを変更したことを示します。
Imports Infragistics.Win Imports Infragistics.Win.UltraWinSchedule Imports System.Diagnostics AddHandler Me.monthViewSingle.AppointmentsDragging, AddressOf OnAppointmentsDragging Private Sub OnAppointmentsDragging(ByVal sender As Object, ByVal e As AppointmentsDraggingEventArgs) ' Get a reference to the schedule control and the associated UltraCalendarInfo Dim control As UltraScheduleControlBase = sender Dim calendarInfo As UltraCalendarInfo = control.CalendarInfo ' Disallow copying of appointments this prevents copies of the ' dragged appointments from being made when the user presses the ' Control key. e.AllowCopy = False ' Disallow dragging the appointments to the unassigned owner, ' if they originally belonged to a different owner. If (Not (e.NewOwner Is e.InitialOwner) AndAlso e.NewOwner.IsUnassigned) Then e.AllowOwnerChange = False End If ' If the delta between the initial date and the new date is more ' than seven days, prompt the user to make sure they want to continue. ' ' To avoid stealing capture (and thus terminating the drag operation), ' we can only do this during the final phase of the drag operation, ' so check e.Phase to make sure that is the case. If e.Phase = AppointmentDragPhase.Ending Then Dim span As TimeSpan = e.NewDateTime.Date.Subtract(e.InitialDateTime.Date) Dim delta As Int32 = Math.Abs(span.TotalDays) If (delta > 7.0F) Then Dim sb As StringBuilder = New StringBuilder() sb.AppendLine("The following appointment(s) are being dragged by more than seven days from their initial start time(s):") sb.AppendLine(Environment.NewLine) Dim appointment As Appointment For Each appointment In e.Appointments sb.AppendLine(String.Format("{0} ({1})", appointment.Subject, appointment.StartDateTime.ToShortDateString())) Next sb.AppendLine(Environment.NewLine) sb.AppendLine("Do you want to move the appointment(s)?") Dim result As DialogResult = MessageBox.Show(sb.ToString(), "AppointmentsDragging", MessageBoxButtons.YesNo) If (result = System.Windows.Forms.DialogResult.No) Then e.Cancel = True End If End If End Sub
using Infragistics.Win; using Infragistics.Win.UltraWinSchedule; using System.Diagnostics; this.monthViewSingle.AppointmentsDragging += new AppointmentsDraggingHandler(OnAppointmentsDragging); private void OnAppointmentsDragging(object sender, AppointmentsDraggingEventArgs e) { // Get a reference to the schedule control and the associated UltraCalendarInfo UltraScheduleControlBase control = sender as UltraScheduleControlBase; UltraCalendarInfo calendarInfo = control.CalendarInfo; // Disallow copying of appointments; this prevents copies of the // dragged appointments from being made when the user presses the // Control key. e.AllowCopy = false; // Disallow dragging the appointments to the unassigned owner, // if they originally belonged to a different owner. if ( e.NewOwner != e.InitialOwner && e.NewOwner.IsUnassigned ) e.AllowOwnerChange = false; // If the delta between the initial date and the new date is more // than seven days, prompt the user to make sure they want to continue. // // To avoid stealing capture (and thus terminating the drag operation), // we can only do this during the final phase of the drag operation, // so check e.Phase to make sure that is the case. if ( e.Phase == AppointmentDragPhase.Ending ) { TimeSpan span = e.NewDateTime.Date.Subtract( e.InitialDateTime.Date ); int delta = (int)Math.Abs(span.TotalDays); if ( delta > 7f ) { StringBuilder sb = new StringBuilder(); sb.AppendLine( "The following appointment(s) are being dragged by more than seven days from their initial start time(s):" ); sb.AppendLine( Environment.NewLine ); foreach( Appointment appointment in e.Appointments ) { sb.AppendLine( string.Format("{0} ({1})", appointment.Subject, appointment.StartDateTime.ToShortDateString()) ); } sb.AppendLine( Environment.NewLine ); sb.AppendLine( "Do you want to move the appointment(s)?" ); DialogResult result = MessageBox.Show( sb.ToString(), "AppointmentsDragging", MessageBoxButtons.YesNo ); if ( result == DialogResult.No ) e.Cancel = true; } } }