Dawang_FormMain(二)


    Private Sub Form1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.DoubleClick
        If IsFullMode Then
            WindowMode()
        Else
            FullMode()

        End If


        IsFullMode = Not IsFullMode

    End Sub
    Sub WindowMode()

        Me.Size = New Size(Screen.PrimaryScreen.Bounds.Width - 22, Screen.PrimaryScreen.Bounds.Height - 120)
        Me.CenterToScreen()

        ' Me.Location = New Point((Screen.PrimaryScreen.Bounds.Width - Me.Width) / 2, (Screen.PrimaryScreen.Bounds.Height - Me.Height) / 2)

    End Sub

 

 

 

    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LabelClose.Click
        Close()

    End Sub

    Dim thDownLoadPic As Thread
    Private Sub LabelView_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LabelView.Click


        '-------------------------------------------

        If Me.BaseURL Is Nothing Then

            MsgBox("请选择打望项")
            Exit Sub

        End If

 

        If IsNumeric(Me.PicIndexTextBox.Text) AndAlso 0 < Me.PicIndexTextBox.Text AndAlso Me.PicIndexTextBox.Text <= PicMaximum Then


            Me.BackgroundImage = Me.bgLightPic

 

 


            If File.Exists(strLocalPath & CInt(PicIndexTextBox.Text) & ".jpg") Then


                Me.BackgroundImage = Me.bgDarkPic

                showPic(strLocalPath & CInt(PicIndexTextBox.Text) & ".jpg", strLocalPath & CInt(PicIndexTextBox.Text) & ".jpg")
                Me.PicIndexTextBox.Text += 1
                If Me.AutoPlay Then
                    CanStartAutoPlay = True
                End If


                Exit Sub


            End If
            '-------------------------
            Me.LabelProgress.Visible = True

            Me.TimerDownLoad.Start()
            thDownLoadPic = New Thread(AddressOf downLoadPic)


            thDownLoadPic.Start()


        Else


            MsgBox("请输入数字且数字不能搜索超过本项的图片数量的最大值" & Me.PicMaximum)

 

        End If


    End Sub

 


    Dim BaseURL As String


    Delegate Sub dld()

 

 

 

    Sub downLoadPic()
        '    MsgBox(CStr(Me.PicIndexTextBox.Tag) & CInt(PicIndexTextBox.Text) & ".jpg")
        Try


            Dim myWebClient As New WebClient

            myWebClient.DownloadFile(BaseURL & Me.PicIndexTextBox.Text & ".jpg", strLocalPath & CInt(PicIndexTextBox.Text) & ".jpg")


            Me.Cmplete = True
            Me.CanStartAutoPlay = True

 

            'Me.PictureBoxShower.Image = Image.FromFile("Pictures/" & CInt(PicIndexTextBox.Text) & ".jpg")

            Me.BackgroundImage = bgDarkPic

 

 

 

 

        Catch ex As Exception

            Me.TimerDownLoad.Stop()
            Me.LabelProgress.Width = 0
            Me.BackgroundImage = Me.bgLightPic


            MsgBox("下载图片出错!" & BaseURL & Me.PicIndexTextBox.Text & ".jpg")


        End Try

        If thDownLoadPic.IsAlive Then

            thDownLoadPic.Abort()

        End If


        showPic(strLocalPath & CInt(PicIndexTextBox.Text) & ".jpg", strLocalPath & CInt(PicIndexTextBox.Text) & ".jpg")


        Me.PicIndexTextBox.Text += 1

        i += 1


    End Sub


    Dim fi As FileInfo

    Dim j As Integer
    Private Sub TimerDownLoad_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerDownLoad.Tick


        j += 1

        If Me.Cmplete = True Then

            Me.TimerDownLoad.Stop()
            Me.Cmplete = False
            Me.LabelProgress.Width = 0
            Me.LabelScan.Visible = False


        Else
            Me.LabelProgress.Width += 22

            Me.LabelScan.Visible = True
            If Me.LabelProgress.Width >= Screen.PrimaryScreen.Bounds.Width - 210 Then

                Me.LabelProgress.Width = 0

            End If

 


        End If


        '------------------------------------------


    End Sub

 


    Sub showPic(ByVal strPicPath As String, ByVal StrLocalPath As String)

 

 


        Me.PictureBoxShower.Image = Image.FromFile(strPicPath)


        Me.PictureBoxShower.Size = Me.PictureBoxShower.Image.Size

        Me.PictureBoxShower.Location = New Point((Me.Width - Me.PictureBoxShower.Width) / 2, (Me.Height - Me.PictureBoxShower.Height) / 2)
        Dim newPictureBox As New PictureBox


        With newPictureBox
            .Name = "newPictureBox" & wi
            .Image = Me.PictureBoxShower.Image

            .SizeMode = PictureBoxSizeMode.StretchImage
            .Height = Me.PaneBotoom.Height - 22
            .Width = .Height - 22
            .Top = 2
            .Left = smallPicSize.Width * wi
            .Tag = StrLocalPath
            .Cursor = Cursors.Hand

        End With
        Me.PaneBotoom.Controls.Add(newPictureBox)
        newPictureBox.Visible = True

        AddHandler newPictureBox.Click, AddressOf newPictureBox_Click
        AddHandler newPictureBox.DoubleClick, AddressOf newPictureBox_DoubleClick


        wi += 1

        If AutoPlay Then

            Me.TimerAutoPlay.Start()

        Else
            Exit Sub

        End If

 

    End Sub

    Sub newPictureBox_Click(ByVal sender As Object, ByVal e As EventArgs)

        Me.PictureBoxShower.Image = CType(sender, PictureBox).Image


    End Sub

    Sub newPictureBox_DoubleClick(ByVal sender As Object, ByVal e As EventArgs)
        Dim p As New Process

        MsgBox(Application.StartupPath & "/" & CStr(CType(sender, PictureBox).Tag))

        p.Start(Application.StartupPath.TrimEnd & "/" & CStr(CType(sender, PictureBox).Tag))

 


    End Sub

 


    Sub DoAutoPlay()

    End Sub
    '-------------------------------------------------------------

    Private Sub PicIndexTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PicIndexTextBox.TextChanged

        If IsNumeric(Me.PicIndexTextBox.Text) = False Then
            Try


            Catch ex As System.Exception

            End Try


        End If


    End Sub

 

    Private Sub TimerAutoPlay_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerAutoPlay.Tick


        If Me.AutoPlay Then

            If CanStartAutoPlay Then

                LabelView_Click(Nothing, Nothing)
                CanStartAutoPlay = False


            End If
        Else
            Me.TimerAutoPlay.Stop()

        End If

    End Sub


    Private Sub CheckBoxAutoPlay_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxAutoPlay.CheckedChanged

        Me.AutoPlay = Me.CheckBoxAutoPlay.Checked

 

 

    End Sub

    Private Sub PictureBoxShower_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBoxShower.Click

    End Sub

 

 

 

 


    '*****************************************
    Private oOriginalRegion As Region = Nothing
    ' 用于窗体移动
    Private bFormDragging As Boolean = False
    Private oPointClicked As Point

    '******************************************

    Private Sub PictureBoxShower_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBoxShower.MouseDown

        Me.bFormDragging = True
        Me.oPointClicked = New Point(e.X, e.Y)

    End Sub
    '******************************************

    Private Sub PictureBoxShower_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBoxShower.MouseUp
        Me.bFormDragging = False

    End Sub
    '******************************************

    Private Sub PictureBoxShower_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBoxShower.MouseMove
        If Me.bFormDragging Then
            Dim oMoveToPoint As Point
            ' 以当前鼠标位置为基础,找出目标位置
            oMoveToPoint = Me.PictureBoxShower.MousePosition


            ' 根据开始位置作出调整
            oMoveToPoint.Offset(Me.oPointClicked.X * -1, Me.oPointClicked.Y * -1)
            ' 移动窗体
            Me.PictureBoxShower.Location = oMoveToPoint


            Me.PictureBoxShower.Refresh()
        End If

    End Sub


    Private Sub tv_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles tv.AfterSelect

        LabelView.Enabled = True

        If e.Node.Text Like "http*" Then
            MsgBox("")
            Dim strSavePath As String = "Pictures/SearchPic/" & e.Node.Parent.Parent.Text & "/" & e.Node.Parent.Text
            If Directory.Exists(strSavePath) = False Then
                Directory.CreateDirectory(strSavePath)
            End If
        End If
        If (Not e.Node.Tag Is Nothing) AndAlso CType(e.Node.Tag(0), String).LastIndexOf("/") <> -1 Then

            Me.BaseURL = tv.SelectedNode.Tag(0)
            Me.PicMaximum = e.Node.Tag(1)

            If Me.PicIndexTextBox.Text = "" Then
                Me.PicIndexTextBox.Text = 1
            End If


            Me.LabelCurentSelect.Text = e.Node.Parent.Parent.Text & "-->" & e.Node.Parent.Text & "-->" & e.Node.Text

            strLocalPath = "Pictures/" & e.Node.Parent.Parent.Text & "/" & e.Node.Parent.Text & "/" & e.Node.Text & "/"


            If Directory.Exists(strLocalPath) = False Then


                Directory.CreateDirectory(strLocalPath)


            End If


        End If
    End Sub

    Private Sub Form2_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
        '------------------------------------

 

    End Sub
    Dim fa As FormAbout
    Private Sub LabelAbout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LabelAbout.Click

        fa = New FormAbout

        fa.Show()


    End Sub

    Private Sub LabelMini_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LabelMini.Click
        Me.WindowState = FormWindowState.Minimized

    End Sub

 


    Private Sub PaneBotoom_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PaneBotoom.Paint

    End Sub
End Class

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值