コード例 #1
0
ファイル: SvgPage.cs プロジェクト: notator/Moritz
        /// <summary>
        /// Writes this page.
        /// </summary>
        /// <param name="w"></param>
        public void WriteSVG(SvgWriter w, Metadata metadata)
        {
            int nOutputVoices = 0;
            int nInputVoices = 0;
            GetNumbersOfVoices(Systems[0], ref nOutputVoices, ref nInputVoices);

            w.WriteStartDocument(); // standalone="no"
            //<?xml-stylesheet href="../../fontsStyleSheet.css" type="text/css"?>
            w.WriteProcessingInstruction("xml-stylesheet", "href=\"../../fontsStyleSheet.css\" type=\"text/css\"");
            w.WriteStartElement("svg", "http://www.w3.org/2000/svg");

            WriteSvgHeader(w);

            WriteSodipodiNamedview(w);

            metadata.WriteSVG(w, _pageNumber, _score.PageCount, _pageFormat.AboutLinkURL, nOutputVoices, nInputVoices);

            _score.WriteDefs(w);

            #region layers

            int layerNumber = 1;

            if(_pageNumber > 0)
            {
                WriteFrameLayer(w, layerNumber++, "frame", _pageFormat.Right, _pageFormat.Bottom);
            }

            WriteScoreLayer(w, layerNumber++, "score", _pageNumber, metadata);

            WriteEmptyLayer(w, layerNumber++, "user annotations", true);
            #endregion layers

            w.WriteEndElement(); // close the svg element
            w.WriteEndDocument();
        }
コード例 #2
0
ファイル: SvgScore.cs プロジェクト: notator/Moritz
        private void SetScoreMetadata(string scoreTitleName, string keywords, string comment)
        {
            Metadata = new Metadata();

            /// The Metadata.MainTitle is the large title displayed at the top centre of page 1
            /// of the score. It is also the name of the folder inside the standard Moritz scores folder
            /// used for saving all the scores components.
            Metadata.MainTitle = scoreTitleName;
            Metadata.Keywords = keywords;
            Metadata.Comment = comment;

            Metadata.Date = M.NowString;
        }
コード例 #3
0
ファイル: SvgScore.cs プロジェクト: notator/Moritz
        /// <summary>
        /// Writes an SVG file containing one page of the score.
        /// </summary>
        public void SaveSVGPage(string pagePath, SvgPage page, Metadata metadata)
        {
            if(File.Exists(pagePath))
            {
                File.Delete(pagePath);
            }

            XmlWriterSettings settings = new XmlWriterSettings();
            settings.Indent = true;
            settings.IndentChars = ("\t");
            settings.CloseOutput = true;
            settings.NewLineOnAttributes = true;
            settings.NamespaceHandling = NamespaceHandling.OmitDuplicates;
            settings.Encoding = Encoding.GetEncoding("utf-8");

            using(SvgWriter w = new SvgWriter(pagePath, settings))
            {
                page.WriteSVG(w, metadata);
            }
        }
コード例 #4
0
ファイル: SvgPage.cs プロジェクト: notator/Moritz
        private void WriteScoreLayer(SvgWriter w, int layerNumber, string layerName, int pageNumber, Metadata metadata)
        {
            w.WriteStartElement("g"); // start layer (for Inkscape)
            WriteInkscapeLayerAttributes(w, layerNumber, layerName, true);

            w.SvgText("timeStamp", _infoTextInfo, 32, 80);

            if(pageNumber == 1 || pageNumber == 0)
            {
                WritePage1TitleAndAuthor(w, metadata);
            }

            int systemNumber = 1;
            foreach(SvgSystem system in Systems)
            {
                system.WriteSVG(w, systemNumber++, _pageFormat);
            }

            w.WriteEndElement(); // end layer (for Inkscape)
        }
コード例 #5
0
ファイル: SvgPage.cs プロジェクト: notator/Moritz
        /// <summary>
        /// Adds the link, main title and the author to the first page.
        /// </summary>
        protected void WritePage1TitleAndAuthor(SvgWriter w, Metadata metadata)
        {
            string titlesFontFamily = "Open Sans";

            TextInfo titleInfo =
                new TextInfo(metadata.MainTitle, titlesFontFamily, _pageFormat.Page1TitleHeight,
                    null, TextHorizAlign.center);
            TextInfo authorInfo =
              new TextInfo(metadata.Author, titlesFontFamily, _pageFormat.Page1AuthorHeight,
                  null, TextHorizAlign.right);
            w.WriteStartElement("g");
            w.WriteAttributeString("id", "titles");
            w.SvgText("mainTitle", titleInfo, _pageFormat.Right / 2F, _pageFormat.Page1TitleY);
            w.SvgText("author", authorInfo, _pageFormat.RightMarginPos, _pageFormat.Page1TitleY);
            w.WriteEndElement(); // group
        }