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 VA.DOM.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 VA.Text.Markup.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 VA.Text.Markup.TextElement(chunk[i]); } else { // empty } 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 void Draw(Session session) { var normalized_values = this.DataPoints.GetNormalizedValues(); var heights = DOMUtil.ConstructPositions(this.DataPoints.Count(), CellHeight, this.VerticalSeparation); var widths = DOMUtil.ConstructPositions(new[] { this.CategoryLabelHeight, this.CellWidth }, this.HorizontalSeparation); var grid = new GridLayout(widths, heights); int catcol = 0; int barcol = 2; var content_rects = this.SkipOdd(grid.GetRectsInCol(barcol)).ToList(); var domshapescol = new VA.DOM.ShapeList(); var bar_rects = new List<VA.Drawing.Rectangle>(content_rects.Count); for (int i = 0; i < content_rects.Count; i++) { var r = content_rects[i]; domshapescol.DrawRectangle(r); var size = new VA.Drawing.Size(normalized_values[i] * r.Width, this.CellHeight); var bar_rect = new VA.Drawing.Rectangle(r.LowerLeft, size); bar_rects.Add(bar_rect); } var cat_rects = this.SkipOdd(grid.GetRectsInCol(catcol)).ToList(); var bar_shapes = DOMUtil.DrawRects(domshapescol, bar_rects, session.MasterRectangle); var cat_shapes = DOMUtil.DrawRects(domshapescol, cat_rects, session.MasterRectangle); for (int i = 0; i < this.DataPoints.Count; i++) { bar_shapes[i].Text = new VA.Text.Markup.TextElement(this.DataPoints[i].Text); cat_shapes[i].Text = new VA.Text.Markup.TextElement(this.CategoryLabels[i]); } foreach (var shape in bar_shapes) { var cells = shape.Cells; cells.FillForegnd = this.ValueFillColor; cells.LineColor = this.LineLightBorder; } foreach (var shape in cat_shapes) { var cells = shape.Cells; cells.FillPattern = this.CategoryFillPattern; cells.LineWeight = this.CategoryLineWeight; cells.LinePattern = this.CategoryLinePattern; } domshapescol.Render(session.Page); }
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 VA.DOM.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 VA.Text.Markup.TextElement(chunk[i]); n1.Text.CharacterCells.Color = colors[j]; } else { // empty } 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 VA.DOM.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 VA.DOM.ShapeList(); var vrect1 = new VisioAutomation.DOM.Rectangle(1, 1, 9, 9); vrect1.Text = new VA.Text.Markup.TextElement("HELLO WORLD"); vrect1.CustomProperties = new Dictionary <string, VA.Shapes.CustomProperties.CustomPropertyCells>(); var cp1 = new VA.Shapes.CustomProperties.CustomPropertyCells(); cp1.Value = "FOOVALUE"; cp1.Label = "Foo Label"; var cp2 = new VA.Shapes.CustomProperties.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(VA.Shapes.CustomProperties.CustomPropertyHelper.Contains(vrect1.VisioShape, "FOO")); Assert.IsTrue(VA.Shapes.CustomProperties.CustomPropertyHelper.Contains(vrect1.VisioShape, "BAR")); doc.Close(true); }
public static List<IVisio.Shape> DrawRects(IList<VA.Drawing.Rectangle> rects, IVisio.Master rectmaster, IVisio.Page page) { var dom_shapes = new List<VA.DOM.Shape>(); var domshapescol = new VA.DOM.ShapeList(); foreach (var rect in rects) { var dom_shape = domshapescol.Drop(rectmaster, rect.Center); dom_shape.Cells.Width = rect.Width; dom_shape.Cells.Height = rect.Height; dom_shapes.Add(dom_shape); } domshapescol.Render(page); var shapes = new List<IVisio.Shape>(); foreach (var dom_shape in dom_shapes) { shapes.Add(dom_shape.VisioShape); } return shapes; }
public static void BoxLayout_TwoLevelGrouping() { int num_types = 10; int max_properties = 50; var types = typeof (UserDefinedCell).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 = CreateTwoLevelLayout(data); layout1.PerformLayout(); // TODO: Check that each data item has at least 3 values // 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 VA.DOM.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 VA.Text.Markup.TextElement(info.Text); } shape.Cells = info.ShapeCells.ShallowCopy(); } domshapescol.Render(page); var bordersize = new VA.Drawing.Size(0.5, 0.5); page.ResizeToFitContents(bordersize); }
public void DOM_CustomProperties() { // Create the doc var shape_nodes = new VA.DOM.ShapeList(); var vrect1 = new VA.DOM.Rectangle(1, 1, 9, 9); vrect1.Text = new VA.Text.Markup.TextElement("HELLO WORLD"); vrect1.CustomProperties = new Dictionary<string, VA.Shapes.CustomProperties.CustomPropertyCells>(); var cp1 = new VA.Shapes.CustomProperties.CustomPropertyCells(); cp1.Value = "FOOVALUE"; cp1.Label = "Foo Label"; var cp2 = new VA.Shapes.CustomProperties.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(VA.Shapes.CustomProperties.CustomPropertyHelper.Contains(vrect1.VisioShape, "FOO")); Assert.IsTrue(VA.Shapes.CustomProperties.CustomPropertyHelper.Contains(vrect1.VisioShape, "BAR")); doc.Close(true); }
public void DOM_DropShapes() { // Render it var app = this.GetVisioApplication(); var doc = this.GetNewDoc(); var stencil = app.Documents.OpenStencil("basic_u.vss"); var rectmaster = stencil.Masters["Rectangle"]; // Create the doc var shape_nodes = new VA.DOM.ShapeList(); shape_nodes.DrawRectangle(0, 0, 1, 1); shape_nodes.Drop(rectmaster, 3, 3); shape_nodes.Render(app.ActivePage); app.ActiveDocument.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 VA.DOM.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 VA.DOM.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 VA.DOM.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 VA.DOM.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 VA.Text.Markup.TextElement( node_data.Text ); } 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 VA.DOM.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 VA.Text.Markup.TextElement(chunk[i]); n1.Text.CharacterCells.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 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 VA.DOM.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 VA.Text.Markup.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 VA.Text.Markup.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 BoxLayout_TwoLevelGrouping() { int num_types = 10; int max_properties = 50; var types = typeof(UserDefinedCell).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 = CreateTwoLevelLayout(data); layout1.PerformLayout(); // TODO: Check that each data item has at least 3 values // 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 VA.DOM.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 VA.Text.Markup.TextElement(info.Text); } shape.Cells = info.ShapeCells.ShallowCopy(); } domshapescol.Render(page); var bordersize = new VA.Drawing.Size(0.5, 0.5); page.ResizeToFitContents(bordersize); }
public void Draw(Session session) { var normalized_values = DataPoints.GetNormalizedValues(); var widths = DOMUtil.ConstructPositions(DataPoints.Count(), this.CellWidth, HorizontalSeparation); var heights = DOMUtil.ConstructPositions(new[] { CategoryLabelHeight, CellHeight }, VerticalSeparation); var grid = new GridLayout(widths, heights); int catrow = 0; int barrow = 2; var top_rects = this.SkipOdd(grid.GetRectsInRow(barrow)).ToList(); var cat_rects = this.SkipOdd(grid.GetRectsInRow(catrow)).ToList(); var domshapescol = new VA.DOM.ShapeList(); var circle_shapes = new List<VA.DOM.Arc>(); var slice_shapes = new List<VA.DOM.Arc>(); for (int i = 0; i < DataPoints.Count; i++) { var dp = DataPoints[i]; var start = 0.0; var end = System.Math.PI * 2.0 * normalized_values[i]; double radius = top_rects[i].Width / 2.0; var circle_shape = domshapescol.DrawArc(top_rects[i].Center, radius * 0.7, radius, start, System.Math.PI * 2.0); circle_shapes.Add(circle_shape); var dom_shape = domshapescol.DrawArc(top_rects[i].Center, radius*0.7, radius, start, end); slice_shapes.Add(dom_shape); } var cat_shapes = DOMUtil.DrawRects(domshapescol, cat_rects, session.MasterRectangle); for (int i = 0; i < DataPoints.Count; i++) { slice_shapes[i].Text = new VA.Text.Markup.TextElement(DataPoints[i].Text); cat_shapes[i].Text = new VA.Text.Markup.TextElement(CategoryLabels[i]); } foreach (var shape in circle_shapes) { var cells = shape.Cells; cells.FillForegnd = NonValueColor; cells.LineColor = LineLightBorder; } foreach (var shape in slice_shapes) { var cells = shape.Cells; cells.FillForegnd = ValueFillColor; cells.LineColor = LineLightBorder; } foreach (var shape in cat_shapes) { var cells = shape.Cells; cells.FillPattern = CategoryFillPattern; cells.LineWeight = CategoryLineWeight; cells.LinePattern = CategoryLinePattern; } domshapescol.Render(session.Page); }
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 VA.DOM.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 VA.DOM.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 VA.DOM.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 VA.DOM.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 VA.Text.Markup.TextElement(node_data.Text); } domshapescol.Render(page); var bordersize = new VA.Drawing.Size(0.5, 0.5); page.ResizeToFitContents(bordersize); }
private void Render(IVisio.Page page, BL.BoxLayout layout) { layout.PerformLayout(); var doc = page.Document; var fonts = doc.Fonts; var default_font = fonts[this.Font]; int default_font_id = default_font.ID; // Perform Rendering var domshapescol = new VA.DOM.ShapeList(); foreach (var n in layout.Nodes) { if (n.Data != null) { var r = n.Rectangle; var n_data = (RenderItem) n.Data; var s = domshapescol.DrawRectangle(r); // Set Text if (n_data.ShapeText != null) { s.Text = new VA.Text.Markup.TextElement(this.ToUpper ? n_data.ShapeText.ToUpper() : n_data.ShapeText); } // Set Cells if (n_data.Cells != null) { s.Cells = n_data.Cells; } // draw Underline if (n_data.Underline) { var u = domshapescol.DrawLine(r.LowerLeft, r.LowerRight); } n_data.Cells.CharFont = default_font_id; } } domshapescol.Render(page); }