Hi,
You have to add Images to
Output
class in order to Serialize those picrures.
Change the
SavePerson()
function in the
MainWindow Form
private void SavePerson()
{
for (int i = 0; i < tableLayoutPanel1.Controls.Count; i++)
{
Panel p = tableLayoutPanel1.Controls[i] as Panel;
Image image = (p.Controls[0] as PictureBox).Image;
Customer c = new Customer();
c.Index = i;
c.Picture = (Bitmap)image;
output.Person.Add(c);
}
output.Save(AppDomain.CurrentDomain.BaseDirectory + "output.out");
}
also change the
LoadPerson()
function in the same form as follows
private void LoadPerson()
{
output.Load(AppDomain.CurrentDomain.BaseDirectory + "output.out");
tableLayoutPanel1.Controls.Clear();
tableLayoutPanel1.ColumnCount = output.Column;
tableLayoutPanel1.RowCount = output.Row;
foreach (Customer c in output.Person)
{
int rows = c.Index / output.Column;
int col = c.Index % output.Column;
Panel p = new Panel();
PictureBox picb = new PictureBox();
picb.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
picb.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
picb.BackColor = Color.White;
picb.Dock = DockStyle.Fill;
picb.Image = c.Picture;
p.Controls.Add(picb);
picb.MouseClick += pb_Click;
picb.MouseLeave += pb_Leave;
tableLayoutPanel1.Controls.Add(p, col, rows);
}
}
I think this will work..
There are other mistakes like, Border setting, back color...etc
I think you can do all those things.
I just concentrated on Serialize and Deserialize of image files
All the best..:thumbsup: