View.cs 1.91 KB
Newer Older
1
2
3
4
5
6
7
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Drawing;
using System.IO;
using Svg;
Eric Domke's avatar
Eric Domke committed
8
using System.Diagnostics;
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

namespace SvgW3CTestRunner
{
    public partial class View : Form
    {
        private const string _svgBasePath = @"..\..\..\W3CTestSuite\svg\";
        private const string _pngBasePath = @"..\..\..\W3CTestSuite\png\";

        public View()
        {
            InitializeComponent();
            // ignore tests pertaining to javascript or xml reading
            var files = (from f in (from g in Directory.GetFiles(_svgBasePath)
                                    select Path.GetFileName(g))
                         where !f.StartsWith("animate-") && !f.StartsWith("conform-viewer") &&
                            !f.Contains("-dom-") && !f.StartsWith("linking-") && !f.StartsWith("interact-")
                         orderby f
                         select (object)f);
            lstFiles.Items.AddRange(files.ToArray());
        }

        private void lstFiles_SelectedIndexChanged(object sender, EventArgs e)
        {
            var fileName = lstFiles.SelectedItem.ToString();
Eric Domke's avatar
Eric Domke committed
33
34
            try
            {
Eric Domke's avatar
Eric Domke committed
35
                Debug.Print(fileName);
Eric Domke's avatar
Eric Domke committed
36
                var doc = SvgDocument.Open(_svgBasePath + fileName);
Eric Domke's avatar
Eric Domke committed
37
38
39
40
41
42
43
44
45
46
                if (fileName.StartsWith("__"))
                {
                    picSvg.Image = doc.Draw(); 
                }
                else
                {
                    var img = new Bitmap(480, 360);
                    doc.Draw(img);
                    picSvg.Image = img; 
                }
Eric Domke's avatar
Eric Domke committed
47
48
49
50
51
52
53
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                picSvg.Image = null;
            }
            
54
55
56
57
58
            var png = Image.FromFile(_pngBasePath + Path.GetFileNameWithoutExtension(fileName) + ".png");
            picPng.Image = png;
        }
    }
}