public static void AutoConnectManyShapes()
        {
            var app = new IVisio.ApplicationClass();
            var docs = app.Documents;
            var doc = docs.Add("");
            var page = app.ActivePage;
            short flags = (short)
                ( IVisio.VisOpenSaveArgs.visOpenDocked | 
                IVisio.VisOpenSaveArgs.visOpenRO);
            
            var basic_stencil = docs.OpenEx("basic_u.vss", flags);
            var basic_masters = basic_stencil.Masters;
            var rounded_rect_master = basic_masters["Rounded Rectangle"];

            // three masters to drop
            var masters = new object[] { rounded_rect_master, rounded_rect_master, rounded_rect_master };

            // three coordinates to make the drop
            var xy_array = new double[] { 1, 2, 3, 5, 6, 2 };

            // perform the drop of all shapes at once
            // and get the shape ids back out
            System.Array shape_ids_sa;
            page.DropManyU(masters, xy_array, out shape_ids_sa);
            var shape_ids = (short[])shape_ids_sa;

            var from_ids = new int [] {shape_ids[0], shape_ids[1]};
            var to_ids = new int[] { shape_ids[1], shape_ids[2] };
            var dirs = new int[] { (short)IVisio.VisAutoConnectDir.visAutoConnectDirNone, (short) IVisio.VisAutoConnectDir.visAutoConnectDirNone };

            page.AutoConnectMany(from_ids,to_ids, dirs, null);
        }
        public static void HelloWorld()
        {
            var app = new IVisio.ApplicationClass();
            var docs = app.Documents;
            var doc = docs.Add("");

            var page = app.ActivePage;
            var shape0 = page.DrawRectangle(1, 2, 6, 3);
            shape0.Text = "Hello World";
        }
        private static void Main(string[] args)
        {
            var app = new IVisio.ApplicationClass();
            var docs = app.Documents;
            var doc = docs.Add("");

            VS2010_CSharp_Samples.Shape_GetFormulas(doc);
            VS2010_CSharp_Samples.Shape_GetResults(doc);
            VS2010_CSharp_Samples.Page_GetFormulas(doc);
            VS2010_CSharp_Samples.Page_GetResults(doc);
            VS2010_CSharp_Samples.Shape_SetFormulas(doc);
            VS2010_CSharp_Samples.Shape_SetResults(doc);
            VS2010_CSharp_Samples.Page_SetFormulas(doc);
            VS2010_CSharp_Samples.Page_SetResults(doc);
        }
        public static void LoadStencilDropShape()
        {
            var app = new IVisio.ApplicationClass();
            var docs = app.Documents;
            var doc = docs.Add("");
            var page = app.ActivePage;
            short flags = (short)
                ( IVisio.VisOpenSaveArgs.visOpenDocked | 
                IVisio.VisOpenSaveArgs.visOpenRO);
            
            var basic_stencil = docs.OpenEx("basic_u.vss", flags);
            var basic_masters = basic_stencil.Masters;
            var rounded_rect_master = basic_masters["Rounded Rectangle"];

            double x = 2.0;
            double y = 3.0;
            page.Drop(rounded_rect_master, x, y);
        }
        public static void AddContainer()
        {
            var app = new IVisio.ApplicationClass();

            var docs = app.Documents;
            var doc = docs.Add("");
            var page = app.ActivePage;
            short flags = (short)
                (IVisio.VisOpenSaveArgs.visOpenDocked |
                IVisio.VisOpenSaveArgs.visOpenRO);

            var basic_stencil = docs.OpenEx("basic_u.vss", flags);
            var basic_masters = basic_stencil.Masters;
            var rounded_rect_master = basic_masters["Rounded Rectangle"];

            double x = 2.0;
            double y = 3.0;

            var shape1 = page.Drop(rounded_rect_master, x, y);
            var shape2 = page.Drop(rounded_rect_master, x + 3.0, y + 1.0);

            var stenciltype = IVisio.VisBuiltInStencilTypes.visBuiltInStencilContainers;

            var measurementsys = IVisio.VisMeasurementSystem.visMSDefault;
            short containeropenflags = (short)IVisio.VisOpenSaveArgs.visOpenHidden;
            string containerstencil_filename = app.GetBuiltInStencilFile(stenciltype, measurementsys);
            var container_stencil = docs.OpenEx(containerstencil_filename, containeropenflags);
            var containermasters = container_stencil.Masters;
            var container = containermasters["Container 1"];

            var activewindow = app.ActiveWindow;
            short selectargs = (short)IVisio.VisSelectArgs.visSelect;
            activewindow.Select(shape1, selectargs);
            activewindow.Select(shape2, selectargs);

            page.DropContainer(container, activewindow.Selection);

        }
        public static void DrawOrgChart()
        {
            var app = new IVisio.ApplicationClass();
            var docs = app.Documents;

            // Create a new OrgChart using the org chart template
            var doc = docs.AddEx("orgch_u.vst", IVisio.VisMeasurementSystem.visMSUS, 0,0);
            var page = app.ActivePage;

            // Get the masters
            bool is_visio_2013 = app.Version.StartsWith("15.");
            var orgchart_masters = doc.Masters;
            var position_master = orgchart_masters[is_visio_2013 ? "Position Belt" : "Position"];
            var dyncon = orgchart_masters["Dynamic Connector"];

            // three masters to drop
            var masters = new object[] { position_master, position_master, position_master };

            // three coordinates to make the drop
            var xy_array = new double[] {1,2 ,3,5, 6,2};

            // perform the drop of all shapes at once
            // and get the shape ids back out
            System.Array shape_ids_sa;
            page.DropManyU(masters, xy_array, out shape_ids_sa);
            var shape_ids = (short[])shape_ids_sa;

            // using the shape ids, get the shape objects
            var shape0 = page.Shapes.ItemFromID16[shape_ids[0]];
            var shape1 = page.Shapes.ItemFromID16[shape_ids[1]];
            var shape2 = page.Shapes.ItemFromID16[shape_ids[2]];

            // perform connections using the Dynamic Connection master
            shape0.AutoConnect(shape1, IVisio.VisAutoConnectDir.visAutoConnectDirNone, dyncon);
            shape1.AutoConnect(shape2, IVisio.VisAutoConnectDir.visAutoConnectDirNone, dyncon);

        }