/// <summary> /// Reads an OGAMA slideshow file. /// </summary> /// <param name="filePath">Path to slideshow file.</param> /// <returns><strong>True</strong> if successful, /// otherwise <strong>false</strong>.</returns> private DialogResult OpenSlideshowFromFile(string filePath) { try { Slideshow newSlideshow = null; using (FileStream fs = new FileStream(filePath, FileMode.Open)) { // Create an instance of the XmlSerializer class; // specify the type of object to be deserialized XmlSerializer serializer = new XmlSerializer(typeof(Slideshow)); /* Use the Deserialize method to restore the object's state with * data from the XML document. */ newSlideshow = (Slideshow)serializer.Deserialize(fs); newSlideshow.SetModifiedToAllSlides(); } if (this.trvSlideshow.Nodes[0].Nodes.Count > 0) { string message = "Do you want to delete the existing slideshow items" + "before importing ?" + Environment.NewLine + "Otherwise the imported slides will be inserted at the current selected node."; DialogResult result = InformationDialog.Show("Delete existing slideshow ?", message, true, MessageBoxIcon.Information); switch (result) { case DialogResult.Cancel: return(DialogResult.Cancel); case DialogResult.No: newSlideshow.SetNewNodeIDs(this.slideshow.GetUnusedNodeID()); if (this.trvSlideshow.SelectedNodes.Count > 0) { this.trvSlideshow.SelectedNodes[0].Nodes.Add(newSlideshow); } else { this.trvSlideshow.Nodes[0].Nodes.Add(newSlideshow); } break; case DialogResult.Yes: this.trvSlideshow.Nodes[0].Nodes.Clear(); this.lsvDetails.ClearObjects(); this.slideshow = newSlideshow; this.PopulateTreeView(this.slideshow); break; } } else { this.slideshow = newSlideshow; this.PopulateTreeView(this.slideshow); } this.SlideShowModified(); return(DialogResult.OK); } catch (Exception ex) { ExceptionMethods.HandleException(ex); return(DialogResult.Abort); } }