public void BoxLayout_Test_single_node_padding()
        {
            var layout = new BoxL.BoxLayout();

            layout.Root = new BoxL.Container(BoxL.Direction.BottomToTop);
            var root = layout.Root;
            var n1   = root.AddBox(10, 5);

            root.PaddingBottom = 1.0;
            root.PaddingLeft   = 1.0;
            root.PaddingRight  = 1.0;
            root.PaddingTop    = 1.0;

            layout.PerformLayout();
            double delta = 0.00000001;

            AssertUtil.AreEqual(1.0, 1.0, 11, 6, n1.Rectangle, delta);
        }
        public void BoxLayout_Test_single_node()
        {
            var layout = new VABOX.BoxLayout();

            layout.Root = new VABOX.Container(VABOX.Direction.BottomToTop);
            var root = layout.Root;

            root.PaddingBottom = 0.0;
            root.PaddingLeft   = 0.0;
            root.PaddingRight  = 0.0;
            root.PaddingTop    = 0.0;
            var n1 = root.AddBox(10, 5);

            layout.PerformLayout();
            double delta = 0.00000001;

            AssertUtil.AreEqual((0, 0, 10, 5), n1.Rectangle, delta);
            AssertUtil.AreEqual((0, 0, 10, 5), root.Rectangle, delta);
        }
示例#3
0
        public static void Render(VABOXMODEL.BoxLayout layout, IVisio.Document doc)
        {
            layout.PerformLayout();
            var page1 = doc.Pages.Add();
            // and tinker with it
            // render
            var nodes = layout.Nodes.ToList();

            foreach (var node in nodes)
            {
                var shape = page1.DrawRectangle(node.Rectangle);
                node.Data = shape;
            }

            var root_shape = (IVisio.Shape)layout.Root.Data;

            root_shape.CellsU["FillForegnd"].FormulaForceU = "rgb(240,240,240)";
            var margin = new VA.Drawing.Size(0.5, 0.5);

            page1.ResizeToFitContents(margin);
        }
        public void BoxLayout_Test_empty()
        {
            var layout = new BoxL.BoxLayout();

            layout.Root = new BoxL.Container(BoxL.Direction.BottomToTop);
            Assert.IsNotNull(layout.Root);

            bool thrown = false;

            try
            {
                layout.PerformLayout();
            }
            catch (AutomationException)
            {
                thrown = true;
            }

            if (!thrown)
            {
                Assert.Fail();
            }
        }
        public void BoxLayout_Test_empty()
        {
            var layout = new VABOX.BoxLayout();

            layout.Root = new VABOX.Container(VABOX.Direction.BottomToTop);
            Assert.IsNotNull(layout.Root);

            bool thrown = false;

            try
            {
                layout.PerformLayout();
            }
            catch (System.ArgumentException)
            {
                thrown = true;
            }

            if (!thrown)
            {
                Assert.Fail();
            }
        }
        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);
        }