Example #1
0
        public static BoxL.Box AddNodeEx(this BoxL.Container p, double w, double h, string s)
        {
            var box       = p.AddBox(w, h);
            var node_data = new NodeData();

            node_data.Text = s;
            box.Data       = node_data;
            return(box);
        }
        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);
        }
Example #3
0
        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);
        }