public void Container_PerformLayoutBeforeRender() { // Purpose: Verify that if PerformLayout is NOT called before Render() // is called then an exception will be thrown bool caught = false; var layout = new CONMODEL.ContainerLayout(); var doc = this.GetNewDoc(); try { var c1 = layout.AddContainer("A"); var i1 = c1.Add("A1"); // layout.PerformLayout(); IVisio.Page page = layout.Render(doc); page.Delete(0); } catch (VA.AutomationException) { caught = true; } doc.Close(true); if (caught == false) { Assert.Fail("Did not catch expected exception"); } }
public void Container_Diagram2() { // Make sure that empty containers can be drawn var doc = this.GetNewDoc(); var layout1 = new CONMODEL.ContainerLayout(); var l1_c1 = layout1.AddContainer("L1/C1"); var l1_c1_i1 = l1_c1.Add("L1/C1/I1"); var l1_c2 = layout1.AddContainer("L1/C2"); // this is the empty container layout1.PerformLayout(); var page1 = layout1.Render(doc); page1.Delete(0); doc.Close(true); }
public void Container_Diagram1() { // Purpose: Simple test to make sure that both Containers and Non-Container // rendering are supported. The diagram is a single container having a single // container item var doc = this.GetNewDoc(); var layout1 = new CONMODEL.ContainerLayout(); var l1_c1 = layout1.AddContainer("L1/C1"); var l1_c1_i1 = l1_c1.Add("L1/C1/I1"); layout1.PerformLayout(); var page1 = layout1.Render(doc); page1.Delete(0); doc.Close(true); }
public static void SimpleContainer() { var m = new CONTMODEL.ContainerLayout(); var c1 = m.AddContainer("Container 1"); var c2 = m.AddContainer("Container 2"); c1.Add("A"); c1.Add("B"); c1.Add("C"); c2.Add("1"); c2.Add("2"); c2.Add("3"); m.LayoutOptions = new CONTMODEL.LayoutOptions(); m.LayoutOptions.ContainerFormatting.FormatCells.FillForegnd = "rgb(0,176,240)"; m.LayoutOptions.ContainerItemFormatting.FormatCells.FillForegnd = "rgb(250,250,250)"; m.LayoutOptions.ContainerItemFormatting.FormatCells.LinePattern = "0"; m.PerformLayout(); m.Render(SampleEnvironment.Application.ActiveDocument); }
public static void SimpleContainer() { var m = new CONTMODEL.ContainerLayout(); var c1 = m.AddContainer("Container 1"); var c2 = m.AddContainer("Container 2"); c1.Add("A"); c1.Add("B"); c1.Add("C"); c2.Add("1"); c2.Add("2"); c2.Add("3"); m.LayoutOptions = new CONTMODEL.LayoutOptions(); m.LayoutOptions.ContainerFormatting.FormatCells.FillForegnd = "rgb(0,176,240)"; m.LayoutOptions.ContainerItemFormatting.FormatCells.FillForegnd = "rgb(250,250,250)"; m.LayoutOptions.ContainerItemFormatting.FormatCells.LinePattern= "0"; m.PerformLayout(); m.Render(SampleEnvironment.Application.ActiveDocument); }
public IVisio.Page Render(IVisio.Document doc) { if (!this.IsLayedOut) { string msg = string.Format("{0} usage error. {1}() before calling {2}().", nameof(ContainerLayout), nameof(PerformLayout), nameof(Render)); throw new AutomationException(msg); } // create a new drawing var app = doc.Application; var docs = app.Documents; var pages = doc.Pages; var page = pages.Add(); // load the stencil used to draw the items var item_stencil = docs.OpenStencil(this.LayoutOptions.ManualItemStencil); var item_stencil_masters = item_stencil.Masters; var item_master = item_stencil_masters[this.LayoutOptions.ManualItemMaster]; var plain_container_master = item_stencil_masters[this.LayoutOptions.ManualContainerMaster]; var page_shapes = page.Shapes; // Drop the container shapes var ct_items = this.Containers.ToList(); var ct_rects = ct_items.Select(item => item.Rectangle).ToList(); var masters = ct_items.Select(i => plain_container_master).ToList(); short[] ct_shapeids = ContainerLayout.DropManyU(page, masters, ct_rects); // associate each container with the corresponding shape oject and shape id for (int i = 0; i < ct_items.Count; i++) { var ct_item = ct_items[i]; var ct_shapeid = ct_shapeids[i]; var shape = page_shapes[ct_shapeid]; ct_item.VisioShape = shape; ct_item.ShapeID = ct_shapeid; } // Render the items var items = this.ContainerItems.ToList(); var item_rects = items.Select(item => item.Rectangle).ToList(); var item_masters = items.Select(i => item_master).ToList(); short[] shapeids = ContainerLayout.DropManyU(page, item_masters, item_rects); // Associate each item with the corresponding shape object and shape id for (int i = 0; i < items.Count; i++) { var item = items[i]; var shapeid = shapeids[i]; var shape = page_shapes[shapeid]; item.VisioShape = shape; item.ShapeID = shapeid; } // Often useful to show everthing because these diagrams can get large app.ActiveWindow.ViewFit = (short)IVisio.VisWindowFit.visFitPage; // Set the items foreach (var item in items.Where(i => i.Text != null)) { item.VisioShape.Text = item.Text; } var update = new ShapeSheet.Update(); // Format the containers and shapes foreach (var item in this.Containers) { this.LayoutOptions.ContainerFormatting.Apply(update, item.ShapeID, item.ShapeID); } foreach (var item in this.ContainerItems) { this.LayoutOptions.ContainerItemFormatting.Apply(update, item.ShapeID, item.ShapeID); } update.BlastGuards = true; update.Execute(page); // Set the Container Text foreach (var ct in this.Containers) { if (ct.Text != null) { ct.Text.SetText(ct.VisioShape); } } page.ResizeToFitContents(); app.ActiveWindow.ViewFit = (short)IVisio.VisWindowFit.visFitPage; return(page); }