Beispiel #1
0
        private void FillXmlTree(_XMLTree tree, string XML, int startChar, ref int lastChar)
        {
            tree.tagOpen = GetMainTag(XML);
            TagContent content = DefineTagContent(XML);
            string     remains;

            if (content == TagContent.Content)
            {
                tree.tagContent = GetContent(XML, out remains);
            }
            else if (content == TagContent.Tree)
            {
                int idx = startChar;

                string NewXml = XML.Remove(0, tree.tagOpen.Length + 2);
                idx += tree.tagOpen.Length + 2;
                do
                {
                    int lastIdx = 0;
                    tree.subTrees.Add(new _XMLTree());
                    FillXmlTree(tree.subTrees[tree.subTrees.Count - 1], NewXml, idx, ref lastIdx);
                    NewXml = NewXml.Remove(0, lastIdx - idx);
                    idx   += lastIdx;
                } while (!isClosingTagNext(tree.tagOpen, NewXml));
            }
        }
Beispiel #2
0
        private void RenderSampleDataSection(TagContent content)
        {
            if (string.IsNullOrWhiteSpace(_project.Index.SampleFileName))
            {
                content.Add(T.g("p")[
                                "No sample file loaded. ",
                                T.g("a", "href", SetSampleFileCommand)["Add a sample file"]
                            ]);
            }
            else
            {
                content.Add(T.g("p")[
                                $"Sample file '{_project.Index.SampleFileName}'. ",
                                T.g("a", "href", SetSampleFileCommand)["Replace sample file"]
                            ]);
            }

            content.Add(T.g("p")[
                            T.g("a", "href", SetDataFiltersCommand)["Setup data filters and splits"]
                        ]);

            content.Add(T.g("p")[
                            T.g("a", "href", RenderSampleCommand)["Render PDF from sample data"]
                        ]);
        }
Beispiel #3
0
        /// <summary>
        /// 解析标签内容
        /// </summary>
        public bool ParseContent()
        {
            int pos1  = TagContent.IndexOf(']');
            int pos2  = TagContent.LastIndexOf("[/XCY");
            int tempi = TagContent.IndexOf("[");

            if (TagContent.Length > 0 && pos1 > 1 && pos2 > 1)
            {
                Primary = TagContent.Substring(tempi + 1, pos1 - 1);
                int n = pos2 - pos1 - 1;
                if (n > 0)
                {
                    Inserted = TagContent.Substring(pos1 + 1, n);
                }
            }
            pos1  = TagContent.IndexOf("PIC]");
            pos2  = TagContent.LastIndexOf("[/PIC");
            tempi = TagContent.IndexOf("[PIC");
            if (TagContent.Length > 0 && pos1 > 1 && pos2 > 1)
            {
                int n = pos2 - pos1 - 4;
                if (n > 0)
                {
                    InsertedPic = TagContent.Substring(pos1 + 4, n);
                }
            }
            return(AnalyzeLabel());
        }
Beispiel #4
0
 private TagContent BasePage(out TagContent body)
 {
     body = T.g("body");
     return(T.g("html")[
                T.g("head"),
                body
            ]);
 }
Beispiel #5
0
        public void ShowPage(TagContent bodyContent)
        {
            var page = BasePage(out var body);

            body.Add(bodyContent);
            _midNavigation = true;
            mainViewHtml !.DocumentText = page;
        }
Beispiel #6
0
        public void TestContentDefinition2()
        {
            string              xml             = "<a><b>123</b></a>";
            TagContent          content         = TagContent.Tree;
            _XMLDeserialization deserialization = new _XMLDeserialization(xml);
            TagContent          factContent     = deserialization.DefineTagContent(deserialization.XML_String);

            Assert.AreEqual(content, factContent);
        }
Beispiel #7
0
 private void RenderProjectHeader(TagContent content)
 {
     content.Add(
         T.g("p")[_project.BasePath],
         T.g("h1")[_project.Index.Name],
         T.g("p")[_project.Index.Notes],
         T.g("a", "href", EditProjectNotesCommand)["Edit project name & notes"]
         );
 }
 private static void AddSubtypeWarning(TagContent block)
 {
     block.Add(T.g("p")[
                   T.g("b")["Note: "],
                   "This type does not derive from ",
                   T.g("code")["Gasconade.TemplatedLogMessage"],
                   " and can't be sent"
               ]);
 }
        private static void AddTitle(TemplateMetadata info, TagContent block)
        {
            if (!string.IsNullOrWhiteSpace(info.Description.RetirementMessage))
            {
                block.Add(T.g("p", "class", "titleNote")[info.Description.RetirementMessage]);
            }

            block.Add(T.g("h3", "class", "header", "id", info.FullName)[info.Name]);
            if (!info.IsCorrectHierarchy)
            {
                AddSubtypeWarning(block);
            }
        }
Beispiel #10
0
        public static string ConvertToStyledString(this TagContent tagContent)
        {
            var result = string.Empty;

            if (tagContent.ContentType == TagContentTypes.String)
            {
                return(tagContent.Value.ToString().ConvertExtendedAscii());
            }

            var content = (tagContent.Value as Tag).TagContent;

            result = result + " " + ConvertToStyledStrings(content);
            return(result);
        }
Beispiel #11
0
        static string ConvertToNoTagsString(this TagContent tagContent)
        {
            var result = string.Empty;

            if (tagContent.ContentType == TagContentTypes.String)
            {
                return(tagContent.Value.ToString());
            }

            var content = (tagContent.Value as Tag).TagContent;

            result = result + " " + ConvertToNoTagsString(content);
            return(result);
        }
Beispiel #12
0
 private static void AddTemplate(TemplateMetadata info, TagContent block)
 {
     if (string.IsNullOrWhiteSpace(info.Template))
     {
         block.Add(T.g("i")["This message has no template, and will be given a default message"]);
     }
     else if (info.Description.IsObsolete)
     {
         block.Add(T.g("code", "class", "obsoleteTemplate")[info.Template]);
     }
     else
     {
         block.Add(T.g("code", "class", "template")[info.Template]);
     }
 }
Beispiel #13
0
        private void RenderPageInfo(TemplatePage templatePage, TagContent content, int index)
        {
            var clearLine = T.g("hr/", "style", "clear:both");

            content.Add(
                T.g("a", "href", $"{InsertPageCommand}?index={index}")["Insert new page here"],
                clearLine,
                T.g("div", "id", $"page{index}", "style", "float:left;width:40%;margin-right:5%;")[
                    RenderPageInfoAndCommands(templatePage, index)
                ],
                T.g("div", "style", "float:left;width:50%;height:60%;overflow-y:scroll")[
                    RenderBackgroundPreview(templatePage, index)
                ],
                clearLine
                );
        }
        private static string TagHttpPage(TagContent body)
        {
            if (body.Tag != "body")
            {
                body = T.g("body")[body];
            }

            body.Add(T.g("script", "type", "text/javascript")[GetScriptData()]);

            var content = T.g("html")[
                T.g("head")[
                    T.g("title")["Log documentation (Gasconade)"],
                    T.g("style")[GetStyleData()]
                ],
                body
                          ];

            return(content);
        }
Beispiel #15
0
        private static Task <HttpResponseMessage> TagHttpPage(TagContent body)
        {
            if (body.Tag != "body")
            {
                body = T.g("body")[body];
            }

            body.Add(T.g("script", "type", "text/javascript")[GetScriptData()]);

            var content = T.g("html")[
                T.g("head")[
                    T.g("title")["Log documentation (Gasconade)"],
                    T.g("style")[GetStyleData()]
                ],
                body
                          ];

            var sampleMessage = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(content, Encoding.UTF8, "text/html")
            };

            return(Task.FromResult(sampleMessage));
        }
Beispiel #16
0
        /// <summary>
        /// Create a html body that lists out all the known log message types with descriptions
        /// </summary>
        public static TagContent ListingDocument(List <Type> all, string returnLink = null, TagContent heading = null)
        {
            var lines = T.g();

            lines.Add(T.g("i")["Gasconade "]);
            if (!string.IsNullOrWhiteSpace(returnLink))
            {
                lines.Add(T.g("a", "href", returnLink)["Return to API docs"]);
            }
            lines.Add(T.g("h1")["Log Documentation"]);

            if (heading != null)
            {
                lines.Add(heading);
            }

            var sorted = all.Select(ReadTemplateMetadata).OrderBy(m => m.Description.IsObsolete).ThenBy(m => m.Name);

            foreach (var info in sorted)
            {
                var block = T.g("div", "class", "MessageBlock");

                AddTitle(info, block);
                AddTemplate(info, block);
                block.Add(BuildDetailsExpander(info));

                lines.Add(block);
            }

            return(lines);
        }
Beispiel #17
0
        private static void DrawLines(double[] hist, double max, int height, int width, TagContent root, string @class)
        {
            var count = hist.Length;

            var Hprop = Math.Max(1, max / height);
            var Vprop = (double)width / count;

            for (int i = 1; i < count; i++)
            {
                var Ly = hist[i - 1] / Hprop;
                var Lx = (i - 1) * Vprop;
                var Ry = hist[i] / Hprop;
                var Rx = i * Vprop;

                root.Add(SimpleLine(Lx, height - Ly, Rx, height - Ry, @class));
            }
        }
Beispiel #18
0
 private static TagContent SvgHeader(int width, int height, out TagContent rootElement)
 {
     rootElement = T.g("g", "transform", "translate(0,0)");
     return(T.g("svg", "id", "svgroot", "width", width + "px", "height", height + "px")[rootElement]);
 }