public static void FontGlyphComparision2(IVisio.Document doc, string[] fontnames, List <string> samplechars) { double w = 2.0; double h = 1; double th = 1; int chunksize = 12; var chunks = LinqUtil.Split(samplechars, chunksize); foreach (var chunk in chunks) { var domshapescol = new ShapeList(); for (int j = 0; j < fontnames.Count(); j++) { string fontname = fontnames[j]; double x0 = j * w; var r = new VA.Drawing.Rectangle(x0, 0 - th, x0 + w, 0); var n1 = domshapescol.Drop("Rectangle", "basic_u.vss", r); n1.Text = new VisioAutomation.Models.Text.TextElement(fontname.ToUpper()); n1.Cells.FillForegnd = "rgb(255,255,255)"; n1.Cells.LineWeight = 0.0; n1.Cells.LinePattern = 0; n1.Cells.CharSize = "16pt"; } for (int j = 0; j < fontnames.Count(); j++) { for (int i = 0; i < chunksize; i++) { double x0 = j * w; double y0 = i * h * -1 - th - h; var r = new VA.Drawing.Rectangle(x0, y0, x0 + w, y0 + h); var n1 = domshapescol.Drop("Rectangle", "basic_u.vss", r); if (i < chunk.Count) { n1.Text = new VisioAutomation.Models.Text.TextElement(chunk[i]); } n1.CharFontName = fontnames[j]; n1.Cells.CharSize = "36pt"; n1.Cells.FillForegnd = "rgb(255,255,255)"; n1.Cells.LineWeight = 0.0; n1.Cells.LinePattern = 0; } } var page = doc.Pages.Add(); domshapescol.Render(page); var bordersize = new VA.Drawing.Size(0.5, 0.5); page.ResizeToFitContents(bordersize); } }
public static void FontGlyphComparision3(IVisio.Document doc, string[] fontnames, List <string> samplechars) { var colors = new[] { "rgb(0,0,255)", "rgb(255,0,0)" }; double w = 2.0; double h = 1; int chunksize = 12; var chunks = LinqUtil.Split(samplechars, chunksize); foreach (var chunk in chunks) { var domshapescol = new ShapeList(); for (int j = 0; j < fontnames.Count(); j++) { for (int i = 0; i < chunksize; i++) { double x0 = 0; double y0 = i * h * -1; var r = new VA.Drawing.Rectangle(x0, y0, x0 + w, y0 + h); var n1 = domshapescol.Drop("Rectangle", "basic_u.vss", r); if (i < chunk.Count) { n1.Text = new VisioAutomation.Models.Text.TextElement(chunk[i]); n1.Text.CharacterFormatting.Color = colors[j]; } n1.CharFontName = fontnames[j]; //n1.Cells.CharColor = "=RGB(255,0,0)";// colors[j]; n1.Cells.CharTransparency = 0.7; n1.Cells.CharSize = "36pt"; n1.Cells.FillPattern = 0; n1.Cells.LineWeight = 0.0; n1.Cells.LinePattern = 0; } } var page = doc.Pages.Add(); domshapescol.Render(page); var bordersize = new VA.Drawing.Size(0.5, 0.5); page.ResizeToFitContents(bordersize); } }
public void Dom_DropShapes() { // Render it var app = this.GetVisioApplication(); var doc = this.GetNewDoc(); var stencil = app.Documents.OpenStencil(this.basic_u_vss); var rectmaster = stencil.Masters[this.rectangle]; // Create the doc var shape_nodes = new ShapeList(); shape_nodes.DrawRectangle(0, 0, 1, 1); shape_nodes.Drop(rectmaster, 3, 3); shape_nodes.Render(app.ActivePage); app.ActiveDocument.Close(true); }
public void Dom_CustomProperties() { // Create the doc var shape_nodes = new ShapeList(); var vrect1 = new Rectangle(1, 1, 9, 9); vrect1.Text = new VisioAutomation.Models.Text.Element("HELLO WORLD"); vrect1.CustomProperties = new CustomPropertyDictionary(); var cp1 = new CustomPropertyCells(); cp1.Value = "\"FOOVALUE\""; cp1.Label = "\"Foo Label\""; var cp2 = new CustomPropertyCells(); cp2.Value = "\"BARVALUE\""; cp2.Label = "\"Bar Label\""; vrect1.CustomProperties["FOO"] = cp1; vrect1.CustomProperties["BAR"] = cp2; shape_nodes.Add(vrect1); // Render it var app = this.GetVisioApplication(); var doc = this.GetNewDoc(); shape_nodes.Render(app.ActivePage); // Verify Assert.IsNotNull(vrect1.VisioShape); Assert.AreEqual("HELLO WORLD", vrect1.VisioShape.Text); Assert.IsTrue(CustomPropertyHelper.Contains(vrect1.VisioShape, "FOO")); Assert.IsTrue(CustomPropertyHelper.Contains(vrect1.VisioShape, "BAR")); doc.Close(true); }
public static void FontGlyphComparision(IVisio.Document doc, string[] fontnames, List <string> samplechars) { var layout = new BoxL.BoxLayout(); var root = new BoxL.Container(BoxL.Direction.TopToBottom); layout.Root = root; root.ChildSpacing = 0.5; var nodedata = new NodeData(); nodedata.Render = false; root.Data = nodedata; var fontname_cells = new ShapeCells(); fontname_cells.FillPattern = 0; fontname_cells.LinePattern = 0; fontname_cells.LineWeight = 0.0; fontname_cells.ParaHorizontalAlign = 0; fontname_cells.CharSize = "36pt"; var charbox_cells = new ShapeCells(); charbox_cells.FillPattern = 0; charbox_cells.LinePattern = 1; charbox_cells.LineWeight = 0.0; charbox_cells.LineColor = "rgb(150,150,150)"; charbox_cells.ParaHorizontalAlign = 1; charbox_cells.CharSize = "24pt"; foreach (string fontname in fontnames) { var fontname_box = root.AddNodeEx(5, 0.5, fontname); var fontname_box_data = (NodeData)fontname_box.Data; fontname_box_data.Cells = fontname_cells; var font_box = root.AddContainer(BoxL.Direction.TopToBottom); font_box.ChildSpacing = 0.25; var font_vox_data = (NodeData)font_box.Data; if (font_vox_data != null) { font_vox_data.Render = false; } int numcols = 17; int numrows = 5; int numcells = numcols * numrows; foreach (int row in Enumerable.Range(0, numrows)) { var row_box = font_box.AddContainer(BoxL.Direction.LeftToRight); row_box.ChildSpacing = 0.25; var row_box_data = new NodeData(); row_box_data.Render = false; row_box.Data = row_box_data; foreach (int col in Enumerable.Range(0, numcols)) { int charindex = (col + (numcols * row)) % numcells; string curchar = samplechars[charindex]; var cell_box = row_box.AddNodeEx(0.50, 0.50, curchar); var cell_box_data = (NodeData)cell_box.Data; cell_box_data.Font = fontname; cell_box_data.Cells = charbox_cells; } } } layout.PerformLayout(); var page = doc.Pages.Add(); var domshapescol = new ShapeList(); foreach (var node in layout.Nodes) { if (node.Data == null) { continue; } var node_data = (NodeData)node.Data; if (node_data.Render == false) { continue; } var shape_node = domshapescol.Drop("Rectangle", "basic_u.vss", node.Rectangle); var cells = node_data.Cells; if (cells == null) { cells = new ShapeCells(); } else { cells = node_data.Cells.ShallowCopy(); } if (node_data.Font != null) { shape_node.CharFontName = node_data.Font; } shape_node.Cells = cells; shape_node.Text = new VisioAutomation.Models.Text.TextElement(node_data.Text); } domshapescol.Render(page); var bordersize = new VA.Drawing.Size(0.5, 0.5); page.ResizeToFitContents(bordersize); }
public static void BoxLayout_TwoLevelGrouping() { int num_types = 10; int max_properties = 50; var types = typeof(UserDefinedCellCells).Assembly.GetExportedTypes().Take(num_types).ToList(); var data = new List <string[]>(); foreach (var type in types) { var properties = type.GetProperties().Take(max_properties).ToList(); foreach (var property in properties) { var item = new[] { type.Name, property.Name[0].ToString().ToUpper(), property.Name }; data.Add(item); } } var layout1 = BoxLayout2Samples.CreateTwoLevelLayout(data); layout1.PerformLayout(); // Create a blank canvas in Visio var app = SampleEnvironment.Application; var documents = app.Documents; var doc = documents.Add(string.Empty); var page = app.ActivePage; var domshapescol = new ShapeList(); //var rect_master = dom.m foreach (var item in layout1.Nodes) { if (item.Data == null) { continue; } var info = (TwoLevelInfo)item.Data; if (!info.Render) { continue; } var shape = domshapescol.Drop("Rectangle", "Basic_U.VSS", item.Rectangle); if (info.Text != null) { shape.Text = new VisioAutomation.Models.Text.Element(info.Text); } shape.Cells = info.ShapeCells.ShallowCopy(); } domshapescol.Render(page); var bordersize = new VA.Geometry.Size(0.5, 0.5); page.ResizeToFitContents(bordersize); }