OidArea() public method

public OidArea ( TextWriter w, int oid ) : void
w System.IO.TextWriter
oid int
return void
Exemplo n.º 1
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.º 2
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.º 3
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.º 4
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>
");
            }
        }