'宣言 Public Property PrimaryInterval As DateTimeInterval
public DateTimeInterval PrimaryInterval {get; set;}
PrimaryInterval プロパティはアクティビティを表おじするコントロールの領域によって間隔を定義します。列ヘッダーの下の行に常に表示します。PrimaryInterval で決定されたコントロールによって表示される各 タイムスロット の期間。
AdditionalIntervals コレクションのメンバーがインターフェイスで非表示になっている場合、PrimaryInterval によって作成されたヘッダーが常に表示されます。
PrimaryInterval プロパティを null に設定できますが、このプロパティは null 値を返しません。コントロールによって少なくても 1 つの時間間隔が常に定義されているためにデフォルト インスタンスを保持します。15 分間のサイクルを作成する TimeInterval 型のインスタンス。
PrimaryInterval プロパティが新しい値に割り当てられている場合、または Interval (または IntervalUnits) プロパティの値が変更された場合、PrimaryIntervalChanged イベントが発生し、リスナーは変更に対応することができます。たとえば、TimeSlotInterval プロパティを同じ UltraCalendarInfo と関連付けられた UltraDayView コントロールと同期するために使用できます。
Imports System.Collections.Generic Imports Infragistics.Win Imports Infragistics.Win.UltraWinSchedule Public Sub InitDateTimeIntervals(ByVal control As UltraTimelineView) ' Remove all additional intervals control.AdditionalIntervals.Clear() ' Get the current culture's date/time format info Dim formatInfo As System.Globalization.DateTimeFormatInfo = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat ' Create a monthly interval set its header format to the YearMonthPattern ' for the current culture so that the year is displayed along with the month name. Dim monthInterval As DateInterval = New DateInterval(1, DateIntervalUnits.Months) monthInterval.HeaderTextFormat = formatInfo.YearMonthPattern ' Create a bi-weekly interval use the 'RangeStart' HeaderTextFormatStyle, ' and customize the format so it shows as a pay period. Also, set its ' SynchronizingDate property to the first Monday of the year so that the ' cycles begin on a Monday. Dim biWeeklyInterval As DateInterval = New DateInterval(2, DateIntervalUnits.Weeks) biWeeklyInterval.HeaderTextFormatStyle = TimelineViewHeaderTextFormatStyle.RangeStart biWeeklyInterval.HeaderTextFormat = String.Format("\P\a\y \P\e\r\i\o\d: {0}", formatInfo.MonthDayPattern) biWeeklyInterval.SynchronizingDate = New DateTime(2009, 1, 5) ' Create a daily interval since we already have the year showing, ' we can set the format to only display the name of the day of the week. Dim dayInterval As DateInterval = New DateInterval(1, DateIntervalUnits.Days) dayInterval.HeaderTextFormat = "dddd" ' Create 1-hour TimeIntervals for some of the different U.S. time zones Dim tzHawaii As TimeZoneInfo = TimeZoneInfo.FromStandardName("Hawaiian Standard Time", False) If Not tzHawaii Is Nothing Then Dim hawaii As New TimeInterval(1, TimeIntervalUnits.Hours) hawaii.TimeZone = tzHawaii hawaii.LabelText = "Hawaii" hawaii.LabelToolTipText = tzHawaii.DisplayName ' Use the colors of the Hawaii state flag to style the appearance hawaii.HeaderAppearance.BackGradientStyle = GradientStyle.None hawaii.HeaderAppearance.ForeColor = Color.Red hawaii.HeaderAppearance.BackColor = Color.White hawaii.HeaderAppearance.BorderColor = Color.Black hawaii.LabelAppearance.BackColor = Color.White hawaii.DateNavigationButtonAppearance.ForeColor = Color.Red hawaii.DateNavigationButtonAppearance.BorderColor = Color.Navy ' Set DateNavigationButtonVisibility to 'ShowOnFirstAndLastHeader', and set ' DateNavigationButtonAction to 'None' hawaii.DateNavigationButtonVisibility = TimelineViewDateNavigationButtonVisibility.ShowOnFirstAndLastHeader hawaii.DateNavigationButtonAction = TimelineViewDateNavigationButtonAction.None ' Add it to the AdditionalIntervals collection control.AdditionalIntervals.Add(hawaii) End If Dim tzAlaska As TimeZoneInfo = TimeZoneInfo.FromStandardName("Alaskan Standard Time", False) If Not tzAlaska Is Nothing Then Dim alaska As TimeInterval = New TimeInterval(1, TimeIntervalUnits.Hours) alaska.TimeZone = tzAlaska alaska.LabelText = "Alaska" alaska.LabelToolTipText = tzAlaska.DisplayName ' Use the colors of the Alaska state flag to style the appearance alaska.HeaderAppearance.BackGradientStyle = GradientStyle.None alaska.HeaderAppearance.ForeColor = Color.Goldenrod alaska.HeaderAppearance.BackColor = Color.CornflowerBlue alaska.HeaderAppearance.BorderColor = Color.Black alaska.LabelAppearance.BackColor = Color.CornflowerBlue alaska.DateNavigationButtonAppearance.ForeColor = Color.Goldenrod alaska.DateNavigationButtonAppearance.BorderColor = Color.Black ' Set DateNavigationButtonVisibility to 'ShowOnFirstAndLastHeader', and set ' DateNavigationButtonAction to 'None' alaska.DateNavigationButtonVisibility = TimelineViewDateNavigationButtonVisibility.ShowOnFirstAndLastHeader alaska.DateNavigationButtonAction = TimelineViewDateNavigationButtonAction.None ' Add it to the AdditionalIntervals collection control.AdditionalIntervals.Add(alaska) End If ' Handle the DateNavigationButtonClicked event so we can customize ' the navigation for the Alaska and Hawaii intervals. AddHandler control.DateNavigationButtonClicked, AddressOf Me.OnDateNavigationButtonClicked ' Create a 30-minute TimeInterval that will be used as the PrimaryInterval; ' Since we have other time zones showing, show the current time zone's name ' in the tooltip. Dim primaryInterval As TimeInterval = New TimeInterval(30, TimeIntervalUnits.Minutes) Dim tzCurrent As TimeZoneInfo = TimeZoneInfo.CurrentTimeZone If Not tzCurrent Is Nothing Then Dim standardName As String = tzCurrent.StandardName Dim acronym As String = standardName ' Build an acronym from the standard name and assign that ' string value to the LabelText property Dim split As String() = standardName.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries) If (Split.Length > 1) Then acronym = String.Empty For Each s As String In split acronym += s(0) Next End If primaryInterval.LabelText = acronym primaryInterval.LabelToolTipText = standardName ' Set some appearance properties primaryInterval.HeaderAppearance.BackGradientStyle = GradientStyle.None primaryInterval.HeaderAppearance.ForeColor = SystemColors.ControlDark primaryInterval.HeaderAppearance.BackColor = SystemColors.Control primaryInterval.HeaderAppearance.BorderColor = SystemColors.ControlDarkDark primaryInterval.LabelAppearance.BackColor = SystemColors.Control End If ' Assign the TimeInterval to the PrimaryInterval property control.PrimaryInterval = primaryInterval ' Add each interval we created to the AdditionalIntervals collection control.AdditionalIntervals.Add(monthInterval) control.AdditionalIntervals.Add(biWeeklyInterval) control.AdditionalIntervals.Add(dayInterval) End Sub
using System.Collections.Generic; using Infragistics.Win; using Infragistics.Win.UltraWinSchedule; public void InitDateTimeIntervals( UltraTimelineView control ) { // Remove all additional intervals control.AdditionalIntervals.Clear(); // Get the current culture's date/time format info System.Globalization.DateTimeFormatInfo formatInfo = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat; // Create a monthly interval; set its header format to the YearMonthPattern // for the current culture so that the year is displayed along with the month name. DateInterval monthInterval = new DateInterval( 1, DateIntervalUnits.Months ); monthInterval.HeaderTextFormat = formatInfo.YearMonthPattern; // Create a bi-weekly interval; use the 'RangeStart' HeaderTextFormatStyle, // and customize the format so it shows as a pay period. Also, set its // SynchronizingDate property to the first Monday of the year so that the // cycles begin on a Monday. DateInterval biWeeklyInterval = new DateInterval( 2, DateIntervalUnits.Weeks ); biWeeklyInterval.HeaderTextFormatStyle = TimelineViewHeaderTextFormatStyle.RangeStart; biWeeklyInterval.HeaderTextFormat = string.Format("\\P\\a\\y \\P\\e\\r\\i\\o\\d: {0}", formatInfo.MonthDayPattern); biWeeklyInterval.SynchronizingDate = new DateTime(2009, 1, 5 ); // Create a daily interval; since we already have the year showing, // we can set the format to only display the name of the day of the week. DateInterval dayInterval = new DateInterval( 1, DateIntervalUnits.Days ); dayInterval.HeaderTextFormat = "dddd"; // Create 1-hour TimeIntervals for some of the different U.S. time zones TimeZoneInfo tzHawaii = TimeZoneInfo.FromStandardName( "Hawaiian Standard Time", false ); if ( tzHawaii != null ) { TimeInterval hawaii = new TimeInterval( 1, TimeIntervalUnits.Hours ); hawaii.TimeZone = tzHawaii; hawaii.LabelText = "Hawaii"; hawaii.LabelToolTipText = tzHawaii.DisplayName; // Use the colors of the Hawaii state flag to style the appearance hawaii.HeaderAppearance.BackGradientStyle = GradientStyle.None; hawaii.HeaderAppearance.ForeColor = Color.Red; hawaii.HeaderAppearance.BackColor = Color.White; hawaii.HeaderAppearance.BorderColor = Color.Black; hawaii.LabelAppearance.BackColor = Color.White; hawaii.DateNavigationButtonAppearance.ForeColor = Color.Red; hawaii.DateNavigationButtonAppearance.BorderColor = Color.Navy; // Set DateNavigationButtonVisibility to 'ShowOnFirstAndLastHeader', and set // DateNavigationButtonAction to 'None' hawaii.DateNavigationButtonVisibility = TimelineViewDateNavigationButtonVisibility.ShowOnFirstAndLastHeader; hawaii.DateNavigationButtonAction = TimelineViewDateNavigationButtonAction.None; // Add it to the AdditionalIntervals collection control.AdditionalIntervals.Add( hawaii ); } TimeZoneInfo tzAlaska = TimeZoneInfo.FromStandardName( "Alaskan Standard Time", false ); if ( tzAlaska != null ) { TimeInterval alaska = new TimeInterval( 1, TimeIntervalUnits.Hours ); alaska.TimeZone = tzAlaska; alaska.LabelText = "Alaska"; alaska.LabelToolTipText = tzAlaska.DisplayName; // Use the colors of the Alaska state flag to style the appearance alaska.HeaderAppearance.BackGradientStyle = GradientStyle.None; alaska.HeaderAppearance.ForeColor = Color.Goldenrod; alaska.HeaderAppearance.BackColor = Color.CornflowerBlue; alaska.HeaderAppearance.BorderColor = Color.Black; alaska.LabelAppearance.BackColor = Color.CornflowerBlue; alaska.DateNavigationButtonAppearance.ForeColor = Color.Goldenrod; alaska.DateNavigationButtonAppearance.BorderColor = Color.Black; // Set DateNavigationButtonVisibility to 'ShowOnFirstAndLastHeader', and set // DateNavigationButtonAction to 'None'. alaska.DateNavigationButtonVisibility = TimelineViewDateNavigationButtonVisibility.ShowOnFirstAndLastHeader; alaska.DateNavigationButtonAction = TimelineViewDateNavigationButtonAction.None; // Add it to the AdditionalIntervals collection control.AdditionalIntervals.Add( alaska ); } // Handle the DateNavigationButtonClicked event so we can customize // the navigation for the Alaska and Hawaii intervals. control.DateNavigationButtonClicked += new DateNavigationButtonClickedHandler(OnDateNavigationButtonClicked); // Create a 30-minute TimeInterval that will be used as the PrimaryInterval TimeInterval primaryInterval = new TimeInterval(30, TimeIntervalUnits.Minutes); TimeZoneInfo tzCurrent = TimeZoneInfo.CurrentTimeZone; if ( tzCurrent != null ) { string standardName = tzCurrent.StandardName; string acronym = standardName; // Build an acronym from the standard name and assign that // string value to the LabelText property string[] split = standardName.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if ( split.Length > 1 ) { acronym = string.Empty; foreach( string s in split ) { acronym += s[0]; } } primaryInterval.LabelText = acronym; primaryInterval.LabelToolTipText = standardName; // Set some appearance properties primaryInterval.HeaderAppearance.BackGradientStyle = GradientStyle.None; primaryInterval.HeaderAppearance.ForeColor = SystemColors.ControlDark; primaryInterval.HeaderAppearance.BackColor = SystemColors.Control; primaryInterval.HeaderAppearance.BorderColor = SystemColors.ControlDarkDark; primaryInterval.LabelAppearance.BackColor = SystemColors.Control; } // Assign the TimeInterval to the PrimaryInterval property control.PrimaryInterval = primaryInterval; // Add each interval we created to the AdditionalIntervals collection control.AdditionalIntervals.Add( monthInterval ); control.AdditionalIntervals.Add( biWeeklyInterval ); control.AdditionalIntervals.Add( dayInterval ); }