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