|
-
Dec 14th, 2009, 08:53 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Web Colour RGB Colour Picker Code
hi vb been making Web Colour /rgb colour picker plus code i cant get the panel to display the right colour being selected by the trackbar or imput boxes can you help me out here is the code
HTML Code:
Imports System.Windows.Forms
Imports System.Drawing
Imports System.Web
Imports System.Data
Imports System
Imports System.Deployment
Public Class WebColourRGB
#Region "Declarations"
Private mRed As Integer
Private mGreen As Integer
Private mBlue As Integer
#End Region
Private Sub WebColourRGB_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
mRed = 0
mGreen = 0
mBlue = 0
ColourPanelPreview.BackColor = System.Drawing.Color.FromArgb(mRed, mGreen, mBlue)
txtWebColor.Text = GetWebColor()
txtRGB.Text = "RGB(" & mRed & ", " & mGreen & ", " & mBlue & ")"
End Sub
Private Sub tbarRed_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RedTbar.Scroll
txtRed.Text = RedTbar.Value
mRed = RedTbar.Value
ColourPanelPreview.BackColor = System.Drawing.Color.FromArgb(mRed, mGreen, mBlue)
txtWebColor.Text = GetWebColor()
txtRGB.Text = "RGB(" & mRed & ", " & mGreen & ", " & mBlue & ")"
End Sub
Private Sub tbarGreen_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GreenTbar.Scroll
txtGreen.Text = GreenTbar.Value
mGreen = GreenTbar.Value
ColourPanelPreview.BackColor = System.Drawing.Color.FromArgb(mRed, mGreen, mBlue)
txtWebColor.Text = GetWebColor()
txtRGB.Text = "RGB(" & mRed & ", " & mGreen & ", " & mBlue & ")"
End Sub
Private Sub tbarBlue_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BlueTbar.Scroll
txtBlue.Text = BlueTbar.Value
mBlue = BlueTbar.Value
ColourPanelPreview.BackColor = System.Drawing.Color.FromArgb(mRed, mGreen, mBlue)
txtWebColor.Text = GetWebColor()
txtRGB.Text = "RGB(" & mRed & ", " & mGreen & ", " & mBlue & ")"
End Sub
Private Function GetWebColor() As String
Dim clr As Color
clr = Color.FromArgb(mRed, mGreen, mBlue)
Dim wc As String = ColorTranslator.ToHtml(clr).ToString()
Return wc
End Function
Private Sub txtRed_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtRed.KeyPress
If Char.IsNumber(e.KeyChar) Or e.KeyChar = ControlChars.Back Then
'ok, its a number so let it go
Else
e.KeyChar = Nothing
End If
End Sub
Private Sub txtRed_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtRed.TextChanged
Try
If (Convert.ToInt32(txtRed.Text) >= 0 And Convert.ToInt32(txtRed.Text) <= 255) Then
RedTbar.Value = Convert.ToInt32(txtRed.Text)
mRed = RedTbar.Value
ColourPanelPreview.BackColor = System.Drawing.Color.FromArgb(mRed, mGreen, mBlue)
txtWebColor.Text = GetWebColor()
txtRGB.Text = "RGB(" & mRed & ", " & mGreen & ", " & mBlue & ")"
Else
' input last valid number
txtRed.Text = mRed.ToString()
End If
Catch ex As Exception
'do nothing
End Try
End Sub
Private Sub txtGreen_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtGreen.KeyPress
If Char.IsNumber(e.KeyChar) Or e.KeyChar = ControlChars.Back Then
'ok, its a number so let it go
Else
e.KeyChar = Nothing
End If
End Sub
Private Sub txtGreen_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtGreen.TextChanged
Try
If (Convert.ToInt32(txtGreen.Text) >= 0 And Convert.ToInt32(txtGreen.Text) <= 255) Then
GreenTbar.Value = Convert.ToInt32(txtGreen.Text)
mGreen = GreenTbar.Value
ColourPanelPreview.BackColor = System.Drawing.Color.FromArgb(mRed, mGreen, mBlue)
txtWebColor.Text = GetWebColor()
txtRGB.Text = "RGB(" & mRed & ", " & mGreen & ", " & mBlue & ")"
Else
' input last valid number
txtGreen.Text = mGreen.ToString()
End If
Catch ex As Exception
'do nothing
End Try
End Sub
Private Sub txtBlue_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtBlue.KeyPress
If Char.IsNumber(e.KeyChar) Or e.KeyChar = ControlChars.Back Then
'ok, its a number so let it go
Else
e.KeyChar = Nothing
End If
End Sub
Private Sub txtBlue_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtBlue.TextChanged
Try
If (Convert.ToInt32(txtBlue.Text) >= 0 And Convert.ToInt32(txtBlue.Text) <= 255) Then
BlueTbar.Value = Convert.ToInt32(txtBlue.Text)
mBlue = BlueTbar.Value
ColourPanelPreview.BackColor = System.Drawing.Color.FromArgb(mRed, mGreen, mBlue)
txtWebColor.Text = GetWebColor()
txtRGB.Text = "RGB(" & mRed & ", " & mGreen & ", " & mBlue & ")"
Else
' input last valid number
txtBlue.Text = mBlue.ToString()
End If
Catch ex As Exception
'do nothing
End Try
End Sub
Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
Me.DialogResult = System.Windows.Forms.DialogResult.OK
Me.Close()
End Sub
Private Sub ColourPanelPreview_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles ColourPanelPreview.Paint
GetWebColor()
End Sub
End Class
-
Dec 14th, 2009, 08:54 PM
#2
Thread Starter
Addicted Member
Re: Web Colour RGB Colour Picker Code
hang on a min i think i know what ive done one min
-
Dec 14th, 2009, 09:00 PM
#3
Thread Starter
Addicted Member
Re: Web Colour RGB Colour Picker Code
nope i couldnt do it please help me
-
Dec 14th, 2009, 09:32 PM
#4
Thread Starter
Addicted Member
Re: Web Colour RGB Colour Picker Code
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|