Click here to Skip to main content
15,886,055 members
Articles / Programming Languages / XSLT

XML Visualizer v.2

Rate me:
Please Sign up or sign in to vote.
4.88/5 (107 votes)
16 Nov 2016CPOL5 min read 292.9K   18.7K   404  
XML Visualizer v.2 improves the standard XML Visualizer in Visual Studio 2005, 2008, 2010, 2012, 2013 and 2015.
// Xml Visualizer v.2
// by Lars Hove Christiansen (larshove@gmail.com)
// http://www.codeplex.com/XmlVisualizer

using System;
using System.Threading;
using System.Windows.Forms;
using XmlVisualizer;

namespace TestStandAloneVisualizer
{
    public partial class Form1 : Form
    {
        //public Form1()
        //{
        //    Visualizer.OnDisposeEventStatic += Visualizer_OnDisposeEvent;
        //    InitializeComponent();
        //}

        //private void modelessButton_Click(object sender, EventArgs e)
        //{
        //    Visualizer.ShowModeless_LoadXmlFromString("<xml>test</xml>");
        //}

        //private void modalButton_Click(object sender, EventArgs e)
        //{
        //    Visualizer.ShowModal_LoadXmlFromString("<xml>test</xml>");
        //}

        //private static void Visualizer_OnDisposeEvent(string modifiedXml)
        //{
        //    MessageBox.Show(string.Format("Returned from Xml Visualizer v.2:\r\n{0}", modifiedXml));
        //}

        public Form1()
        {
            InitializeComponent();
        }

        private void modelessButton_Click(object sender, EventArgs e)
        {
            Thread thread = new Thread(delegate(object textObject)
            {
                Visualizer v = new Visualizer();
                v.OnDisposeEvent += v_OnDisposeEvent;
                v.LoadXmlFromString(textObject.ToString());
                v.Show();
                v.Dispose();
            });
            thread.SetApartmentState(ApartmentState.STA);
            thread.Start("<xml>test</xml>");
        }

        private static void v_OnDisposeEvent(string modifiedXml)
        {
            MessageBox.Show(string.Format("Returned from Xml Visualizer v.2:\r\n{0}", modifiedXml));
        }

        private void modalButton_Click(object sender, EventArgs e)
        {
            Visualizer v = new Visualizer();
            v.LoadXmlFromString("<xml>test</xml>");
            string modifiedXml = v.ShowDialog();

            MessageBox.Show(string.Format("Returned from Xml Visualizer v.2:\r\n{0}", modifiedXml));
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Denmark Denmark
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions