Example #1
0
        public static KTextModule TryCreateFromModuleNode(XmlNode moduleNode)
        {
            if (moduleNode.Name != "text")
            {
                return(null);
            }

            var text = new KTextModule();

            text.LoadBasicsFromNode(moduleNode);

            text.Properties.Add("internal_type", "TextModule");

            text.AddOptional(moduleNode, "font", "text_family", s => {
                if (s.StartsWith("kfile://"))
                {
                    return(s);
                }
                else
                {
                    return("kfile://org.kustom.provider/fonts/" + s);
                }
            });

            text.AddOptional(moduleNode, "align", "text_align");
            text.AddOptional(moduleNode, "width", "text_width");
            text.AddOptional(moduleNode, "height", "text_height");
            text.AddOptional(moduleNode, "maxlines", "text_lines");
            text.AddOptional(moduleNode, "size", "text_size");
            text.AddOptional(moduleNode, "type", "text_size_type");

            var textNode = moduleNode.SelectSingleNode("text");

            if (textNode == null)
            {
                throw KmlParseException.MissingRequiredNode("text", moduleNode);
            }
            text.AddFromContent(textNode, "text_expression", text.Properties);

            var textFiltersNode = moduleNode.SelectSingleNode("textfilters");

            if (textFiltersNode != null)
            {
                var filterNodes = textFiltersNode.SelectNodes("filter");
                foreach (XmlNode filterNode in filterNodes)
                {
                    text.TextFilter.Add(filterNode.InnerText);
                }
            }

            return(text);
        }
Example #2
0
        public static KModule ModuleNodeToKModule(XmlNode moduleNode)
        {
            KModule module = null;

            module = KShapeModule.TryCreateFromModuleNode(moduleNode);
            if (module == null)
            {
                module = KTextModule.TryCreateFromModuleNode(moduleNode);
            }

            if (module == null)
            {
                throw KmlParseException.UnknownModuleName(moduleNode.Name);
            }

            return(module);
        }