Advanced Image Viewer in VB.Net


Advanced Image Viewer with source code:

                               (Screen Shot)
*****************************************
'Code from here
Public Class Form1
    Dim filepath As String
    Dim filename As String
    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        stopSlideShow = True
        Application.Exit()
    End Sub

    Private Sub btnOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim path As String
        OpenFileDialog1.Filter = "Image Files (*.jpg, *.jpeg, *.png, *bmp, *.gif|*.jpg; *.jpeg; *.png; *bmp; *.gif"
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            For Each path In OpenFileDialog1.FileNames
                If My.Computer.FileSystem.GetFileInfo(path).Extension.ToLower = ".jpg" Or _
                   My.Computer.FileSystem.GetFileInfo(path).Extension.ToLower = ".jpeg" Or _
                   My.Computer.FileSystem.GetFileInfo(path).Extension.ToLower = ".png" Or _
                       My.Computer.FileSystem.GetFileInfo(path).Extension.ToLower = ".bmp" Or _
                           My.Computer.FileSystem.GetFileInfo(path).Extension.ToLower = ".gif" Then
                    filename = My.Computer.FileSystem.GetName(path)
                    ListBox1.Items.Add(path)
                    ListBox1.SelectedIndex = 0
                    TextBox1.Text = ListBox1.SelectedItem
                End If
            Next
        End If
    End Sub

    Private Sub btnZoomIn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        PictureBox1.Height *= 1.5
        PictureBox1.Width *= 1.5
    End Sub

    Private Sub btnZoomOut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        PictureBox1.Height *= 0.5
        PictureBox1.Width *= 0.5
    End Sub

    Private Sub btnPrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        If ListBox1.SelectedIndex <= 0 Then
            Button2.Enabled = False
        Else
            ListBox1.SelectedIndex = ListBox1.SelectedIndex - 1
            Button3.Enabled = True
        End If
    End Sub

    Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        If ListBox1.SelectedIndex = ListBox1.Items.Count - 1 Then
            Button3.Enabled = False
        Else
            ListBox1.SelectedIndex = ListBox1.SelectedIndex + 1
            Button2.Enabled = True
        End If

    End Sub

    Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
        TextBox1.Text = ListBox1.SelectedItem
        PictureBox1.Load(TextBox1.Text)
    End Sub

    Private Sub btnRorateL_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Dim rotateImage As Image = New Bitmap(PictureBox1.Image)
        rotateImage.RotateFlip(RotateFlipType.Rotate90FlipX)
        PictureBox1.Image = rotateImage
    End Sub

    Private Sub btnRotateR_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Dim rotateImage As Image = New Bitmap(PictureBox1.Image)
        rotateImage.RotateFlip(RotateFlipType.Rotate270FlipY)
        PictureBox1.Image = rotateImage
    End Sub
    Dim slideDelay As Integer = 2000
    Dim stopSlideShow As Boolean = False
    Private Sub btnSlideShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
        Dim count As Integer = ListBox1.Items.Count
        If count <= 0 Then Exit Sub
        Dim start As Integer = ListBox1.SelectedIndex
        Do
            ListBox1.SelectedIndex = start
            pause(slideDelay)
            start += 1
            If start >= count Then
                start = 0
            End If
        Loop Until stopSlideShow
    End Sub
    Private Sub pause(ByVal delay As Integer)
        Dim s As Integer = Environment.TickCount
        Dim e As Integer = 0
        Do : My.Application.DoEvents()
            Threading.Thread.Sleep(1)
            e = Environment.TickCount
        Loop Until (e - s) >= delay
    End Sub

    Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
        stopSlideShow = True
    End Sub
End Class
********************* END Project *****************************

Comments

Popular posts from this blog

Complete Python Database Project with sqlite3

Complete StopWatch in Java with source code

System sound recorder using NAudio dll with complete code