' - - - - - - - - - - - - -
' - - - - - - - - - - - - -
' (著作權聲明) Copyright Statement:
' Copyright 2000-2009, SoftHuman Corporation. All rights reserved.
' 善解科技股份有限公司
' 著作權 2000-2009。版權所有,保留一切權利。
'
' (本段程式之目的) Purpose:
' Object of this class can help you to report the X and Y coordinates of the mouse tip clicking on the
' surface of a Windows.Form.PictureBox control.
'
' (友善的模組名稱) Friendly name of this module:
' SHColorPicker_2009-0322.WJPictureBoxHelper_Y2009M03D22
'
' Code Name of this Visual Basic 2003 Windows Form Application:
' (程式用模組名稱) Code name of this module:
' SHColorPicker_2009-0322.WJPictureBoxHelper_Y2009M03D22
' - - - - - - - - - - - - -
' - - - - - - - - - - - - -
' Version 1.00.03; Last Updated on [2009-03-22-PM-02-18-37]
' The following functionalities are ready in this version:
' Public Function RGBColorOfThePixelPointedByMouseTip() As System.Drawing.Color
' Public Function RGBValueOfThePixelPointedByMouseTip() As Integer
'
' Version 1.00.02; Last Updated on [2009-03-22-PM-01-53-12]
' The following functionalities are ready in this version:
' Public Sub Enable_Handling_MouseMove_Event()
' Public Sub Disable_Handling_MouseMove_Event()
' Public ReadOnly Property X_CoordinateOfMouseTip() As Integer
' Public ReadOnly Property Y_CoordinateOfMouseTip() As Integer
'
' Version 1.00.01; Last Updated on [2009-03-22-MM-12-49-49]
' - - - - - - - - - - - - -
' - - - - - - - - - - - - -
' (本段程式是否已經在被使用中) In use: Yes
' (程式撰寫的進度) Developing: 100% (Mandatory)
' (程式堪用的程度) Workable: 80% (Threshold at 80%)
' (程式的測試程度) Code tested: 80% (max 99%)
' - - - - - - - - - - - - -
' - - - - - - - - - - - - -
Public Class WJPictureBoxHelper_Y2009M03D22
' - - - - - - - - - - - - -
' - - - - - - - - - - - - -
Public Delegate Sub ReportMouseTipCoordinates_Delegate(ByVal X As Integer, ByVal Y As Integer)
Private m_ReportMouseTipCoordinates_Delegate As WJPictureBoxHelper_Y2009M03D22.ReportMouseTipCoordinates_Delegate = Nothing
Private WithEvents m_PictureBox As Windows.Forms.PictureBox = Nothing
Private m_flagHandle_MouseMove_Event As Boolean = True
Private m_PositionOfMouseTip As Point
Private m_X_CoordinateOfMouseTip As Integer
Private m_Y_CoordinateOfMouseTip As Integer
' - - - - - - - - - - - - -
' - - - - - - - - - - - - -
Public Sub Enable_Handling_MouseMove_Event()
' OK
Me.m_flagHandle_MouseMove_Event = True
End Sub
' - - - - - - - - - - - - -
' - - - - - - - - - - - - -
Public Sub Disable_Handling_MouseMove_Event()
' OK
Me.m_flagHandle_MouseMove_Event = False
End Sub
' - - - - - - - - - - - - -
' - - - - - - - - - - - - -
Public ReadOnly Property X_CoordinateOfMouseTip() As Integer
' OK
Get
Return Me.m_X_CoordinateOfMouseTip
End Get
End Property
' - - - - - - - - - - - - -
' - - - - - - - - - - - - -
Public ReadOnly Property Y_CoordinateOfMouseTip() As Integer
' OK
Get
Return Me.m_Y_CoordinateOfMouseTip
End Get
End Property
' - - - - - - - - - - - - -
' - - - - - - - - - - - - -
Public Function GetTestingResultAsOneString() As String
' OK, but with ongoing nature
Dim SB As New System.Text.StringBuilder
With SB
.Append(vbNewLine)
.Append(vbNewLine)
.Append("Me.X_CoordinateOfMouseTip = ")
' .Append(vbNewLine)
.Append(Me.X_CoordinateOfMouseTip)
.Append(vbNewLine)
.Append(vbNewLine)
.Append("Me.Y_CoordinateOfMouseTip = ")
' .Append(vbNewLine)
.Append(Me.Y_CoordinateOfMouseTip)
.Append(vbNewLine)
'.Append(vbNewLine)
'.Append(vbNewLine)
End With
Return SB.ToString
'Return "Me.X_CoordinateOfMouseTip =" & Me.X_CoordinateOfMouseTip & "," & "Me._CoordinateOfMouseTip =" & Me.Y_CoordinateOfMouseTip
End Function
' - - - - - - - - - - - - -
' - - - - - - - - - - - - -
Public Sub New(ByVal AnyPictureBox As System.Windows.Forms.PictureBox, ByVal D As WJPictureBoxHelper_Y2009M03D22.ReportMouseTipCoordinates_Delegate)
' OK
Me.m_PictureBox = AnyPictureBox
Me.m_ReportMouseTipCoordinates_Delegate = D
End Sub
' - - - - - - - - - - - - -
' - - - - - - - - - - - - -
Private Sub m_PictureBox_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles m_PictureBox.MouseDown
' OK
' MsgBox("into m_PictureBox_MouseDown")
If Me.m_flagHandle_MouseMove_Event Then
' wjTeach: wjKnowHow:
' Me.m_PictureBox.PointToClient(Cursor.Position)
'
' Search Microsoft related web sites using Google
' http://www.google.com/microsoft
'
Me.m_PositionOfMouseTip = Me.m_PictureBox.PointToClient(Cursor.Position)
'Dim X_CoordinateOfMouseTip As Integer
'Dim Y_CoordinateOfMouseTip As Integer
With Me.m_PositionOfMouseTip
Me.m_X_CoordinateOfMouseTip = .X
Me.m_Y_CoordinateOfMouseTip = .Y
End With
' wjKeyStep:
Me.m_ReportMouseTipCoordinates_Delegate(Me.X_CoordinateOfMouseTip, Me.Y_CoordinateOfMouseTip)
'MsgBox("me.GetTestingResultAsOneString = " & Me.GetTestingResultAsOneString)
Else
Exit Sub
End If
End Sub
' - - - - - - - - - - - - -
' - - - - - - - - - - - - -
Public Function RGBColorOfThePixelPointedByMouseTip() As System.Drawing.Color
' OK
Dim ImageWidth As Integer
Dim ImageHeight As Integer
Dim BMP As System.Drawing.Bitmap
BMP = Me.m_PictureBox.Image
ImageWidth = BMP.Width
ImageHeight = BMP.Height
Dim C As System.Drawing.Color
'Dim C_DefaultColor As System.Drawing.Color = System.Drawing.Color.Black
If Me.X_CoordinateOfMouseTip > ImageWidth Or Me.Y_CoordinateOfMouseTip > ImageHeight Then
'C = C_DefaultColor
C = Me.m_PictureBox.BackColor
Else
C = BMP.GetPixel(Me.X_CoordinateOfMouseTip, Me.Y_CoordinateOfMouseTip)
End If
Return C
End Function
' - - - - - - - - - - - - -
' - - - - - - - - - - - - -
Public Function RGBValueOfThePixelPointedByMouseTip() As Integer
' OK
Return Me.RGBColorOfThePixelPointedByMouseTip.ToArgb
End Function
' - - - - - - - - - - - - -
' - - - - - - - - - - - - -
Public Function RValueGValueAndBValueOfThePixelPointedByMouseTip() As String
' OK
Dim C As System.Drawing.Color
C = Me.RGBColorOfThePixelPointedByMouseTip
Dim SB As New System.Text.StringBuilder
With SB
.Append("R = ")
.Append(CType(C.R, Integer))
.Append(vbNewLine)
.Append("G = ")
.Append(CType(C.G, Integer))
.Append(vbNewLine)
.Append("B = ")
.Append(CType(C.B, Integer))
.Append(vbNewLine)
'.Append(vbNewLine)
'.Append(vbNewLine)
End With
Return SB.ToString
End Function
' - - - - - - - - - - - - -
' - - - - - - - - - - - - -
End Class ' WJPictureBoxHelper_Y2009M03D22
沒有留言:
張貼留言