Пример #1
0
        public static Font extractFontFromLine(string tempL)
        {
            string CharStyle = findStringWithDelimiter(tempL, "AppliedCharacterStyle=\"", "\"");

            //carico il default dello stile del carattere
            FontID F = dictStyles[CharStyle].clone();

            // leggo PointSize se c'è
            if (tempL.Contains("PointSize=\""))
            {
                F.pointSize = findStringWithDelimiter(tempL, "PointSize=\"", "\"");
                if (F.pointSize.Contains("."))
                {
                    F.pointSize = F.pointSize.Substring(0, F.pointSize.IndexOf("."));
                }
            }

            // leggo // leggo FontStyle se c'è
            if (tempL.Contains("FontStyle=\""))
            {
                F.fontStyle = findStringWithDelimiter(tempL, "FontStyle=\"", "\"");
            }
            Font curFont = null;

            problems += F.GetFont(dictStyles, ref curFont);
            return(curFont);
        }
Пример #2
0
        public static void loadStyles()
        {
            StreamReader sr = File.OpenText(IDMLTempPath + @"\resources\styles.xml");

            dictStyles = new Dictionary <string, FontID>();
            FontID LastFont = new FontID();

            while (!sr.EndOfStream)
            {
                string tempL = sr.ReadLine();
                if (tempL.Contains("CharacterStyle Self=\""))
                {
                    //int PointSize=-1;
                    //bool FoundPointSize = false;
                    //bool FoundStyle = false;
                    //FontStyle Fs = new FontStyle();
                    //string charStyle = extractFontFromLine(tempL,"CharacterStyle Self=\"",ref PointSize,ref  Fs, ref FoundPointSize, ref FoundStyle);
                    //if ((FoundPointSize & FoundStyle) == false) extractFontFromStyleFile(charStyle, ref PointSize, ref Fs, ref FoundPointSize, ref FoundStyle);

                    string charstyle = findStringWithDelimiter(tempL, "CharacterStyle Self=\"", "\"");
                    string pointsize = "";
                    string fontstyle = "";
                    if (tempL.Contains("PointSize=\""))
                    {
                        string Strpointsize = findStringWithDelimiter(tempL, "PointSize=\"", "\"");
                        if (Strpointsize.Contains("."))
                        {
                            pointsize = Strpointsize.Substring(0, Strpointsize.IndexOf("."));
                        }
                        else
                        {
                            pointsize = Strpointsize;
                        }
                    }

                    if (tempL.Contains("FontStyle=\""))
                    {
                        fontstyle = findStringWithDelimiter(tempL, "FontStyle=\"", "\"");
                    }

                    LastFont = new FontID(charstyle, pointsize, fontstyle);
                    //aggiungo Font
                    dictStyles.Add(charstyle, LastFont);
                }

                // <BasedOn type="object">CharacterStyle/DIN</BasedOn>
                if (tempL.Contains("<BasedOn type=\"object\">"))
                {
                    LastFont.basedOn = findStringWithDelimiter(tempL, "<BasedOn type=\"object\">", "</BasedOn>");
                }
            }
            sr.Close();
        }