コード例 #1
0
        public OptionSettings(WpfDrawingSettings wpfSettings, string testPath)
        {
            _wpfSettings = wpfSettings;

            _localSuitePath = testPath;
            _testSuites     = SvgTestSuite.Create();

            if (wpfSettings == null)
            {
                _wpfSettings = new WpfDrawingSettings();
            }

            // For the start the default is selected
            var selectedSuite = SvgTestSuite.GetDefault(_testSuites);

            if (selectedSuite != null)
            {
                if (string.IsNullOrWhiteSpace(testPath))
                {
                    _localSuitePath = selectedSuite.LocalSuitePath;
                }
                _webSuitePath = selectedSuite.WebSuitePath;
            }

            if (!Directory.Exists(_localSuitePath))
            {
                Directory.CreateDirectory(_localSuitePath);
            }
        }
コード例 #2
0
        public OptionSettings(WpfDrawingSettings wpfSettings, string testPath)
        {
            _wpfSettings = wpfSettings;

            _localSuitePath = testPath;
            _testSuites     = SvgTestSuite.Create();

            if (wpfSettings == null)
            {
                _wpfSettings = new WpfDrawingSettings();
            }

            // For the start the default is selected
            var selectedSuite = SvgTestSuite.GetDefault(_testSuites);

            if (selectedSuite != null)
            {
                if (string.IsNullOrWhiteSpace(testPath))
                {
                    _localSuitePath = selectedSuite.LocalSuitePath;
                }
                _webSuitePath = selectedSuite.WebSuitePath;
            }

            if (!Directory.Exists(_localSuitePath))
            {
                Directory.CreateDirectory(_localSuitePath);
            }

            _webFontsPath   = SvgTestSuite.WebDirBase + FontsPrefix + SvgTestSuite.FileExtZip;
            _localFontsPath = Path.GetFullPath(Path.Combine(SvgTestSuite.LocalDirBase, FontsPrefix));

            if (!Directory.Exists(_localFontsPath))
            {
                Directory.CreateDirectory(_localFontsPath);
            }

            _wpfSettings.AddFontLocation(_localFontsPath);
        }
コード例 #3
0
ファイル: AboutPage.xaml.cs プロジェクト: zellus/SharpVectors
        private bool LoadFile(Stream stream, SvgTestInfo testInfo)
        {
            testDetailsDoc.Blocks.Clear();

            Regex rgx = new Regex("\\s+");

            testTitle.Text      = testInfo.Title;
            testDescrition.Text = rgx.Replace(testInfo.Description, " ").Trim();
            testFilePath.Text   = _svgFilePath;

            btnFilePath.IsEnabled = true;

            XmlReaderSettings settings = new XmlReaderSettings();

            settings.IgnoreWhitespace             = false;
            settings.IgnoreComments               = true;
            settings.IgnoreProcessingInstructions = true;
            settings.DtdProcessing = DtdProcessing.Parse;
            settings.XmlResolver   = null;

            SvgTestSuite selectedTestSuite = null;

            if (_optionSettings != null)
            {
                selectedTestSuite = _optionSettings.SelectedTestSuite;
            }
            if (selectedTestSuite == null)
            {
                selectedTestSuite = SvgTestSuite.GetDefault(SvgTestSuite.Create());
            }

            int majorVersion = selectedTestSuite.MajorVersion;
            int minorVersion = selectedTestSuite.MinorVersion;

            using (XmlReader reader = XmlReader.Create(stream, settings))
            {
                if (majorVersion == 1 && minorVersion == 1)
                {
                    if (reader.ReadToFollowing("d:SVGTestCase"))
                    {
                        _testCase = new SvgTestCase();

                        while (reader.Read())
                        {
                            string      nodeName = reader.Name;
                            XmlNodeType nodeType = reader.NodeType;
                            if (nodeType == XmlNodeType.Element)
                            {
                                if (string.Equals(nodeName, "d:operatorScript", StringComparison.OrdinalIgnoreCase))
                                {
                                    string inputText = reader.ReadInnerXml();
                                    string xamlText  = HTMLConverter.HtmlToXamlConverter.ConvertHtmlToXaml(inputText, false);

                                    Paragraph titlePara = new Paragraph();
                                    titlePara.FontWeight = FontWeights.Bold;
                                    titlePara.FontSize   = 16;
                                    titlePara.Inlines.Add(new Run("Operator Script"));

                                    if (_useConverter)
                                    {
                                        StringReader stringReader = new StringReader(xamlText);
                                        XmlReader    xmlReader    = XmlReader.Create(stringReader);

                                        Section nextSection = (Section)XamlReader.Load(xmlReader);
                                        if (nextSection != null)
                                        {
                                            testDetailsDoc.Blocks.Add(titlePara);
                                            testDetailsDoc.Blocks.Add(nextSection);
                                        }
                                    }
                                    else
                                    {
                                        Section   pageSession = new Section();
                                        Paragraph nextPara    = new Paragraph();
                                        //nextPara.Padding = new Thickness(3, 5, 3, 5);
                                        string paraText = rgx.Replace(inputText, " ").Trim();
                                        nextPara.Inlines.Add(new Run(paraText));
                                        pageSession.Blocks.Add(titlePara);
                                        pageSession.Blocks.Add(nextPara);

                                        testDetailsDoc.Blocks.Add(pageSession);
                                    }
                                }
                                else if (string.Equals(nodeName, "d:passCriteria", StringComparison.OrdinalIgnoreCase))
                                {
                                    string inputText = reader.ReadInnerXml();
                                    string xamlText  = HTMLConverter.HtmlToXamlConverter.ConvertHtmlToXaml(inputText, false);

                                    Paragraph titlePara = new Paragraph();
                                    titlePara.FontWeight = FontWeights.Bold;
                                    titlePara.FontSize   = 16;
                                    titlePara.Inlines.Add(new Run("Pass Criteria"));

                                    if (_useConverter)
                                    {
                                        StringReader stringReader = new StringReader(xamlText);
                                        XmlReader    xmlReader    = XmlReader.Create(stringReader);

                                        Section nextSection = (Section)XamlReader.Load(xmlReader);
                                        if (nextSection != null)
                                        {
                                            testDetailsDoc.Blocks.Add(titlePara);
                                            testDetailsDoc.Blocks.Add(nextSection);
                                        }
                                    }
                                    else
                                    {
                                        Section   pageSession = new Section();
                                        Paragraph nextPara    = new Paragraph();
                                        //nextPara.Padding = new Thickness(3, 5, 3, 5);
                                        string paraText = rgx.Replace(inputText, " ").Trim();
                                        nextPara.Inlines.Add(new Run(paraText));
                                        pageSession.Blocks.Add(titlePara);
                                        pageSession.Blocks.Add(nextPara);

                                        testDetailsDoc.Blocks.Add(pageSession);
                                    }
                                }
                                else if (string.Equals(nodeName, "d:testDescription", StringComparison.OrdinalIgnoreCase))
                                {
                                    string inputText = reader.ReadInnerXml();
                                    string xamlText  = HTMLConverter.HtmlToXamlConverter.ConvertHtmlToXaml(inputText, false);

                                    Paragraph titlePara = new Paragraph();
                                    titlePara.FontWeight = FontWeights.Bold;
                                    titlePara.FontSize   = 16;
                                    titlePara.Inlines.Add(new Run("Test Description"));

                                    if (_useConverter)
                                    {
                                        StringReader stringReader = new StringReader(xamlText);
                                        XmlReader    xmlReader    = XmlReader.Create(stringReader);

                                        Section nextSection = (Section)XamlReader.Load(xmlReader);
                                        if (nextSection != null)
                                        {
                                            testDetailsDoc.Blocks.Add(titlePara);
                                            testDetailsDoc.Blocks.Add(nextSection);
                                        }
                                    }
                                    else
                                    {
                                        Section   pageSession = new Section();
                                        Paragraph nextPara    = new Paragraph();
                                        //nextPara.Padding = new Thickness(3, 5, 3, 5);
                                        string paraText = rgx.Replace(inputText, " ").Trim();
                                        nextPara.Inlines.Add(new Run(paraText));
                                        pageSession.Blocks.Add(titlePara);
                                        pageSession.Blocks.Add(nextPara);

                                        testDetailsDoc.Blocks.Add(pageSession);
                                    }

                                    _testCase.Paragraphs.Add(inputText);
                                }
                            }
                            else if (nodeType == XmlNodeType.EndElement &&
                                     string.Equals(nodeName, "SVGTestCase", StringComparison.OrdinalIgnoreCase))
                            {
                                break;
                            }
                        }
                    }
                }
                else if (majorVersion == 1 && minorVersion == 2)
                {
                    if (reader.ReadToFollowing("SVGTestCase"))
                    {
                        _testCase = new SvgTestCase();

                        while (reader.Read())
                        {
                            string      nodeName = reader.Name;
                            XmlNodeType nodeType = reader.NodeType;
                            if (nodeType == XmlNodeType.Element)
                            {
                                if (string.Equals(nodeName, "d:OperatorScript", StringComparison.OrdinalIgnoreCase))
                                {
                                    string inputText = reader.ReadInnerXml();
                                    string xamlText  = HTMLConverter.HtmlToXamlConverter.ConvertHtmlToXaml(inputText, false);

                                    if (_useConverter)
                                    {
                                        StringReader stringReader = new StringReader(xamlText);
                                        XmlReader    xmlReader    = XmlReader.Create(stringReader);

                                        Section nextSection = (Section)XamlReader.Load(xmlReader);
                                        if (nextSection != null)
                                        {
                                            testDetailsDoc.Blocks.Add(nextSection);
                                        }
                                    }
                                    else
                                    {
                                        Section   pageSession = new Section();
                                        Paragraph nextPara    = new Paragraph();
                                        //nextPara.Padding = new Thickness(3, 5, 3, 5);
                                        string paraText = rgx.Replace(inputText, " ").Trim();
                                        nextPara.Inlines.Add(new Run(paraText));
                                        pageSession.Blocks.Add(nextPara);

                                        testDetailsDoc.Blocks.Add(pageSession);
                                    }
                                }
                                else if (string.Equals(nodeName, "d:PassCriteria", StringComparison.OrdinalIgnoreCase))
                                {
                                    string inputText = reader.ReadInnerXml();
                                    string xamlText  = HTMLConverter.HtmlToXamlConverter.ConvertHtmlToXaml(inputText, false);

                                    if (_useConverter)
                                    {
                                        StringReader stringReader = new StringReader(xamlText);
                                        XmlReader    xmlReader    = XmlReader.Create(stringReader);

                                        Section nextSection = (Section)XamlReader.Load(xmlReader);
                                        if (nextSection != null)
                                        {
                                            testDetailsDoc.Blocks.Add(nextSection);
                                        }
                                    }
                                    else
                                    {
                                        Section   pageSession = new Section();
                                        Paragraph nextPara    = new Paragraph();
                                        //nextPara.Padding = new Thickness(3, 5, 3, 5);
                                        string paraText = rgx.Replace(inputText, " ").Trim();
                                        nextPara.Inlines.Add(new Run(paraText));
                                        pageSession.Blocks.Add(nextPara);

                                        testDetailsDoc.Blocks.Add(pageSession);
                                    }
                                }
                                else if (string.Equals(nodeName, "d:TestDescription", StringComparison.OrdinalIgnoreCase))
                                {
                                    string inputText = reader.ReadInnerXml();
                                    string xamlText  = HTMLConverter.HtmlToXamlConverter.ConvertHtmlToXaml(inputText, false);

                                    if (_useConverter)
                                    {
                                        StringReader stringReader = new StringReader(xamlText);
                                        XmlReader    xmlReader    = XmlReader.Create(stringReader);

                                        Section nextSection = (Section)XamlReader.Load(xmlReader);
                                        if (nextSection != null)
                                        {
                                            testDetailsDoc.Blocks.Add(nextSection);
                                        }
                                    }
                                    else
                                    {
                                        Section   pageSession = new Section();
                                        Paragraph nextPara    = new Paragraph();
                                        //nextPara.Padding = new Thickness(3, 5, 3, 5);
                                        string paraText = rgx.Replace(inputText, " ").Trim();
                                        nextPara.Inlines.Add(new Run(paraText));
                                        pageSession.Blocks.Add(nextPara);

                                        testDetailsDoc.Blocks.Add(pageSession);
                                    }

                                    _testCase.Paragraphs.Add(inputText);
                                }
                            }
                            else if (nodeType == XmlNodeType.EndElement &&
                                     string.Equals(nodeName, "SVGTestCase", StringComparison.OrdinalIgnoreCase))
                            {
                                break;
                            }
                        }
                    }
                }
                else
                {
                    if (reader.ReadToFollowing("SVGTestCase"))
                    {
                        _testCase = new SvgTestCase();

                        while (reader.Read())
                        {
                            string      nodeName = reader.Name;
                            XmlNodeType nodeType = reader.NodeType;
                            if (nodeType == XmlNodeType.Element)
                            {
                                if (string.Equals(nodeName, "OperatorScript", StringComparison.OrdinalIgnoreCase))
                                {
                                    string revisionText = reader.GetAttribute("version");
                                    if (!string.IsNullOrWhiteSpace(revisionText))
                                    {
                                        revisionText       = revisionText.Replace("$", string.Empty);
                                        _testCase.Revision = revisionText.Trim();
                                    }
                                    string nameText = reader.GetAttribute("testname");
                                    if (!string.IsNullOrWhiteSpace(nameText))
                                    {
                                        _testCase.Name = nameText.Trim();
                                    }
                                }
                                else if (string.Equals(nodeName, "Paragraph", StringComparison.OrdinalIgnoreCase))
                                {
                                    string inputText = reader.ReadInnerXml();
                                    string xamlText  = HTMLConverter.HtmlToXamlConverter.ConvertHtmlToXaml(inputText, false);

                                    if (_useConverter)
                                    {
                                        StringReader stringReader = new StringReader(xamlText);
                                        XmlReader    xmlReader    = XmlReader.Create(stringReader);

                                        Section nextSection = (Section)XamlReader.Load(xmlReader);

                                        testDetailsDoc.Blocks.Add(nextSection);
                                    }
                                    else
                                    {
                                        Section   pageSession = new Section();
                                        Paragraph nextPara    = new Paragraph();
                                        //nextPara.Padding = new Thickness(3, 5, 3, 5);
                                        string paraText = rgx.Replace(inputText, " ").Trim();
                                        nextPara.Inlines.Add(new Run(paraText));
                                        pageSession.Blocks.Add(nextPara);

                                        testDetailsDoc.Blocks.Add(pageSession);
                                    }

                                    _testCase.Paragraphs.Add(inputText);
                                }
                            }
                            else if (nodeType == XmlNodeType.EndElement &&
                                     string.Equals(nodeName, "SVGTestCase", StringComparison.OrdinalIgnoreCase))
                            {
                                break;
                            }
                        }
                    }
                }
            }

            SubscribeToAllHyperlinks();

            return(true);
        }