Пример #1
0
        public static void GradientTransparencies()
        {
            int num_cols = 1;
            int num_rows = 10;
            var color1   = new ColorRGB(0xff000);
            var color2   = new ColorRGB(0x000ff);

            var page_size = new VA.Drawing.Size(num_rows / 2.0, num_rows);
            var upperleft = new VA.Drawing.Point(0, page_size.Height);

            var page    = SampleEnvironment.Application.ActiveDocument.Pages.Add();
            var app     = page.Application;
            var docs    = app.Documents;
            var stencil = docs.OpenStencil("basic_U.vss");
            var master  = stencil.Masters["Rectangle"];

            SampleEnvironment.SetPageSize(page, page_size);

            var layout = new GRIDMODEL.GridLayout(num_cols, num_rows, new VA.Drawing.Size(6.0, 1.0), master);

            layout.RowDirection = GRIDMODEL.RowDirection.TopToBottom;
            layout.Origin       = upperleft;
            layout.CellSpacing  = new VA.Drawing.Size(0.1, 0.1);
            layout.PerformLayout();

            double[] trans = EffectsSamples.RangeSteps(0.0, 1.0, num_rows).ToArray();

            int i = 0;

            foreach (var node in layout.Nodes)
            {
                double transparency = trans[i];

                var fmt = new VA.DOM.ShapeCells();
                node.Cells = fmt;

                fmt.FillPattern      = 25; // Linear pattern left to right
                fmt.FillForegnd      = color1.ToFormula();
                fmt.FillBkgnd        = color2.ToFormula();
                fmt.FillForegndTrans = 0;
                fmt.FillBkgndTrans   = transparency;
                fmt.LinePattern      = 0;

                node.Text = string.Format("bg trans = {0}%", transparency);
                i++;
            }

            layout.Render(page);

            page.ResizeToFitContents();
        }
        public static void GradientTransparencies()
        {
            int num_cols = 1;
            int num_rows = 10;
            var color1 = new VA.Drawing.ColorRGB(0xff000);
            var color2 = new VA.Drawing.ColorRGB(0x000ff);

            var page_size = new VA.Drawing.Size(num_rows/2.0, num_rows);
            var upperleft = new VA.Drawing.Point(0, page_size.Height);

            var page = SampleEnvironment.Application.ActiveDocument.Pages.Add();
            var app = page.Application;
            var docs = app.Documents;
            var stencil = docs.OpenStencil("basic_U.vss");
            var master = stencil.Masters["Rectangle"];

            SampleEnvironment.SetPageSize(page,page_size);

            var layout = new GRIDMODEL.GridLayout(num_cols, num_rows, new VA.Drawing.Size(6.0, 1.0), master);
            layout.RowDirection = GRIDMODEL.RowDirection.TopToBottom;
            layout.Origin = upperleft;
            layout.CellSpacing = new VA.Drawing.Size(0.1, 0.1);
            layout.PerformLayout();

            double[] trans = RangeSteps(0.0, 1.0, num_rows).ToArray();

            int i = 0;
            foreach (var node in layout.Nodes)
            {
                double transparency = trans[i];

                var fmt = new VA.DOM.ShapeCells();
                node.Cells = fmt;

                fmt.FillPattern = 25; // Linear pattern left to right
                fmt.FillForegnd = color1.ToFormula();
                fmt.FillBkgnd = color2.ToFormula();
                fmt.FillForegndTrans = 0;
                fmt.FillBkgndTrans = transparency;
                fmt.LinePattern = 0;

                node.Text = string.Format("bg trans = {0}%", transparency);
                i++;
            }

            layout.Render(page);

            page.ResizeToFitContents();
        }
Пример #3
0
        public static void TreeWithTwoPassLayoutAndFormatting()
        {
            var doc   = SampleEnvironment.Application.ActiveDocument;
            var page1 = doc.Pages.Add();

            var t = new TREEMODEL.Drawing();

            t.Root = new TREEMODEL.Node("Root");

            var na = new TREEMODEL.Node("A");
            var nb = new TREEMODEL.Node("B");

            var na1 = new TREEMODEL.Node("A1");
            var na2 = new TREEMODEL.Node("A2");

            var nb1 = new TREEMODEL.Node("B1");
            var nb2 = new TREEMODEL.Node("B2");

            t.Root.Children.Add(na);
            t.Root.Children.Add(nb);

            na.Children.Add(na1);
            na.Children.Add(na2);

            nb.Children.Add(nb1);
            nb1.Children.Add(nb2);

            var fontname = "Segoe UI";
            var font     = doc.Fonts[fontname];

            foreach (var tn in t.Nodes)
            {
                var cells = new VA.DOM.ShapeCells();
                tn.Cells = cells;

                cells.ParaHorizontalAlign = 0; // align text to left
                cells.VerticalAlign       = 0; // align text block to top
                cells.CharFont            = font.ID;
                cells.CharSize            = "10pt";
                cells.FillForegnd         = "rgb(255,250,200)";
                cells.CharColor           = "rgb(255,0,0)";
            }

            // TODO: Complete this sample
        }
        public static void TreeWithTwoPassLayoutAndFormatting()
        {
            var doc = SampleEnvironment.Application.ActiveDocument;
            var page1 = doc.Pages.Add();

            var t = new TREEMODEL.Drawing();

            t.Root = new TREEMODEL.Node("Root");

            var na = new TREEMODEL.Node("A");
            var nb = new TREEMODEL.Node("B");

            var na1 = new TREEMODEL.Node("A1");
            var na2 = new TREEMODEL.Node("A2");

            var nb1 = new TREEMODEL.Node("B1");
            var nb2 = new TREEMODEL.Node("B2");

            t.Root.Children.Add(na);
            t.Root.Children.Add(nb);

            na.Children.Add(na1);
            na.Children.Add(na2);

            nb.Children.Add(nb1);
            nb1.Children.Add(nb2);

            var fontname = "Segoe UI";
            var font = doc.Fonts[fontname];

            foreach (var tn in t.Nodes)
            {
                var cells = new VA.DOM.ShapeCells();
                tn.Cells = cells;

                cells.ParaHorizontalAlign = 0; // align text to left
                cells.VerticalAlign = 0; // align text block to top
                cells.CharFont = font.ID;
                cells.CharSize = "10pt";
                cells.FillForegnd = "rgb(255,250,200)";
                cells.CharColor = "rgb(255,0,0)";
            }

            // TODO: Complete this sample
        }
        private static BOXMODEL.BoxLayout CreateTwoLevelLayout(List<string[]> data)
        {
            double itemsep = 0.0;
            var major_group_direction = BOXMODEL.Direction.LeftToRight;
            var minor_group_direction = BOXMODEL.Direction.TopToBottom;

            var name_to_major_group = new Dictionary<string, BOXMODEL.Container>();
            var name_to_minor_group = new Dictionary<string, BOXMODEL.Container>();

            var layout1 = new BOXMODEL.BoxLayout();
            layout1.Root = new BOXMODEL.Container(major_group_direction);

            var major_cells = new VA.DOM.ShapeCells();
            major_cells.FillForegnd = "rgb(245,245,245)";
            major_cells.CharFont = 0;
            major_cells.CharSize = "12pt";
            major_cells.ParaHorizontalAlign = "0";
            major_cells.VerticalAlign = "0";
            major_cells.LineWeight = "0";
            major_cells.LinePattern = "0";

            var minor_cells = new VA.DOM.ShapeCells();
            minor_cells.FillForegnd = "rgb(230,230,230)";
            minor_cells.CharFont = 0;
            minor_cells.CharSize = "10pt";
            minor_cells.ParaHorizontalAlign = "0";
            minor_cells.VerticalAlign = "0";
            minor_cells.LineWeight = "0";
            minor_cells.LinePattern = "0";

            var item_cells = new VA.DOM.ShapeCells();
            item_cells.CharFont = 0;
            item_cells.FillPattern = "0";
            item_cells.CharSize = "8pt";
            item_cells.ParaHorizontalAlign = "0";
            item_cells.VerticalAlign = "0";
            item_cells.LineWeight = "0";
            item_cells.LinePattern = "0";

            foreach (var row in data)
            {
                var majorname = row[0];
                var minorname = row[1];
                var itemname = row[2];

                BOXMODEL.Container majorcnt;
                if (name_to_major_group.ContainsKey(majorname))
                {
                    majorcnt = name_to_major_group[majorname];
                }
                else
                {
                    majorcnt = layout1.Root.AddContainer(minor_group_direction, 1, 1);

                    var major_info = new TwoLevelInfo();
                    major_info.Text = majorname;
                    major_info.Render = true;
                    major_info.ShapeCells = major_cells;
                    majorcnt.Data = major_info;

                    name_to_major_group[majorname] = majorcnt;

                    BOXMODEL.Box headerbox = majorcnt.AddBox(2, 0.25);
                }

                BOXMODEL.Container minorcnt;
                var minorkey = majorname + "___" + minorname;
                if (name_to_minor_group.ContainsKey(minorkey))
                {
                    minorcnt = name_to_minor_group[minorkey];
                }
                else
                {
                    minorcnt = majorcnt.AddContainer(minor_group_direction);
                    minorcnt.ChildSpacing = itemsep;
                    var minor_info = new TwoLevelInfo();
                    minor_info.Text = minorname;
                    minor_info.Render = true;
                    minor_info.ShapeCells = minor_cells;
                    minorcnt.Data = minor_info;
                    name_to_minor_group[minorkey] = minorcnt;

                    BOXMODEL.Box headerbox = minorcnt.AddBox(2, 0.25);
                }

                BOXMODEL.Box itembox = minorcnt.AddBox(2, 0.25);

                var item_info = new TwoLevelInfo();
                item_info.Text = itemname;
                item_info.Render = true;

                item_info.ShapeCells = item_cells;

                itembox.Data = item_info;
            }
            return layout1;
        }
        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 NodeData()
 {
     this.Render = true;
     this.Cells = new VA.DOM.ShapeCells();
 }
Пример #8
0
        private static BOXMODEL.BoxLayout CreateTwoLevelLayout(List <string[]> data)
        {
            double itemsep = 0.0;
            var    major_group_direction = BOXMODEL.Direction.LeftToRight;
            var    minor_group_direction = BOXMODEL.Direction.TopToBottom;

            var name_to_major_group = new Dictionary <string, BOXMODEL.Container>();
            var name_to_minor_group = new Dictionary <string, BOXMODEL.Container>();

            var layout1 = new BOXMODEL.BoxLayout();

            layout1.Root = new BOXMODEL.Container(major_group_direction);

            var major_cells = new VA.DOM.ShapeCells();

            major_cells.FillForegnd         = "rgb(245,245,245)";
            major_cells.CharFont            = 0;
            major_cells.CharSize            = "12pt";
            major_cells.ParaHorizontalAlign = "0";
            major_cells.VerticalAlign       = "0";
            major_cells.LineWeight          = "0";
            major_cells.LinePattern         = "0";

            var minor_cells = new VA.DOM.ShapeCells();

            minor_cells.FillForegnd         = "rgb(230,230,230)";
            minor_cells.CharFont            = 0;
            minor_cells.CharSize            = "10pt";
            minor_cells.ParaHorizontalAlign = "0";
            minor_cells.VerticalAlign       = "0";
            minor_cells.LineWeight          = "0";
            minor_cells.LinePattern         = "0";

            var item_cells = new VA.DOM.ShapeCells();

            item_cells.CharFont            = 0;
            item_cells.FillPattern         = "0";
            item_cells.CharSize            = "8pt";
            item_cells.ParaHorizontalAlign = "0";
            item_cells.VerticalAlign       = "0";
            item_cells.LineWeight          = "0";
            item_cells.LinePattern         = "0";


            foreach (var row in data)
            {
                var majorname = row[0];
                var minorname = row[1];
                var itemname  = row[2];

                BOXMODEL.Container majorcnt;
                if (name_to_major_group.ContainsKey(majorname))
                {
                    majorcnt = name_to_major_group[majorname];
                }
                else
                {
                    majorcnt = layout1.Root.AddContainer(minor_group_direction, 1, 1);

                    var major_info = new TwoLevelInfo();
                    major_info.Text       = majorname;
                    major_info.Render     = true;
                    major_info.ShapeCells = major_cells;
                    majorcnt.Data         = major_info;


                    name_to_major_group[majorname] = majorcnt;

                    BOXMODEL.Box headerbox = majorcnt.AddBox(2, 0.25);
                }

                BOXMODEL.Container minorcnt;
                var minorkey = majorname + "___" + minorname;
                if (name_to_minor_group.ContainsKey(minorkey))
                {
                    minorcnt = name_to_minor_group[minorkey];
                }
                else
                {
                    minorcnt = majorcnt.AddContainer(minor_group_direction);
                    minorcnt.ChildSpacing = itemsep;
                    var minor_info = new TwoLevelInfo();
                    minor_info.Text               = minorname;
                    minor_info.Render             = true;
                    minor_info.ShapeCells         = minor_cells;
                    minorcnt.Data                 = minor_info;
                    name_to_minor_group[minorkey] = minorcnt;

                    BOXMODEL.Box headerbox = minorcnt.AddBox(2, 0.25);
                }

                BOXMODEL.Box itembox = minorcnt.AddBox(2, 0.25);

                var item_info = new TwoLevelInfo();
                item_info.Text   = itemname;
                item_info.Render = true;


                item_info.ShapeCells = item_cells;

                itembox.Data = item_info;
            }
            return(layout1);
        }
Пример #9
0
        public IVisio.Document DrawNamespacesAndClasses(IList <System.Type> types_)
        {
            this.AssertApplicationAvailable();

            string segoeui_fontname      = "Segoe UI";
            string segoeuilight_fontname = "Segoe UI Light";
            string def_linecolor         = "rgb(180,180,180)";
            string def_shape_fill        = "rgb(245,245,245)";

            var doc               = this.Client.Document.New(8.5, 11, null);
            var fonts             = doc.Fonts;
            var font_segoe        = fonts[segoeui_fontname];
            var font_segoelight   = fonts[segoeuilight_fontname];
            int fontid_segoe      = font_segoe.ID16;
            int fontid_segoelight = font_segoelight.ID16;

            var types = types_.Select(t => new TypeInfo(t));

            var pathbuilder = new PathTreeBuilder();

            foreach (var type in types)
            {
                pathbuilder.Add(type.Type.Namespace);
            }

            var namespaces = pathbuilder.GetPaths();

            var tree_layout = new TREEMODEL.Drawing();

            tree_layout.LayoutOptions.Direction     = TREEMODEL.LayoutDirection.Down;
            tree_layout.LayoutOptions.ConnectorType = TREEMODEL.ConnectorType.PolyLine;
            var ns_node_map     = new Dictionary <string, TREEMODEL.Node>(namespaces.Count);
            var node_to_nslabel = new Dictionary <TREEMODEL.Node, string>(namespaces.Count);

            // create nodes for every namespace
            foreach (string ns in namespaces)
            {
                string label             = ns;
                int    index_of_last_sep = ns.LastIndexOf(pathbuilder.Separator);
                if (index_of_last_sep > 0)
                {
                    label = ns.Substring(index_of_last_sep + 1);
                }

                string ns1 = ns;
                var    types_in_namespace = types.Where(t => t.Type.Namespace == ns1)
                                            .OrderBy(t => t.Type.Name)
                                            .Select(t => t.Label);
                var node = new TREEMODEL.Node(ns);
                node.Size = new VA.Drawing.Size(2.0, (0.15) * (1 + 2 + types_in_namespace.Count()));


                var markup = new VA.Text.Markup.TextElement();
                var m1     = markup.AddElement(label + "\n");
                m1.CharacterCells.Font  = fontid_segoe;
                m1.CharacterCells.Size  = "12.0pt";
                m1.CharacterCells.Style = "1"; // Bold
                var m2 = markup.AddElement();
                m2.CharacterCells.Font = fontid_segoe;
                m2.CharacterCells.Size = "8.0pt";
                m2.AddText(string.Join("\n", types_in_namespace));

                node.Text = markup;

                ns_node_map[ns]       = node;
                node_to_nslabel[node] = label;
            }

            // add children to nodes
            foreach (string ns in namespaces)
            {
                var parent_ns = pathbuilder.PathToParentPath[ns];

                if (parent_ns != null)
                {
                    // the current namespace has a parent
                    var parent_node = ns_node_map[parent_ns];
                    var child_node  = ns_node_map[ns];
                    parent_node.Children.Add(child_node);
                }
                else
                {
                    // that means this namespace is a root, forget about it
                }
            }

            if (pathbuilder.Roots.Count == 0)
            {
            }
            else if (pathbuilder.Roots.Count == 1)
            {
                // when there is exactly one root namespace, then that node will be the tree's root node
                var first_root = pathbuilder.Roots[0];
                var root_n     = ns_node_map[first_root];
                tree_layout.Root = root_n;
            }
            else
            {
                // if there are multiple root namespaces, inject an empty placeholder root
                var root_n = new TREEMODEL.Node();
                tree_layout.Root = root_n;

                foreach (var root_ns in pathbuilder.Roots)
                {
                    var node = ns_node_map[root_ns];
                    tree_layout.Root.Children.Add(node);
                }
            }

            // format the shapes
            foreach (var node in tree_layout.Nodes)
            {
                if (node.Cells == null)
                {
                    node.Cells = new VA.DOM.ShapeCells();
                }
                node.Cells.FillForegnd = def_shape_fill;
                //node.ShapeCells.LineWeight = "0";
                //node.ShapeCells.LinePattern = "0";
                node.Cells.LineColor           = def_linecolor;
                node.Cells.ParaHorizontalAlign = "0";
                node.Cells.VerticalAlign       = "0";
            }

            var cxn_cells = new VA.DOM.ShapeCells();

            cxn_cells.LineColor = def_linecolor;
            tree_layout.LayoutOptions.ConnectorCells = cxn_cells;
            tree_layout.Render(doc.Application.ActivePage);

            hide_ui_stuff(doc);

            return(doc);
        }
Пример #10
0
        public IVisio.Document DrawNamespaces(IList <System.Type> types)
        {
            this.AssertApplicationAvailable();

            string def_linecolor = "rgb(140,140,140)";
            string def_fillcolor = "rgb(240,240,240)";
            string def_font      = "Segoe UI";

            var doc    = this.Client.Document.New(8.5, 11, null);
            var fonts  = doc.Fonts;
            var font   = fonts[def_font];
            int fontid = font.ID16;

            var pathbuilder = new PathTreeBuilder();

            foreach (var type in types)
            {
                pathbuilder.Add(type.Namespace);
            }

            var namespaces = pathbuilder.GetPaths();

            var tree_layout = new TREEMODEL.Drawing();

            tree_layout.LayoutOptions.Direction     = TREEMODEL.LayoutDirection.Right;
            tree_layout.LayoutOptions.ConnectorType = TREEMODEL.ConnectorType.CurvedBezier;
            var ns_node_map = new Dictionary <string, TREEMODEL.Node>(namespaces.Count);

            // create nodes for every namespace
            foreach (string ns in namespaces)
            {
                string label             = ns;
                int    index_of_last_sep = ns.LastIndexOf(pathbuilder.Separator);
                if (index_of_last_sep > 0)
                {
                    label = ns.Substring(index_of_last_sep + 1);
                }

                var node = new TREEMODEL.Node(ns);
                node.Text       = new VA.Text.Markup.TextElement(label);
                node.Size       = new VA.Drawing.Size(2.0, 0.25);
                ns_node_map[ns] = node;
            }

            // add children to nodes
            foreach (string ns in namespaces)
            {
                var parent_ns = pathbuilder.PathToParentPath[ns];

                if (parent_ns != null)
                {
                    // the current namespace has a parent
                    var parent_node = ns_node_map[parent_ns];
                    var child_node  = ns_node_map[ns];
                    parent_node.Children.Add(child_node);
                }
                else
                {
                    // that means this namespace is a root, forget about it
                }
            }

            if (pathbuilder.Roots.Count == 0)
            {
            }
            else if (pathbuilder.Roots.Count == 1)
            {
                // when there is exactly one root namespace, then that node will be the tree's root node
                var first_root = pathbuilder.Roots[0];
                var root_n     = ns_node_map[first_root];
                tree_layout.Root = root_n;
            }
            else
            {
                // if there are multiple root namespaces, inject an empty placeholder root
                var root_n = new TREEMODEL.Node();
                tree_layout.Root = root_n;

                foreach (var root_ns in pathbuilder.Roots)
                {
                    var node = ns_node_map[root_ns];
                    tree_layout.Root.Children.Add(node);
                }
            }

            // format the shapes
            foreach (var node in tree_layout.Nodes)
            {
                if (node.Cells == null)
                {
                    node.Cells = new VA.DOM.ShapeCells();
                }
                node.Cells.FillForegnd         = def_fillcolor;
                node.Cells.CharFont            = fontid;
                node.Cells.LineColor           = def_linecolor;
                node.Cells.ParaHorizontalAlign = "0";
            }

            var cxn_cells = new VA.DOM.ShapeCells();

            cxn_cells.LineColor = def_linecolor;
            tree_layout.LayoutOptions.ConnectorCells = cxn_cells;


            tree_layout.Render(doc.Application.ActivePage);

            hide_ui_stuff(doc);
            return(doc);
        }
Пример #11
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);
        }
Пример #12
0
 public NodeData()
 {
     this.Render = true;
     this.Cells  = new VA.DOM.ShapeCells();
 }