Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ' ***********************************************************************
- ' Author : Elektro
- ' Modified : 11-December-2014
- ' ***********************************************************************
- ' <copyright file="ElektroListBox.vb" company="Elektro Studios">
- ' Copyright (c) Elektro Studios. All rights reserved.
- ' </copyright>
- ' ***********************************************************************
- #Region " UserControl Features Summary "
- #Region " Properties "
- ' ReadOnly
- ' TextFormat.Alignment
- ' TextFormat.FormatFlags
- ' TextFormat.LineAlignment
- ' TextFormat.Trimming
- ' StateEnabled.BorderColor
- ' StateDisabled.BorderColor
- ' StateReadOnly.BorderColor
- ' StateEnabled.Cursor
- ' StateDisabled.Cursor
- ' StateReadOnly.Cursor
- ' StateEnabled.Grid.Enabled
- ' StateEnabled.Grid.Color
- ' StateDisabled.Grid.Enabled
- ' StateDisabled.Grid.Color
- ' StateReadOnly.Grid.Enabled
- ' StateReadOnly.Grid.Color
- ' StateEnabled.Items.Background.Selected
- ' StateEnabled.Items.Background.Unselected
- ' StateEnabled.Items.Background.UnselectedAlternate
- ' StateEnabled.Items.Foreground.Selected
- ' StateEnabled.Items.Foreground.Unselected
- ' StateEnabled.Items.Foreground.UnselectedAlternate
- ' StateDisabled.Items.Background.Selected
- ' StateDisabled.Items.Background.Unselected
- ' StateDisabled.Items.Background.UnselectedAlternate
- ' StateDisabled.Items.Foreground.Selected
- ' StateDisabled.Items.Foreground.Unselected
- ' StateDisabled.Items.Foreground.UnselectedAlternate
- ' StateReadOnly.Items.Background.Selected
- ' StateReadOnly.Items.Background.Unselected
- ' StateReadOnly.Items.Background.UnselectedAlternate
- ' StateReadOnly.Items.Foreground.Selected
- ' StateReadOnly.Items.Foreground.Unselected
- ' StateReadOnly.Items.Foreground.UnselectedAlternate
- #End Region
- #Region " Methods "
- ' HasDuplicatedItems
- ' RemoveDuplicatedItems
- ' MoveItem
- ' SetSelectedNoJump
- ' SetSelectedAllorNone
- #End Region
- #End Region
- #Region " Option Statements "
- Option Explicit On
- Option Strict On
- Option Infer Off
- #End Region
- #Region " Imports "
- Imports System.ComponentModel
- Imports System.Runtime.InteropServices
- Imports System.Drawing.Drawing2D
- #End Region
- #Region " ElektroListBox "
- Namespace UserControls
- ''' <summary>
- ''' A custom <see cref="T:ListBox"/> user control.
- ''' </summary>
- Public Class ElektroListBox : Inherits ListBox
- #Region " P/Invoking "
- ''' <summary>
- ''' Platform Invocation methods (P/Invoke), access unmanaged code.
- ''' This class does not suppress stack walks for unmanaged code permission.
- ''' <see cref="System.Security.SuppressUnmanagedCodeSecurityAttribute"/> must not be applied to this class.
- ''' This class is for methods that can be used anywhere because a stack walk will be performed.
- ''' MSDN Documentation: http://msdn.microsoft.com/en-us/library/ms182161.aspx
- ''' </summary>
- Protected Class NativeMethods
- #Region " Methods "
- ''' <summary>
- ''' Retrieves the device context (DC) for the entire window, including title bar, menus, and scroll bars.
- ''' A window device context permits painting anywhere in a window,
- ''' because the origin of the device context is the upper-left corner of the window instead of the client area.
- ''' GetWindowDC assigns default attributes to the window device context each time it retrieves the device context.
- ''' Previous attributes are lost.
- ''' MSDN Documentation: http://msdn.microsoft.com/es-es/library/windows/desktop/dd144947%28v=vs.85%29.aspx
- ''' </summary>
- ''' <param name="hWnd">
- ''' A handle to the window with a device context that is to be retrieved.
- ''' If this value is NULL, GetWindowDC retrieves the device context for the entire screen.
- ''' If this parameter is NULL, GetWindowDC retrieves the device context for the primary display monitor.
- ''' </param>
- ''' <returns>
- ''' If the function succeeds, the return value is a handle to a device context for the specified window.
- ''' If the function fails, the return value is <see cref="IntPtr.Zero"/>, indicating an error or an invalid hWnd parameter.
- ''' </returns>
- <DllImport("User32.dll")>
- Friend Shared Function GetWindowDC(
- ByVal hWnd As IntPtr
- ) As IntPtr
- End Function
- ''' <summary>
- ''' The ReleaseDC function releases a device context (DC), freeing it for use by other applications.
- ''' The effect of the ReleaseDC function depends on the type of DC. It frees only common and window DCs.
- ''' It has no effect on class or private DCs.
- ''' MSDN Documentation: http://msdn.microsoft.com/en-us/library/windows/desktop/dd162920%28v=vs.85%29.aspx
- ''' </summary>
- ''' <param name="hWnd">A handle to the window whose DC is to be released.</param>
- ''' <param name="hDC">A handle to the DC to be released.</param>
- ''' <returns><c>true</c> if the DC was released, <c>false</c> otherwise.</returns>
- <DllImport("user32.dll")>
- Friend Shared Function ReleaseDC(
- ByVal hWnd As IntPtr,
- ByVal hDC As IntPtr
- ) As <MarshalAs(UnmanagedType.Bool)> Boolean
- End Function
- ''' <summary>
- ''' Creates a rectangular region.
- ''' </summary>
- ''' <param name="lpRect">
- ''' Pointer to a <see cref="Rect"/> structure that contains the coordinates of the upper-left
- ''' and lower-right corners of the rectangle that defines the region in logical units.
- ''' MSDN Documentation: http://msdn.microsoft.com/en-us/library/windows/desktop/dd183515%28v=vs.85%29.aspx
- ''' </param>
- ''' <returns>
- ''' If the function succeeds, the return value is the handle to the region.
- ''' If the function fails, the return value is <see cref="IntPtr.Zero"/>.
- ''' </returns>
- <DllImport("gdi32.dll")>
- Friend Shared Function CreateRectRgnIndirect(
- ByRef lpRect As Rect
- ) As IntPtr
- End Function
- #End Region
- #Region " Structures "
- ''' <summary>
- ''' Defines the coordinates of the upper-left and lower-right corners of a rectangle.
- ''' MSDN Documentation: http://msdn.microsoft.com/en-us/library/windows/desktop/dd162897%28v=vs.85%29.aspx
- ''' </summary>
- <StructLayout(LayoutKind.Sequential)>
- Friend Structure Rect
- ''' <summary>
- ''' The x-coordinate of the upper-left corner of the rectangle.
- ''' </summary>
- Public Left As Integer
- ''' <summary>
- ''' The y-coordinate of the upper-left corner of the rectangle.
- ''' </summary>
- Public Top As Integer
- ''' <summary>
- ''' The x-coordinate of the lower-right corner of the rectangle.
- ''' </summary>
- Public Right As Integer
- ''' <summary>
- ''' The y-coordinate of the lower-right corner of the rectangle.
- ''' </summary>
- Public Bottom As Integer
- End Structure
- #End Region
- End Class
- #End Region
- #Region " Properties "
- ''' <summary>
- ''' Gets the enabled state's <see cref="T:StateLayout"/>.
- ''' </summary>
- ''' <value>The enabled state's <see cref="T:StateLayout"/>.</value>
- <Category("Appearance")>
- <Description("Enabled state.")>
- <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)>
- Public ReadOnly Property StateEnabled() As StateLayout
- Get
- Return Me.stateEnabled1
- End Get
- End Property
- ''' <summary>
- ''' The enabled state's <see cref="T:StateLayout"/>.
- ''' </summary>
- Private ReadOnly stateEnabled1 As StateLayout
- ''' <summary>
- ''' Gets the disabled state's <see cref="T:StateLayout"/>.
- ''' </summary>
- ''' <value>The disabled state's <see cref="T:StateLayout"/>.</value>
- <Category("Appearance")>
- <Description("Disabled state.")>
- <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)>
- Public ReadOnly Property StateDisabled() As StateLayout
- Get
- Return Me.stateDisabled1
- End Get
- End Property
- ''' <summary>
- ''' The disabled state's <see cref="T:StateLayout"/>.
- ''' </summary>
- Private ReadOnly stateDisabled1 As StateLayout
- ''' <summary>
- ''' Gets the readonly state's <see cref="T:StateLayout"/>.
- ''' </summary>
- ''' <value>The readonly state's <see cref="T:StateLayout"/>.</value>
- <Category("Appearance")>
- <Description("ReadOnly state.")>
- <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)>
- Public ReadOnly Property StateReadOnly() As StateLayout
- Get
- Return Me.stateReadOnly1
- End Get
- End Property
- ''' <summary>
- ''' The readonly state's <see cref="T:StateLayout"/>.
- ''' </summary>
- Private ReadOnly stateReadOnly1 As StateLayout
- ''' <summary>
- ''' Gets or sets a value indicating whether the Listbox is in ReadOnly mode.
- ''' </summary>
- <Category("Behavior")>
- <Description("When enabling ReadOnly mode, the control is not selectable.")>
- Public Property [ReadOnly]() As Boolean
- Get
- Return Me.readOnly1
- End Get
- Set(ByVal value As Boolean)
- If Not Me.readOnly1 = value Then
- Me.readOnly1 = value
- Me.NotifyStateChanged(PropertyName.State)
- End If
- End Set
- End Property
- ''' <summary>
- ''' A value indicating whether the Listbox is in ReadOnly mode.
- ''' </summary>
- Private readOnly1 As Boolean
- ''' <summary>
- ''' Gets or sets the cursor that is displayed when the mouse pointer is over the control.
- ''' </summary>
- ''' <value>The cursor that is displayed when the mouse pointer is over the control.</value>
- ''' <PermissionSet>
- ''' <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
- ''' <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
- ''' <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
- ''' <IPermission class="System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
- ''' </PermissionSet>
- <Category("Appearance")>
- <Description("The cursor that appears when the pointer moves over the control.")>
- <Browsable(False)>
- <EditorBrowsableAttribute(EditorBrowsableState.Never)>
- <DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)>
- Public Overrides Property Cursor As Cursor = Cursors.Default
- ''' <summary>
- ''' Gets or sets the drawing mode for the control.
- ''' </summary>
- ''' <value>The drawing mode for the control.</value>
- ''' <PermissionSet>
- ''' <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
- ''' <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
- ''' <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
- ''' <IPermission class="System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
- ''' </PermissionSet>
- <Category("Behavior")>
- <Description("Controls the listbox painting.")>
- <Browsable(False)>
- <EditorBrowsableAttribute(EditorBrowsableState.Never)>
- <DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)>
- Public Overrides Property DrawMode As DrawMode
- Get
- Return Windows.Forms.DrawMode.OwnerDrawVariable
- End Get
- Set(ByVal value As DrawMode)
- Exit Property
- End Set
- End Property
- ''' <summary>
- ''' Gets or sets the height of an item in the <see cref="T:ElektroListBox"/>.
- ''' </summary>
- ''' <value>The height of an item in the <see cref="T:ElektroListBox"/>..</value>
- ''' <PermissionSet>
- ''' <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
- ''' <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
- ''' <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
- ''' <IPermission class="System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
- ''' </PermissionSet>
- <Category("Appearance")>
- <Description("The height of an item.")>
- <Browsable(True)>
- <EditorBrowsableAttribute(EditorBrowsableState.Always)>
- <DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)>
- Public Overrides Property ItemHeight As Integer
- Get
- Return MyBase.ItemHeight
- End Get
- Set(ByVal value As Integer)
- MyBase.ItemHeight = value
- MyBase.RefreshItems()
- End Set
- End Property
- ''' <summary>
- ''' Gets the text format <see cref="T:StringFormatLayout"/>.
- ''' </summary>
- ''' <value>The text format <see cref="T:StringFormatLayout"/>.</value>
- <Category("Appearance")>
- <Description("The text formatting.")>
- <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)>
- public ReadOnly Property TextFormat As StringFormatLayout
- Get
- Return Me.textFormat1
- End Get
- End Property
- ''' <summary>
- ''' The text format <see cref="T:StringFormatLayout"/>.
- ''' </summary>
- Private ReadOnly textFormat1 As StringFormatLayout
- #End Region
- #Region " Constructors "
- ''' <summary>
- ''' Initializes a new instance of the <see cref="T:ElektroListBox"/> class.
- ''' </summary>
- Public Sub New()
- MyBase.DoubleBuffered = True
- MyBase.DrawMode = Windows.Forms.DrawMode.OwnerDrawFixed
- MyBase.SetStyle(ControlStyles.SupportsTransparentBackColor, False)
- Me.stateDisabled1 = New StateLayout(Me)
- Me.stateEnabled1 = New StateLayout(Me)
- Me.stateReadOnly1 = New StateLayout(Me)
- Me.textFormat1 = New StringFormatLayout(Me)
- End Sub
- #End Region
- #Region " Types "
- #Region " StateLayout "
- ''' <summary>
- ''' Describes an state layout.
- ''' </summary>
- <ToolboxItem(False)>
- Public NotInheritable Class StateLayout : Inherits Component
- #Region " Properties "
- ''' <summary>
- ''' Gets the <see cref="T:ElektroListBox"/>.
- ''' </summary>
- ''' <value>The <see cref="T:ElektroListBox"/>.</value>
- Protected Property ListBox() As ElektroListBox
- ''' <summary>
- ''' Gets the foreground layout.
- ''' </summary>
- ''' <value>The foreground layout.</value>
- <Category("Appearance")>
- <Description("The item foreground.")>
- <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)>
- Public ReadOnly Property Items As ItemLayout
- Get
- Return Me.items1
- End Get
- End Property
- ''' <summary>
- ''' The foreground layout.
- ''' </summary>
- Private ReadOnly items1 As ItemLayout
- ''' <summary>
- ''' Gets the cursor that appears when the pointer moves over the control.
- ''' </summary>
- ''' <value>The cursor that appears when the pointer moves over the control.</value>
- <Category("Appearance")>
- <Description("The cursor that appears when the pointer moves over the control.")>
- <DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)>
- Public Property Cursor As Cursor
- Get
- Return Me.cursor1
- End Get
- Set(ByVal value As Cursor)
- Me.cursor1 = value
- Me.ListBox.NotifyStateChanged(PropertyName.Cursor)
- End Set
- End Property
- ''' <summary>
- ''' The cursor that appears when the pointer moves over the control.
- ''' </summary>
- Private cursor1 As Cursor = Cursors.Default
- ''' <summary>
- ''' Gets or sets the border color.
- ''' </summary>
- ''' <value>The border color.</value>
- <Category("Appearance")>
- Public Property BorderColor() As Color
- Get
- Return borderColor1
- End Get
- Set(ByVal value As Color)
- Me.borderColor1 = value
- Me.ListBox.NotifyStateChanged(PropertyName.BorderColor)
- End Set
- End Property
- ''' <summary>
- ''' The border color.
- ''' </summary>
- Private borderColor1 As Color = SystemColors.ControlDark
- ''' <summary>
- ''' Gets the foreground layout.
- ''' </summary>
- ''' <value>The foreground layout.</value>
- <Category("Appearance")>
- <Description("The item foreground.")>
- <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)>
- Public ReadOnly Property Grid As GridLayout
- Get
- Return Me.grid1
- End Get
- End Property
- ''' <summary>
- ''' The foreground layout.
- ''' </summary>
- Private ReadOnly grid1 As GridLayout
- #End Region
- #Region " Constructors "
- ''' <summary>
- ''' Initializes a new instance of the <see cref="T:StateLayout"/> class.
- ''' </summary>
- ''' <param name="listBox">The <see cref="T:ElektroListBox"/>.</param>
- Public Sub New(ByVal listBox As ElektroListBox)
- Me.ListBox = listBox
- Me.items1 = New ItemLayout(ListBox)
- Me.grid1 = New GridLayout(ListBox)
- End Sub
- #End Region
- #Region " Hidden Members "
- ''' <summary>
- ''' Retrieves the current lifetime service object that controls the lifetime policy for this instance.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Function GetLifeTimeService() As Object
- Return MyBase.GetLifetimeService
- End Function
- ''' <summary>
- ''' Obtains a lifetime service object to control the lifetime policy for this instance.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Function InitializeLifeTimeService() As Object
- Return MyBase.InitializeLifetimeService
- End Function
- ''' <summary>
- ''' Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Function CreateObjRef(requestedType As Type) As System.Runtime.Remoting.ObjRef
- Return MyBase.CreateObjRef(requestedType)
- End Function
- ''' <summary>
- ''' Serves as a hash function for a particular type.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Function GetHashCode() As Integer
- Return MyBase.GetHashCode
- End Function
- ''' <summary>
- ''' Determines whether the specified System.Object instances are considered equal.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Function Equals(ByVal obj As Object) As Boolean
- Return MyBase.Equals(obj)
- End Function
- ''' <summary>
- ''' Determines whether the specified System.Object instances are the same instance.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Private Shadows Sub ReferenceEquals()
- End Sub
- ''' <summary>
- ''' Returns a String that represents the current object.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Function ToString() As String
- Return MyBase.ToString
- End Function
- ''' <summary>
- ''' Gets the System.Type of the current instance.
- ''' </summary>
- ''' <returns>The exact runtime type of the current instance.</returns>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Function [GetType]() As Type
- Return MyBase.GetType
- End Function
- ''' <summary>
- ''' Releases all resources used by the System.ComponentModel.Component.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Sub Dispose()
- MyBase.Dispose()
- End Sub
- ''' <summary>
- ''' Gets or sets the System.ComponentModel.ISite of the System.ComponentModel.Component.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Property Site As ISite = MyBase.site
- ''' <summary>
- ''' Gets the System.ComponentModel.IContainer that contains the System.ComponentModel.Component.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Property Container As IContainer = MyBase.container
- #End Region
- End Class
- #End Region
- #Region " ItemLayout "
- ''' <summary>
- ''' Describes an state layout.
- ''' </summary>
- <ToolboxItem(False)>
- Public NotInheritable Class ItemLayout : Inherits Component
- #Region " Properties "
- ''' <summary>
- ''' Gets the background layout.
- ''' </summary>
- ''' <value>The background layout.</value>
- <Category("Appearance")>
- <Description("The item background.")>
- <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)>
- Public ReadOnly Property Background As ItemLayoutColors
- Get
- Return Me.background1
- End Get
- End Property
- ''' <summary>
- ''' The background layout.
- ''' </summary>
- Private ReadOnly background1 As ItemLayoutColors
- ''' <summary>
- ''' Gets the foreground layout.
- ''' </summary>
- ''' <value>The foreground layout.</value>
- <Category("Appearance")>
- <Description("The item foreground.")>
- <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)>
- Public ReadOnly Property Foreground As ItemLayoutColors
- Get
- Return Me.foreground1
- End Get
- End Property
- ''' <summary>
- ''' The foreground layout.
- ''' </summary>
- Private ReadOnly foreground1 As ItemLayoutColors
- #End Region
- #Region " Constructors "
- ''' <summary>
- ''' Initializes a new instance of the <see cref="T:ItemLayout"/> class.
- ''' </summary>
- ''' <param name="listBox">The <see cref="T:ElektroListBox"/>.</param>
- ''' <exception cref="System.ArgumentNullException">layout</exception>
- Public Sub New(ByVal listBox As ElektroListBox)
- Me.background1 = New ItemLayoutColors(listBox) With
- {
- .Selected = SystemColors.Highlight,
- .Unselected = SystemColors.Window,
- .UnselectedAlternate = SystemColors.Window
- }
- Me.foreground1 = New ItemLayoutColors(listBox) With
- {
- .Selected = SystemColors.HighlightText,
- .Unselected = SystemColors.WindowText,
- .UnselectedAlternate = SystemColors.WindowText
- }
- End Sub
- #End Region
- #Region " Hidden Members "
- ''' <summary>
- ''' Retrieves the current lifetime service object that controls the lifetime policy for this instance.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Function GetLifeTimeService() As Object
- Return MyBase.GetLifetimeService
- End Function
- ''' <summary>
- ''' Obtains a lifetime service object to control the lifetime policy for this instance.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Function InitializeLifeTimeService() As Object
- Return MyBase.InitializeLifetimeService
- End Function
- ''' <summary>
- ''' Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Function CreateObjRef(requestedType As Type) As System.Runtime.Remoting.ObjRef
- Return MyBase.CreateObjRef(requestedType)
- End Function
- ''' <summary>
- ''' Serves as a hash function for a particular type.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Function GetHashCode() As Integer
- Return MyBase.GetHashCode
- End Function
- ''' <summary>
- ''' Determines whether the specified System.Object instances are considered equal.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Function Equals(ByVal obj As Object) As Boolean
- Return MyBase.Equals(obj)
- End Function
- ''' <summary>
- ''' Determines whether the specified System.Object instances are the same instance.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Private Shadows Sub ReferenceEquals()
- End Sub
- ''' <summary>
- ''' Returns a String that represents the current object.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Function ToString() As String
- Return MyBase.ToString
- End Function
- ''' <summary>
- ''' Gets the System.Type of the current instance.
- ''' </summary>
- ''' <returns>The exact runtime type of the current instance.</returns>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Function [GetType]() As Type
- Return MyBase.GetType
- End Function
- ''' <summary>
- ''' Releases all resources used by the System.ComponentModel.Component.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Sub Dispose()
- MyBase.Dispose()
- End Sub
- ''' <summary>
- ''' Gets or sets the System.ComponentModel.ISite of the System.ComponentModel.Component.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Property Site As ISite = MyBase.site
- ''' <summary>
- ''' Gets the System.ComponentModel.IContainer that contains the System.ComponentModel.Component.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Property Container As IContainer = MyBase.container
- #End Region
- End Class
- #End Region
- #Region " ItemLayoutColors "
- ''' <summary>
- ''' Describes an item layout colors.
- ''' </summary>
- <ToolboxItem(False)>
- Public NotInheritable Class ItemLayoutColors : Inherits Component
- #Region " Properties "
- ''' <summary>
- ''' Gets the <see cref="T:ElektroListBox"/>.
- ''' </summary>
- ''' <value>The <see cref="T:ElektroListBox"/>.</value>
- Protected Property ListBox() As ElektroListBox
- ''' <summary>
- ''' Gets or sets the selected color.
- ''' </summary>
- ''' <value>The selected color.</value>
- <Category("Appearance")>
- <Description("The background color for a selected item.")>
- Public Property Selected() As Color
- Get
- Return Me.selected1
- End Get
- Set(ByVal value As Color)
- If (value <> Me.selected1) Then
- Me.selected1 = value
- Me.ListBox.NotifyStateChanged(PropertyName.Selected)
- End If
- End Set
- End Property
- ''' <summary>
- ''' The selected color.
- ''' </summary>
- Private selected1 As Color
- ''' <summary>
- ''' Gets or sets the unselected color.
- ''' </summary>
- ''' <value>The unselected color.</value>
- <Category("Appearance")>
- <Description("The background color for a non selected item.")>
- Public Property Unselected() As Color
- Get
- Return Me.unselected1
- End Get
- Set(ByVal value As Color)
- If (value <> Me.unselected1) Then
- Me.unselected1 = value
- Me.ListBox.NotifyStateChanged(PropertyName.Unselected)
- End If
- End Set
- End Property
- ''' <summary>
- ''' The unselected color.
- ''' </summary>
- Private unselected1 As Color
- ''' <summary>
- ''' Gets or sets the alternate unselected color.
- ''' </summary>
- ''' <value>The alternate unselected color.</value>
- <Category("Appearance")>
- <Description("The alternate background color for a non selected item.")>
- Public Property UnselectedAlternate() As Color
- Get
- Return Me.unselectedAlternate1
- End Get
- Set(ByVal value As Color)
- If (value <> Me.unselectedAlternate1) Then
- Me.unselectedAlternate1 = value
- Me.ListBox.NotifyStateChanged(PropertyName.UnselectedAlternate)
- End If
- End Set
- End Property
- ''' <summary>
- ''' The alternate unselected color.
- ''' </summary>
- Private unselectedAlternate1 As Color
- #End Region
- #Region " Constructors "
- ''' <summary>
- ''' Initializes a new instance of the <see cref="T:ItemLayoutColors"/> class.
- ''' </summary>
- ''' <param name="listBox">The <see cref="T:ElektroListBox"/>.</param>
- ''' <exception cref="System.ArgumentNullException">layout</exception>
- Public Sub New(ByVal listBox As ElektroListBox)
- Me.ListBox = listBox
- End Sub
- #End Region
- #Region " Hidden Members "
- ''' <summary>
- ''' Retrieves the current lifetime service object that controls the lifetime policy for this instance.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Function GetLifeTimeService() As Object
- Return MyBase.GetLifetimeService
- End Function
- ''' <summary>
- ''' Obtains a lifetime service object to control the lifetime policy for this instance.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Function InitializeLifeTimeService() As Object
- Return MyBase.InitializeLifetimeService
- End Function
- ''' <summary>
- ''' Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Function CreateObjRef(requestedType As Type) As System.Runtime.Remoting.ObjRef
- Return MyBase.CreateObjRef(requestedType)
- End Function
- ''' <summary>
- ''' Serves as a hash function for a particular type.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Function GetHashCode() As Integer
- Return MyBase.GetHashCode
- End Function
- ''' <summary>
- ''' Determines whether the specified System.Object instances are considered equal.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Function Equals(ByVal obj As Object) As Boolean
- Return MyBase.Equals(obj)
- End Function
- ''' <summary>
- ''' Determines whether the specified System.Object instances are the same instance.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Private Shadows Sub ReferenceEquals()
- End Sub
- ''' <summary>
- ''' Returns a String that represents the current object.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Function ToString() As String
- Return MyBase.ToString
- End Function
- ''' <summary>
- ''' Gets the System.Type of the current instance.
- ''' </summary>
- ''' <returns>The exact runtime type of the current instance.</returns>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Function [GetType]() As Type
- Return MyBase.GetType
- End Function
- ''' <summary>
- ''' Releases all resources used by the System.ComponentModel.Component.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Sub Dispose()
- MyBase.Dispose()
- End Sub
- ''' <summary>
- ''' Gets or sets the System.ComponentModel.ISite of the System.ComponentModel.Component.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Property Site As ISite = MyBase.site
- ''' <summary>
- ''' Gets the System.ComponentModel.IContainer that contains the System.ComponentModel.Component.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Property Container As IContainer = MyBase.container
- #End Region
- End Class
- #End Region
- #Region " StringFormatLayout "
- ''' <summary>
- ''' Describes an StringFormat layout.
- ''' </summary>
- <ToolboxItem(False)>
- Public NotInheritable Class StringFormatLayout : Inherits Component
- #Region " Properties "
- ''' <summary>
- ''' Gets the <see cref="T:ElektroListBox"/>.
- ''' </summary>
- ''' <value>The <see cref="T:ElektroListBox"/>.</value>
- Protected Property ListBox() As ElektroListBox
- ''' <summary>
- ''' Gets or sets the alignment of a text string relative to its layout rectangle.
- ''' </summary>
- ''' <value>The alignment of a text string relative to its layout rectangle.</value>
- <Category("Appearance")>
- <Description("The alignment of a text string relative to its layout rectangle.")>
- <Browsable(True)>
- <EditorBrowsable(EditorBrowsableState.Always)>
- <DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)>
- Public Property Alignment As StringAlignment
- Get
- Return Me.alignment1
- End Get
- Set(ByVal value As StringAlignment)
- Me.alignment1 = value
- Me.ListBox.NotifyStateChanged(PropertyName.StringFormat)
- End Set
- End Property
- ''' <summary>
- ''' The alignment of a text string relative to its layout rectangle.
- ''' </summary>
- Private alignment1 As StringAlignment = StringAlignment.Near
- ''' <summary>
- ''' Gets or sets the alignment of a text string relative to its layout rectangle.
- ''' </summary>
- ''' <value>The alignment of a text string relative to its layout rectangle.</value>
- <Category("Appearance")>
- <Description("The alignment of a text string relative to its layout rectangle.")>
- <Browsable(True)>
- <EditorBrowsable(EditorBrowsableState.Always)>
- <DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)>
- Public Property LineAlignment As StringAlignment
- Get
- Return Me.lineAlignment1
- End Get
- Set(ByVal value As StringAlignment)
- Me.lineAlignment1 = value
- Me.ListBox.NotifyStateChanged(PropertyName.StringFormat)
- End Set
- End Property
- ''' <summary>
- ''' The alignment of a text string relative to its layout rectangle.
- ''' </summary>
- Private lineAlignment1 As StringAlignment = StringAlignment.Center
- ''' <summary>
- ''' Gets or sets a value indicating how to trim characters from a string that does not completely fit into a layout shape.
- ''' </summary>
- ''' <value>A value indicating how to trim characters from a string that does not completely fit into a layout shape.</value>
- <Category("Appearance")>
- <Description("Specifies how to trim characters from a string that does not completely fit into a layout shape.")>
- <Browsable(True)>
- <EditorBrowsable(EditorBrowsableState.Always)>
- <DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)>
- Public Property Trimming As StringTrimming
- Get
- Return Me.trimming1
- End Get
- Set(ByVal value As StringTrimming)
- Me.trimming1 = value
- Me.ListBox.NotifyStateChanged(PropertyName.StringFormat)
- End Set
- End Property
- ''' <summary>
- ''' A value indicating how to trim characters from a string that does not completely fit into a layout shape.
- ''' </summary>
- Private trimming1 As StringTrimming = StringTrimming.None
- ''' <summary>
- ''' Gets or sets the display and layout information for text strings.
- ''' </summary>
- ''' <value>The display and layout information for text strings.</value>
- <Category("Appearance")>
- <Description("Specifies the display and layout information for text strings.")>
- <Browsable(True)>
- <EditorBrowsable(EditorBrowsableState.Always)>
- <DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)>
- Public Property FormatFlags As StringFormatFlags
- Get
- Return Me.formatFlags1
- End Get
- Set(ByVal value As StringFormatFlags)
- Me.formatFlags1 = value
- Me.ListBox.NotifyStateChanged(PropertyName.StringFormat)
- End Set
- End Property
- ''' <summary>
- ''' The display and layout information for text strings
- ''' </summary>
- Private formatFlags1 As StringFormatFlags = StringFormatFlags.NoWrap
- #End Region
- #Region " Constructors "
- ''' <summary>
- ''' Initializes a new instance of the <see cref="T:StateLayout"/> class.
- ''' </summary>
- ''' <param name="listBox">The <see cref="T:ElektroListBox"/>.</param>
- Public Sub New(ByVal listBox As ElektroListBox)
- Me.ListBox = listBox
- End Sub
- #End Region
- #Region " Hidden Members "
- ''' <summary>
- ''' Retrieves the current lifetime service object that controls the lifetime policy for this instance.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Function GetLifeTimeService() As Object
- Return MyBase.GetLifetimeService
- End Function
- ''' <summary>
- ''' Obtains a lifetime service object to control the lifetime policy for this instance.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Function InitializeLifeTimeService() As Object
- Return MyBase.InitializeLifetimeService
- End Function
- ''' <summary>
- ''' Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Function CreateObjRef(requestedType As Type) As System.Runtime.Remoting.ObjRef
- Return MyBase.CreateObjRef(requestedType)
- End Function
- ''' <summary>
- ''' Serves as a hash function for a particular type.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Function GetHashCode() As Integer
- Return MyBase.GetHashCode
- End Function
- ''' <summary>
- ''' Determines whether the specified System.Object instances are considered equal.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Function Equals(ByVal obj As Object) As Boolean
- Return MyBase.Equals(obj)
- End Function
- ''' <summary>
- ''' Determines whether the specified System.Object instances are the same instance.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Private Shadows Sub ReferenceEquals()
- End Sub
- ''' <summary>
- ''' Returns a String that represents the current object.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Function ToString() As String
- Return MyBase.ToString
- End Function
- ''' <summary>
- ''' Gets the System.Type of the current instance.
- ''' </summary>
- ''' <returns>The exact runtime type of the current instance.</returns>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Function [GetType]() As Type
- Return MyBase.GetType
- End Function
- ''' <summary>
- ''' Releases all resources used by the System.ComponentModel.Component.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Sub Dispose()
- MyBase.Dispose()
- End Sub
- ''' <summary>
- ''' Gets or sets the System.ComponentModel.ISite of the System.ComponentModel.Component.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Property Site As ISite = MyBase.site
- ''' <summary>
- ''' Gets the System.ComponentModel.IContainer that contains the System.ComponentModel.Component.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Property Container As IContainer = MyBase.container
- #End Region
- End Class
- #End Region
- #Region " GridLayout "
- ''' <summary>
- ''' Describes a Grid layout.
- ''' </summary>
- <ToolboxItem(False)>
- Public NotInheritable Class GridLayout : Inherits Component
- #Region " Properties "
- ''' <summary>
- ''' Gets the <see cref="T:ElektroListBox"/>.
- ''' </summary>
- ''' <value>The <see cref="T:ElektroListBox"/>.</value>
- Protected Property ListBox() As ElektroListBox
- ''' <summary>
- ''' Gets or sets a value indicating whether grid lines drawing are enabled to separate items.
- ''' </summary>
- ''' <value>A value indicating whether grid lines drawing are enabled to separate items.</value>
- <Category("Appearance")>
- <Description("Enable or disable the grid lines.")>
- <Browsable(True)>
- <EditorBrowsable(EditorBrowsableState.Always)>
- <DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)>
- Public Property Enabled As Boolean
- Get
- Return Me.enabled1
- End Get
- Set(ByVal value As Boolean)
- Me.enabled1 = value
- Me.ListBox.NotifyStateChanged(PropertyName.Grid)
- End Set
- End Property
- ''' <summary>
- ''' A value indicating whether grid lines drawing are enabled to separate items.
- ''' </summary>
- Private enabled1 As Boolean = False
- ''' <summary>
- ''' Gets or sets the grid lines color.
- ''' </summary>
- ''' <value>The grid lines color.</value>
- <Category("Appearance")>
- <Description("The alignment of a text string relative to its layout rectangle.")>
- <Browsable(True)>
- <EditorBrowsable(EditorBrowsableState.Always)>
- <DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)>
- Public Property Color As Color
- Get
- Return Me.color1
- End Get
- Set(ByVal value As Color)
- Me.color1 = value
- Me.ListBox.NotifyStateChanged(PropertyName.Grid)
- End Set
- End Property
- ''' <summary>
- ''' The grid lines color.
- ''' </summary>
- Private color1 As Color = Color.Black
- #End Region
- #Region " Constructors "
- ''' <summary>
- ''' Initializes a new instance of the <see cref="T:GridLayout"/> class.
- ''' </summary>
- ''' <param name="listBox">The <see cref="T:ElektroListBox"/>.</param>
- Public Sub New(ByVal listBox As ElektroListBox)
- Me.ListBox = listBox
- End Sub
- #End Region
- #Region " Hidden Members "
- ''' <summary>
- ''' Retrieves the current lifetime service object that controls the lifetime policy for this instance.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Function GetLifeTimeService() As Object
- Return MyBase.GetLifetimeService
- End Function
- ''' <summary>
- ''' Obtains a lifetime service object to control the lifetime policy for this instance.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Function InitializeLifeTimeService() As Object
- Return MyBase.InitializeLifetimeService
- End Function
- ''' <summary>
- ''' Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Function CreateObjRef(requestedType As Type) As System.Runtime.Remoting.ObjRef
- Return MyBase.CreateObjRef(requestedType)
- End Function
- ''' <summary>
- ''' Serves as a hash function for a particular type.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Function GetHashCode() As Integer
- Return MyBase.GetHashCode
- End Function
- ''' <summary>
- ''' Determines whether the specified System.Object instances are considered equal.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Function Equals(ByVal obj As Object) As Boolean
- Return MyBase.Equals(obj)
- End Function
- ''' <summary>
- ''' Determines whether the specified System.Object instances are the same instance.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Private Shadows Sub ReferenceEquals()
- End Sub
- ''' <summary>
- ''' Returns a String that represents the current object.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Function ToString() As String
- Return MyBase.ToString
- End Function
- ''' <summary>
- ''' Gets the System.Type of the current instance.
- ''' </summary>
- ''' <returns>The exact runtime type of the current instance.</returns>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Function [GetType]() As Type
- Return MyBase.GetType
- End Function
- ''' <summary>
- ''' Releases all resources used by the System.ComponentModel.Component.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Sub Dispose()
- MyBase.Dispose()
- End Sub
- ''' <summary>
- ''' Gets or sets the System.ComponentModel.ISite of the System.ComponentModel.Component.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Property Site As ISite = MyBase.site
- ''' <summary>
- ''' Gets the System.ComponentModel.IContainer that contains the System.ComponentModel.Component.
- ''' </summary>
- <EditorBrowsable(EditorBrowsableState.Never)>
- Public Shadows Property Container As IContainer = MyBase.container
- #End Region
- End Class
- #End Region
- #End Region
- #Region " Enumerations "
- ''' <summary>
- ''' Specifies an <see cref="T:ElektroListBox"/> item state.
- ''' </summary>
- Public Enum ItemState As Integer
- ''' <summary>
- ''' Selects the listbox Item.
- ''' </summary>
- Selected = -&H1 ' True
- ''' <summary>
- ''' Unselects the listbox Item.
- ''' </summary>
- Unselected = &H0 ' False
- End Enum
- ''' <summary>
- ''' Indicates the <see cref="T:ElektroListBox"/> items to select.
- ''' </summary>
- Public Enum ListBoxItems As Integer
- ''' <summary>
- ''' Selects all the items.
- ''' </summary>
- All = -&H1 ' True
- ''' <summary>
- ''' Unselects all the items.
- ''' </summary>
- None = &H0 ' False
- End Enum
- ''' <summary>
- ''' Specifies a Windows Message.
- ''' </summary>
- Private Enum WindowsMessages As Integer
- ''' <summary>
- ''' Posted when the user presses the left mouse button while the cursor is in the client area of a window.
- ''' If the mouse is not captured, the message is posted to the window beneath the cursor.
- ''' Otherwise, the message is posted to the window that has captured the mouse.
- ''' MSDN Documentation: http://msdn.microsoft.com/es-es/library/windows/desktop/ms645607%28v=vs.85%29.aspx
- ''' </summary>
- WM_LBUTTONDOWN = &H201
- ''' <summary>
- ''' Posted to the window with the keyboard focus when a nonsystem key is pressed.
- ''' A nonsystem key is a key that is pressed when the ALT key is not pressed.
- ''' MSDN Documentation: http://msdn.microsoft.com/es-es/library/windows/desktop/ms646280%28v=vs.85%29.aspx
- ''' </summary>
- WM_KEYDOWN = &H100
- ' ''' <summary>
- ' ''' Sent when the system or another application makes a request to paint a portion of an application's window.
- ' ''' MSDN Documentation: http://msdn.microsoft.com/en-us/library/windows/desktop/dd145213%28v=vs.85%29.aspx
- ' ''' </summary>
- ' WM_PAINT = &HF
- ' ''' <summary>
- ' ''' Sent to a window when its frame must be painted.
- ' ''' MSDN Documentation: http://msdn.microsoft.com/en-us/library/windows/desktop/dd145212%28v=vs.85%29.aspx
- ' ''' </summary>
- WM_NCPAINT = &H85
- End Enum
- ''' <summary>
- ''' Specifies a property name of an the <see cref="T:ItemLayout"/>.
- ''' </summary>
- Private Enum PropertyName
- ''' <summary>
- ''' The selected item's color.
- ''' </summary>
- Selected
- ''' <summary>
- ''' The unselected item's color.
- ''' </summary>
- Unselected
- ''' <summary>
- ''' The unselected alternate item's color.
- ''' </summary>
- UnselectedAlternate
- ''' <summary>
- ''' The control's state (Enabled, Disabled, ReadOnly).
- ''' </summary>
- State
- ''' <summary>
- ''' The control's cursor.
- ''' </summary>
- Cursor
- ''' <summary>
- ''' The control's border color.
- ''' </summary>
- BorderColor
- ''' <summary>
- ''' The string formatting.
- ''' </summary>
- StringFormat
- ''' <summary>
- ''' The grid lines.
- ''' </summary>
- Grid
- End Enum
- #End Region
- #Region " Events "
- #End Region
- #Region " Public Methods "
- ''' <summary>
- ''' Returns a value indicating whether this <see cref="T:ElektroListBox"/> contains duplicated items.
- ''' </summary>
- Public Function HasDuplicatedItems() As Boolean
- Return CBool(Me.Items.Count - Me.Items.Cast(Of String).Distinct().Count)
- End Function
- ''' <summary>
- ''' Removes all duplicated items in this <see cref="T:ElektroListBox"/>.
- ''' </summary>
- Public Sub RemoveDuplicatedItems()
- If Me.HasDuplicatedItems() Then
- Dim items As IEnumerable(Of String) = Me.Items.Cast(Of String).Distinct()
- Me.Items.Clear()
- Me.Items.AddRange(items.ToArray)
- End If
- End Sub
- ''' <summary>
- ''' Selects or unselects a ListBox Item without jumping at Item position.
- ''' </summary>
- ''' <param name="ItemIndex">Indicates the index of the Item to set.</param>
- ''' <param name="ItemState">Indicates the state for the item.</param>
- ''' <exception cref="System.ArgumentOutOfRangeException">itemIndex</exception>
- Public Sub SetSelectedNoJump(ByVal itemIndex As Integer,
- ByVal itemState As ItemState)
- If (itemIndex > Me.Items.Count) Then
- Throw New ArgumentOutOfRangeException("itemIndex")
- End If
- Me.SetSelectedNoJump({itemIndex}, itemState)
- End Sub
- ''' <summary>
- ''' Selects or unselects ListBox Items without jumping at Item position.
- ''' </summary>
- ''' <param name="ItemIndex">Indicates the index of the Items to set.</param>
- ''' <param name="ItemState">Indicates the state for the items.</param>
- ''' <exception cref="System.ArgumentOutOfRangeException">itemIndex</exception>
- Public Sub SetSelectedNoJump(ByVal itemIndex As IEnumerable(Of Integer),
- ByVal itemState As ItemState)
- If itemIndex.Count = 0 Then
- Exit Sub
- ElseIf itemIndex.Max > Me.Items.Count Then
- Throw New ArgumentOutOfRangeException("itemIndex")
- End If
- ' Store the selected item index.
- Dim i As Integer = Me.TopIndex
- ' Disable drawing on control.
- Me.BeginUpdate()
- For Each index As Integer In itemIndex
- ' Select or Unselect the item.
- Me.SetSelected(index, CBool(itemState))
- Next index
- ' Jump to the previous selected item.
- Me.TopIndex = i
- ' Eenable drawing.
- Me.EndUpdate()
- End Sub
- ''' <summary>
- ''' Selects or unselects all the items in this <see cref="T:ElektroListBox"/>.
- ''' </summary>
- ''' <param name="ListBoxItems">Indicates the Items to select or unselect.</param>
- Public Sub SetSelectedAllorNone(ByVal listBoxItems As ListBoxItems)
- If ((Me.SelectedItems.Count = 0) AndAlso (listBoxItems = ElektroListBox.ListBoxItems.None)) _
- OrElse ((Me.SelectedItems.Count = Me.Items.Count) AndAlso (listBoxItems = ElektroListBox.ListBoxItems.All)) Then
- Exit Sub
- End If
- Me.SetSelectedNoJump(Enumerable.Range(0, Me.Items.Count), DirectCast(listBoxItems, ItemState))
- End Sub
- ''' <summary>
- ''' Moves an item to other position.
- ''' </summary>
- ''' <param name="oldIndex">The item index.</param>
- ''' <param name="newIndex">The new item index.</param>
- ''' <exception cref="System.ArgumentOutOfRangeException">oldIndex or newIndex</exception>
- Public Sub MoveItem(ByVal oldIndex As Integer, ByVal newIndex As Integer)
- Dim itemCount As Integer = Me.Items.Count
- If (oldIndex < itemCount) OrElse (oldIndex > itemCount) Then
- Throw New ArgumentOutOfRangeException("oldIndex")
- ElseIf (newIndex < itemCount) OrElse (newIndex > itemCount) Then
- Throw New ArgumentOutOfRangeException("newIndex")
- Else
- Dim oldItem As Object = Me.Items.Item(oldIndex)
- Dim newItem As Object = Me.Items.Item(newIndex)
- Me.Items.Item(oldIndex) = newItem
- Me.Items.Item(newIndex) = oldItem
- End If
- End Sub
- #End Region
- #Region " Private Methods "
- ''' <summary>
- ''' Gets the current state layout.
- ''' </summary>
- ''' <returns>StateLayout.</returns>
- Private Function GetStateLayout() As StateLayout
- If MyBase.Enabled AndAlso Not Me.[ReadOnly] Then ' Is Enabled
- Return Me.stateEnabled1
- ElseIf Not MyBase.Enabled Then ' Is Disabled
- Return Me.stateDisabled1
- ElseIf Me.[ReadOnly] Then ' Is ReadOnly
- Return Me.stateReadOnly1
- Else
- Return Nothing
- End If
- End Function
- ''' <summary>
- ''' Notifies a property change.
- ''' </summary>
- ''' <param name="propertyName">Name of the property.</param>
- Private Sub NotifyStateChanged(ByVal propertyName As PropertyName)
- #If DEBUG Then
- Debug.WriteLine(String.Format("[{0}]: Property state changed. Property name: {1}",
- Me.Name, propertyName.ToString))
- #End If
- Select Case propertyName
- Case ElektroListBox.PropertyName.Selected,
- ElektroListBox.PropertyName.Unselected,
- ElektroListBox.PropertyName.UnselectedAlternate,
- ElektroListBox.PropertyName.StringFormat,
- ElektroListBox.PropertyName.Grid
- Me.Invalidate(invalidateChildren:=False)
- Case ElektroListBox.PropertyName.State,
- ElektroListBox.PropertyName.Cursor
- Me.SetCursor()
- Me.DrawBorder(Nothing)
- Case ElektroListBox.PropertyName.BorderColor
- Me.DrawBorder(Nothing)
- End Select
- End Sub
- ''' <summary>
- ''' Sets the control's cursor.
- ''' </summary>
- Private Sub SetCursor()
- Me.Cursor = Me.GetStateLayout.Cursor
- End Sub
- ''' <summary>
- ''' Draws a border on the control's surface.
- ''' </summary>
- ''' <param name="m">The Windows <see cref="T:System.Windows.Forms.Message"/> to process.</param>
- Private Sub DrawBorder(Optional ByRef m As Message = Nothing)
- Dim handle As IntPtr = If(m <> Nothing,
- m.HWnd,
- Me.Handle)
- Dim HDC As IntPtr = NativeMethods.GetWindowDC(handle)
- Dim point As Point = Me.PointToScreen(New Point(0, 0))
- Dim rect As NativeMethods.Rect
- With rect
- .Left = point.X
- .Top = point.Y
- .Right = .Left + Me.Width - 4
- .Bottom = .Top + Me.Height - 4
- End With
- Dim region As IntPtr = NativeMethods.CreateRectRgnIndirect(rect)
- If hdc <> IntPtr.Zero Then
- Using g As Graphics = Graphics.FromHdc(hdc)
- g.CompositingQuality = CompositingQuality.Invalid
- g.SmoothingMode = SmoothingMode.None
- g.PixelOffsetMode = PixelOffsetMode.None
- g.InterpolationMode = InterpolationMode.NearestNeighbor
- Using p As New Pen(Me.GetStateLayout.BorderColor)
- g.DrawRectangle(p, 0, 0, Me.Width - p.Width, Me.Height - p.Width)
- End Using ' p
- End Using ' g
- If m <> Nothing Then
- m.WParam = region
- NativeMethods.ReleaseDC(handle, HDC)
- MyBase.WndProc(m) ' Call it to draw what it needs.
- Else
- NativeMethods.ReleaseDC(handle, HDC)
- End If
- End If
- End Sub
- ''' <summary>
- ''' Colorizes the <see cref="T:ElektroListBox"/>.
- ''' </summary>
- ''' <param name="e">The <see cref="DrawItemEventArgs"/> instance containing the event data.</param>
- Private Sub DrawItems(ByVal e As DrawItemEventArgs)
- If Not (Me.Items.Count <> 0) Then
- Exit Sub
- End If
- Dim state As StateLayout = Me.GetStateLayout
- Dim backColor As Color
- Dim foreColor As Color
- Dim gridLineColor As Color = Me.stateEnabled1.Grid.Color
- Dim gridEnabled As Boolean = Me.stateEnabled1.Grid.Enabled
- Dim alternate As Boolean = CBool(e.Index Mod 2 <> 0)
- If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then ' selected item
- backColor = state.Items.Background.Selected
- foreColor = state.Items.Foreground.Selected
- ElseIf (e.State And DrawItemState.Selected) = DrawItemState.None Then ' unselected item
- If alternate Then ' Alternate color
- backColor = state.Items.Background.UnselectedAlternate
- foreColor = state.Items.Foreground.UnselectedAlternate
- Else
- backColor = state.Items.Background.Unselected
- foreColor = state.Items.Foreground.Unselected
- End If
- End If
- With e
- .Graphics.CompositingQuality = CompositingQuality.Invalid
- .Graphics.SmoothingMode = SmoothingMode.None
- .Graphics.PixelOffsetMode = PixelOffsetMode.None
- .Graphics.InterpolationMode = InterpolationMode.NearestNeighbor
- ' .DrawBackground()
- Using backgroundBrush As New SolidBrush(backColor)
- ' Draw the item background.
- .Graphics.FillRectangle(backgroundBrush, e.Bounds)
- If gridEnabled Then ' Draw the item grid line.
- Using pen As New Pen(gridLineColor)
- .Graphics.CompositingQuality = CompositingQuality.Invalid
- .Graphics.SmoothingMode = SmoothingMode.None
- .Graphics.PixelOffsetMode = PixelOffsetMode.None
- .Graphics.InterpolationMode = InterpolationMode.NearestNeighbor
- If e.Index = 0 Then
- .Graphics.DrawLine(pen,
- New Point(e.Bounds.X, e.Bounds.Y - 1),
- New Point(e.Bounds.Right, e.Bounds.Top - 1))
- Else
- .Graphics.DrawLine(pen,
- New Point(e.Bounds.X, e.Bounds.Y),
- New Point(e.Bounds.Right, e.Bounds.Top))
- End If
- End Using ' pen
- End If ' gridEnabled
- End Using ' backgroundBrush
- ' Draw the item text.
- Using foregroundBrush As New SolidBrush(foreColor)
- .Graphics.DrawString(MyBase.GetItemText(MyBase.Items(e.Index)),
- e.Font,
- foregroundBrush,
- e.Bounds, New StringFormat With
- {
- .Alignment = Me.textFormat1.Alignment,
- .FormatFlags = Me.textFormat1.FormatFlags,
- .LineAlignment = Me.textFormat1.LineAlignment,
- .Trimming = Me.textFormat1.Trimming
- })
- End Using ' foregroundBrush
- ' Draw the item's focused rectangle.
- .DrawFocusRectangle()
- End With
- End Sub
- #End Region
- #Region " Event Handlers "
- ''' <summary>
- ''' Handles the <see cref="E:EnabledChanged"/> event of the <see cref="T:ElektroListBox"/> control.
- ''' </summary>
- ''' <param name="sender">The source of the event.</param>
- ''' <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
- Private Sub MyBase_EnabledChanged(ByVal sender As Object, ByVal e As EventArgs) _
- Handles MyBase.EnabledChanged
- Me.NotifyStateChanged(PropertyName.State)
- End Sub
- ''' <summary>
- ''' Handles the DrawItem event of the the <see cref="T:ElektroListBox"/>.
- ''' </summary>
- ''' <param name="sender">The source of the event.</param>
- ''' <param name="e">The <see cref="DrawItemEventArgs"/> instance containing the event data.</param>
- Private Sub MyBase_DrawItem(ByVal sender As Object, ByVal e As DrawItemEventArgs) _
- Handles MyBase.DrawItem
- Me.DrawItems(e)
- End Sub
- #End Region
- #Region " Windows Procedure "
- ''' <summary>
- ''' Processes messages for this window.
- ''' </summary>
- ''' <param name="m">The Windows <see cref="T:System.Windows.Forms.Message"/> to process.</param>
- Protected Overrides Sub WndProc(ByRef m As Message)
- Select Case m.Msg
- Case WindowsMessages.WM_LBUTTONDOWN, WindowsMessages.WM_KEYDOWN
- If Me.[ReadOnly] Then
- ' Disable left click or keyboard on the ListBox.
- Return
- End If
- Case WindowsMessages.WM_NCPAINT
- If Not Me.BorderStyle = Windows.Forms.BorderStyle.None Then
- Me.DrawBorder(m)
- End If
- Return
- End Select
- MyBase.WndProc(m)
- End Sub
- #End Region
- End Class
- End Namespace
- #End Region
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement