private void PopulatePageLst(DisplayPageSerialise[] displayPages) { XMLConverter xml = new XMLConverter(); foreach (DisplayPageSerialise d in displayPages) { DisplayPage dS = new DisplayPage(d.name); if (d.buttonList.Count > 0) { foreach (CustomButtonSerialise c in d.buttonList) { CustomButton cS = new CustomButton(c.poly, 0); cS.SetPageLink(c.pageLink); dS.AddCompletedButton(cS); } } if (d.circleBtnLst.Count > 0) { foreach (CircleButtonSerialise c in d.circleBtnLst) { dS.AddCircleButton(c.centre, c.radius, c.pageLink); } } dS.AddBackgroundImage(xml.GetImageFromBase64(d.backgroundImage)); pageLst.Add(dS); } }
private void btnSelectFolder_Click(object sender, EventArgs e) { XMLConverter xml = new XMLConverter(); string filePath = ""; using (OpenFileDialog dlg = new OpenFileDialog()) { dlg.Title = "Open Project"; dlg.Filter = "hen files (*.hen)|*.hen"; if (dlg.ShowDialog() == DialogResult.OK) { filePath = dlg.FileName; } } try { string xmlText = File.ReadAllText(filePath); PopulatePageLst(xml.FromXml <DisplayPageSerialise[]>(xmlText)); Image main = null; foreach (DisplayPage d in pageLst) { d.SaveImage(); if (d.displayPageName == "Main Page") { main = d.GetBackgroundImage(); } } if (main != null) { int screenWidth = main.Width; int screenHeight = main.Height; projectDisplaySize = new Size(screenWidth, screenHeight); lblSelectedFolder.Visible = true; lblSelectedFolder.Text = "CHOSEN FOLDER : " + filePath; } } catch (Exception ex) { MessageBox.Show("Error could not load the project", "Project load error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } }