Thanks to the following code i create and add images - as thumbnails - to the FlowLayoutPanel.
The implementation is pretty simple. I read the available images within the directory and call the following sub procedure.
Private Sub LoadImages(ByVal FlowPanel As FlowLayoutPanel, ByVal fi As FileInfo)
Pedit = New DevExpress.XtraEditors.PictureEdit
Pedit.Width = txtIconsWidth.EditValue
Pedit.Height = Pedit.Width / (4 / 3)
Dim fs As System.IO.FileStream
fs = New System.IO.FileStream(fi.FullName, IO.FileMode.Open, IO.FileAccess.Read)
Pedit.Image = System.Drawing.Image.FromStream(fs)
fs.Close()
fs.Dispose()
Pedit.Properties.SizeMode = DevExpress.XtraEditors.Controls.PictureSizeMode.Zoom
If FlowPanel Is flowR Then
AddHandler Pedit.MouseClick, AddressOf Pedit_MouseClick
AddHandler Pedit.MouseEnter, AddressOf Pedit_MouseEnter
AddHandler Pedit.MouseLeave, AddressOf Pedit_MouseLeave
End If
FlowPanel.Controls.Add(Pedit)
End Sub
Now, i would like to extend it. I would like to create the paging effect. The application should read all the available images BUT paint only the ones that are visible to screen.
And as usual i do not know from where to start. Could i use your lights please?
...and here comes the C# version!
private void LoadImages(FlowLayoutPanel FlowPanel, FileInfo fi)
{
Pedit = new DevExpress.XtraEditors.PictureEdit();
Pedit.Width = txtIconsWidth.EditValue;
Pedit.Height = Pedit.Width / (4 / 3);
System.IO.FileStream fs = null;
fs = new System.IO.FileStream(fi.FullName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
Pedit.Image = System.Drawing.Image.FromStream(fs);
fs.Close();
fs.Dispose();
Pedit.Properties.SizeMode = DevExpress.XtraEditors.Controls.PictureSizeMode.Zoom;
if (object.ReferenceEquals(FlowPanel, flowR)) {
Pedit.MouseClick += Pedit_MouseClick;
Pedit.MouseEnter += Pedit_MouseEnter;
Pedit.MouseLeave += Pedit_MouseLeave;
}
FlowPanel.Controls.Add(Pedit);
}