Visual Basic.NET - Visualizador de imágenes VB.net Cambio de lógica ayuda urgente

 
Vista:
sin imagen de perfil

Visualizador de imágenes VB.net Cambio de lógica ayuda urgente

Publicado por Victor (1 intervención) el 17/07/2017 21:45:03
Actualmente el visor de imágenes que tengo me lista las imágenes que tengo en una carpeta (la cual me toca elegir manual mente) en un listBox y me las muestra en un PictureBox pero quiero que la dirección la tome de una DB que tengo y que no le toque al usuario elegirla adjunto el código, Cabe destacar que la dirección la tengo en el Form1 y el visor en el Form2, para ´ponerlos en situación tengo una db en access con n clientes y cada uno tiene enlazado la dirección de una carpeta de imágenes la cual quiero que se me muestre en el visor anteriormente dicho cuando lo consulte

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
Option Explicit On
 
Imports System.IO
 
Public Class Form2
 
    ' Array extensiones para los archivos de imagenes
    Private Extension() As String = {"*.jpg", "*.bmp", "*.png",
                                      "*.ico", "*.gif", "*.wmf",
                                      "*.jpeg", "*.tif", "*.psd"}
 
    'LEEMOS LOS ARCHIVOS MEDIANTE EL USO DE FOLDERBROWSERDIALOG
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
            'creamos
            Dim obj As New FolderBrowserDialog
            With obj
 
                ' deshabilitamos el botón: "crear nueva carpeta"  
                .ShowNewFolderButton = False
 
                'ShowDialog
                If .ShowDialog = Windows.Forms.DialogResult.OK Then
                    ListBox1.Items.Clear()
 
                    'Recorremos
                    For Each Archivo As String In My.Computer.FileSystem.GetFiles(
                                  .SelectedPath,
                                       FileIO.SearchOption.SearchTopLevelOnly,
                                         Extension)
 
                        'Agregamos a la lista
                        ListBox1.Items.Add(Archivo)
                    Next
                End If
                Exit Sub
            End With
            '''''''''''''''''''''''''''''''
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
        Exit Sub
    End Sub
 
 
 
    'ACCEDEMOS A LOS ARCHIVOS MEDIANTE EL LISTBOX
    Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
 
 
        Try
            If File.Exists(ListBox1.Text) Then
                imagen.Image = Image.FromFile(ListBox1.Text)
                'Con fileInfo accedemos a la informacion del archivo actual
                Dim datos As New FileInfo(ListBox1.Text.ToString)
                Label1.Text = "Nombre: " & (datos.Name).ToString
                Label3.Text = "Extencion: " & (datos.Extension).ToString
                Label4.Text = "Tamaño: " & (CInt(datos.Length / 1024)).ToString & " KB"
                Label5.Text = "Ultima modificacion: " & (datos.LastWriteTime).ToString
                Label6.Text = "Ancho: " & imagen.Size.Width
                Label7.Text = "Alto: " & imagen.Size.Height
 
            End If
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
 
    End Sub
 
    'CONFIGURACION DE INICIO DE CONTROLES
    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            Panel1.AutoScroll = True
            Panel1.SetAutoScrollMargin(5, 5)
            Panel1.BackColor = Color.Black
 
            With imagen
                .Left = 5
                .Top = 5
                .SizeMode = PictureBoxSizeMode.Zoom
            End With
 
            ListBox1.HorizontalScrollbar = True
 
            With ComboBox1
                .Items.Add("AutoSize")
                .Items.Add("StretchImage")
                .Items.Add("Zoom")
                .Text = "AutoSize"
            End With
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
 
 
    End Sub
 
    Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
        Me.StartPosition = FormStartPosition.CenterScreen
    End Sub
    Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        End
    End Sub
 
    'OPCIONES PARA LOS DIFERENTES  SIZEMODE DEL PICTUREBOX
    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        Try
            If ComboBox1.Text = "AutoSize" Then
                imagen.SizeMode = PictureBoxSizeMode.AutoSize
            End If
            If ComboBox1.Text = "StretchImage" Then
                imagen.SizeMode = PictureBoxSizeMode.StretchImage
            End If
            If ComboBox1.Text = "Zoom" Then
                imagen.SizeMode = PictureBoxSizeMode.Zoom
            End If
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
 
End Class
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder