private void SaveAndClose() { // Format Properties.Settings.Default.Paper = comboBoxFormat.Text; Properties.Settings.Default.IncludeMarginForPunchHoles = checkBoxIncludeMarginForPunchHoles.Checked; // Stamps Options Properties.Settings.Default.IncludeImage = checkBoxIncludeImage.Checked; Properties.Settings.Default.IncludeNumber = checkBoxIncludeNumber.Checked; Properties.Settings.Default.IncludeValueAndColor = checkBoxIncludeValue.Checked; // Frame Options Properties.Settings.Default.FrameStyle = (radioButtonThinSolid.Checked ? FrameStyle.ThinSolid : (radioButtonThick.Checked ? FrameStyle.Thick : FrameStyle.ThinDotted)); // Color Options Properties.Settings.Default.ColorStyle = (radioButtonGreyscale.Checked ? ColorStyle.Greyscale : ColorStyle.Color); // Font Options Properties.Settings.Default.FontSize = (radioButtonSmall.Checked ? FontSize.Small : (radioButtonMedium.Checked ? FontSize.Medium : FontSize.Large)); // Page Options Properties.Settings.Default.IncludeBorder = checkBoxIncludeBorder.Checked; Properties.Settings.Default.IncludeTitle = checkBoxIncludeTitle.Checked; // Catalog Options Properties.Settings.Default.Catalog = Catalogs.Convert(comboBoxCatalog.Text); Properties.Settings.Default.AppendCatalog = checkBoxAppendCatalog.Checked; // Album Options Properties.Settings.Default.IncludeSamplePagesOnly = checkBoxIncludeSamplePagesOnly.Checked; Properties.Settings.Default.IncludePdfImages = checkBoxIncludePdfImage.Checked; Properties.Settings.Default.IncludePdfBookmarks = checkBoxIncludePdfBookmarks.Checked; // Real life page scale Properties.Settings.Default.RealLifePageScale = numericRealLifePageScale.Value; // Save settings Properties.Settings.Default.Save(); Properties.Settings.Default.Reload(); // Reload PageSetup.Load(); // Result this.DialogResult = DialogResult.OK; this.Close(); }
private void WebBrowser_Navigating(object sender, WebBrowserNavigatingEventArgs e) { if (e.Url.AbsolutePath.StartsWith("page(") && e.Url.AbsolutePath.EndsWith("")) { e.Cancel = true; PageSetup.Load(); int pageNumber = Int32.Parse(e.Url.AbsolutePath.Replace("page(", "").Replace(")", "")); preview.Show(); preview.ShowPreview(design, pageNumber, design.GetPagefeed(pageNumber).AlbumNumber, PrintMode.ToScreen, ScreenMode.MatchScreenHeight); preview.Activate(); } else if (e.Url.AbsolutePath.StartsWith("stamp(")) { string id = e.Url.AbsolutePath; int index = Int32.Parse(e.Url.AbsolutePath.Replace("stamp(", "").Replace(")", "")); DesignEntry stamp = design[index]; Design stamps = design.GetStampsFromSeries(pageNumber: stamp.PageNumber, number: stamp.Number); Imaging imaging = new Imaging(); imaging.SetImage( series: stamps, stampNumber: stamp.Number, folder: App.GetSetting("ImagesFolder"), country: design.GetCountry(stamp.PageNumber).Text, section: design.GetSection(stamp.PageNumber).Text ); if (imaging.ShowDialog() == DialogResult.OK) { webBrowser.Refresh(); while (webBrowser.ReadyState != WebBrowserReadyState.Complete) { Application.DoEvents(); } DesignEntry entry = design.FindPageNumber(stamp.PageNumber); HtmlElement element = webBrowser.Document.GetElementById(string.Format("page({0},{1})", entry.PageNumber, entry.AlbumNumber)); if (element != null) { element.ScrollIntoView(true); } } e.Cancel = true; } }
private void Initialize() { #region Restore Window State if (Properties.Settings.Default.MainSize.Width == 0) { Properties.Settings.Default.Upgrade(); } if (Properties.Settings.Default.MainSize.Width == 0 || Properties.Settings.Default.MainSize.Height == 0) { this.Location = new Point(10, 10); this.Size = new Size(512, 512); } else { this.WindowState = Properties.Settings.Default.MainState; if (this.WindowState == FormWindowState.Minimized) { this.WindowState = FormWindowState.Normal; } this.Location = Properties.Settings.Default.MainLocation; this.Size = Properties.Settings.Default.MainSize; } #endregion bool exists = System.Diagnostics.Process.GetProcessesByName(System.IO.Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetEntryAssembly().Location)).Count() > 1; if (exists) { App.SetException(string.Format("The {0} application is already running and can not run more than once at the same time.", App.GetName())); } string pdfDocumentsFolder = App.GetSetting("PDFDocumentsFolder"); if (!Directory.Exists(pdfDocumentsFolder)) { Directory.CreateDirectory(pdfDocumentsFolder); } string pdfImagesFolder = App.GetSetting("PDFImagesFolder"); if (!Directory.Exists(pdfImagesFolder)) { Directory.CreateDirectory(pdfImagesFolder); } string albumsFolder = App.GetSetting("AlbumsFolder"); if (!Directory.Exists(albumsFolder)) { Directory.CreateDirectory(albumsFolder); } string archiveFolder = App.GetSetting("ArchiveFolder"); if (!Directory.Exists(archiveFolder)) { Directory.CreateDirectory(archiveFolder); } RefreshFormats(); SetMenus(enabled: false); menuOpen.Visible = false; RefreshDesigns(); webBrowser.Navigating += WebBrowser_Navigating; webBrowser.IsWebBrowserContextMenuEnabled = false; webBrowser.AllowWebBrowserDrop = false; PageSetup.Load(); this.validator = new Validator(); this.preview = new Preview(); this.editor = new Editor(validator, preview); }
private void PrintDesign() { DesignEntry country = this.design.GetCountry(1); bool excludeNumber = country.Settings.ToLower().Contains("!includenumber"); bool excludeValueAndColor = country.Settings.ToLower().Contains("!includevalueandcolor"); Print print = new Print(PrintMode.ToDocument, excludeNumber, excludeValueAndColor); DialogResult result = print.ShowDialog(); if (result == DialogResult.OK) { preview.Hide(); PageSetup setup = PageSetup.Load(); DesignEntry album = design.GetAlbum(); string pdfName = album.Pdf; if (setup.Catalog != Catalog.None) { pdfName += "_" + setup.Catalog; } pdfName += "_" + setup.PageFormat.FormatName; pdfName += "_v" + album.Version; if (setup.IncludeMarginForPunchHoles) { pdfName += "_offcenter"; } if (setup.IncludeSamplePagesOnly) { pdfName += "_sample"; } if (setup.FontSize == FontSize.Medium) { pdfName += "_font6"; } else if (setup.FontSize == FontSize.Large) { pdfName += "_font7"; } string bookmarksInXml = null; string bookmarksInHtm = null; if (setup.IncludePdfBookmarks) { BookmarksHelper.GetBookmarks(this.design, album.Pdf, setup.IncludeSamplePagesOnly, out bookmarksInXml, out bookmarksInHtm); } PDF995Helper pdfHelper = new PDF995Helper(album.Pdf, pdfName, bookmarksInXml, bookmarksInHtm); Progress progress = new Progress(this.design.NumberOfPages()); progress.Show(); progress.Refresh(); preview.PrintDocument(App.GetSetting("PDFPrinter"), setup.PageFormat.PageWidth, setup.PageFormat.PageHeight, this.design, progress.SetPrintingProgress); if (setup.IncludePdfImages) { for (int pageNumber = 1; pageNumber <= this.design.NumberOfPages(); pageNumber++) { progress.SetCreatingProgress(pageNumber); preview.ShowPreview(this.design, pageNumber, this.design.GetPagefeed(pageNumber).AlbumNumber, PrintMode.ToDocument, ScreenMode.MatchPaper); preview.CreateImage(string.Format("{0}\\{1}-large.jpg", App.GetSetting("PDFImagesFolder"), pageNumber), 0.75F); preview.CreateImage(string.Format("{0}\\{1}-small.jpg", App.GetSetting("PDFImagesFolder"), pageNumber), 0.25F); } } progress.SetWaiting(); pdfHelper.WaitForCompletion(); progress.Close(); } }