Version

AppointmentResizing Event

Event fired when an appointment is resized by the end user.
Syntax
'Declaration
 
Public Event AppointmentResizing As AppointmentResizingHandler
public event AppointmentResizingHandler AppointmentResizing
Event Data

The event handler receives an argument of type AppointmentResizingEventArgs containing data related to this event. The following AppointmentResizingEventArgs properties provide information specific to this event.

PropertyDescription
Appointment Returns the Appointment on which the resize operation is being performed.
Cancel (Inherited from System.ComponentModel.CancelEventArgs) 
InitialDateTime (Inherited from Infragistics.Win.UltraWinSchedule.CancelableAppointmentDragEventArgs)Returns the DateTime over which the cursor was positioned when the operation was initiated.
NewDateTime (Inherited from Infragistics.Win.UltraWinSchedule.CancelableAppointmentDragEventArgs)Returns the DateTime closest to the current cursor position.
Phase Returns the phase of the resize operation that this event firing represents, i.e., whether it is beginning, in progress, or ending.
ResizeType Returns whether the StartDateTime or EndDateTime of the associated appointment is being modified by the resize operation.
SelectionAction Returns or sets how the contents of the SelectedAppointments collection is affected when the resize operation is initiated.
Remarks

The AppointmentsResizing event notifies a listener during all phases of an appointment resize operation. The Phase property identifies whether the resize operation has just been initiated, is continuing because the end user is moving the mouse while the logical left button is pressed, or is about to be committed because the end user released the mouse. The event can be canceled during any phase, in which case the resized appointment is returned to its pre-drag state. The SelectionAction property can be used to determine how the existing appointment selection is affected when the resize operation begins, i.e., whether the existing selection is cleared, preserved, or if only the appointment being resized is selected.

If this event is not canceled, the AppointmentResized event is fired at the end of the resize operation.

Example
The following code sample demonstrates how to use the AppointmentsResizing event to conditionally prevent appointments from being resized:

For an overview of how to handle events in Visual Basic or Visual C#, see Event Handlers in Visual Basic and Visual C#. For specific information and code examples illustrating how to consume events in your application, see Consuming Events in the .NET Framework Developer's Guide.

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;
        }
    }
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also