Attribute VB_Name = "modPalette"
Option Explicit

Public Sub sPaletteCustom_MouseMove(ByRef pbx As PictureBox, ByRef Button As Integer, ByRef Shift As Integer, ByRef X As Single, ByRef Y As Single)
Dim lngColor As Long
 
With pbx
    
    Select Case Button
    Case vbLeftButton:
        If objButtonDownMode = PaintBrush Then
            If fMouseFocusInPictureBox(pbx, X, Y) Then
                .BackColor = frmMDI.pbxColorSelected.BackColor
                .ToolTipText = frmMDI.pbxColorSelected.Tag
                .MouseIcon = frmMDI.pbxCursorPaintBrush.Picture
            Else
                If strLastSampleColor = vbNullString Then
                    .MouseIcon = frmMDI.pbxCursorInvalid.Picture
                Else
                    .BackColor = fColorHexBGRtoRGB(strLastSampleColor)
                    .ToolTipText = strLastSampleColor
                    .MouseIcon = frmMDI.pbxCursorPaintBrushUndo.Picture
                End If
            End If
        End If
    Case vbRightButton:
        If objButtonDownMode = EyeDropper Then
            If fMouseFocusInPictureBox(pbx, X, Y) Then
                If strLastSampleColor = vbNullString Then
                    .MouseIcon = frmMDI.pbxCursorInvalid.Picture
                Else
                    .MouseIcon = frmMDI.pbxCursorEyeDropper.Picture
                End If
            Else
                .MouseIcon = frmMDI.pbxCursorInvalid.Picture
            End If
        End If
    
    'Case Else: 'Nothing
    End Select
        
    If objButtonDownMode = Neutral Then
        If Not .ToolTipText = vbNullString Then
            Call pbxColorPreview_SetColor_HexBGR(.ToolTipText)
        End If
    End If
End With

End Sub

Public Sub sPaletteCustom_MouseDown(ByRef pbx As PictureBox, ByRef Button As Integer, ByRef Shift As Integer, ByRef X As Single, ByRef Y As Single)
    
With pbx
        
    Select Case Button
        Case vbLeftButton:
            If objButtonDownMode = Neutral Then
                strLastSampleColor = .ToolTipText
                .ToolTipText = frmMDI.pbxColorSelected.Tag
                .BackColor = frmMDI.pbxColorSelected.BackColor
                
                objButtonDownMode = PaintBrush
            End If
        Case vbRightButton:
            If objButtonDownMode = Neutral Then
                strLastSampleColor = .ToolTipText
                
                If .ToolTipText = vbNullString Then
                    .MouseIcon = frmMDI.pbxCursorInvalid.Picture
                Else
                    .MouseIcon = frmMDI.pbxCursorEyeDropper.Picture
                End If
                objButtonDownMode = EyeDropper
            End If
    End Select

End With
End Sub

Public Sub sPaletteCustom_MouseUp(ByRef pbx As PictureBox, ByRef Button As Integer, ByRef Shift As Integer, ByRef X As Single, ByRef Y As Single)
    
With pbx
    
    Select Case Button
    Case vbLeftButton:
        If objButtonDownMode = PaintBrush Then
            pbx.MouseIcon = frmMDI.pbxCursorPaintBrush.Picture
            objButtonDownMode = Neutral
        End If
        
    Case vbRightButton:
        If objButtonDownMode = EyeDropper Then
            If fMouseFocusInPictureBox(pbx, X, Y) Then
                If Not .ToolTipText = vbNullString Then
                    Call pbxColorSelected_SetColor_HexBGR(.ToolTipText)
                End If
                
            End If
            
            .MouseIcon = frmMDI.pbxCursorPaintBrush.Picture
            objButtonDownMode = Neutral
            
        End If
        
    End Select

End With

End Sub

Public Sub sPaletteCurrent_MouseMove(ByRef pbx As PictureBox, ByRef Button As Integer, ByRef Shift As Integer, ByRef X As Single, ByRef Y As Single)
On Error Resume Next

'Dim Red As Integer, Green As Integer, Blue As Integer
'Dim lngColor As Long

Dim strToolTipText As String

With pbx
    If objButtonDownMode = EyeDropper Then
        If fMouseFocusInPictureBox(pbx, X, Y) Then
            .MouseIcon = frmMDI.pbxCursorEyeDropper.Picture
            strToolTipText = .ToolTipText
            'lngColor = GetPixel(.hdc, X / Screen.TwipsPerPixelX, Y / Screen.TwipsPerPixelY)
        Else
            .MouseIcon = frmMDI.pbxCursorInvalid.Picture
            strToolTipText = vbNullString
        End If
    Else
        'lngColor = GetPixel(.hdc, X / Screen.TwipsPerPixelX, Y / Screen.TwipsPerPixelY)
        strToolTipText = .ToolTipText
    End If
    
    'If Not lngColor < 0 Then
    '     Call pbxColorPreview_SetColor(lngColor)
    If Not strToolTipText = vbNullString Then
         Call pbxColorPreview_SetColor_HexBGR(strToolTipText)
    End If

End With

End Sub

Public Sub sPaletteCurrent_MouseDown(ByRef pbx As PictureBox, ByRef Button As Integer, ByRef Shift As Integer, ByRef X As Single, ByRef Y As Single)
On Error GoTo Err_:

Select Case Button
    Case vbLeftButton:
        If objButtonDownMode = Neutral Then
            objButtonDownMode = PaintBrush
            pbx.MouseIcon = frmMDI.pbxCursorInvalid.Picture
        End If
    Case vbRightButton:
        If objButtonDownMode = Neutral Then
            objButtonDownMode = EyeDropper
        End If
End Select

Exit_:
Exit Sub

Err_:
fErrMessage Err.Number, Err.Description, "sColor_MouseDown"
Resume Next

End Sub

Public Sub sPaletteCurrent_MouseUp(ByRef pbx As PictureBox, ByRef Button As Integer, ByRef Shift As Integer, ByRef X As Single, ByRef Y As Single)
On Error GoTo Err_

With pbx
    Select Case Button
        Case vbLeftButton:
            If objButtonDownMode = PaintBrush Then
                .MouseIcon = frmMDI.pbxCursorEyeDropper.Picture
                objButtonDownMode = Neutral
            End If
        Case vbRightButton:
            If objButtonDownMode = EyeDropper Then
                If fMouseFocusInPictureBox(pbx, X, Y) Then
                    'Call pbxColorSelected_SetColor(.BackColor)
                    Call pbxColorSelected_SetColor_HexBGR(.ToolTipText)
                End If
                .MouseIcon = frmMDI.pbxCursorEyeDropper.Picture
                objButtonDownMode = Neutral
            End If
    End Select
End With

Exit_:
Exit Sub

Err_:
fErrMessage Err.Number, Err.Description, "Mouse_Up"
Resume Next

End Sub

