Option Strict Off
Option Explicit On
Imports System.Windows.Forms
'------------------------------------ 2023/11/09 ------------------------------------
Friend Class 屲clsPctFilesListDRAG

#Region "愰尵"
    Public m嵟弶偺儕僗僩慖戰帪偺僼傽僀儖儔儀儖偺摿暿側攚宨怓 As Integer = -1 'Not Set 
    Private mDblClick, mMoseDownInCurBox As Boolean
    Private OldX, mFileDragStartID, mFileDragDropID, OldY As Integer
    Private cListColX, cListMax, cListItemWDHT As Integer
    Private cFrameDrawDo As Boolean
    Private c嵟弶偺儕僗僩傕堏摦偱偒傞, c僼傽僀儖柤攝楍傪巊梡偡傞, c傾僀僐儞儕僗僩儌乕僪 As Boolean
    Private mPct嵗昗僘儗X As Integer = 0, mPct嵗昗僘儗Y As Integer = 0
#End Region

#Region "娭悢"
    '仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠
    Friend Function aaStartSet(ByRef r傾僀僐儞儕僗僩儌乕僪 As Boolean, ByRef rListMax As Integer, ByRef rListColX As Integer, ByRef rListItemWDHT As Integer, _
                        ByRef rFrameDrawDo As Boolean, ByRef r僼傽僀儖柤攝楍傪巊梡偡傞 As Boolean, ByRef r嵟弶偺儕僗僩傕堏摦偱偒傞 As Boolean, _
                        ByVal rPct嵗昗僘儗X As Integer, ByVal rPct嵗昗僘儗Y As Integer) As Boolean
        aaStartSet = False
        c傾僀僐儞儕僗僩儌乕僪 = r傾僀僐儞儕僗僩儌乕僪
        cListMax = rListMax
        cListColX = rListColX
        cListItemWDHT = rListItemWDHT
        cFrameDrawDo = rFrameDrawDo
        c僼傽僀儖柤攝楍傪巊梡偡傞 = r僼傽僀儖柤攝楍傪巊梡偡傞
        c嵟弶偺儕僗僩傕堏摦偱偒傞 = r嵟弶偺儕僗僩傕堏摦偱偒傞
        '2022/05/08 add
        mPct嵗昗僘儗X = rPct嵗昗僘儗X
        mPct嵗昗僘儗Y = rPct嵗昗僘儗Y
        aaStartSet = True
    End Function
    '仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠
    Friend Sub pctList_DblClick()
        mDblClick = True
    End Sub
    '仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠
    Friend Sub pctList_MouseDown(ByRef MouseButtonsButton As Integer, ByRef X As Integer, ByRef Y As Integer, ByRef mFileRects() As RECT, ByRef rwCurList As Integer)
        mDblClick = False
        gggint = zz嘳儅僂僗僀儀儞僩専嵏2022(gcoMsDown, MouseButtonsButton, X, Y, 1, 1, 6, 6)
        mMoseDownInCurBox = (MouseButtonsButton = MouseButtons.Left) And 嘳Rect撪偵XY嵗昗偑偁傞(X, Y, mFileRects(rwCurList))
        mFileDragStartID = 0 : mFileDragDropID = 0
    End Sub
    '仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠
    Friend Sub pctList_MouseMove(ByRef MouseButtonsButton As Integer, ByRef X As Integer, ByRef Y As Integer, _
                                 ByRef pctList As PictureBox, ByRef pctDrag As PictureBox, ByRef mFileRects() As RECT, ByRef rwCurList As Integer)
        Dim a As Integer
        If MouseButtonsButton <> 0 Then
            If zz嘳儅僂僗僀儀儞僩専嵏2022(gcoMsMove, MouseButtonsButton, X, Y, 1, 1, 6, 6) Then
                If pctDrag IsNot Nothing Then
                    If pctDrag.Visible = False Then
                        If mMoseDownInCurBox Then
                            mMoseDownInCurBox = False
                            a = rwCurList
                            If (a > 1 Or c嵟弶偺儕僗僩傕堏摦偱偒傞) Then
                                Dim wwhh As Integer
                                If c傾僀僐儞儕僗僩儌乕僪 Then
                                    wwhh = cListItemWDHT + 10
                                    pctDrag.SetBounds(mPct嵗昗僘儗X + mFileRects(a).lll, mPct嵗昗僘儗Y + mFileRects(a).ttt - 6, wwhh, wwhh)
                                    gggbol = 嘳Image_僒僀僘僠僃僢僋_堎側傟偽嵞嶌惉_怓偱怓傝偮傇偡(pctDrag.Image, wwhh, wwhh, &HFF0060&)
                                    gggbol = 嘳Image_Image_Copy(pctDrag.Image, pctList.Image, 4, 4, cListItemWDHT + 2, cListItemWDHT + 2, mFileRects(a).lll - 1, mFileRects(a).ttt - 1, -1, -1)
                                Else
                                    wwhh = cListItemWDHT + 11
                                    pctDrag.SetBounds(mPct嵗昗僘儗X + (mFileRects(a).lll - 5), mPct嵗昗僘儗Y + (mFileRects(a).ttt - 5), wwhh, wwhh)
                                    gggbol = 嘳Image_僒僀僘僠僃僢僋_堎側傟偽嵞嶌惉_怓偱怓傝偮傇偡(pctDrag.Image, wwhh, wwhh, &HFF0060&)
                                    gggbol = 嘳Image_Image_Copy(pctDrag.Image, pctList.Image, 5, 5, cListItemWDHT + 1, cListItemWDHT + 1, mFileRects(a).lll, mFileRects(a).ttt, -1, -1)
                                End If
                                pctDrag.Visible = True : OldX = X - (pctDrag.Left) : OldY = Y - (pctDrag.Top)
                                pctDrag.Refresh()
                                pctDrag.BringToFront()
                                pctDrag.Cursor = Cursors.SizeAll
                                mFileDragStartID = a
                                qqqqq("  pctDrag.Visible = True")
                            End If
                        End If
                    Else
                        pctDrag.SetBounds((X - OldX), (Y - OldY), 0, 0, Windows.Forms.BoundsSpecified.X Or Windows.Forms.BoundsSpecified.Y)
                    End If
                End If
            End If
        End If
    End Sub
    '仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠
    Friend Sub pctList_MouseUp(ByRef wRetIndex儅僂僗億僀儞僩 As Integer, ByRef MouseButtonsButton As Integer, ByRef X As Integer, ByRef Y As Integer, _
                    ByRef pctList As PictureBox, ByRef pctDrag As PictureBox, ByRef wakuClick As 屲clsWakuwaku, _
                    ByRef mFileRects() As RECT, ByRef rwCurList As Integer, ByRef rw僼傽僀儖柤攝楍() As String, _
                    ByRef wBmp曄峏嵪傒 As Boolean, Optional ByRef rwCurUseIDX As Integer = 0, Optional ByRef wakuCurUse As 屲clsWakuwaku = Nothing, _
                    Optional ByRef wMouseRightButtonUp As Boolean = False, Optional ByRef wDblClickAfterUp As Boolean = False, _
                    Optional ByRef wCurListChanged As Boolean = False, Optional ByRef wDragMoveDone As Boolean = False, _
                    Optional ByRef w僔僼僩stt As Integer = 0, Optional ByRef w僔僼僩stp As Integer = 0, Optional ByRef w僔僼僩stepnum As Integer = 0, _
                    Optional ByRef LabelFileName As Label = Nothing, Optional ByRef 尰嵼偺慖戰偑愭摢儕僗僩僀儞僨僢僋僗偱傕True傪曉偡 As Boolean = False)
        Dim b, a, ww As Integer
        Dim rc As RECT, 慖戰僼傽僀儖柤 As String = ""
        Dim MousePostOK As Boolean
        '-------------------------------------------
        wMouseRightButtonUp = False
        wDblClickAfterUp = False
        wCurListChanged = False
        wDragMoveDone = False
        '2022/07/02 add -------------------------
        wRetIndex儅僂僗億僀儞僩 = 0
        '----------------------------------------
        If mDblClick Or zz嘳儅僂僗僀儀儞僩専嵏2022(gcoMsUp, MouseButtonsButton, X, Y, 1, 1, 6, 6) Then
            For a = 1 To cListMax
                If 嘳Rect撪偵XY嵗昗偑偁傞(X, Y, mFileRects(a)) Then
                    '2022/07/02 add -------------------------
                    wRetIndex儅僂僗億僀儞僩 = a
                    '----------------------------------------
                    If rw僼傽僀儖柤攝楍(a) = "" Then
                    Else
                        gggint = CopyRect(rc, mFileRects(a))  '2022/07/22 僄儔乕偩偭偨偑丄挷傋偰傒傟偽丂CopyRect()丂偺栠傝抣偑丂Long丂偵側偭偰偄偨丅
                        ww = 嘳Rect暆(rc) + 11
                        If wakuClick IsNot Nothing Then
                            gggbol = wakuClick.aa_埵抲僒僀僘_Set(rc.lll - 5, pctList.Top + rc.ttt - 5, ww, ww, 0)
                        End If
                        wCurListChanged = (rwCurList <> a)
                        rwCurList = a
                        慖戰僼傽僀儖柤 = rw僼傽僀儖柤攝楍(a)
                    End If
                    Exit For
                End If
            Next
        ElseIf pctDrag.Visible = True Then
            For a = 1 To cListMax
                If 嘳Rect撪偵XY嵗昗偑偁傞(X, Y, mFileRects(a)) Then
                    '2022/07/02 add -------------------------
                    wRetIndex儅僂僗億僀儞僩 = a
                    '----------------------------------------
                    If (a > 1 Or c嵟弶偺儕僗僩傕堏摦偱偒傞) And rw僼傽僀儖柤攝楍(a) <> "" Then
                        mFileDragDropID = a
                        If (mFileDragStartID <> mFileDragDropID) And (rw僼傽僀儖柤攝楍(mFileDragStartID) <> "") And (rw僼傽僀儖柤攝楍(mFileDragDropID) <> "") Then
                            '-------------------------------------
                            慖戰僼傽僀儖柤 = rw僼傽僀儖柤攝楍(mFileDragStartID)
                            If mFileDragStartID < mFileDragDropID Then
                                w僔僼僩stt = mFileDragStartID : w僔僼僩stp = mFileDragDropID - 1 : w僔僼僩stepnum = 1
                            Else
                                w僔僼僩stt = mFileDragStartID : w僔僼僩stp = mFileDragDropID + 1 : w僔僼僩stepnum = -1
                            End If
                            gggint = aa僼傽僀儖儕僗僩僔僼僩堏摦(w僔僼僩stt, w僔僼僩stp, w僔僼僩stepnum, pctList, mFileRects, rw僼傽僀儖柤攝楍, rwCurUseIDX, wakuCurUse)
                            '-------------------------------------
                            b = mFileDragDropID
                            rw僼傽僀儖柤攝楍(b) = 慖戰僼傽僀儖柤
                            gggbol = 嘳Image_Image_Copy(pctList.Image, pctDrag.Image, mFileRects(b).lll, mFileRects(b).ttt, cListItemWDHT + 1, cListItemWDHT + 1, 5, 5, -1, -1)
                            pctList.Refresh()
                            wBmp曄峏嵪傒 = (wBmp曄峏嵪傒 Or True)
                            '-------------------------------------
                            mMoseDownInCurBox = False : mFileDragStartID = 0 : mFileDragDropID = 0
                            pctDrag.Visible = False
                            '-------------------------------------
                            gggbol = aa儅僂僗僀儀儞僩傪敪惗偝偣偰尰嵼偺儕僗僩傪愝掕(b, pctList, pctDrag, wakuClick, mFileRects, rwCurList, rw僼傽僀儖柤攝楍, wBmp曄峏嵪傒, rwCurUseIDX, wakuCurUse, LabelFileName)
                            '-------------------------------------
                            wDragMoveDone = True
                        End If
                    End If
                    Exit For
                End If
            Next
        End If
        If pctDrag.Visible = True Then pctDrag.Visible = False
        pctList.Cursor = Cursors.Default
        OldX = 0 : OldY = 0
        '---------------------------------------------------------------------
        If LabelFileName IsNot Nothing Then
            If m嵟弶偺儕僗僩慖戰帪偺僼傽僀儖儔儀儖偺摿暿側攚宨怓 >= 0 Then LabelFileName.BackColor = 嘳Color峔憿懱_from_怓抣(IIf(rwCurList = 1, m嵟弶偺儕僗僩慖戰帪偺僼傽僀儖儔儀儖偺摿暿側攚宨怓, &HFFFFFF))
            LabelFileName.Text = 慖戰僼傽僀儖柤
        End If
        '---------------------------------------------------------------------
        If (尰嵼偺慖戰偑愭摢儕僗僩僀儞僨僢僋僗偱傕True傪曉偡 Or rwCurList > 1) And rwCurList <= cListMax Then
            MousePostOK = 嘳Rect撪偵XY嵗昗偑偁傞(X, Y, mFileRects(rwCurList))
            If MouseButtonsButton = MouseButtons.Right Then
                wMouseRightButtonUp = True
            ElseIf 慖戰僼傽僀儖柤 <> "" And mDblClick And MousePostOK Then
                wDblClickAfterUp = True
            End If
        End If
        mDblClick = False
    End Sub
    '仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠
    Friend Function aa僼傽僀儖儕僗僩僔僼僩堏摦(ByRef stt As Integer, ByRef stp As Integer, ByRef stepnum As Integer, ByRef pctList As PictureBox, _
                        ByRef mFileRects() As RECT, ByRef rw僼傽僀儖柤攝楍() As String, Optional ByRef rwCurUseIDX As Integer = 0, Optional ByRef wakuCurUse As 屲clsWakuwaku = Nothing) As Boolean
        Dim oldrwCurUseIDX, a, ccc, nnn As Integer
        'qqqqq(CStr(rwCurUseIDX))
        oldrwCurUseIDX = rwCurUseIDX
        ccc = rwCurUseIDX
        If stp + stepnum = rwCurUseIDX Then
            rwCurUseIDX = stp
        ElseIf stt = rwCurUseIDX Then
            rwCurUseIDX = stp + stepnum
        End If
        For a = stt To stp Step stepnum
            If a = ccc And ccc = rwCurUseIDX Then
                rwCurUseIDX = rwCurUseIDX - stepnum
            End If
            nnn = a + stepnum
            If (stepnum > 0 And nnn <= UBound(rw僼傽僀儖柤攝楍)) Or (stepnum < 0 And nnn > 0) Then
                rw僼傽僀儖柤攝楍(a) = rw僼傽僀儖柤攝楍(nnn)
                gggbol = 嘳Image_Image_Copy(pctList.Image, pctList.Image, mFileRects(a).lll, mFileRects(a).ttt, cListItemWDHT, cListItemWDHT, mFileRects(nnn).lll, mFileRects(nnn).ttt, -1, -1)
            End If
            '2019/07/30 delete  榞偵儁儞偑昁梫側偺偱偙偺昤夋偼偱偒側偄  If cFrameDrawDo Then GGGint = 嘳昤夋挿曽宍榞_慄暆巜掕(pctList.hDC, mFileRects(a), 1)
        Next
        If (oldrwCurUseIDX <> rwCurUseIDX) And (wakuCurUse IsNot Nothing) Then
            gggint = aaCurUseIDX_僙儖榞愝掕(pctList, mFileRects(rwCurUseIDX), wakuCurUse)
        End If
        Return True
    End Function
    '仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠
    Friend Function aa儅僂僗僀儀儞僩傪敪惗偝偣偰尰嵼偺儕僗僩傪愝掕(ByRef idx As Integer, ByRef pctList As PictureBox, ByRef pctDrag As PictureBox, ByRef wakuClick As 屲clsWakuwaku, _
                        ByRef mFileRects() As RECT, ByRef rwCurList As Integer, ByRef rw僼傽僀儖柤攝楍() As String, _
                        ByRef wBmp曄峏嵪傒 As Boolean, Optional ByRef rwCurUseIDX As Integer = 0, Optional ByRef wakuCurUse As 屲clsWakuwaku = Nothing, Optional ByRef LabelFileName As Label = Nothing) As Boolean
        pctDrag.Visible = False
        Dim wRetIndex儅僂僗億僀儞僩 As Integer = 0
        Call pctList_MouseDown((MouseButtons.Left), mFileRects(idx).lll + 5, mFileRects(idx).ttt + 5, mFileRects, rwCurList)
        Call pctList_MouseUp(wRetIndex儅僂僗億僀儞僩, (MouseButtons.Left), mFileRects(idx).lll + 5, mFileRects(idx).ttt + 5, pctList, pctDrag, wakuClick, mFileRects, rwCurList, rw僼傽僀儖柤攝楍, wBmp曄峏嵪傒, rwCurUseIDX, wakuCurUse, , , , , , , , LabelFileName)
        Return True
    End Function
    '仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠
    Friend Function aaCurUseIDX_僙儖榞愝掕(ByRef pctList As PictureBox, ByRef rc As RECT, ByRef wakuCurUse As 屲clsWakuwaku) As Boolean
        aaCurUseIDX_僙儖榞愝掕 = False
        Dim bb, n, aa, ww As Integer
        ww = 嘳Rect暆(rc) : n = ww \ 16 : aa = n \ 2 : bb = aa * 2 - 2
        Select Case ww
            Case 88, 125, 150 : bb = bb + 1
        End Select
        If Not wakuCurUse Is Nothing Then
            gggbol = wakuCurUse.aa_埵抲僒僀僘_Set(rc.lll, pctList.Top + rc.ttt, ww + 1, ww + 1, 0)
        End If
        aaCurUseIDX_僙儖榞愝掕 = True
    End Function
    '仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠
    Function zz嘳儅僂僗僀儀儞僩専嵏2022(ByRef gcoMsDown_gcoMsMove_gcoMsUp As Integer, ByRef MouseButtonsButton As Integer, ByRef X As Integer, ByRef Y As Integer, _
                                 ByRef MoveShiftX As Integer, ByRef MoveShiftY As Integer, ByRef UpShiftX As Integer, ByRef UpShiftY As Integer, Optional ByRef wIsMoveDownToUp As Boolean = False) As Boolean
        '-----------------------------------------------------------------------------------------------------------------------------
        '2021/03/19
        '-----------------------------------------------------------------------------------------------------------------------------
        'Boolean = 嘳儅僂僗僀儀儞僩専嵏2018(gcoMsDown_gcoMsMove_gcoMsUp, Index, Button, X, Y, @MoveShiftX, @MoveShiftY, @UpShiftX, @UpShiftY, wIsMoveDownToUp)
        '-----------------------------------------------------------------------------------------------------------------------------
        'MoveShiftX ...... UpShiftY丂斖埻偺堷悢偼丄僗働乕儖儌乕僪偵傛傝揔愗側抣傪愝掕偡傞丅
        '-----------------------------------------------------------------------------------------------------------------------------
        '儅僂僗儉乕僽偺帪揰偱偼丄儅僂僗僪儔僢僌偑幚峴偝傟丄X 偐 Y 偑慜夞傛傝丂MoveShiftX / MoveShiftY丂埲忋摦偄偰偄傟偽丄True丂傪曉偡丅
        '-----------------------------------------------------------------------------------------------------------------------------
        '儅僂僗傾僢僾偺帪揰偱偼丄X 偲 Y 偑 儅僂僗僟僂儞帪傛傝丂UpShiftX / UpShiftY丂偺斖埻埲撪偵偁傞応崌偵偺傒丂True丂傪曉偡丅
        '-----------------------------------------------------------------------------------------------------------------------------
        'wIsMoveDownToUp丂儅僂僗僟僂儞帪偲斾妑偟偰丄X 偐 Y 偑丂UpShiftX / UpShiftY丂偺斖埻撪傪墇偊偰堏摦偡傟偽丂True丂傪曉偡丅
        '-----------------------------------------------------------------------------------------------------------------------------
        Dim 儕僞儞 As Boolean = False
        Static MsDown As Boolean : Static DnX As Integer : Static DnY As Integer : Static DnBtn As Integer : Static MvX As Integer : Static MvY As Integer
        wIsMoveDownToUp = False
        If (gcoMsDown = gcoMsDown_gcoMsMove_gcoMsUp) And (MsDown = False) Then
            MsDown = True : DnBtn = MouseButtonsButton : DnX = X : DnY = Y : MvX = X : MvY = Y
            儕僞儞 = (X >= 0 And Y >= 0)
        ElseIf (MsDown = True) And (DnBtn = MouseButtonsButton) Then
            If gcoMsMove = gcoMsDown_gcoMsMove_gcoMsUp Then
                儕僞儞 = (System.Math.Abs(MvX - X) >= MoveShiftX Or System.Math.Abs(MvY - Y) >= MoveShiftY)
                MvX = X : MvY = Y
                'If 儕僞儞 Then qqqqq("嘳儅僂僗僀儀儞僩専嵏2018 " + CStr(MvX))
            ElseIf gcoMsUp = gcoMsDown_gcoMsMove_gcoMsUp Then
                wIsMoveDownToUp = Not (System.Math.Abs(DnX - X) <= UpShiftX And System.Math.Abs(DnY - Y) <= UpShiftY)
                儕僞儞 = Not wIsMoveDownToUp
                GoTo DataClearExit
            Else
                GoTo DataClearExit
            End If
        Else
            GoTo DataClearExit
        End If
        Return 儕僞儞
        '----------------------------------------------------
DataClearExit:
        MsDown = False : DnBtn = -1 : DnX = -100000 : DnY = -100000 : MvX = -100000 : MvY = -100000
        Return 儕僞儞
    End Function
    '仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠仠
#End Region

End Class