private void FindAlbumNumber() { bool found = true; string input = Interaction.InputBox("Album number:", App.GetName() + " · Find album number"); if (input != "") { DesignEntry entry = design.FindAlbumNumber(input); if (entry == null) { found = false; } else { HtmlElement element = webBrowser.Document.GetElementById(string.Format("page({0},{1})", entry.PageNumber, entry.AlbumNumber)); if (element == null) { found = false; } else { element.ScrollIntoView(true); } } if (!found) { MessageBox.Show(string.Format("Album number '{0}' does not exist.", input), App.GetName() + " · Find album number", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
public static string GetValueAndColor(DesignEntry entry) { string valueAndColor; string value = entry.Value ?? ""; string color = entry.Color ?? ""; if (entry.Separate) { valueAndColor = (value != "" ? value : "!") + HtmlHelper.cBreak + (color != "" ? color : "!"); } else if (value != "" && color == "") { valueAndColor = value; } else if (color != "" && value == "") { valueAndColor = color; } else if (value != "" && color != "") { valueAndColor = value + " · " + color; } else { valueAndColor = "!"; } return(valueAndColor); }
public static Design GetStampsFromSeries(this Design design, int pageNumber, string number) { Design stamps = new Design(); for (int i = 0; i < design.Count(); i++) { DesignEntry entry = design[i]; if (entry.PageNumber == pageNumber && entry.Class == Class.Stamp && entry.Number == number) { int j = i; while (design[j].Class == Class.Stamp) { j--; } j++; while (design[j].Class == Class.Stamp) { stamps.Add(design[j]); j++; } return(stamps); } } return(stamps); }
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 static string GetStamp(DesignEntry entry) { if (entry.Number == "0" || entry.Number == "!") { return(""); } else { return(string.Format("<tr><td><b>{0}</b></td><td>{1}</td><td>{2}</td></tr>", entry.Number, entry.Value.Replace("!", ""), entry.Color?.Replace("!", ""))); } }
private DesignEntry Parse(Design design, string line, int pageNumber, int lineNumber) { DesignEntry entry = new DesignEntry(pageNumber); line = line.Replace("\t", "").Trim(); if (line == "" || line.Substring(0, 1) == "'") { return(null); } string[] splitted = line.Split(Validator.cKeywordSeparator); for (int i = 0; i < splitted.Length; i++) { string s = splitted[i].Replace(" ", ""); switch (s.ToLower()) { case "album": entry.Class = Class.Album; break; case "end": entry.Class = Class.None; entry.PageNumber = -1; break; case "pagefeed": entry.Class = Class.PageFeed; entry.PageNumber++; entry.Text = entry.PageNumber.ToString(); break; case "linefeed": entry.Class = Class.LineFeed; break; default: Parse(design, entry, splitted[i], lineNumber); break; } } return(entry); }
private void PreviewDesign() { if (designMaster.SelectionStart <= 0) { return; } DesignParser designParser = new DesignParser(); Design design = designParser.Parse(designMaster.Text, null, out string error); if (!string.IsNullOrEmpty(error)) { SetStatus(error, failure: true); } else { int pageNumber = 1; int pageFeedIndex = designMaster.Text.LastIndexOf("PageFeed", designMaster.SelectionStart); if (pageFeedIndex >= 0) { string pageFeed = designMaster.GetLineText(designMaster.PositionToPlace(pageFeedIndex).iLine); string[] split = pageFeed.Split("PageNumber="); if (split.Length > 1) { string albumNumber = split[1].Split(' ')[0]; DesignEntry entry = design.FindAlbumNumber(albumNumber); if (entry != null) { pageNumber = entry.PageNumber; } } } preview.ShowPreview(design, pageNumber: pageNumber, albumNumber: design.GetPagefeed(pageNumber).AlbumNumber, printMode: PrintMode.ToScreen, screenMode: ScreenMode.MatchScreenHeight); preview.Show(); this.Focus(); } }
private string GetTextByComment(Design design, string comment) { string text = ""; DesignEntry entry = design.LastOrDefault(e => (e.Class == Class.Series || e.Class == Class.Type || e.Class == Class.Varieties) && e.Comment == comment); if (entry != null) { text = entry.Text; while (text.StartsWith("!") || text.StartsWith("%")) { text = text.Substring(1); } } return(text); }
private static string GetTableOfContents(Design design, int i) { StringBuilder html = new StringBuilder(); string country = design[i].Text; i++; while (i < design.Count() && design[i].Class != Class.Country) { DesignEntry entry = design[i]; if (entry.Class == Class.Section) { html.Append(string.Format("<li><a href=\"#section({0},{1})\"><small>{2}</small></a>", country, entry.Text, entry.Text)); } i++; } return(html.ToString()); }
public static string GetNumber(DesignEntry entry) { string number = ""; PageSetup pageSetup = PageSetup.Get(); if (pageSetup.Catalog == Catalog.None) { number = entry.Number; } else { switch (pageSetup.Catalog) { case Catalog.Scott: number = entry.Sc; break; case Catalog.Michel: number = entry.Mi; break; case Catalog.Yvert: number = entry.Yv; break; case Catalog.Gibbons: number = entry.Sg; break; case Catalog.Chan: number = entry.Ch; break; case Catalog.Afinsa: number = entry.Af; break; case Catalog.Maury: number = entry.Ma; break; case Catalog.Newfoundland: number = entry.Nc; break; case Catalog.Afa: number = entry.Afa; break; case Catalog.Facit: number = entry.Fac; break; } if (pageSetup.AppendCatalog && number != "") { number = entry.Number + " </b>(" + number + ")"; } } return(number); }
public void SetImage(Design series, string stampNumber, string folder, string country, string section) { this.series = series; this.folder = folder; this.country = country; this.section = section; this.stamp = series.GetStampFromSeries(stampNumber); string path = string.Format("{0}\\{1}\\{2}", folder, country, section); this.thumb = string.Format("{0}\\{1}.jpg", path, stamp.Number); this.image = string.Format("{0}\\image\\{1}.jpg", path, stamp.Number); this.color = string.Format("{0}\\xlcolor\\{1}.jpg", path, stamp.Number); this.print = string.Format("{0}\\xlprint\\{1}.jpg", path, stamp.Number); if (File.Exists(cThumb)) { File.Delete(cThumb); } if (File.Exists(cImage)) { File.Delete(cImage); } if (File.Exists(cColor)) { File.Delete(cColor); } if (File.Exists(cPrint)) { File.Delete(cPrint); } if (File.Exists(this.thumb)) { File.Copy(this.thumb, cThumb, overwrite: true); } if (File.Exists(this.image)) { File.Copy(this.image, cImage, overwrite: true); } if (File.Exists(this.color)) { File.Copy(this.color, cColor, overwrite: true); } if (File.Exists(this.print)) { File.Copy(this.print, cPrint, overwrite: true); } pImage.LoadImageAndUnlock(cImage); pThumb.LoadImageAndUnlock(cThumb); pColor.LoadImageAndUnlock(cColor); pPrint.LoadImageAndUnlock(cPrint); pTrial.LoadImageAndUnlock(cTrial); this.baseSize = GetBaseSize(path, pImage.Image.Width, pImage.Image.Height); buttonPrevious.Enabled = this.series.FindIndex(s => s.Number == this.stamp.Number) > 0; buttonNext.Enabled = this.series.FindIndex(s => s.Number == this.stamp.Number) < this.series.Count() - 1; buttonRotate.Enabled = File.Exists(cImage); buttonCrop.Enabled = buttonRotate.Enabled; buttonRecolor.Enabled = buttonRotate.Enabled; buttonBrighten.Enabled = buttonRotate.Enabled; buttonBlacken.Enabled = buttonRotate.Enabled; buttonMeasure.Enabled = !string.IsNullOrEmpty(this.stamp.Perforation); buttonResize.Enabled = buttonRotate.Enabled; buttonSelect.Enabled = buttonRotate.Enabled; buttonThumbnail.Enabled = buttonRotate.Enabled; buttonSave.Enabled = false; buttonUndo.Enabled = false; panelButtons.Visible = true; panelImaging.Visible = false; panelRecolor.Visible = false; this.CancelButton = buttonClose; this.AcceptButton = null; this.mode = ImagingMode.None; labelMode.Text = this.mode.Text(this.stamp.Number, pImage.Image, this.scale); Repaint(); }
public static void GetBookmarks(Design design, string pdfName, bool includeSamplePagesOnly, out string bookmarksInXml, out string bookmarksInHtm) { List <Bookmark> bookmarks = new List <Bookmark>(); Bookmark country = null; Bookmark section = null; Bookmark page = null; Bookmark main = null; for (int i = 0; i < design.Count(); i++) { DesignEntry entry = design[i]; switch (entry.Class) { case Class.Country: country = new Bookmark() { Text = entry.Text, // Set the text for the country ForeColor = "[1 0 1]" // Magenta }; section = new Bookmark() { Text = design[i + 1].Comment, // Set the text for the section (the part follows the country) ForeColor = "[0 0 1]" //Blue }; country.Bookmarks.Add(section); bookmarks.Add(country); break; case Class.PageFeed: if (!entry.Combine) { if (design[i + 1].Class == Class.Section) { if (country.Bookmarks[country.Bookmarks.Count() - 1].Text != design[i + 1].Comment) { section = new Bookmark() { Text = design[i + 1].Comment, ForeColor = "[0 0 1]" // Blue }; country.Bookmarks.Add(section); } } main = new Bookmark() { Text = entry.Html, PageNumber = entry.PageNumber, AlbumNumber = entry.AlbumNumber, PageText = entry.Html, ForeColor = (includeSamplePagesOnly && !entry.Sample ? "[1 0 0]" : "[0 0 0]") }; if (entry.Comment != " ") { main.Text += " (" + entry.Comment + ")"; main.PageText += " (" + entry.Comment + ")"; } if (entry.AlbumNumber != "") { main.Text = entry.AlbumNumber + " : " + main.Text; } section.Bookmarks.Add(main); } else { page = new Bookmark() { Text = entry.AlbumNumber + " : " + entry.Comment, PageNumber = entry.PageNumber, AlbumNumber = entry.AlbumNumber, PageText = entry.Comment, ForeColor = (includeSamplePagesOnly && !entry.Sample ? "[1 0 0]" : "[0 0 0]") }; main.Bookmarks.Add(page); } break; } } Bookmark overview = new Bookmark() { Text = "Overzicht Klemstroken · Overview Mounts", // Set the text for the mounts overview ForeColor = "[1 0 1]" // Magenta }; bookmarks.Add(overview); int pageNumber = 1; StringBuilder doc = new StringBuilder(); doc.AppendLine("<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>"); doc.AppendLine("<Bookmarks>"); foreach (Bookmark c in bookmarks) { if (bookmarks.Count() > 1) { doc.AppendLine(Format(pageNumber, c.Text, c.Bookmarks.Count, c.ForeColor, "2")); } foreach (Bookmark s in c.Bookmarks) { if (c.Bookmarks.Count() > 1) { doc.AppendLine(Format(pageNumber, s.Text, s.Bookmarks.Count, s.ForeColor, "2")); } foreach (Bookmark m in s.Bookmarks) { doc.AppendLine(Format(pageNumber, m.Text, m.Bookmarks.Count, m.ForeColor, "2")); pageNumber++; foreach (Bookmark p in m.Bookmarks) { doc.AppendLine(Format(pageNumber, p.Text, p.Bookmarks.Count, p.ForeColor, "0")); pageNumber++; } } } } doc.AppendLine("</Bookmarks>"); doc.Replace("& ", "& "). Replace(" ", " "). Replace("№", "Nº"). Replace("<b>", ""). Replace("</b>", ""). Replace("<i>", ""). Replace("</i>", ""). Replace("<s>", ""). Replace("</s>", ""). Replace("<f>", ""). Replace("</f>", ""); bookmarksInXml = doc.ToString(); doc = new StringBuilder(); foreach (Bookmark c in bookmarks) { if (bookmarks.Count() > 1) { doc.AppendLine(string.Format("<div ng-init='model.pages={0}'></div>", pageNumber - 1)); doc.AppendLine(string.Format("<h1 align='center' style='font-weight: bold; color: green;'>{0}</h1>", c.Text)); } foreach (Bookmark s in c.Bookmarks) { if (c.Bookmarks.Count() >= 2) // Only show section when there are two or more sections { doc.AppendLine(string.Format("<h2 align='center' style='font-weight: bold; color: blue;'>{0}</h2>", s.Text)); } foreach (Bookmark m in s.Bookmarks) { doc.AppendLine(string.Format("<br><p align='center' style='font-weight: bold;'>{0}</p>", m.PageText)); doc.AppendLine(string.Format("<table align='center'><tr>")); doc.AppendLine(string.Format("<td style='text-align: center; font-size: small;'>")); doc.AppendLine(string.Format("<a style='cursor: pointer;' ng-click='model.zoomPage({0})' href='http://www.eperforationgauge.com/specializedstampalbumpages/pdfs/{1}_samples/{2}-large.jpg' target='_blank'>", m.PageNumber, pdfName, m.PageNumber)); doc.AppendLine(string.Format("<img border='1' src='http://www.eperforationgauge.com/specializedstampalbumpages/pdfs/{0}_samples/{1}-small.jpg'><br><strong>{2}</strong></a><br> ", pdfName, m.PageNumber, m.AlbumNumber)); doc.AppendLine(string.Format("</td>")); foreach (Bookmark p in m.Bookmarks) { doc.AppendLine(string.Format("<td style='text-align: center; font-size: small;'>")); doc.AppendLine(string.Format("<a style='cursor: pointer;' ng-click='model.zoomPage({0})' href='http://www.eperforationgauge.com/specializedstampalbumpages/pdfs/{1}_samples/{2}-large.jpg' target='_blank'>", p.PageNumber, pdfName, p.PageNumber)); doc.AppendLine(string.Format("<img border='1' src='http://www.eperforationgauge.com/specializedstampalbumpages/pdfs/{0}_samples/{1}-small.jpg'><br><strong>{2}</strong></a><br> ", pdfName, p.PageNumber, p.AlbumNumber)); doc.AppendLine(string.Format("</td>")); } doc.AppendLine(string.Format("</tr></table>")); } } } bookmarksInHtm = doc.ToString(); }
private void Parse(Design design, DesignEntry entry, string keyValuePair, int line) { string key; string val; if (keyValuePair.Contains(Validator.cKeywordAssignment)) { string[] keyval = keyValuePair.Split(Validator.cKeywordAssignment, joinAgainExceptFirstOne: true); key = keyval[0].Trim(); val = keyval[1].Trim(); } else { key = keyValuePair.Trim(); val = ""; } switch (key.ToLower()) { case "country": // Eg. Country:=Nederland entry.SetClass(Class.Country, val); break; case "part": // Eg. Part:=Frankeerzegels entry.SetClass(Class.Section, val); break; case "type": // Eg. Type:=Type I entry.SetClass(Class.Type, val); if (entry.Text.Contains("Comment:")) { string comment = entry.Text.Split("Comment:")[1].Replace("!", "").Replace("%", ""); string text = GetTextByComment(design, comment); entry.Text = entry.Text.Replace("Comment:" + comment, text); } break; case "series": // Eg. Series:=1867-1869. Koning Willem III. entry.SetClass(Class.Series, val); break; case "varieties": // Eg. Varieties:=1946-'47.</b> Frankeerzegels. entry.SetClass(Class.Varieties, val); if (entry.Text.Contains("Comment:")) { string comment = entry.Text.Split("Comment:")[1].Replace("!", "").Replace("%", ""); string text = GetTextByComment(design, comment); entry.Text = entry.Text.Replace("Comment:" + comment, text); } entry.Alignment = Alignment.Centered; break; case "description": // Eg. Description:=Getand. entry.SetClass(Class.Description, val); if (entry.Text.Contains("Comment:")) { string comment = entry.Text.Split("Comment:")[1].Replace("!", "").Replace("%", ""); string text = GetTextByComment(design, comment); entry.Text = entry.Text.Replace("Comment:" + comment, text); } entry.Alignment = Alignment.Centered; break; case "stamp": //Eg. Stamp:=19 entry.Class = Class.Stamp; entry.Number = val; break; case "variety": // Eg. Variety:=19A entry.Class = Class.Variety; entry.Number = val; if (design[design.Count() - 1].Class == Class.Description) { entry.Alignment = design[design.Count() - 1].Alignment; } break; case "image": entry.Class = Class.Image; entry.Number = val; break; case "design": // Eg. Design:=A30 entry.SetClass(Class.Design, val); break; case "frontpagetitle": entry.FrontPageTitle = val; break; case "frontpagesubtitle": entry.FrontPageSubTitle = val; break; case "pagetitle": entry.PageTitle = val; break; case "value": // Eg. Vlue:=5 ct. entry.Value = val; break; case "color": entry.Color = val; break; case "maxwidth": entry.MaxWidth = Convert.ToSingle(val); break; case "width": entry.Width = GetSize(entry.Width, val); break; case "height": case "watermarkheight": entry.Height = GetSize(entry.Height, val); break; case "horizontal": entry.OffsetHorizontal = Convert.ToSingle(val); break; case "vertical": entry.OffsetVertical = Convert.ToSingle(val); break; case "verticalmove": case "verticalmoverelative": entry.VerticalMoveRelative = Convert.ToSingle(val); break; case "verticalmoveabsolute": entry.VerticalMoveAbsolute = Convert.ToSingle(val); break; case "skip": entry.Skip = Convert.ToBoolean(val); break; case "roundedcorners": entry.RoundedCorners = Convert.ToBoolean(val); break; case "menu": entry.Menu = Convert.ToBoolean(val); break; case "combine": entry.Combine = Convert.ToBoolean(val); break; case "separate": entry.Separate = Convert.ToBoolean(val); break; case "alignment": switch (val.ToLower()) { case "": case "left": entry.Alignment = Alignment.Left; break; case "centered": entry.Alignment = Alignment.Centered; break; case "right": entry.Alignment = Alignment.Right; break; default: throw new Exception(string.Format("Unknown alignment '{0}'", val)); } break; case "applyto": entry.ApplyTo = val; break; case "applytoframestyle": entry.ApplyToFrameStyle = val; break; case "framecolor": switch (val.ToLower()) { case "": case "black": entry.FrameColor = FrameColor.Black; break; case "white": entry.FrameColor = FrameColor.White; break; default: throw new Exception(string.Format("Unknown frame color '{0}'", val)); } break; case "picture": entry.Picture = val; if (entry.Picture == "bw:") { entry.Picture = "..\\xlprint\\" + entry.Number; while (entry.Picture != "" && (entry.Picture[entry.Picture.Length - 1] < '0' || entry.Picture[entry.Picture.Length - 1] > '9')) { entry.Picture = entry.Picture.Substring(0, entry.Picture.Length - 1); } } else if (entry.Picture.StartsWith("bw:")) { entry.Picture = entry.Picture.Replace("bw:", "..\\xlprint\\"); } break; case "overprint": entry.Overprint = val; switch (entry.Overprint) { case "Serikat": entry.Overprint = "Rockwell|7|False|False|Republik%Indonesia Serikat%27 Des. 49|0|0|0"; break; case "RIS": entry.Overprint = "Aparajita|10|False|True|R I S|0|0|0"; break; case "RISMerdeka": entry.Overprint = "Aparajita|10|False|True|R I S%Merdeka|0|0|0"; break; case "RISDjakarta": entry.Overprint = "Aparajita|10|False|True|R I S%Djakarta|0|0|0"; break; case "AustraliaOSPerfinLarge": entry.Overprint = "AustraliaOSPerfinLarge|15|14"; break; case "AustraliaOSPerfinMedium": entry.Overprint = "AustraliaOSPerfinMedium|13|9"; break; case "AustraliaOSPerfinSmall": entry.Overprint = "AustraliaOSPerfinSmall|15.6|8.5"; break; case "AustraliaOSOverprint": entry.Overprint = "AustraliaOSOverprint|13.2|6.5"; break; case "AustraliaOSOverprintInverted": entry.Overprint = "AustraliaOSOverprintInverted|13.2|6.5"; break; case "HongKongSpecimenOverprint": entry.Overprint = "HongKongSpecimentOverprint|13|2.57"; break; case "HongKongSpecimenPerfin": entry.Overprint = "HongKongSpecimenPerfin|15|9.11"; break; default: if (entry.Overprint.StartsWith("#")) // For the numeral cancels of Iceland { entry.Overprint = "Baskerville Old Face|18|True|False|" + entry.Overprint.Substring(1) + "|100|100|100"; } else { entry.Overprint = ""; } break; } break; case "comment": case "private": entry.Comment = val; break; case "watermark": entry.Watermark = val; break; case "shape": switch (val.ToLower()) { case "": case "rectangle": entry.Shape = Shape.Rectangle; break; case "rectanglerotated": entry.Shape = Shape.RectangleRotated; break; case "triangle60": entry.Shape = Shape.Triangle60; break; case "triangle60inverted": entry.Shape = Shape.Triangle60Inverted; break; case "triangle45": entry.Shape = Shape.Triangle45; break; case "triangle45inverted": entry.Shape = Shape.Triangle45Inverted; break; case "hexagonvertical": entry.Shape = Shape.HexagonVertical; break; default: throw new Exception(string.Format("Unknown shape '{0}'", val)); } break; case "variant": entry.Variant = Convert.ToBoolean(val); if (entry.Variant && entry.Class == Class.Variety) { throw new Exception("Variant attribute not supported on a Variety; check VB for functionality"); } break; case "skipvariant": entry.SkipVariant = Convert.ToBoolean(val); break; case "special": entry.Special = Convert.ToBoolean(val); break; case "sc": entry.Sc = val; switch (entry.Sc) { case "~": entry.Sc = entry.Number; break; case "<": throw new Exception(":=< not supported any more"); } break; case "mi": entry.Mi = val; switch (entry.Mi) { case "~": entry.Mi = entry.Number; break; case "<": throw new Exception(":=< not supported any more"); } break; case "sg": entry.Sg = val; switch (entry.Sg) { case "~": entry.Sg = entry.Number; break; case "<": throw new Exception(":=< not supported any more"); } break; case "yv": entry.Yv = val; switch (entry.Yv) { case "~": entry.Yv = entry.Number; break; case "<": throw new Exception(":=< not supported any more"); } break; case "ch": entry.Ch = val; switch (entry.Ch) { case "~": entry.Ch = entry.Number; break; case "<": throw new Exception(":=< not supported any more"); } break; case "af": entry.Af = val; switch (entry.Af) { case "~": entry.Af = entry.Number; break; case "<": throw new Exception(":=< not supported any more"); } break; case "ma": entry.Ma = val; switch (entry.Ma) { case "~": entry.Ma = entry.Number; break; case "<": throw new Exception(":=< not supported any more"); } break; case "nc": entry.Nc = val; switch (entry.Nc) { case "~": entry.Nc = entry.Number; break; case "<": throw new Exception(":=< not supported any more"); } break; case "afa": entry.Afa = val; switch (entry.Afa) { case "~": entry.Afa = entry.Number; break; case "<": throw new Exception(":=< not supported any more"); } break; case "fac": entry.Fac = val; switch (entry.Fac) { case "~": entry.Fac = entry.Number; break; case "<": throw new Exception(":=< not supported any more"); } break; case "landscape": entry.Landscape = Convert.ToBoolean(val); break; case "unlisted": entry.Unlisted = Convert.ToBoolean(val); break; case "html": entry.Html = val; break; case "catalogue": entry.Catalogue = val; break; case "copyright": entry.Copyright = val; break; case "pagenumber": entry.AlbumNumber = val; break; case "pdf": entry.Pdf = val; break; case "settings": entry.Settings = val; break; case "version": entry.Version = val; break; case "fontoftype": entry.FontOfType = Convert.ToBoolean(val); break; case "fontofdescription": entry.FontOfDescription = Convert.ToBoolean(val); break; case "issued": entry.Issued = val; break; case "perfs": entry.Perfs = val; break; case "printed": entry.Printed = val; break; case "sample": entry.Sample = Convert.ToBoolean(val); break; case "perforation": entry.Perforation = val; break; case "sheet": // Do nothing here, this is for VB break; case "positions": entry.Positions = val; break; case "appearance": switch (val.ToLower()) { case "single": case "singular": entry.Appearance = Appearance.Singular; break; case "rotated": entry.Appearance = Appearance.Rotated; break; case "watermarkinverted": entry.Appearance = Appearance.WatermarkInverted; break; case "watermarkreversed": entry.Appearance = Appearance.WatermarkReversed; break; case "watermarkinvertedandreversed": entry.Appearance = Appearance.WatermarkInvertedAndReversed; break; case "watermarksideways": entry.Appearance = Appearance.WatermarkSideways; SizeF sizeWatermarkSideways = new SizeF(entry.Width, entry.Height); entry.Width = sizeWatermarkSideways.Height; entry.Height = sizeWatermarkSideways.Width; break; case "watermarksidewaysinverted": entry.Appearance = Appearance.WatermarkSidewaysInverted; SizeF sizeWatermarkSidewaysInverted = new SizeF(entry.Width, entry.Height); entry.Width = sizeWatermarkSidewaysInverted.Height; entry.Height = sizeWatermarkSidewaysInverted.Width; break; case "pairhorizontal": case "horizontalpair": entry.Appearance = Appearance.PairHorizontal; entry.Width = 2 * entry.Width - 4; break; case "pairvertical": case "verticalpair": entry.Appearance = Appearance.PairVertical; entry.Height = 2 * entry.Height - 4; break; case "tetebechehorizontal": case "horizontaltetebeche": entry.Appearance = Appearance.TeteBecheHorizontal; entry.Width = 2 * entry.Width - 4; break; case "tetebechevertical": case "verticaltetebeche": entry.Appearance = Appearance.TeteBecheVertical; entry.Height = 2 * entry.Height - 4; break; case "tetebechehorizontalgutter": case "horizontaltetebechegutter": entry.Appearance = Appearance.TeteBecheHorizontalGutter; entry.Width = 3 * entry.Width - 2 * 4; break; case "tetebecheverticalgutter": case "verticaltetebechegutter": entry.Appearance = Appearance.TeteBecheVerticalGutter; entry.Height = 3 * entry.Height - 2 * 4; break; case "horizontalgutterpair": entry.Appearance = Appearance.HorizontalGutterPair; entry.Width = 3 * entry.Width - (3 - 1) * 4; break; case "verticalgutterpair": entry.Appearance = Appearance.VerticalGutterPair; entry.Height = 3 * entry.Height - (3 - 1) * 4; break; case "block": entry.Appearance = Appearance.Block; entry.Width = 2 * entry.Width - 4; entry.Height = 2 * entry.Height - 4; break; case "block5x5": entry.Appearance = Appearance.Block5x5; entry.Width = 5 * entry.Width - (5 - 1) * 4; entry.Height = 5 * entry.Height - (5 - 1) * 4; break; case "block2x5": entry.Appearance = Appearance.Block2x5; entry.Width = 2 * entry.Width - (2 - 1) * 4; entry.Height = 5 * entry.Height - (5 - 1) * 4; break; case "block2x5rotated": entry.Appearance = Appearance.Block2x5Rotated; entry.Width = 2 * entry.Width - (2 - 1) * 4; entry.Height = 5 * entry.Height - (5 - 1) * 4; break; case "sheet2x3": entry.Appearance = Appearance.Sheet2x3; entry.Width = 3 * entry.Width - 2 * 4; entry.Height = 2 * entry.Height - 1 * 4; break; case "proof": entry.Appearance = Appearance.Proof; entry.Width = entry.Width + 8; entry.Height = entry.Height + 8; break; case "horizontalstrip3": entry.Appearance = Appearance.HorizontalStrip3; entry.Width = 3 * entry.Width - (3 - 1) * 4; break; case "horizontalstrip4": entry.Appearance = Appearance.HorizontalStrip4; entry.Width = 4 * entry.Width - (4 - 1) * 4; break; case "horizontalstrip5": entry.Appearance = Appearance.HorizontalStrip5; entry.Width = 5 * entry.Width - (5 - 1) * 4; break; case "horizontalstrip6": entry.Appearance = Appearance.HorizontalStrip6; entry.Width = 6 * entry.Width - (6 - 1) * 4; break; case "verticalstrip3": entry.Appearance = Appearance.VerticalStrip3; entry.Height = 3 * entry.Height - (3 - 1) * 4; break; case "verticalstrip4": entry.Appearance = Appearance.VerticalStrip4; entry.Height = 4 * entry.Height - (4 - 1) * 4; break; case "verticalstrip5": entry.Appearance = Appearance.VerticalStrip5; entry.Height = 5 * entry.Height - (5 - 1) * 4; break; case "verticalstrip6": entry.Appearance = Appearance.VerticalStrip6; entry.Height = 6 * entry.Height - (6 - 1) * 4; break; case "carnetpaire": case "pairecarnet": entry.Appearance = Appearance.PaireCarnet; entry.Height = 2 * (entry.Height - 4 + 0.3F * (entry.Height - 4)) + 4; break; case "bandepublicitaire": case "publicitairebande": entry.Appearance = Appearance.BandePublicitaire; entry.Height = (entry.Height - 4) + 0.4F * (entry.Height - 4) + 4; break; case "interpanneauxhorizontal": case "horizontalinterpanneaux": entry.Appearance = Appearance.HorizontalInterpanneaux; entry.Width = (entry.Width - 4) * 2.5F + 4; break; case "imperfright": entry.Appearance = Appearance.ImperfRight; entry.Width = 2 * entry.Width - 4; break; case "imperfleft": entry.Appearance = Appearance.ImperfLeft; entry.Width = 2 * entry.Width - 4; break; case "imperftop": entry.Appearance = Appearance.ImperfTop; entry.Height = 2 * entry.Height - 4; break; case "imperfbottom": entry.Appearance = Appearance.ImperfBottom; entry.Height = 2 * entry.Height - 4; break; } break; case "size": switch (val.ToLower()) { case "kfs": entry.Width = 21; entry.Height = 25; break; case "kfl": entry.Width = 25; entry.Height = 21; break; case "mfs": entry.Width = 25; entry.Height = 32; break; case "mfl": entry.Width = 32; entry.Height = 25; break; case "gfs": entry.Width = 25; entry.Height = 36; break; case "gfl": entry.Width = 36; entry.Height = 25; break; case "gb_kfs": entry.Width = 20; entry.Height = 24; break; case "gb_kfl": entry.Width = 24; entry.Height = 20; break; case "us_smallportrait": entry.Width = 22; entry.Height = 26; break; case "us_smalllandscape": entry.Width = 26; entry.Height = 22; break; case "us_largeportrait": entry.Width = 26; entry.Height = 41; break; case "us_largelandscape": entry.Width = 41; entry.Height = 26; break; case "petitportrait": entry.Width = 20; entry.Height = 24; break; case "petitpaysage": entry.Width = 24; entry.Height = 20; break; case "moyenportrait": entry.Width = 24; entry.Height = 40; break; case "moyenpaysage": entry.Width = 40; entry.Height = 24; break; case "grandportrait": entry.Width = 26; entry.Height = 40; break; case "grandpaysage": entry.Width = 40; entry.Height = 26; break; case "va": entry.Width = 33; // 32.75 entry.Height = 28; // 27.75 break; case "xa": entry.Width = 33; // 32.75 entry.Height = 28; // 27.75 // entry.Perforation = "Comb Perforation 14 x 13¾"; break; case "ma": entry.Width = 65 - 4; entry.Height = 56 - 4; break; case "vb": entry.Width = 28; // 27.75 entry.Height = 33; // 32.75 break; case "xb": entry.Width = 28; // 27.75 entry.Height = 33; // 32.75 // entry.Perforation = "Comb Perforation 13¾ x 14"; break; case "mb": entry.Width = 56 - 4; entry.Height = 65 - 4; break; case "vc": entry.Width = 39; // 38.75; entry.Height = 30; // 29.75; break; case "xc": entry.Width = 39; // 38.75; entry.Height = 30; // 29.75; // entry.Perforation = "Comb Perforation 13½ x 14¼"; break; case "vd": entry.Width = 30; // 29.75; entry.Height = 39; // 38.75; break; case "xd": entry.Width = 30; // 29.75; entry.Height = 39; // 38.75; // entry.Perforation = "Comb Perforation 14¼ x 13½"; break; case "ve": entry.Width = 38; // 37.5; entry.Height = 47; // 45.25 47; break; case "xe": entry.Width = 38; // 37.5; entry.Height = 47; // 45.25; // entry.Perforation = "Line Perforation 12½"; break; case "vf": entry.Width = 42; // 41.75; entry.Height = 35; break; case "xfa": entry.Width = 42; // 41.75; entry.Height = 35; // entry.Perforation = "Line Perforation 14½"; break; case "xfb": entry.Width = 42; // 41.75; entry.Height = 35; // entry.Perforation = "Line Perforation 13¾"; break; case "mf": entry.Width = 74 - 4; entry.Height = 62 - 4; break; case "vg": entry.Width = 35; entry.Height = 42; // 41.75; break; case "xga": entry.Width = 35; entry.Height = 42; // 41.75; // entry.Perforation = "Line Perforation 14½"; break; case "xgb": entry.Width = 35; entry.Height = 42; // 41.75; // entry.Perforation = "Line Perforation 13¾"; break; case "mg": entry.Width = 68 - 4; entry.Height = 70 - 4; break; case "vh": entry.Width = 38; // 38.25; entry.Height = 30; // 29.75; break; case "xh": entry.Width = 38; // 38.25; entry.Height = 30; // 29.75; // entry.Perforation = "Comb Perforation 13½ x 14½"; break; case "mh": entry.Width = 74 - 4; entry.Height = 60 - 4; break; case "vi": entry.Width = 41; // 41.25; entry.Height = 32; // 31.5; break; case "xia":; entry.Width = 41; // 41.25; entry.Height = 32; // 31.5; // entry.Perforation = "Line Perforation 14½"; break; case "xib": entry.Width = 41; // 41.25; entry.Height = 32; // 31.5; // entry.Perforation = "Line Perforation 13¾"; break; case "mi": entry.Width = 74 - 4; entry.Height = 60 - 4; break; case "vj": entry.Width = 28; // 27.5; entry.Height = 33; // 32.75; break; case "xj": entry.Width = 28; // 27.5; entry.Height = 33; // 32.75; // entry.Perforation = "Comb Perforation 13¾ x 14"; break; case "vk": entry.Width = 30; // 30.25; entry.Height = 37; // 36.5; break; case "xka": entry.Width = 30; // 30.25; entry.Height = 37; // 36.5; // entry.Perforation = "Line Perforation 14½"; break; case "xkb": entry.Width = 30; // 30.25; entry.Height = 37; // 36.5; // entry.Perforation = "Line Perforation 13¾"; break; case "vl": entry.Width = 61; // 61.25; entry.Height = 30; // 29.5; break; case "xl": entry.Width = 61; // 61.25; entry.Height = 30; // 29.5; // entry.Perforation = "Line Perforation 12½"; break; case "vm": entry.Width = 30; // 29.5; entry.Height = 62; // 61.5; break; case "xm": entry.Width = 30; // 29.5; entry.Height = 62; // 61.5; // entry.Perforation = "Line Perforation 12½"; break; case "vn": entry.Width = 62; entry.Height = 31; break; case "xna": entry.Width = 62; entry.Height = 31; // entry.Perforation = "Line Perforation 14½"; break; case "xnb": entry.Width = 62; entry.Height = 31; // entry.Perforation = "Line Perforation 13¾"; break; case "vo": entry.Width = 31; entry.Height = 62; break; case "xoa": entry.Width = 31; entry.Height = 62; // entry.Perforation = "Line Perforation 14½"; break; case "xob": entry.Width = 31; entry.Height = 62; // entry.Perforation = "Line Perforation 13¾"; break; case "vp": entry.Width = 30; // 29.75; entry.Height = 39; // 38.75; break; case "xp": entry.Width = 30; // 29.75; entry.Height = 3; // 38.75; // entry.Perforation = "Comb Perforation 14¼ x 13½"; break; case "v1": case "x1": entry.Width = 148; entry.Height = 88; // 87.5; break; case "v2": case "x2": entry.Width = 88.5F; entry.Height = 116; // 115.5; break; case "fdc": entry.Width = 164; entry.Height = 92; break; default: var designEntry = design.LastOrDefault(x => x.Class == Class.Design && x.Text == val); if (designEntry == null) { throw new Exception(string.Format("Cannot find the design '{0}'", val)); } entry.Width = designEntry.Width; entry.Height = designEntry.Height; break; } entry.Width += 4; entry.Height += 4; break; default: throw new Exception(string.Format("Parser found an unknown keyword '{0}'", key)); } }
public Design Parse(string designText, Action <int> setProgress, out string error) { Design design = new Design(); error = ""; progress = setProgress; string line; try { string[] lines = designText.Split('\n'); int i = 0; int p = 0; DesignEntry lastEntry = null; bool end = false; while (i < lines.Length && string.IsNullOrEmpty(error) && !end) { line = lines[i]; DesignEntry entry = Parse(design, line, p, i); if (entry != null) { if (lastEntry != null) { if (entry.Class == Class.Stamp || entry.Class == Class.Variety || entry.Class == Class.Description || entry.Class == Class.LineFeed) { if (lastEntry.Class != Class.Stamp && lastEntry.Class != Class.Variety && lastEntry.Class != Class.Description && lastEntry.Class != Class.LineFeed) { // It looks like it has no use Class.Images & Class.ListBegin, but leave it, otherwise the HtmlHelper fails design.Add(new DesignEntry(Class.Images, p)); design.Add(new DesignEntry(Class.ListBegin, p)); } } if (lastEntry.Class == Class.Stamp || lastEntry.Class == Class.Variety || lastEntry.Class == Class.Description || lastEntry.Class == Class.LineFeed) { if (entry.Class != Class.Stamp && entry.Class != Class.Variety && entry.Class != Class.Description && entry.Class != Class.LineFeed) { // It looks like it has no use Class.ListEnd, but leave it, otherwise the HtmlHelper fails design.Add(new DesignEntry(Class.ListEnd, p)); } } } if (lastEntry != null) { if (entry.Class == Class.Varieties && lastEntry.Class == Class.Varieties) { throw new Exception(string.Format("Found '{0}', expected '{1}' or '{2}'", entry.Class.ToString(), Class.Variety, Class.Description)); } } design.Add(entry); lastEntry = entry; p = entry.PageNumber; end = (entry.Class == Class.None); } i++; SetProgress(i, lines.Length); } if (!end) { design.Add(Parse(design, "End", 0, 0)); } } catch (Exception e) { error = e.Message; } // The page number for Country, Section and Series is too low, increment them with 1 for (int i = 0; i < design.Count(); i++) { if (design[i].Class == Class.Country) { int j = i; while (design[j].Class != Class.PageFeed) { design[j++].PageNumber++; } } } return(design); }
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(); } }
public static string GetDesignInHtml(Design design) { StringBuilder html = new StringBuilder(); html.Append(@" <style> a, a.visited { color: blue; } body, td { font-family: Arial; font-size: 75%; } img.display-image-exists { border: 1px solid #ddd; border-radius: 3px; padding: 30px; } img.display-image-not-exists { border: 2px solid rgba(255, 0, 0, 1); border-radius: 3px; padding: 3px; } img:hover { box-shadow: 0 0 3px 1px rgba(0, 140, 186, 0.5); } </style> "); string country = ""; string section = ""; for (int i = 0; i < design.Count(); i++) { DesignEntry entry = design[i]; switch (entry.Class) { case Class.PageFeed: html.Append(string.Format("<center><h1 id=\"page({0},{1})\"><a href=\"page({2})\">{3} ({4})</a></h1></center>", entry.PageNumber, entry.AlbumNumber, entry.PageNumber, entry.AlbumNumber, entry.PageNumber)); if (!entry.Combine) { html.Append(string.Format("<center>{0} ({1})</center>", entry.Html, entry.Comment)); } else { html.Append(string.Format("<center>{0}</center>", entry.Comment)); } break; case Class.Country: country = entry.Text; html.Append(GetHeading("1", entry.Text)); html.Append(GetTableOfContents(design, i)); break; case Class.Section: section = entry.Text; html.Append(string.Format("<a name=\"section({0},{1})\"></a>", country, entry.Text)); html.Append(GetHeading("2", entry.Text)); break; case Class.Type: html.Append(GetHeading("3", entry.Text)); break; case Class.Series: html.Append(GetHeading("4", entry.Text)); break; case Class.Varieties: html.Append(GetText(entry.Text)); break; case Class.Variety: case Class.Description: html.Append("<table>"); while (entry.Class == Class.Variety || entry.Class == Class.Description) { if (entry.Class == Class.Variety) { html.Append(GetStamp(entry)); } else if (entry.Class == Class.Description) { html.Append(GetStampDescription(entry.Text)); } entry = design[++i]; } html.Append("</table><br>"); break; case Class.Stamp: string thumbnail = ImageHelper.GetThumbnailImage(App.GetSetting("ImagesFolder"), country, section, entry.Number, entry.Width, entry.Height, out bool existsDisplayImage); string s; if (existsDisplayImage) { s = string.Format("<a href=\"stamp({0})\"><img src=\"{1}\" title=\"{2}\" style=\"border:3px solid white\"></a>", i, thumbnail, entry.Number); } else { s = string.Format("<a href=\"stamp({0})\"><img src=\"{1}\" title=\"{2}\" style=\"border:3px dotted red\"> </a>", i, thumbnail, entry.Number); } html.Append(s); break; } } return(html.ToString()); }
public static Page Get(Design design, int pageNumber, FrameStyle frameStyle) { string subType = ""; string subTypeToPass = ""; string description = ""; DesignEntry pagefeed = design.GetPagefeed(pageNumber); Page page = new Page(pagefeed.Html, pagefeed.Comment); // Look up the title // a) NEDERLAND // b) BADEN // c) REPUBLIK MALUKU SELATAN DesignEntry country = design.GetCountry(pageNumber); page.Country = country.Text; page.Copyright = country.Copyright; page.FrontPageTitle = country.FrontPageTitle; page.FrontPageSubTitle = country.FrontPageSubTitle; page.PageTitle = country.PageTitle; // Loop up the folder // a) Frankeerzegels // b) Briefmarken // c) Cinderellas DesignEntry section = design.GetSection(pageNumber); page.Section = section.Text; page.ImagesPath = string.Format("{0}\\{1}\\{2}\\", App.GetSetting("ImagesFolder"), page.Country, page.Section); // Look up the sub title // a) 1867-1869. Koning Willem III. // b) ALTDEUTSCHLAND // c) 1950. U.P.U. DesignEntry series = design.GetSeries(pageNumber); page.Series = series.Text; // Look up the sub sub title // a) Type I. // b) Portomarken // c) Regular. DesignEntry mainType = design.FirstOrDefault(entry => entry.Class == Class.Type && entry.PageNumber == pageNumber); if (mainType != null) { page.MainType = mainType.Text; } // Look up the first entry having this page number int first = design.FindIndex(entry => entry.PageNumber == pageNumber); int i = first; while (design[i].PageNumber == design[first].PageNumber) { DesignEntry entry = design[i]; switch (entry.Class) { case Class.PageFeed: page.OffsetVertical = entry.OffsetVertical; page.AlbumNumber = entry.AlbumNumber; page.IsSample = entry.Sample; if (entry.Width != 0) { page.Spacing = entry.Width; } break; case Class.Image: page.AddImage(entry.Number, entry.Width, entry.Height, entry.OffsetHorizontal, entry.OffsetVertical, entry.RoundedCorners); break; case Class.Type: subType = entry.Text; break; case Class.Description: description = entry.Text; break; case Class.Varieties: case Class.LineFeed: if (subType != page.MainType) { subTypeToPass = subType; } else { subTypeToPass = ""; } page.AddVarieties( entry.Text, entry.Comment, subTypeToPass, entry.OffsetHorizontal, entry.OffsetVertical, entry.VerticalMoveRelative, entry.VerticalMoveAbsolute, entry.Combine, entry.Alignment, entry.FontOfType, entry.FontOfDescription, entry.Width, entry.Height, entry.Watermark, entry.Appearance, entry.MaxWidth ); subType = ""; break; case Class.Variety: if (entry.ApplyTo.ToUpper() != "VB" && PassFrameStyle(entry.ApplyToFrameStyle, frameStyle)) { page.AddVariety( Variety.GetNumber(entry), Variety.GetValueAndColor(entry), description, entry.FrameColor, entry.Width, entry.Height, entry.OffsetHorizontal, entry.OffsetVertical, entry.Skip, entry.Appearance, string.IsNullOrEmpty(entry.Picture) ? entry.Number : entry.Picture, entry.Overprint, entry.Shape, entry.Alignment, entry.Positions ); description = ""; } break; } i++; } return(page); }