'宣言 Public Property SelectionAction As AppointmentResizeSelectionAction
public AppointmentResizeSelectionAction SelectionAction {get; set;}
このプロパティは、Phase プロパティが 「Beginning」 を返す場合のみ適用されます。その他の段階でこのプロパティを設定するも機能しません。
従来の動作をサポートするために、このプロパティのデフォルト値は、UltraDayView コントロールの場合 「ClearExistingSelection」 で、UltraWeekView または UltraMonthViewSingle コントロールの場合 「PreserveExistingSelection」 です。
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; } }