protected void Initialize()
        {
            System.IO.DirectoryInfo directoryInfo = new System.IO.DirectoryInfo(source);
            System.IO.FileInfo[] filesInfo = directoryInfo.GetFiles();
            var files = filesInfo.OrderBy(f => f.FullName);//sort alphabetically
            //foreach (System.IO.FileInfo info in filesInfo)
            foreach(System.IO.FileInfo info in files)
            {
                //System.Diagnostics.Debug.WriteLine("Reading " + info.Name + "...");

                SvgReader reader = new SvgReader(info.FullName);
                //HACK: At this moment only support one Path in a template file. Ideal case is get a group of graphic object.
                var elements = reader.GetXMLElements("path");
                foreach (XElement element in elements)
                {
                    Path path = new Path();
                    path.Fill = Brushes.Black;
                    XAttribute attribute = element.Attribute(XName.Get("d"));
                    path.Data = (Geometry)new GeometryConverter().ConvertFromString(attribute.Value);//key

                    //string name = info.Name.ToLower().TrimEnd(new char[] { 'g', 'v', 's', '.' });//caused some ended with 's' interpreted wrongly.
                    string name = info.Name.ToLower().Substring(0, info.Name.Length - 4);
                    string label = GetLabel(info.Name);
                    if (label.Length > 0) name = name.Replace(label, string.Empty);

                    PathViewModel item = new PathViewModel(name, path, label);
                    this.items.Add(item);
                    break;
                }
            }//end loops
        }
Exemple #2
0
        /// <summary>
        /// Retrieve svg path tag value.
        /// </summary>
        /// <param name="templateName"></param>
        /// <returns></returns>
        private string GetMuslimMonthSvgPath(string templateName)
        {
            string line = string.Empty;
            var elements = new SvgReader(templateName).GetXMLElements("path");

            line += "<path";
            foreach (XElement e in elements)
            {
                //line = e.ToString();

                line += "\n";
                XAttribute attribute = e.Attribute(XName.Get("d"));
                line += attribute.Name + "=\"" + attribute.Value + "\" ";

                line += "\n";
                attribute = e.Attribute(XName.Get("style"));
                line += attribute.Name + "=\"" + attribute.Value + "\" ";
            }
            line += "/>";

            return line;
        }
Exemple #3
0
 private IEnumerable<XElement> GetSvgPath(string templateName)
 {
     string line = string.Empty;
     var elements = new SvgReader(templateName).GetXMLElements("path");
     return elements;
 }