バージョン

DefaultScheme プロパティ

Infragistics.Win.Office2007ColorTable.ColorSchemeResolved プロパティの現在の値に基づいて、デフォルトのカラー スキームを返します。
シンタックス
'宣言
 
Public ReadOnly Property DefaultScheme As Outlook2007ColorScheme
public Outlook2007ColorScheme DefaultScheme {get;}
使用例
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinSchedule
Imports Infragistics.Win.UltraWinEditors
Imports System.Drawing.Drawing2D

' <summary>
' UltraComboEditor-derived class which emulates a color-picker
' for the purpose of providing the end user with a way to select
' Outlook2007ColorScheme instances.
' </summary>
Public Class Outlook2007ColorSchemeDropDown
    Inherits UltraComboEditor


    Private Shared ReadOnly defaultItemHeight As Integer = 18
    Private _calendarLook As UltraCalendarLook = Nothing

    Public Sub New(ByVal parent As Control, ByVal calendarLook As UltraCalendarLook)

        MyBase.New()

        If parent Is Nothing Then Throw New ArgumentNullException()
        If calendarLook Is Nothing Then Throw New ArgumentNullException()

        Me._calendarLook = calendarLook

        '	Set the DropDownStyle to DropDownList so the end user
        '	can only select items from the list.
        Me.DropDownStyle = DropDownStyle.DropDownList

        '	Set some of the properties of the ValueList
        '	so that we only display an image of the color
        Dim ValueList As ValueList = Me.Items.ValueList
        ValueList.DisplayStyle = ValueListDisplayStyle.Picture
        ValueList.ItemHeight = Outlook2007ColorSchemeDropDown.defaultItemHeight
        ValueList.ScaleItemImage = ScaleImage.Never

        '	Populate the list
        Me.PopulateList()

        '   Add the control to the parent Controls collection
        parent.Controls.Add(Me)
    End Sub


    ' <summary>
    ' Gets/sets the UltraCalendarLook component associated with this Outlook2007ColorSchemeDropDown instance.
    ' </summary>
    Public Property CalendarLook() As UltraCalendarLook
        Get
            Return Me._calendarLook
        End Get
        Set(ByVal Value As UltraCalendarLook)
            If Not Value Is Me._calendarLook Then
                Me._calendarLook = Value
                Me.PopulateList()
            End If
        End Set
    End Property

    Public Property SelectedColorScheme() As Outlook2007ColorScheme
        Get
            Dim selectedItem As ValueListItem = Me.SelectedItem
            Return IIf(Not selectedItem Is Nothing, selectedItem.DataValue, Nothing)
        End Get

        Set(ByVal Value As Outlook2007ColorScheme)
            Dim selectedIndex As Integer = -1

            If Value Is Nothing Then
                selectedIndex = -1
            Else

                Dim items As ValueListItemsCollection = Me.Items
                Dim i As Integer
                For i = 0 To items.Count - 1

                    Dim item As ValueListItem = items(i)
                    Dim colorScheme As Outlook2007ColorScheme = item.DataValue

                    If (Value Is colorScheme) Then
                        selectedIndex = i
                        Exit For
                    End If
                Next

                Me.SelectedIndex = selectedIndex
            End If

        End Set
    End Property


    Private Sub PopulateList()
        '	Clear the Items collection
        Dim items As ValueListItemsCollection = Me.Items
        items.Clear()

        If (Me.CalendarLook Is Nothing) Then Return

        '	Get the width and height to use for the images we are going to generate
        Dim width As Integer = Me.Width - 2
        Dim height As Integer = Outlook2007ColorSchemeDropDown.defaultItemHeight

        '	Iterate the members of the CalendarLook's Outlook2007ColorSchemes
        '	collection...add an item to the Items collection for each color scheme
        Dim colorSchemes As Outlook2007ColorSchemeCollection = Me.CalendarLook.Outlook2007ColorSchemes

        Dim i As Integer
        For i = 0 To colorSchemes.Count - 1

            '	Use the SupportedColors array to index into the
            '	Outlook2007ColorSchemes collection
            Dim colorScheme As Outlook2007ColorScheme = colorSchemes(colorSchemes.SupportedColors(i))

            '	Add a ValueListItem, and assign the color scheme to its DataValue property.
            Dim item As ValueListItem = items.Add(colorScheme)

            '	Get the colors we will use to represent this color scheme
            Dim backColor As Color = colorScheme.AppointmentBackColor2
            Dim backColor2 As Color = colorScheme.BaseColor
            Dim borderColor As Color = colorScheme.AppointmentBorderColor

            '	Create a Bitmap and get a Graphics object for it
            Dim bitmap As Bitmap = New Bitmap(width, height)
            Dim gr As Graphics = Graphics.FromImage(bitmap)

            '	Create the Rectangle for the fill colors
            Dim rect As Rectangle = New Rectangle(Point.Empty, bitmap.Size)
            rect.Inflate(-1, -1)

            '	Create a LinearGradientBrush with the fill colors,
            '	and a Pen for the border color.
            Dim brush As New LinearGradientBrush(rect, backColor, backColor2, 90.0F)
            Dim pen As New Pen(borderColor)

            '	Fill the Rectangle with the gradient colors
            gr.FillRectangle(brush, rect)

            '	Reduce the width and height of the Rectangle and draw the border
            rect.Width -= 1
            rect.Height -= 1
            gr.DrawRectangle(pen, rect)

            '	Dispose of the GDI+ objects we created to render the image
            brush.Dispose()
            pen.Dispose()
            gr.Dispose()

            '	Assign the resulting Bitmap to the ValueListItem's Appearance.Image.
            item.Appearance.Image = bitmap

        Next

        If (items.Count > 0) Then
            '	Since this is a relatively short list, set the MaxDropDownItems
            '	property to the number of items in the collection so that no
            '	scrollbar is shown.
            Me.MaxDropDownItems = items.Count

            '	Select the item which corresponds to the default color scheme
            Me.SelectedColorScheme = colorSchemes.DefaultScheme
        End If

    End Sub

End Class
using Infragistics.Win;
using Infragistics.Win.UltraWinSchedule;
using System.Diagnostics;

	/// <summary>
	/// UltraComboEditor-derived class which emulates a color-picker
	/// for the purpose of providing the end user with a way to select
	/// Outlook2007ColorScheme instances.
	/// </summary>
	public class Outlook2007ColorSchemeDropDown : UltraComboEditor
	{
		static private readonly int defaultItemHeight = 18;
		private UltraCalendarLook calendarLook = null;

		/// <summary>
		/// Creates a new instance of the Outlook2007ColorSchemeDropDown class.
		/// </summary>
		/// <param name="parent">The parent control</param>
		/// <param name="calendarLook">The UltraCalendarLook associated with the dropdown.</param>
		public Outlook2007ColorSchemeDropDown( Control parent, UltraCalendarLook calendarLook )
		{
			if ( parent == null )
				throw new ArgumentNullException( "parent" );

			if ( calendarLook == null )
				throw new ArgumentNullException( "calendarLook" );

			this.calendarLook = calendarLook;

			//	Set the DropDownStyle to DropDownList so the end user
			//	can only select items from the list.
			this.DropDownStyle = DropDownStyle.DropDownList;

			//	Set some of the properties of the ValueList
			//	so that we only display an image of the color
			ValueList valueList = this.Items.ValueList;
			valueList.DisplayStyle = ValueListDisplayStyle.Picture;
			valueList.ItemHeight = Outlook2007ColorSchemeDropDown.defaultItemHeight;
			valueList.ScaleItemImage = ScaleImage.Never;

			//	Populate the list
			this.PopulateList();

			//	Add the control to the parent Controls collection
			parent.Controls.Add( this );
		}

		/// <summary>
		/// Gets/sets the UltraCalendarLook component associated with this Outlook2007ColorSchemeDropDown instance.
		/// </summary>
		public UltraCalendarLook CalendarLook
		{
			get{ return this.calendarLook; }
			set
			{ 
				if ( value != this.calendarLook )
				{
					this.calendarLook = value;
					this.PopulateList();
				}
			}
		}

		/// <summary>
		/// Gets/sets the currently selected Outlook2007ColorScheme.
		/// </summary>
		public Outlook2007ColorScheme SelectedColorScheme
		{
			get
			{ 
				ValueListItem selectedItem = this.SelectedItem;
				return selectedItem != null ? selectedItem.DataValue as Outlook2007ColorScheme : null;
			}

			set
			{
				int selectedIndex = -1;

				if ( value == null )
					selectedIndex = -1;
				else
				{
					ValueListItemsCollection items = this.Items;
					for ( int i = 0; i < items.Count; i ++ )
					{
						ValueListItem item = items[i];
						Outlook2007ColorScheme colorScheme = item.DataValue as Outlook2007ColorScheme;
						
						if ( value == colorScheme )
						{
							selectedIndex = i;
							break;
						}
					}

					this.SelectedIndex = selectedIndex;
				}
			}
		}


		private void PopulateList()
		{
			//	Clear the Items collection
			ValueListItemsCollection items = this.Items;
			items.Clear();

			if ( this.CalendarLook == null )
				return;

			//	Get the width and height to use for the images we are going to generate
			int width = this.Width - 2;
			int height = Outlook2007ColorSchemeDropDown.defaultItemHeight;

			//	Iterate the members of the CalendarLook's Outlook2007ColorSchemes
			//	collection...add an item to the Items collection for each color scheme
			Outlook2007ColorSchemeCollection colorSchemes = this.CalendarLook.Outlook2007ColorSchemes;

			for ( int i = 0; i < colorSchemes.Count; i ++ )
			{
				//	Use the SupportedColors array to index into the
				//	Outlook2007ColorSchemes collection
				Outlook2007ColorScheme colorScheme = colorSchemes[ colorSchemes.SupportedColors[i] ];

				//	Add a ValueListItem, and assign the color scheme to its DataValue property.
				ValueListItem item = items.Add( colorScheme );

				//	Get the colors we will use to represent this color scheme
				Color backColor = colorScheme.AppointmentBackColor2;
				Color backColor2 = colorScheme.BaseColor;
				Color borderColor = colorScheme.AppointmentBorderColor;

				//	Create a Bitmap and get a Graphics object for it
				Bitmap bitmap = new Bitmap( width, height );
				Graphics gr = Graphics.FromImage( bitmap );

				//	Create the Rectangle for the fill colors
				Rectangle rect = new Rectangle( Point.Empty, bitmap.Size );
				rect.Inflate( -1, -1 );

				//	Create a LinearGradientBrush with the fill colors,
				//	and a Pen for the border color.
				LinearGradientBrush brush = new LinearGradientBrush( rect, backColor, backColor2, 90f );
				Pen pen = new Pen( borderColor );

				//	Fill the Rectangle with the gradient colors
				gr.FillRectangle( brush, rect );

				//	Reduce the width and height of the Rectangle and draw the border
				rect.Width -= 1;
				rect.Height -= 1;
				gr.DrawRectangle( pen, rect );

				//	Dispose of the GDI+ objects we created to render the image
				brush.Dispose();
				pen.Dispose();
				gr.Dispose();

				//	Assign the resulting Bitmap to the ValueListItem's Appearance.Image.
				item.Appearance.Image = bitmap;
			}

			if ( items.Count > 0 )
			{
				//	Since this is a relatively short list, set the MaxDropDownItems
				//	property to the number of items in the collection so that no
				//	scrollbar is shown.
				this.MaxDropDownItems = items.Count;

				//	Select the item which corresponds to the default color scheme
				this.SelectedColorScheme = colorSchemes.DefaultScheme;
			}
		}
	}
参照