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