'宣言 Public ReadOnly Property Phase As AppointmentResizePhase
public AppointmentResizePhase Phase {get;}
「Beginning」の戻り値は、関連付けられた操作のイベントが初めて発生していることを示します。「Moving」値は、操作が現在実行中であることを示し、前回のイベントが発生した後でユーザーが別の day または TimeSlot にカーソルを移動したことを示します。
Imports System.Collections.Generic Imports Infragistics.Win Imports Infragistics.Win.UltraWinSchedule Imports System.Diagnostics AddHandler Me.dayView.AppointmentResizing, AddressOf OnAppointmentsResizing Private Sub OnAppointmentsResizing(ByVal sender As Object, ByVal e As AppointmentResizingEventArgs) Dim control As UltraDayView = sender If Not control Is Nothing Then ' Get the delta between the original drag point and the new one Dim span As TimeSpan = e.InitialDateTime.Subtract(e.NewDateTime) Dim delta As Int32 = Math.Abs(span.TotalMinutes) ' Access the change history from the Tag property Dim changeHistory As List(Of AppointmentChangeHistoryItem) = Nothing If e.Appointment.Tag Is Nothing Then e.Appointment.Tag = New List(Of AppointmentChangeHistoryItem) changeHistory = e.Appointment.Tag ' If the appointment's duration is being increased by more than one hour, ' add an entry to the change history If (e.Phase = AppointmentResizePhase.Ending AndAlso delta > 60) Then changeHistory.Add(New AppointmentChangeHistoryItem(DateTime.Now, e)) End If ' If the duration has been changed more than a certain number ' of times, cancel the event If e.Phase = AppointmentResizePhase.Beginning AndAlso changeHistory.Count > 5 Then e.Cancel = True MessageBox.Show("Access denied", "AppointmentsResizing", MessageBoxButtons.OK) End If ' Clear the selection when a new resize operation begins e.SelectionAction = AppointmentResizeSelectionAction.SelectOnlyThisAppointment End If End Sub Public Structure AppointmentChangeHistoryItem Public timeStamp As DateTime Public data As AppointmentResizingEventArgs Public Sub New(ByVal timeStamp As DateTime, ByVal data As AppointmentResizingEventArgs) Me.timeStamp = timeStamp Me.data = data End Sub End Structure
using System.Collections.Generic; using Infragistics.Win; using Infragistics.Win.UltraWinSchedule; using System.Diagnostics; this.dayView.AppointmentResizing += new AppointmentResizingHandler(OnAppointmentsResizing); private void OnAppointmentsResizing(object sender, AppointmentResizingEventArgs e) { UltraDayView control = sender as UltraDayView; if ( control != null ) { // Get the delta between the original drag point and the new one TimeSpan span = e.InitialDateTime.Subtract( e.NewDateTime ); int delta = (int)Math.Abs( span.TotalMinutes ); // Access the change history from the Tag property List<AppointmentChangeHistoryItem> changeHistory = null; if ( e.Appointment.Tag == null ) e.Appointment.Tag = new List<AppointmentChangeHistoryItem>(); changeHistory = e.Appointment.Tag as List<AppointmentChangeHistoryItem>; // If the appointment's duration is being increased by more than one hour, // add an entry to the change history if ( e.Phase == AppointmentResizePhase.Ending && delta > 60 ) changeHistory.Add( new AppointmentChangeHistoryItem(DateTime.Now, e) ); // If the duration has been changed more than a certain number // of times, cancel the event if ( e.Phase == AppointmentResizePhase.Beginning && changeHistory.Count > 5 ) { e.Cancel = true; MessageBox.Show( "Access denied", "AppointmentsResizing", MessageBoxButtons.OK ); } // Clear the selection when a new resize operation begins e.SelectionAction = AppointmentResizeSelectionAction.SelectOnlyThisAppointment; } } public struct AppointmentChangeHistoryItem { public DateTime timeStamp; public AppointmentResizingEventArgs data; public AppointmentChangeHistoryItem( DateTime timeStamp, AppointmentResizingEventArgs data ) { this.timeStamp = timeStamp; this.data = data; } }