private void msiOpenComic_Click(object sender, EventArgs e) { var result = openComicDialog.ShowDialog(); if (result != System.Windows.Forms.DialogResult.OK) return; string filename = openComicDialog.FileName; FileFormatReader.ComicBookFormat fileFormat = FileFormatReader.GetComicBookFormat(filename); if (fileFormat == FileFormatReader.ComicBookFormat.Unknown) { MessageBox.Show("Sorry, this file format is unsupported.", "Application Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (pbWorkingImage.Image != null) pbWorkingImage.Image.Dispose(); if (pbPreviewPanels.Image != null) pbPreviewPanels.Image.Dispose(); pbWorkingImage.Image = null; pbPreviewPanels.Image = null; FileFormatReader rdr = new FileFormatReader(openComicDialog.FileName, fileFormat); Cursor = Cursors.WaitCursor; rdr.ExtractToFolder("Temp"); string[] files = rdr.ExtractedFiles; comicFile_RootFolder = System.IO.Path.GetFileName(System.IO.Path.GetDirectoryName(files[0])); if (comicFile_RootFolder.ToLower() == "temp") comicFile_RootFolder = ""; ComicPages.Clear(); cbPages.Items.Clear(); int index = 1; foreach (string file in files) { ComicPage cpage = new ComicPage(file, "Page " + index.ToString()); ComicPages.Add(cpage); cbPages.Items.Add(cpage.ToString()); index++; } cbPages.SelectedIndex = 0; Cursor = Cursors.Default; statusLblComicName.Text = System.IO.Path.GetFileName(filename); statusLblProjectName.Text = ""; WorkingProject_FileName = ""; workingProject_ComicFile = openComicDialog.FileName; comic_Filename = System.IO.Path.GetFileName(filename); enableTools(true); }
private void msiOpenProject_Click(object sender, EventArgs e) { var result = openProjectDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK; if (!result) return; if (pbWorkingImage.Image != null) pbWorkingImage.Image.Dispose(); if (pbPreviewPanels.Image != null) pbPreviewPanels.Image.Dispose(); pbWorkingImage.Image = null; pbPreviewPanels.Image = null; WorkingProject_FileName = openProjectDialog.FileName; string json = System.IO.File.ReadAllText(openProjectDialog.FileName, Encoding.UTF8); Serializing.CPRFileFormat cpr = (Serializing.CPRFileFormat)Newtonsoft.Json.JsonConvert.DeserializeObject<Serializing.CPRFileFormat>(json); string comicFilePath = System.IO.Path.GetDirectoryName(openProjectDialog.FileName); comicFilePath = System.IO.Path.Combine(comicFilePath, cpr.ComicFile); workingProject_ComicFile = comicFilePath; FileFormatReader.ComicBookFormat fileFormat = FileFormatReader.GetComicBookFormat(comicFilePath); FileFormatReader rdr = new FileFormatReader(comicFilePath, fileFormat); Cursor = Cursors.WaitCursor; rdr.ExtractToFolder("Temp"); string[] files = rdr.ExtractedFiles; comicFile_RootFolder = System.IO.Path.GetFileName(System.IO.Path.GetDirectoryName(files[0])); if (comicFile_RootFolder.ToLower() == "temp") comicFile_RootFolder = ""; ComicPages.Clear(); cbPages.Items.Clear(); foreach (var cp in ComicPages) cp.Panels.Clear(); Cursor = Cursors.Default; statusLblComicName.Text = System.IO.Path.GetFileName(comicFilePath); //statusLblProjectName.Text = "[Project: " + System.IO.Path.GetFileName(workingProject_FileName) + "]"; comic_Filename = System.IO.Path.GetFileName(comicFilePath); reloadPicture(); ComicPages = cpr.Pages; bindPagesToComboBox(); if (cbPages.Items.Count > cpr.LastWorkingPage) cbPages.SelectedIndex = cpr.LastWorkingPage; else cbPages.SelectedIndex = 0; foreach (ListViewItem li in listView1.Items) li.Selected = false; enableTools(true); #region Read Grid settings useGrid = cpr.UseGrid; gridSize = cpr.GridSize; msiUseGrid.Checked = useGrid; setMenuItemGridChecked(gridSize); #endregion #region Read Project Info cpdInfo_Author = cpr.Author; cpdInfo_Comments = cpr.Comments; #endregion }