'宣言 Public ReadOnly Property Appointments As ReadOnlyAppointmentsCollection
public ReadOnlyAppointmentsCollection Appointments {get;}
Appointments プロパティは、ドラッグされた実際の予定を含む読み取り専用のコレクションを返します。予定には、ドラッグ操作の結果を反映する開始時間と終了時間があります。一方、CopiedAppointments プロパティは、ドラッグされた予定のクローンを返します。たとえば、予定が現在の日付からドラッグされて、ドラッグ操作が完了する前にコントロールキーが押された場合、Appointments プロパティは、次の日にドラッグされた予定として同じインスタンスを返します。CopiedAppointments プロパティは、現在の日付に属するインスタンスを返します。ドラッグ操作が完了した時、SelectedAppointments コレクションは、Appointments プロパティに返されたものと同じインスタンスを含みます。
従来の動作をサポートするために、アクテイブな owner の変更時に SelectedAppointments コレクションがクリアされます。ClearSelectedAppointments プロパティがリスナーで明示的に False に設定しない限り、ドロップされたオーナーと最初のオーナーと違う場合に、このイベントが発生された後にドラッグされた予定がすぐに選択解除されます。
Imports System.Collections.Generic Imports Infragistics.Win Imports Infragistics.Win.UltraWinSchedule Imports System.Diagnostics AddHandler Me.dayView.AppointmentsDragDrop, AddressOf OnAppointmentsDragDrop Private Sub OnAppointmentsDragDrop(ByVal sender As Object, ByVal e As AppointmentsDragDropEventArgs) If Not (e.NewOwner Is e.InitialOwner) Then Dim scheduleControl As UltraScheduleControlBase = sender Dim changeHistory As List(Of AppointmentOwnershipChangeHistoryItem) = scheduleControl.Tag If changeHistory Is Nothing Then changeHistory = New List(Of AppointmentOwnershipChangeHistoryItem) End If changeHistory.Add(New AppointmentOwnershipChangeHistoryItem(DateTime.Now, e.InitialOwner, e.NewOwner, e.Appointments, e.HasCopies)) scheduleControl.Tag = changeHistory End If End Sub Public Structure AppointmentOwnershipChangeHistoryItem Public timeStamp As DateTime Public copied As Boolean Public initialOwner As Owner Public newOwner As Owner Public appointments As ReadOnlyAppointmentsCollection Public Sub New(ByVal timeStamp As DateTime, ByVal initialOwner As Owner, ByVal newOwner As Owner, ByVal appointments As ReadOnlyAppointmentsCollection, ByVal copied As Boolean) Me.timeStamp = timeStamp Me.initialOwner = initialOwner Me.newOwner = newOwner Me.appointments = appointments Me.copied = copied End Sub End Structure
using System.Collections.Generic; using Infragistics.Win; using Infragistics.Win.UltraWinSchedule; using System.Diagnostics; this.dayView.AppointmentsDragDrop += new AppointmentsDragDropHandler(OnAppointmentsDragDrop); private void OnAppointmentsDragDrop(object sender, AppointmentsDragDropEventArgs e) { if ( e.NewOwner != e.InitialOwner ) { UltraScheduleControlBase scheduleControl = sender as UltraScheduleControlBase; List<AppointmentOwnershipChangeHistoryItem> changeHistory = scheduleControl.Tag as List<AppointmentOwnershipChangeHistoryItem>; if ( changeHistory == null ) changeHistory = new List<AppointmentOwnershipChangeHistoryItem>(); changeHistory.Add( new AppointmentOwnershipChangeHistoryItem( DateTime.Now, e.InitialOwner, e.NewOwner, e.Appointments, e.HasCopies ) ); scheduleControl.Tag = changeHistory; } } public struct AppointmentOwnershipChangeHistoryItem { public DateTime timeStamp; public bool copied; public Owner initialOwner; public Owner newOwner; public ReadOnlyAppointmentsCollection appointments; public AppointmentOwnershipChangeHistoryItem( DateTime timeStamp, Owner initialOwner, Owner newOwner, ReadOnlyAppointmentsCollection appointments, bool copied ) { this.timeStamp = timeStamp; this.initialOwner = initialOwner; this.newOwner = newOwner; this.appointments = appointments; this.copied = copied; } }