'宣言 Public Class UltraTimelineViewKeyActionMapping Inherits Infragistics.Win.KeyActionMappingBase
public class UltraTimelineViewKeyActionMapping : Infragistics.Win.KeyActionMappingBase
Imports System.Collections.Generic Imports Infragistics.Win Imports Infragistics.Win.UltraWinSchedule Imports System.Diagnostics Public Sub EnableHorizontalPaging(ByVal control As UltraTimelineView) ' Remove each default key action that is mapped to the PageUp or PageDown keys Dim forRemoval As List(Of UltraTimelineViewKeyActionMapping) = New List(Of UltraTimelineViewKeyActionMapping)() Dim keyMappings As UltraTimelineViewKeyActionMappings = control.KeyActionMappings For Each mapping As UltraTimelineViewKeyActionMapping In keyMappings If mapping.KeyCode = Keys.PageUp Or mapping.KeyCode = Keys.PageDown Then forRemoval.Add(mapping) Next For Each mapping As UltraTimelineViewKeyActionMapping In forRemoval keyMappings.Remove(mapping) Next ' Create a mapping that navigates to the next day disallow the ' 'AppointmentEditing' state so the action is not performed when ' an edit mode session is in progress. Dim nextDay As UltraTimelineViewKeyActionMapping = _ New UltraTimelineViewKeyActionMapping( _ Keys.PageDown, _ UltraTimelineViewAction.ScrollToNextDay, _ UltraTimelineViewState.AppointmentEditing, _ UltraTimelineViewState.None, _ 0, _ 0) ' Also create a mapping that navigates to the previous day. Dim prevDay As UltraTimelineViewKeyActionMapping = _ New UltraTimelineViewKeyActionMapping( _ Keys.PageUp, _ UltraTimelineViewAction.ScrollToNextDay, _ UltraTimelineViewState.AppointmentEditing, _ UltraTimelineViewState.None, _ 0, _ 0) ' Add the custom mappings. keyMappings.Add(nextDay) keyMappings.Add(prevDay) End Sub
using System.Collections.Generic; using Infragistics.Win; using Infragistics.Win.UltraWinSchedule; using System.Diagnostics; public void EnableHorizontalPaging( UltraTimelineView control ) { // Remove each default key action that is mapped to the PageUp or PageDown keys List<UltraTimelineViewKeyActionMapping> forRemoval = new List<UltraTimelineViewKeyActionMapping>(); UltraTimelineViewKeyActionMappings keyMappings = control.KeyActionMappings; foreach( UltraTimelineViewKeyActionMapping mapping in keyMappings ) { if ( mapping.KeyCode == Keys.PageUp || mapping.KeyCode == Keys.PageDown ) forRemoval.Add( mapping ); } foreach( UltraTimelineViewKeyActionMapping mapping in keyMappings ) { keyMappings.Remove( mapping ); } // Create a mapping that navigates to the next day; disallow the // 'AppointmentEditing' state so the action is not performed when // an edit mode session is in progress. UltraTimelineViewKeyActionMapping nextDay = new UltraTimelineViewKeyActionMapping( Keys.PageDown, UltraTimelineViewAction.ScrollToNextDay, UltraTimelineViewState.AppointmentEditing, UltraTimelineViewState.None, 0, 0 ); // Also create a mapping that navigates to the previous day. UltraTimelineViewKeyActionMapping prevDay = new UltraTimelineViewKeyActionMapping( Keys.PageUp, UltraTimelineViewAction.ScrollToNextDay, UltraTimelineViewState.AppointmentEditing, UltraTimelineViewState.None, 0, 0 ); // Add the custom mappings. keyMappings.Add( nextDay ); keyMappings.Add( prevDay ); }