Bonjour à tous !
J'aurais besoin d'une aide sur la visualisation des petites images dans une listview avec la possibilité ou pas de voir le nom du fichier sous l'image!
Voici mon code actuel:
et la partie générant les fichier xml utilisé comme settings:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 Imports System Imports System.Drawing Imports System.ComponentModel Imports System.Windows.Forms Imports System.IO Public Class Slideshow Dim SDK As Object Private PluginSettings As cMySettings Private TempPluginSettings As cMySettings Private allowedExtensions() As String = {".gif", ".jpg", ".bmp", ".png"} ', ".tiff"} Private Sub Slideshow_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load If Not Directory.Exists(Application.StartupPath & "\Photo") Then Directory.CreateDirectory(Application.StartupPath & "\Photo") End If PluginSettings = New cMySettings(Path.Combine(Application.StartupPath, "SlideShow")) ' read in defaults cMySettings.DeseralizeFromXML(PluginSettings) ' copy to temp TempPluginSettings = New cMySettings(PluginSettings) 'SDK = CreateObject("RideRunner.SDK") mylist() End Sub Private Sub mylist() Dim imlTemp As New ImageList Dim dirFiles() As String = IO.Directory.GetFiles(Application.StartupPath & "\Photo") Dim _imgList As New ImageList Dim imgSize As New Size imgSize.Width = TempPluginSettings.PictureSize_X imgSize.Height = TempPluginSettings.PictureSize_Y _imgList.ColorDepth = ColorDepth.Depth32Bit ListView2.LargeImageList = _imgList Dim count As Integer = 0 Dim item As New ListViewItem For Each dirFile As String In dirFiles For Each extension As String In allowedExtensions If extension = IO.Path.GetExtension(dirFile) Then Dim img As New System.Drawing.Bitmap(dirFile) _imgList.ImageSize = imgSize _imgList.Images.Add(img) img.Dispose() ListView2.Items.Add(dirFile, count) count += 1 End If Next Next End Sub Private Sub listView2_MouseDown(sender As Object, e As MouseEventArgs) Handles ListView2.MouseDown Dim results = ListView2.HitTest(e.Location) If results.Item IsNot Nothing Then 'MessageBox.Show(Application.StartupPath & "\Photo") 'MessageBox.Show(results.Item.Text & vbCrLf & results.Location) Dim PicturePath As String = Path.GetDirectoryName(results.Item.Text) Dim PictureName As String = Path.GetFileName(results.Item.Text) SDK.Execute(TempPluginSettings.SendCommandToRR & PictureName) End If End Sub End Class
Le résultat donne ceci avec les parties entourées que je voudrais voir disparaître !
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 Option Strict Off Option Explicit On Imports System.IO Imports System.Xml Imports System.Xml.Serialization Imports System.Text Public Class cMySettings Public SendCommandToRR As String Public PictureSize_X As Integer Public PictureSize_Y As Integer Private Shared XMLFilename As String Public Sub New() SetToDefault(Me) End Sub Public Sub New(FileName As String) XMLFilename = FileName If Path.GetExtension(XMLFilename).ToLower() <> "xml" Then XMLFilename = XMLFilename + ".xml" If File.Exists(XMLFilename) = False Then SerializeToXML(New cMySettings()) End Sub Public Sub New(ByRef Settings As cMySettings) Me.SendCommandToRR = Settings.SendCommandToRR Me.PictureSize_X = Settings.PictureSize_X Me.PictureSize_Y = Settings.PictureSize_Y End Sub Public Shared Sub SerializeToXML(ByRef Settings As cMySettings) Dim xmlSerializer As New XmlSerializer(GetType(cMySettings)) Using xmlTextWriter As New XmlTextWriter(XMLFilename, Encoding.UTF8) xmlTextWriter.Formatting = Formatting.Indented xmlSerializer.Serialize(xmlTextWriter, Settings) xmlTextWriter.Close() End Using End Sub Public Shared Sub DeseralizeFromXML(ByRef Settings As cMySettings) Dim fs As FileStream = Nothing ' do i have settings? If File.Exists(XMLFilename) = True Then Try fs = New FileStream(XMLFilename, FileMode.Open, FileAccess.Read) Dim xmlSerializer As New XmlSerializer(GetType(cMySettings)) Settings = xmlSerializer.Deserialize(fs) Catch 'load error of some sort, or OBJECT deserialize error 'do we tell anyone? Exit Sub Finally If Not fs Is Nothing Then fs.Close() fs = Nothing End Try End If End Sub Public Shared Sub Copy(ByRef SourceSettings As cMySettings, ByRef DestSettings As cMySettings) DestSettings.SendCommandToRR = SourceSettings.SendCommandToRR DestSettings.PictureSize_X = SourceSettings.PictureSize_X DestSettings.PictureSize_Y = SourceSettings.PictureSize_Y End Sub Public Shared Sub SetToDefault(ByRef Settings) Settings.SendCommandToRR = "MOBILEPHONE_ADDPICTURETOITEM;" Settings.PictureSize_X = 70 Settings.PictureSize_Y = 70 End Sub Public Shared Function Compare(ByRef Settings1 As cMySettings, ByRef Setting2 As cMySettings) As Boolean If Settings1.SendCommandToRR <> Setting2.SendCommandToRR Then Compare = False : Exit Function If Settings1.PictureSize_X <> Setting2.PictureSize_X Then Compare = False : Exit Function If Settings1.PictureSize_Y <> Setting2.PictureSize_Y Then Compare = False : Exit Function Compare = True End Function End Class
Merci de votre aide par avance !
Partager