Imports Infragistics.Win Imports Infragistics.Win.UltraWinSchedule Imports Infragistics.Win.UltraWinEditors Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click ' Set the UltraMonthViewSingle control up to separate owners Me.ultraMonthViewSingle1.OwnerDisplayStyle = OwnerDisplayStyle.Separate Me.ultraMonthViewSingle1.ActiveOwner = Me.ultraCalendarInfo1.Owners.UnassignedOwner Me.ultraMonthViewSingle1.CalendarLook.ViewStyle = ViewStyle.Office2007 ' Reserve the color schemes which correspond to the Office2007 color schemes Dim colorSchemes As Outlook2007ColorSchemeCollection = Me.ultraCalendarLook1.Outlook2007ColorSchemes Me.ultraMonthViewSingle1.CalendarLook.Outlook2007ColorSchemes.DisallowAutoAssignment(colorSchemes.BaseColorBlue) Me.ultraMonthViewSingle1.CalendarLook.Outlook2007ColorSchemes.DisallowAutoAssignment(colorSchemes.BaseColorBlack) Me.ultraMonthViewSingle1.CalendarLook.Outlook2007ColorSchemes.DisallowAutoAssignment(colorSchemes.BaseColorSilver) ' Create a new instance of the Outlook2007ColorSchemeDropDown ' (see code sample included with the Outlook2007ColorScheme class help topic) Dim dropDown As New Outlook2007ColorSchemeDropDown(Me, Me.ultraCalendarLook1) ' Hook the SelectionChangeCommitted event AddHandler dropDown.SelectionChangeCommitted, AddressOf Me.Outlook2007ColorSchemeDropDown_SelectionChangeCommitted End Sub Private Sub Outlook2007ColorSchemeDropDown_SelectionChangeCommitted(ByVal sender As Object, ByVal e As EventArgs) Dim dropDown As Outlook2007ColorSchemeDropDown = sender If Not (Me.ultraMonthViewSingle1.ActiveOwner Is Nothing) Then ' Get a reference to the Outlook2007ColorScheme that was selected by the end user. Dim selectedColorScheme As Outlook2007ColorScheme = dropDown.SelectedColorScheme Dim calendarLook As UltraCalendarLook = dropDown.CalendarLook Dim colorSchemes As Outlook2007ColorSchemeCollection = calendarLook.Outlook2007ColorSchemes ' If the color scheme is reserved, and not assigned to this owner, prompt the end user Dim result As DialogResult = DialogResult.Yes If (colorSchemes.IsAvailableForAutoAssignment(selectedColorScheme.BaseColor) = False) Then Dim currentlyAssignedScheme As Outlook2007ColorScheme = Me.ultraMonthViewSingle1.ActiveOwner.Outlook2007ColorScheme If Not currentlyAssignedScheme Is Nothing AndAlso Not currentlyAssignedScheme.BaseColor.Equals(selectedColorScheme.BaseColor) Then result = MessageBox.Show(Me, "The color scheme you selected is currently reserved. Do you want to assign it anyway?", "Assign Color Scheme", MessageBoxButtons.YesNo) End If End If ' Assign the color scheme to the Owner's Outlook2007ColorScheme property, ' and mark it as unavailable If (result = DialogResult.Yes) Then Me.ultraMonthViewSingle1.ActiveOwner.Outlook2007ColorScheme = selectedColorScheme End If End If End Sub
using Infragistics.Win; using Infragistics.Win.UltraWinSchedule; using Infragistics.Win.UltraWinEditors; using System.Diagnostics; private void button1_Click(object sender, System.EventArgs e) { // Set the UltraMonthViewSingle control up to separate owners this.ultraMonthViewSingle1.OwnerDisplayStyle = OwnerDisplayStyle.Separate; this.ultraMonthViewSingle1.ActiveOwner = this.ultraCalendarInfo1.Owners.UnassignedOwner; this.ultraMonthViewSingle1.CalendarLook.ViewStyle = ViewStyle.Office2007; // Reserve the color schemes which correspond to the Office2007 color schemes Outlook2007ColorSchemeCollection colorSchemes = this.ultraCalendarLook1.Outlook2007ColorSchemes; this.ultraMonthViewSingle1.CalendarLook.Outlook2007ColorSchemes.DisallowAutoAssignment( colorSchemes.BaseColorBlue ); this.ultraMonthViewSingle1.CalendarLook.Outlook2007ColorSchemes.DisallowAutoAssignment( colorSchemes.BaseColorBlack ); this.ultraMonthViewSingle1.CalendarLook.Outlook2007ColorSchemes.DisallowAutoAssignment( colorSchemes.BaseColorSilver ); // Create a new instance of the Outlook2007ColorSchemeDropDown // (see code sample included with the Outlook2007ColorScheme class help topic) Outlook2007ColorSchemeDropDown dropDown = new Outlook2007ColorSchemeDropDown( this, this.ultraCalendarLook1 ); // Hook the SelectionChangeCommitted event dropDown.SelectionChangeCommitted += new EventHandler( this.Outlook2007ColorSchemeDropDown_SelectionChangeCommitted ); } private void Outlook2007ColorSchemeDropDown_SelectionChangeCommitted( object sender, EventArgs e ) { Outlook2007ColorSchemeDropDown dropDown = sender as Outlook2007ColorSchemeDropDown; if ( this.ultraMonthViewSingle1.ActiveOwner != null ) { // Get a reference to the Outlook2007ColorScheme that was selected by the end user. Outlook2007ColorScheme selectedColorScheme = dropDown.SelectedColorScheme; UltraCalendarLook calendarLook = dropDown.CalendarLook; Outlook2007ColorSchemeCollection colorSchemes = calendarLook.Outlook2007ColorSchemes; // If the color scheme is reserved, and not assigned to this owner, prompt the end user DialogResult result = DialogResult.Yes; if ( colorSchemes.IsAvailableForAutoAssignment(selectedColorScheme.BaseColor) == false ) { Outlook2007ColorScheme currentlyAssignedScheme = this.ultraMonthViewSingle1.ActiveOwner.Outlook2007ColorScheme; if ( currentlyAssignedScheme != null && currentlyAssignedScheme.BaseColor != selectedColorScheme.BaseColor ) result = MessageBox.Show( this, "The color scheme you selected is currently reserved. Do you want to assign it anyway?", "Assign Color Scheme", MessageBoxButtons.YesNo ); } // Assign the color scheme to the Owner's Outlook2007ColorScheme property, // and mark it as unavailable if ( result == DialogResult.Yes ) this.ultraMonthViewSingle1.ActiveOwner.Outlook2007ColorScheme = selectedColorScheme; } }