Inheritance: HtmlGenerator
Exemplo n.º 1
0
 public Settings()
 {
     NextProductId = 800;
     var w = new OidSvgWriter(new TiptoiOidCode());
     OidDotSize = w.DotSize;
     OidGridSpacing = w.GridSpacing;
 }
Exemplo n.º 2
0
        public static void CreateTemplateSVGPage(string testPagePath)
        {
            var code = new TiptoiOidCode();



            using (var w = new StreamWriter(testPagePath))
            {
                w.WriteLine(@"<?xml version=""1.0"" encoding=""ISO-8859-1"" standalone=""no""?>
<!DOCTYPE svg PUBLIC ""-//W3C//DTD SVG 20010904//EN""  ""http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"">
<svg class=""oid-area"">
");

                w.WriteLine("<defs>");
                var oidWriter = new OidSvgWriter(code);

                for (var oid = 800; oid < 840; oid++)
                {
                    oidWriter.OidPattern(w, oid);
                }
                for (var oid = 10250; oid < 10290; oid++)
                {
                    oidWriter.OidPattern(w, oid);
                }
                w.WriteLine(@"</defs>");
                w.WriteLine(@"</svg>");
            }
        }
Exemplo n.º 3
0
        public Settings()
        {
            NextProductId = 800;
            var w = new OidSvgWriter(new TiptoiOidCode());

            OidDotSize     = w.DotSize;
            OidGridSpacing = w.GridSpacing;
        }
Exemplo n.º 4
0
 public PackageBuilder(
     IPackageDirectoryStructure structure,
     MediaFileConverter converter,
     OidSvgWriter oidWriter
     )
 {
     this.packageDirectoryStructure = structure;
     this.converter = converter;
     this.MaxGmeSize = 800 * 1024 * 1024;
     OidSvgWriter = oidWriter;
 }
Exemplo n.º 5
0
 public PackageBuilder(
     IPackageDirectoryStructure structure,
     MediaFileConverter converter,
     OidSvgWriter oidWriter
     )
 {
     this.packageDirectoryStructure = structure;
     this.converter  = converter;
     this.MaxGmeSize = 800 * 1024 * 1024;
     OidSvgWriter    = oidWriter;
 }
Exemplo n.º 6
0
        public static void CreatePrinterSVGPage(string testPagePath)
        {
            var code = new TiptoiOidCode();



            using (var w = new StreamWriter(testPagePath))
            {
                w.WriteLine(@"<?xml version=""1.0"" encoding=""ISO-8859-1"" standalone=""no""?>
<!DOCTYPE svg PUBLIC ""-//W3C//DTD SVG 20010904//EN""  ""http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"">
<svg class=""oid-area"">
");


                var defaultOidWriter = new OidSvgWriter(code);
                var oid = 10250;

                var powBase = 1.1;

/*
 *              for (int dotSize = -4; dotSize <= 4; ++dotSize)
 *              {
 *                  var fDotSize = (float)Math.Pow(powBase, dotSize);
 *                  w.Write("<td>"); w.Write(T(String.Format("Dot Size {0:F4} cm", defaultOidWriter.DotSize * fDotSize))); w.Write("</td>");
 *              }
 *              w.Write("</tr>");*/

                for (int gridSpacing = -4; gridSpacing <= 4; ++gridSpacing)
                {
                    var fGridSpacing = (float)Math.Pow(powBase, gridSpacing);
                    //w.Write("<tr>");
                    //w.Write("<td>"); w.Write(T(String.Format("Grid Spacing {0:F4} cm", defaultOidWriter.GridSpacing * fGridSpacing))); w.Write("</td>");
                    for (int dotSize = -4; dotSize <= 4; ++dotSize)
                    {
                        var fDotSize = (float)Math.Pow(powBase, dotSize);

                        var oidWriter = new OidSvgWriter(code)
                        {
                            DotOffset   = defaultOidWriter.DotOffset,
                            DotSize     = defaultOidWriter.DotSize * fDotSize,
                            GridSpacing = defaultOidWriter.GridSpacing * fGridSpacing
                        };
                        w.WriteLine("<defs>");
                        oidWriter.OidPattern(w, oid);
                        w.WriteLine(@"</defs>");
                        w.WriteLine(@"<rect fill=""url(#Code{0})"" x=""{1}cm"" y=""{2}cm"" width=""1cm"" height=""1cm""/>", oid, (dotSize + 5) * 2, (gridSpacing + 5) * 2);
                        oid++;
                    }
                }

                w.WriteLine(@"</svg>");
            }
        }
Exemplo n.º 7
0
        public static void CreatePrinterTestPage(string testPagePath)
        {
            var code = new TiptoiOidCode();

            var mediaDir = Path.Combine(Path.GetDirectoryName(testPagePath), "media");
            PathUtil.EnsureDirectoryExists(mediaDir);
            foreach (var mediaFile in new[]
            {
                "note_to_pen.png",
                "style.css"
            })
            {
                PathUtil.CopyIfNewer(
                    Path.Combine(PathUtil.GetDirectory(), "media", mediaFile),
                    Path.Combine(mediaDir, mediaFile));
            }

            using (var w = new StreamWriter(testPagePath))
            {
                w.WriteLine(@"
<!doctype html>
<html moznomarginboxes mozdisallowselectionprint>
  <head>
    <meta charset=""utf-8"">
    <meta name=""viewport"" content=""width=device-width, initial-scale=1.0"">
    <title>ttaudio Printer Test Page</title>
	<link rel=""stylesheet"" href=""media/style.css"" />
    <style>
    .oid-button {
        width: 4cm;
    }
    </style>
  </head>
  <body>
    <div class=""printInstructions"">
        <img src=""media/note_to_pen.png"" />
        <p><a href=""javascript:window.print();"">Click here to print the test page with optical codes.</a> Use a printer with at least 600 dpi.</p>
        <p>This page was generated by <a href=""" + About.GithubUri.ToString() + @""">" + T(About.Product) + @"</a> on " + T(DateTime.Now.ToString()) +
        @".</p></div>
    <h1>ttaudio Printer Test Page</h1>
");


                var defaultOidWriter = new OidSvgWriter(code);
                var oid = 10250;

                var powBase = 1.1;

                w.Write("<table>");
                w.Write("<tr>");
                w.Write("<td/>");
                for (int dotSize = -4; dotSize <= 4; ++dotSize)
                {
                    var fDotSize = (float)Math.Pow(powBase, dotSize);
                    w.Write("<td>"); w.Write(T(String.Format("Dot Size {0:F4} cm", defaultOidWriter.DotSize * fDotSize))); w.Write("</td>");
                }
                w.Write("</tr>");

                for (int gridSpacing = -4; gridSpacing <= 4; ++gridSpacing)
                {
                    var fGridSpacing = (float)Math.Pow(powBase, gridSpacing);
                    w.Write("<tr>");
                    w.Write("<td>"); w.Write(T(String.Format("Grid Spacing {0:F4} cm", defaultOidWriter.GridSpacing * fGridSpacing))); w.Write("</td>");
                    for (int dotSize = -4; dotSize <= 4; ++dotSize)
                    {
                        var fDotSize = (float)Math.Pow(powBase, dotSize);

                        var oidWriter = new OidSvgWriter(code)
                        {
                            DotOffset = defaultOidWriter.DotOffset,
                            DotSize = defaultOidWriter.DotSize * fDotSize,
                            GridSpacing = defaultOidWriter.GridSpacing * fGridSpacing
                        };

                        w.Write("<td>");
                        oidWriter.OidArea(w, oid++); // , String.Format("spacing: {0:F0}%, dot: {1:F0}%", fGridSpacing*100, fDotSize*100));
                        w.Write("</td>");
                    }
                    w.Write("</tr>");
                }
                w.Write("</table>");

                w.WriteLine(@"
  </body>
</html>
");
            }
        }
Exemplo n.º 8
0
        public static void CreatePrinterTestPage(string testPagePath)
        {
            var code = new TiptoiOidCode();

            var mediaDir = Path.Combine(Path.GetDirectoryName(testPagePath), "media");

            PathUtil.EnsureDirectoryExists(mediaDir);
            foreach (var mediaFile in new[]
            {
                "note_to_pen.png",
                "style.css"
            })
            {
                PathUtil.CopyIfNewer(
                    Path.Combine(PathUtil.GetDirectory(), "media", mediaFile),
                    Path.Combine(mediaDir, mediaFile));
            }

            using (var w = new StreamWriter(testPagePath))
            {
                w.WriteLine(@"
<!doctype html>
<html moznomarginboxes mozdisallowselectionprint>
  <head>
    <meta charset=""utf-8"">
    <meta name=""viewport"" content=""width=device-width, initial-scale=1.0"">
    <title>ttaudio Printer Test Page</title>
	<link rel=""stylesheet"" href=""media/style.css"" />
    <style>
    .oid-button {
        width: 4cm;
    }
    </style>
  </head>
  <body>
    <div class=""printInstructions"">
        <img src=""media/note_to_pen.png"" />
        <p><a href=""javascript:window.print();"">Click here to print the test page with optical codes.</a> Use a printer with at least 600 dpi.</p>
        <p>This page was generated by <a href=""" + About.GithubUri.ToString() + @""">" + T(About.Product) + @"</a> on " + T(DateTime.Now.ToString()) +
                            @".</p></div>
    <h1>ttaudio Printer Test Page</h1>
");


                var defaultOidWriter = new OidSvgWriter(code);
                var oid = 10250;

                var powBase = 1.1;

                w.Write("<table>");
                w.Write("<tr>");
                w.Write("<td/>");
                for (int dotSize = -4; dotSize <= 4; ++dotSize)
                {
                    var fDotSize = (float)Math.Pow(powBase, dotSize);
                    w.Write("<td>"); w.Write(T(String.Format("Dot Size {0:F4} cm", defaultOidWriter.DotSize * fDotSize))); w.Write("</td>");
                }
                w.Write("</tr>");

                for (int gridSpacing = -4; gridSpacing <= 4; ++gridSpacing)
                {
                    var fGridSpacing = (float)Math.Pow(powBase, gridSpacing);
                    w.Write("<tr>");
                    w.Write("<td>"); w.Write(T(String.Format("Grid Spacing {0:F4} cm", defaultOidWriter.GridSpacing * fGridSpacing))); w.Write("</td>");
                    for (int dotSize = -4; dotSize <= 4; ++dotSize)
                    {
                        var fDotSize = (float)Math.Pow(powBase, dotSize);

                        var oidWriter = new OidSvgWriter(code)
                        {
                            DotOffset   = defaultOidWriter.DotOffset,
                            DotSize     = defaultOidWriter.DotSize * fDotSize,
                            GridSpacing = defaultOidWriter.GridSpacing * fGridSpacing
                        };

                        w.Write("<td>");
                        oidWriter.OidArea(w, oid++); // , String.Format("spacing: {0:F0}%, dot: {1:F0}%", fGridSpacing*100, fDotSize*100));
                        w.Write("</td>");
                    }
                    w.Write("</tr>");
                }
                w.Write("</table>");

                w.WriteLine(@"
  </body>
</html>
");
            }
        }
Exemplo n.º 9
0
        public static void CreatePrinterTestPage(string testPagePath)
        {
            var code = new TiptoiOidCode();

            var mediaDir = Path.Combine(Path.GetDirectoryName(testPagePath), "media");

            PathUtil.EnsureDirectoryExists(mediaDir);
            foreach (var mediaFile in new[]
            {
                "note_to_pen.png",
                "style.css"
            })
            {
                PathUtil.CopyIfNewer(
                    Path.Combine(PathUtil.GetDirectory(), "media", mediaFile),
                    Path.Combine(mediaDir, mediaFile));
            }

            using (var w = new StreamWriter(testPagePath))
            {
                w.WriteLine(@"
<!doctype html>
<html moznomarginboxes mozdisallowselectionprint>
  <head>
    <meta charset=""utf-8"">
    <meta name=""viewport"" content=""width=device-width, initial-scale=1.0"">
    <title>ttaudio Printer Test Page</title>
	<link rel=""stylesheet"" href=""media/style.css"" />
    <style>
    .oid-button {
        width: 4cm;
    }
    table { 
      margin: 1em;
      float: left;
    }
    </style>
  </head>
  <body>
    <div class=""printInstructions"">
        <img src=""media/note_to_pen.png"" />
        <p><a href=""javascript:window.print();"">Click here to print the test page with optical codes.</a> Use a printer with at least 600 dpi. Then use the TipToi pen to find out 
        which combination of dot size and grid spacing works best for your printer. Enter the found values in 
        <i>ttaudio &gt; Main Menu &gt; Tools &gt; Options...</i></p>
        <p>This page was generated by <a href=""" + About.GithubUri.ToString() + @""">" + T(About.Product) + @"</a> on " + T(DateTime.Now.ToString()) +
                            @".</p></div>
    <h1>ttaudio Printer Test Page</h1>
");


                var defaultOidWriter = new OidSvgWriter(code);
                var oid = 10250;

                var powBase = 1.1;

                const char columnLetterStart = '1';
                const char rowLetterStart    = 'A';

                w.Write("<table>");
                w.Write("<tr>");
                w.Write("<td/>");
                char columnLetter = columnLetterStart;
                for (int dotSize = -4; dotSize <= 4; ++dotSize)
                {
                    var fDotSize = (float)Math.Pow(powBase, dotSize);
                    w.Write("<td>"); w.Write(T(String.Format("{0}", columnLetter++))); w.Write("</td>");
                }
                w.Write("</tr>");

                char rowLetter = rowLetterStart;
                for (int gridSpacing = -4; gridSpacing <= 4; ++gridSpacing)
                {
                    var fGridSpacing = (float)Math.Pow(powBase, gridSpacing);
                    w.Write("<tr>");
                    w.Write("<td>"); w.Write(T(String.Format("{0}", rowLetter++))); w.Write("</td>");
                    for (int dotSize = -4; dotSize <= 4; ++dotSize)
                    {
                        var fDotSize = (float)Math.Pow(powBase, dotSize);

                        var oidWriter = new OidSvgWriter(code)
                        {
                            DotOffset   = defaultOidWriter.DotOffset,
                            DotSize     = defaultOidWriter.DotSize * fDotSize,
                            GridSpacing = defaultOidWriter.GridSpacing * fGridSpacing
                        };

                        w.Write("<td>");
                        oidWriter.OidArea(w, oid++); // , String.Format("spacing: {0:F0}%, dot: {1:F0}%", fGridSpacing*100, fDotSize*100));
                        w.Write("</td>");
                    }
                    w.Write("</tr>");
                }
                w.Write("</table>");

                w.Write("<p/>");
                w.Write("<table border=\"solid\">");
                w.Write("<tr><th>Row</th><th>Dot Size</th></tr>");
                rowLetter = rowLetterStart;
                for (int dotSize = -4; dotSize <= 4; ++dotSize)
                {
                    w.Write("<tr>");
                    var fDotSize = (float)Math.Pow(powBase, dotSize);
                    w.Write("<td>"); w.Write(T(String.Format("{0}", rowLetter++))); w.Write("</td>");
                    w.Write("<td>"); w.Write(T(String.Format("{0:F0} µm", defaultOidWriter.DotSize * fDotSize * 1e4))); w.Write("</td>");
                    w.Write("</tr>");
                }
                w.Write("</table>");

                w.Write("<p/>");
                w.Write("<table border=\"1\" style=\"border: solid 1px;\" >");
                w.Write("<tr><th>Column</th><th>Grid Spacing</th></tr>");
                columnLetter = columnLetterStart;
                for (int gridSpacing = -4; gridSpacing <= 4; ++gridSpacing)
                {
                    var fGridSpacing = (float)Math.Pow(powBase, gridSpacing);
                    w.Write("<tr>");
                    w.Write("<td>"); w.Write(T(String.Format("{0}", columnLetter++))); w.Write("</td>");
                    w.Write("<td>"); w.Write(T(String.Format("{0:F0} µm", defaultOidWriter.GridSpacing * fGridSpacing * 1e4))); w.Write("</td>");
                    w.Write("</tr>");
                }
                w.Write("</table>");

                w.WriteLine(@"
  </body>
</html>
");
            }
        }
Exemplo n.º 10
0
        private void WriteHtml(CancellationToken cancellationToken)
        {
            var p = packageDirectoryStructure.Package;
            var htmlMediaFiles = new List<string>();

            AddStaticMediaFile(cancellationToken, "style.css");
            AddStaticMediaFile(cancellationToken, "power.svg");
            AddStaticMediaFile(cancellationToken, "stop.svg");

            var styles = new DirectoryInfo(Path.Combine(PathUtil.GetDirectory(), "media")).GetFiles("*.css")
                .Where(_ => !object.Equals(_.Name, "style.css")).ToList();

            foreach (var i in styles)
            {
                AddStaticMediaFile(cancellationToken, i.Name);
            }

            AddStaticMediaFile(cancellationToken, "note_to_pen.png");

            log.InfoFormat("Write {0}", packageDirectoryStructure.HtmlFile);

            var ow = new OidSvgWriter(new TiptoiOidCode());
            PathUtil.EnsureParentDirectoryExists(packageDirectoryStructure.HtmlFile);
            using (var w = new StreamWriter(packageDirectoryStructure.HtmlFile))
            {
                w.WriteLine(@"
<!doctype html>
<html moznomarginboxes mozdisallowselectionprint>
  <head>
    <meta charset=""utf-8"">
    <meta name=""viewport"" content=""width=device-width, initial-scale=1.0"">
	<link rel=""stylesheet"" href=""media/style.css"" />
	<link rel=""stylesheet"" href=""media/default.css"" />
    <title>" + T(this.packageDirectoryStructure.Package.Title) + @"</title>
	<script>
	function changeCSS(cssFile) {
		var cssLinkIndex = 1;
		var oldlink = document.getElementsByTagName(""link"").item(cssLinkIndex);
		oldlink.setAttribute(""href"", cssFile);
	}
	</script>
  </head>
  <body>
    <div class=""printInstructions"">
        <img src=""media/note_to_pen.png"" />
        <p><a href=""javascript:window.print();"">Click here to print the page with optical codes to play your audio files.</a> Use a printer with at least 600 dpi.</p>
        <p>This page was generated by <a href=""" + About.GithubUri.ToString() + @""">" + T(About.Product) + @"</a> on " + T(DateTime.Now.ToString()) +
        @". Product ID = " + T(p.ProductId.ToString()) + @", GME file = " + T(packageDirectoryStructure.GmeFile) + @"</p>

Style: ");

                foreach (var i in styles)
                {
                    w.WriteLine(@"<a href=""#"" onclick=""changeCSS('media/{0}')"" >{1}</a>", i.Name, Path.GetFileNameWithoutExtension(i.Name));
                }

                w.WriteLine(@"</div>");
                w.WriteLine("<h1>");
                ow.OidButton(w, p.ProductId, "<img class=\"oid-area\" src=\"media/power.svg\" />");
                ow.OidButton(w, p.StopOid, "<img class=\"oid-area\" src=\"media/stop.svg\" />");
                w.WriteLine(T(p.Title));
                w.WriteLine("</h1>");

                foreach (var album in p.Albums)
                {
                    w.WriteLine(@"<div class=""album"">");
                    var pic = Extract(album.GetPicture());
                    htmlMediaFiles.Add(Path.GetFileName(pic));
                    w.WriteLine(@"<img src={0} class=""album-art"" />", ("media/" + Path.GetFileName(pic)).Quote());
                    w.WriteLine("<h2 class=\"album-title\" >{0} - {1}</h2>", T(album.Artist), T(album.Title));
                    w.WriteLine(@"<ul class={0}>", "track-list");
                    foreach (var track in album.Tracks)
                    {
                        w.WriteLine("<li>");
                        ow.OidArea(w, track.Oid);
                        w.WriteLine("</a>");
                        w.WriteLine("<span class={0}>{1}</span> ", "track-number".Quote(), T(track.TrackNumber.ToString()));
                        w.WriteLine("<span class={0}>{1}</span> ", "track-title".Quote(), T(track.Title));
                        w.WriteLine("<span class={0}>({1})</span> ", "track-duration".Quote(), T(track.Duration.ToString(@"mm\:ss")));
                        w.WriteLine("</li>");
                    }
                    w.WriteLine("</ul>");
                    w.WriteLine(@"<br class=""album-clear"" />");
                    w.WriteLine(@"</div>");
                }

                w.WriteLine(@"
  </body>
</html>
");
            }
        }
Exemplo n.º 11
0
        public static void CreatePrinterTestPage(string testPage)
        {
            var code = new TiptoiOidCode();

            using (var w = new StreamWriter(testPage))
            {
                w.WriteLine(@"
<!doctype html>
<html moznomarginboxes mozdisallowselectionprint>
  <head>
    <meta charset=""utf-8"">
    <meta name=""viewport"" content=""width=device-width, initial-scale=1.0"">
    <title>ttaudio Printer Test Page</title>
    <style>

.printInstructions {
	font-size: 12px;
	border: solid;
	border-width: 1px;

	background-color: lightyellow;
	
	padding: 4px;
	margin: 4px;
}

@media print {

	.printInstructions {
		display: none;
	}
}

.oid-area { 
   	width: 0.5cm;
	height: 0.5cm;
}

.oid-button { 
	border: solid;
	border-width: 1px;
	display: inline-block;

	padding: 4px;
	margin: 4px;
    width: 4cm;
}

</style>
  </head>
  <body>
    <div class=""printInstructions"">
        <img src=""media/note_to_pen.png"" />
        <p><a href=""javascript:window.print();"">Click here to print the test page with optical codes.</a> Use a printer with at least 600 dpi.</p>
        <p>This page was generated by <a href=""" + About.GithubUri.ToString() + @""">" + T(About.Product) + @"</a> on " + T(DateTime.Now.ToString()) +
        @".</p></div>");


                var defaultOidWriter = new OidSvgWriter(code);

                for (int gridSpacing = -3; gridSpacing <= 3; ++gridSpacing)
                {
                    for (int dotSize = -3; dotSize <= 3; ++dotSize)
                    {
                        var oidWriter = new OidSvgWriter(code)
                        {
                            DotOffset = defaultOidWriter.DotOffset,
                            DotSize = defaultOidWriter.DotSize * (float)Math.Pow(2.0, dotSize),
                            GridSpacing = defaultOidWriter.GridSpacing * (float)Math.Pow(2.0, gridSpacing)
                        };
                        
                        oidWriter.OidButton(w, 10250, String.Format("spacing: {0}, dot: {1}", gridSpacing, dotSize));
                    }
                }

                w.WriteLine(@"
  </body>
</html>
");
            }
        }