I have a CheckedListBox and a thumbnail control and I am trying to save and retrieve back the images along with their path.
I need to show their image path in the checked list box which I am able to do but I am unable to get the images.
I want to know how to read Images from the saved text file and display it in the thumbnail control.
Here is the code:
Private Sub LoadProject_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles LoadProject.Click
Using ofdlg As New Windows.Forms.OpenFileDialog
ofdlg.DefaultExt = "amk"
ofdlg.Filter = "AquaMark Project|*.amk"
ofdlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
If ofdlg.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim r As New IO.StreamReader("C:\Test\test.txt")
While (r.Peek() > -1)
CheckedListBox1.Items.Add((r.ReadLine), CheckState.Checked)
Dim Pname As String
For i As Integer = 0 To CheckedListBox1.CheckedItems.Count - 1
Pname = CheckedListBox1.SelectedIndex.ToString
Next
End While
r.Close()
Dim SaveData As New gCanvasData
Using objStreamReader As New StreamReader(ofdlg.FileName)
Dim x As New XmlSerializer(GetType(gCanvasData))
SaveData = CType(x.Deserialize(objStreamReader), gCanvasData)
objStreamReader.Close()
End Using
With SaveData
frmDisplay.GCanvas1.ZoomFactor = 1
frmDisplay.GCanvas1.ImageXYReset()
frmDisplay.GCanvas1.Image = .Image
frmDisplay.GCanvas1.gAnnotates = .gAnnotates
frmDisplay.GCanvas1.RebuildAll()
frmDisplay.GCanvas1.AssembleBitmap()
End With
End If
End Using
End Sub
I have modified the code and placing the code here so that it might help others: