private void createSlideshowToolStripMenuItem_Click(object sender, EventArgs e) { // It should only be possible to invoke the Create Slideshow menu item for a // folder, but we will check to make sure ListView.SelectedListViewItemCollection selectedItems = this.listView.SelectedItems; if (selectedItems.Count == 1) { if (selectedItems[0].SubItems[1].Text.Equals("Directory")) { string currentDirectory = TreePath(treeView.SelectedNode); string subDirectory = selectedItems[0].SubItems[0].Text; SlideShow newShow = SlideShow.Create(currentDirectory, subDirectory); if (newShow != null) { // Note: slide show has no title - could copy code from AlbumForm // addNewToolStripMenuItem_Click method if (newShow.Save()) { // Refresh display (should be a new XML file) MessageBox.Show("SlideShow created", "PhotoStudio"); ListFolderContents(new DirectoryInfo(currentDirectory)); } else { MessageBox.Show("Failed to create slideshow", "PhotoStudio"); } } } } }
private void addNewToolStripMenuItem_Click(object sender, EventArgs e) { int currentItem = eventsListBox.SelectedIndex; // Get current selected item if ((currentItem < 0) || (currentItem >= eventsListBox.Items.Count)) { // Not a valid selection, but cater for the special case in which there // is an empty EventList, hence nothing to select, but we do want to allow // an event to be added. if (iEventList.Count == 0) { currentItem = 0; } else { // Not a valid selection - don't allow event to be added return; } } createSlideShowDialog.SelectedPath = Path.GetDirectoryName(iEventList.Path); DialogResult res = createSlideShowDialog.ShowDialog(this); if (res == DialogResult.OK) { string slideShowFolder = createSlideShowDialog.SelectedPath; string currentDirectory = Path.GetDirectoryName(slideShowFolder); string subDirectory = Path.GetFileName(slideShowFolder); SlideShow newShow = SlideShow.Create(currentDirectory, subDirectory); if (newShow != null) { // Let the user title the slide show SlideShowTitleForm titleForm = new SlideShowTitleForm(); DialogResult result = titleForm.ShowDialog(); if (result == DialogResult.OK) { // Save titled slide show to XML file newShow.Title = titleForm.FullTitle; if (newShow.Save()) { // Add the saved show to the Events List iEventList.Insert(currentItem, titleForm.BriefTitle, newShow); iEventListChanged = true; // Remember that an edit has taken place // Repopulate the listbox with the new longer event list PopulateEventsListBox(true); } else { MessageBox.Show("Failed to create slideshow", "PhotoStudio"); } } titleForm.Close(); } } }
private void SlideShowEditor_FormClosing(object sender, FormClosingEventArgs e) { if (iSlideShowChanged) { DialogResult response = MessageBox.Show("Slide show has been modified. Save changes?", "PhotoStudio", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (response == DialogResult.Yes) { iSlideShow.Save(); } } }
static void Main(string[] args) { HtmlReader htmlReader = new HtmlReader(); if (args.Count() < 2) { Usage(); } else { string option = args[0]; string masterFilename = args[1]; if (option.Equals("page", StringComparison.CurrentCultureIgnoreCase)) { string diagnostic = null; SlideShow slideShow = htmlReader.ReadSlideShow(masterFilename, out diagnostic); if (slideShow == null) { Console.WriteLine("Converter: failed to read slide show in " + masterFilename); Console.WriteLine(diagnostic); Usage(); } // Determine the name of the XML output file from the name of the HTML input file string directory = GetDirectory(masterFilename); string baseFilename = GetBaseFilename(masterFilename); string xmlFilename = directory + "\\" + baseFilename + ".xml"; slideShow.Save(xmlFilename); } else if (option.Equals("album", StringComparison.CurrentCultureIgnoreCase)) { string diagnostic = null; if (htmlReader.ReadAlbum(masterFilename, out diagnostic) == null) { Console.WriteLine("Converter: failed to read album in " + masterFilename); Console.WriteLine(diagnostic); Usage(); } } else { Usage(); } } }
void convertMenuItem_Click(object sender, EventArgs e) { // It should only be possible to invoke the Convert menu item for an HTML // file, but we will check to make sure ListView.SelectedListViewItemCollection selectedItems = this.listView.SelectedItems; if (selectedItems.Count == 1) { string filename = selectedItems[0].Text; if (IsHtml(new FileInfo(filename))) { // Parse HTML file string currentDirectory = TreePath(treeView.SelectedNode); string htmlPath = currentDirectory + "\\" + filename; HtmlReader htmlReader = new HtmlReader(); string diagnostic = null; string baseFilename = Path.GetFileNameWithoutExtension(filename); string xmlFilename = Path.Combine(currentDirectory, baseFilename + ".xml"); if (baseFilename.Equals("yearframe", StringComparison.CurrentCultureIgnoreCase)) { // Create album from parsing Album album = htmlReader.ReadAlbum(htmlPath, out diagnostic); if (album == null) { MessageBox.Show("Failed to read HTML file\n" + diagnostic, "PhotoStudio"); } else { // Save album to XML file xmlFilename = currentDirectory + "\\album.xml"; album.Save(xmlFilename); MessageBox.Show("Album converted", "PhotoStudio"); } } else if (baseFilename.Equals("events", StringComparison.CurrentCultureIgnoreCase)) { // Create event list from parsing EventList events = htmlReader.ReadEvents(htmlPath, out diagnostic); if (events == null) { MessageBox.Show("Failed to read HTML file\n" + diagnostic, "PhotoStudio"); } else { // Save event list to XML file events.Save(true); MessageBox.Show("Events converted", "PhotoStudio"); } } else { // Create slide show from parsing SlideShow slideShow = htmlReader.ReadSlideShow(htmlPath, out diagnostic); if (slideShow == null) { MessageBox.Show("Failed to read HTML file\n" + diagnostic, "PhotoStudio"); } else { // Save slide show to XML file slideShow.Save(xmlFilename); MessageBox.Show("SlideShow converted", "PhotoStudio"); } } // Refresh display (should be a new XML file) ListFolderContents(new DirectoryInfo(currentDirectory)); } } }