T
TonyT1978Sweden
Guest
Hello, trying to learn as I go along but struggling with a project.
I am trying to create a Windows Form which will have up to 16 boxes in which will have pictures from the same directory with next/previous buttons. The aim is to be able to create a layout of pipe sections which the the user can configure. I currently use the 'FolderBrowserDialog' to select the directory but I want to set it up so the path to the pictures is there on start up.
Any help would be greatly appreciated. This what I have so far
Public Class Form1
Dim Filenames As List(Of String) = New List(Of String)
Dim Counter As Integer = 0
Private Sub launchbutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles launchbutton.Click
If FolderBrowserDialog1.ShowDialog() = DialogResult.OK Then
Filenames.AddRange(System.IO.Directory.GetFiles(FolderBrowserDialog1.SelectedPath, "*.jpg"))
Filenames.AddRange(System.IO.Directory.GetFiles(FolderBrowserDialog1.SelectedPath, "*.bmp"))
Filenames.AddRange(System.IO.Directory.GetFiles(FolderBrowserDialog1.SelectedPath, "*.png"))
If Filenames.Count > 1 Then PictureBox1.Load(Filenames(Counter))
If Filenames.Count > 1 Then PictureBox2.Load(Filenames(Counter))
If Filenames.Count > 1 Then PictureBox3.Load(Filenames(Counter))
If Filenames.Count > 1 Then PictureBox4.Load(Filenames(Counter))
End If
End Sub
Private Sub NextButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nextbutton1.Click
If Counter < Filenames.Count - 1 Then
Counter += 1
Else
Counter = 0
End If
PictureBox1.Load(Filenames(Counter))
End Sub
Private Sub PrevButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles previousbutton1.Click
If Counter > 0 Then
Counter -= 1
Else
Counter = Filenames.Count - 1
End If
PictureBox1.Load(Filenames(Counter))
End Sub
Private Sub NextButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nextbutton2.Click
If Counter < Filenames.Count - 1 Then
Counter += 1
Else
Counter = 0
End If
PictureBox2.Load(Filenames(Counter))
End Sub
Private Sub PrevButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles previousbutton2.Click
If Counter > 0 Then
Counter -= 1
Else
Counter = Filenames.Count - 1
End If
PictureBox2.Load(Filenames(Counter))
End Sub
Private Sub NextButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nextbutton3.Click
If Counter < Filenames.Count - 1 Then
Counter += 1
Else
Counter = 0
End If
PictureBox3.Load(Filenames(Counter))
End Sub
Private Sub PrevButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles previousbutton3.Click
If Counter > 0 Then
Counter -= 1
Else
Counter = Filenames.Count - 1
End If
PictureBox3.Load(Filenames(Counter))
End Sub
Private Sub NextButton4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nextbutton4.Click
If Counter < Filenames.Count - 1 Then
Counter += 1
Else
Counter = 0
End If
PictureBox4.Load(Filenames(Counter))
End Sub
Private Sub PrevButton4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles previousbutton4.Click
If Counter > 0 Then
Counter -= 1
Else
Counter = Filenames.Count - 1
End If
PictureBox4.Load(Filenames(Counter))
End Sub
End Class
Continue reading...
I am trying to create a Windows Form which will have up to 16 boxes in which will have pictures from the same directory with next/previous buttons. The aim is to be able to create a layout of pipe sections which the the user can configure. I currently use the 'FolderBrowserDialog' to select the directory but I want to set it up so the path to the pictures is there on start up.
Any help would be greatly appreciated. This what I have so far
Public Class Form1
Dim Filenames As List(Of String) = New List(Of String)
Dim Counter As Integer = 0
Private Sub launchbutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles launchbutton.Click
If FolderBrowserDialog1.ShowDialog() = DialogResult.OK Then
Filenames.AddRange(System.IO.Directory.GetFiles(FolderBrowserDialog1.SelectedPath, "*.jpg"))
Filenames.AddRange(System.IO.Directory.GetFiles(FolderBrowserDialog1.SelectedPath, "*.bmp"))
Filenames.AddRange(System.IO.Directory.GetFiles(FolderBrowserDialog1.SelectedPath, "*.png"))
If Filenames.Count > 1 Then PictureBox1.Load(Filenames(Counter))
If Filenames.Count > 1 Then PictureBox2.Load(Filenames(Counter))
If Filenames.Count > 1 Then PictureBox3.Load(Filenames(Counter))
If Filenames.Count > 1 Then PictureBox4.Load(Filenames(Counter))
End If
End Sub
Private Sub NextButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nextbutton1.Click
If Counter < Filenames.Count - 1 Then
Counter += 1
Else
Counter = 0
End If
PictureBox1.Load(Filenames(Counter))
End Sub
Private Sub PrevButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles previousbutton1.Click
If Counter > 0 Then
Counter -= 1
Else
Counter = Filenames.Count - 1
End If
PictureBox1.Load(Filenames(Counter))
End Sub
Private Sub NextButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nextbutton2.Click
If Counter < Filenames.Count - 1 Then
Counter += 1
Else
Counter = 0
End If
PictureBox2.Load(Filenames(Counter))
End Sub
Private Sub PrevButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles previousbutton2.Click
If Counter > 0 Then
Counter -= 1
Else
Counter = Filenames.Count - 1
End If
PictureBox2.Load(Filenames(Counter))
End Sub
Private Sub NextButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nextbutton3.Click
If Counter < Filenames.Count - 1 Then
Counter += 1
Else
Counter = 0
End If
PictureBox3.Load(Filenames(Counter))
End Sub
Private Sub PrevButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles previousbutton3.Click
If Counter > 0 Then
Counter -= 1
Else
Counter = Filenames.Count - 1
End If
PictureBox3.Load(Filenames(Counter))
End Sub
Private Sub NextButton4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nextbutton4.Click
If Counter < Filenames.Count - 1 Then
Counter += 1
Else
Counter = 0
End If
PictureBox4.Load(Filenames(Counter))
End Sub
Private Sub PrevButton4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles previousbutton4.Click
If Counter > 0 Then
Counter -= 1
Else
Counter = Filenames.Count - 1
End If
PictureBox4.Load(Filenames(Counter))
End Sub
End Class
Continue reading...