private void GenerateSVG()
        {
            string DotFilePath = String.Format("{0}\\DOTFILE.dot", Application.UserAppDataPath);
            graph.ToDotFile(DotFilePath);

            DOT dotfile = new DOT();
            DotFile = File.ReadAllText(DotFilePath);
            string svg = dotfile.ToSvg(DotFile);

            File.WriteAllText(SVGFilePath, svg);

            XDocument doc = XDocument.Parse(svg);
            SVGFile = (XElement)doc.LastNode;
            FormatSVG();

            ZoomFactor = -2;

            SVGFile.Attribute("currentScale").SetValue(Math.Pow(1.25, ZoomFactor));
            SVGFile.Attribute("width").SetValue(((int)(SVGWidth * Math.Pow(1.25, ZoomFactor))) + "px");
            SVGFile.Attribute("height").SetValue(((int)(SVGHeight * Math.Pow(1.25, ZoomFactor))) + "px");
            SVGFile.Save(SVGFilePath);
            webBrowser1.Refresh();
        }
Exemplo n.º 2
0
        public Form2()
        {
            InitializeComponent();
            /*
            string DotFilePath = String.Format(@"C:\Users\Zenith\AppData\Roaming\HNClusterUI\HNClusterUI\1.0.0.0\DOTFILE - Copy - Copy.dot");
            //graph.ToDotFile(DotFilePath);

            DOT dotfile2 = new DOT();
            string DotFile1 = File.ReadAllText(DotFilePath);
            string svg2 = dotfile2.ToSvg(DotFile1);
            return;*/

            this.MouseWheel += new System.Windows.Forms.MouseEventHandler(Form2_MouseWheel);
            this.KeyDown += Form2_KeyDown_KeyUp;
            this.KeyUp += Form2_KeyDown_KeyUp;
            this.KeyPreview = true;
            webBrowser1.WebBrowserShortcutsEnabled = false;
            webBrowser1.IsWebBrowserContextMenuEnabled = false;
            webBrowser1.PreviewKeyDown += webBrowser1_PreviewKeyDown;
            Control c = webBrowser1;
            c.KeyDown += Form2_KeyDown_KeyUp;
            c.KeyUp += Form2_KeyDown_KeyUp;
            //c.Enabled = false;
            /*
            foreach (Control control in this.Controls)
            {
                control.KeyDown += new KeyEventHandler(Form2_KeyDown_KeyUp);
                control.KeyUp += new KeyEventHandler(Form2_KeyDown_KeyUp);
                //control.KeyPress += new KeyEventHandler(Form2_KeyDown_KeyUp);
            }*/

            graph = new Xglore.Plugin.Graphviz.RootGraph("Clusters", false, false);
            string MainNode = " _3D.P–r,i:nt–ing'L13_01111111101-- 010Noro–Frenkel_law_of_corresponding___stat&es+ ";
            AddNode(MainNode);

            AddNode("0");
            AddNode("00");
            AddNode("000");
            AddNode("001");
            AddNode("01");
            AddNode("010");
            AddNode("011");

            AddNode("1");
            AddNode("10");
            AddNode("100");
            AddNode("101");
            AddNode("11");
            AddNode("110");
            AddNode("111");

            AddEdge(MainNode, "0");
            AddEdge(MainNode, "1");

            AddEdge("0", "00");
            AddEdge("00", "000");
            AddEdge("00", "001");
            AddEdge("0", "01");
            AddEdge("01", "010");
            AddEdge("01", "011");
            AddEdge("1", "10");
            AddEdge("10", "100");
            AddEdge("10", "101");
            AddEdge("1", "11");
            AddEdge("11", "110");
            AddEdge("11", "111");

            for (int i = 0; i < 10; ++i)
            {
                AddNode(i.ToString());
            }

            for (int x = 0; x < 10; ++x)
            {
                for (int y = x; y < 10; ++y)
                {
                    if (x != y)
                    AddEdge(x.ToString(), y.ToString());
                }
            }

            string dotPath = String.Format("{0}\\DOTFILE.dot", Application.UserAppDataPath);
            graph.ToDotFile(dotPath);

            DOT dotfile = new DOT();
            string strBlah3 = System.IO.File.ReadAllText(dotPath);

            string svg = dotfile.ToSvg(strBlah3);

            System.IO.File.WriteAllText(String.Format("{0}\\SVG.svg", Application.UserAppDataPath), svg);

            //webBrowser1.Url = new Uri(@"C:\Users\Zenith\Documents\GitHub\Wikipedia-Clustering\HNCluster\HNCluster\bin\Debug\" + "SVG.svg");
            Uri url = new Uri(String.Format("{0}\\SVG.svg", Application.UserAppDataPath));
            webBrowser1.Url = url;
            XDocument doc = XDocument.Parse(svg);
            SVGFile = (XElement)doc.LastNode;
            //SVGFile = XDocument.Parse(svg).Element("svg");
            this.Focus();
        }