Get all Known color and calcuate its Brightness and Saturation : Color « 2D « VB.Net

Home
VB.Net
1.2D
2.Application
3.Class
4.Data Structure
5.Data Types
6.Database ADO.net
7.Development
8.Event
9.File Directory
10.Generics
11.GUI
12.Language Basics
13.LINQ
14.Network Remote
15.Security
16.Thread
17.Windows Presentation Foundation
18.Windows System
19.XML
20.XML LINQ
VB.Net Tutorial
VB.Net by API
VB.Net » 2D » ColorScreenshots 
Get all Known color and calcuate its Brightness and Saturation
Get all Known color and calcuate its Brightness and Saturation

Imports System
Imports System.Drawing
Imports System.Windows.Forms
Imports System.IO


public class MainClass

   Shared Sub Main()
      Dim form1 As Form = New Form1
      Application.Run(form1)
   End Sub

End Class




Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is NothingThen
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents lstColors As System.Windows.Forms.ListBox
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents lblBrightness As System.Windows.Forms.Label
    Friend WithEvents lblHue As System.Windows.Forms.Label
    Friend WithEvents lblSaturation As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()Private Sub InitializeComponent()
        Me.lstColors = New System.Windows.Forms.ListBox()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.lblBrightness = New System.Windows.Forms.Label()
        Me.lblHue = New System.Windows.Forms.Label()
        Me.lblSaturation = New System.Windows.Forms.Label()
        Me.SuspendLayout()
        '
        'lstColors
        '
        Me.lstColors.Location = New System.Drawing.Point(1240)
        Me.lstColors.Name = "lstColors"
        Me.lstColors.Size = New System.Drawing.Size(200238)
        Me.lstColors.TabIndex = 0
        '
        'Label1
        '
        Me.Label1.BackColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.Label1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.Label1.FlatStyle = System.Windows.Forms.FlatStyle.System
        Me.Label1.Location = New System.Drawing.Point(1212)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(20020)
        Me.Label1.TabIndex = 1
        Me.Label1.Text = " Choose a Background Color:"
        '
        'lblBrightness
        '
        Me.lblBrightness.BackColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.lblBrightness.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.lblBrightness.FlatStyle = System.Windows.Forms.FlatStyle.System
        Me.lblBrightness.Location = New System.Drawing.Point(26812)
        Me.lblBrightness.Name = "lblBrightness"
        Me.lblBrightness.Size = New System.Drawing.Size(13620)
        Me.lblBrightness.TabIndex = 2
        Me.lblBrightness.Text = " Brightness"
        '
        'lblHue
        '
        Me.lblHue.BackColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.lblHue.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.lblHue.FlatStyle = System.Windows.Forms.FlatStyle.System
        Me.lblHue.Location = New System.Drawing.Point(26836)
        Me.lblHue.Name = "lblHue"
        Me.lblHue.Size = New System.Drawing.Size(13620)
        Me.lblHue.TabIndex = 3
        Me.lblHue.Text = " Hue"
        '
        'lblSaturation
        '
        Me.lblSaturation.BackColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.lblSaturation.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.lblSaturation.FlatStyle = System.Windows.Forms.FlatStyle.System
        Me.lblSaturation.Location = New System.Drawing.Point(26860)
        Me.lblSaturation.Name = "lblSaturation"
        Me.lblSaturation.Size = New System.Drawing.Size(13620)
        Me.lblSaturation.TabIndex = 4
        Me.lblSaturation.Text = " Saturation"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(514)
        Me.ClientSize = New System.Drawing.Size(436294)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.lblSaturation, Me.lblHue, Me.lblBrightness, Me.Label1, Me.lstColors})
        Me.Font = New System.Drawing.Font("Tahoma"8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Name = "Form1"
        Me.Text = "Color Changer"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgsHandles MyBase.Load
        Dim ColorNames() As String
        ColorNames = System.Enum.GetNames(GetType(KnownColor))

        lstColors.Items.AddRange(ColorNames)
    End Sub

    Private Sub lstColors_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgsHandles lstColors.SelectedIndexChanged
        Dim SelectedColor As KnownColor
        SelectedColor = System.Enum.Parse(GetType(KnownColor), lstColors.Text)
        Me.BackColor = System.Drawing.Color.FromKnownColor(SelectedColor)

        lblBrightness.Text = " Brightness = " & Me.BackColor.GetBrightness.ToString()
        lblHue.Text = " Hue = " & Me.BackColor.GetHue.ToString()
        lblSaturation.Text = " Saturation = " & Me.BackColor.GetSaturation.ToString()
    End Sub

End Class

           
       
Related examples in the same category
1.Track Form background ColorTrack Form background Color
2.Using different colors in Visual BasicUsing different colors in Visual Basic
3.Color Dialog: Changing the background and text colors of a formColor Dialog: Changing the background and text colors of a form
4.Construct Color from R G B ValueConstruct Color from R G B Value
5.Use color dialog to set form backgroundUse color dialog to set form background
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.