コード例 #1
0
        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);
            }
        }
コード例 #2
0
        private void CreateDynamicConnectorEdges(VA.DOM.ShapeList shape_nodes, MG.GeometryGraph msagl_graph)
        {
            // CREATE EDGES
            foreach (var i in msagl_graph.Edges)
            {
                var layoutconnector = (DGMODEL.Connector)i.UserData;
                var vconnector      = new VA.DOM.Connector(
                    layoutconnector.From.DOMNode,
                    layoutconnector.To.DOMNode, "Dynamic Connector", "connec_u.vss");
                layoutconnector.DOMNode = vconnector;
                shape_nodes.Add(vconnector);
            }

            var edge_pairs = from n in msagl_graph.Edges
                             let lc = (DGMODEL.Connector)n.UserData
                                      select
                                      new { msagl_edge = n, layout_connector = lc, vconnector = (VA.DOM.Connector)lc.DOMNode };

            foreach (var i in edge_pairs)
            {
                int con_route_style   = (int)ConnectorTypeToCellVal_Appearance(i.layout_connector.ConnectorType);
                int shape_route_style = (int)ConnectorTypeToCellVal_Style(i.layout_connector.ConnectorType);

                i.vconnector.Text = new VA.Text.Markup.TextElement(i.layout_connector.Label);

                i.vconnector.Cells = i.layout_connector.Cells != null?
                                     i.layout_connector.Cells.ShallowCopy()
                                         : new VA.DOM.ShapeCells();

                i.vconnector.Cells.ConLineRouteExt = con_route_style;
                i.vconnector.Cells.ShapeRouteStyle = shape_route_style;
            }
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        private VA.DOM.BezierCurve draw_edge_bezier(
            VA.DOM.ShapeList page,
            DGMODEL.Connector connector,
            MG.Edge edge)
        {
            var final_bez_points =
                VA.Internal.MSAGLUtil.ToVAPoints(edge).Select(p => ToDocumentCoordinates(p)).ToList();

            var bez_shape = new VA.DOM.BezierCurve(final_bez_points);

            return(bez_shape);
        }
コード例 #6
0
        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);
            }
        }
コード例 #7
0
ファイル: DOM_Tests.cs プロジェクト: sk8tz/VisioAutomation
        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);
        }
コード例 #8
0
ファイル: DOM_Tests.cs プロジェクト: sk8tz/VisioAutomation
        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);
        }
コード例 #9
0
        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;
        }
コード例 #10
0
        private void CreateBezierEdges(VA.DOM.ShapeList domshapes, MG.GeometryGraph msagl_graph)
        {
            // DRAW EDGES WITH BEZIERS
            foreach (var msagl_edge in msagl_graph.Edges)
            {
                var layoutconnector = (DGMODEL.Connector)msagl_edge.UserData;
                var vconnector      = draw_edge_bezier(domshapes, layoutconnector, msagl_edge);
                layoutconnector.DOMNode = vconnector;
                domshapes.Add(vconnector);
            }

            var edge_pairs = from n in msagl_graph.Edges
                             let lc = (DGMODEL.Connector)n.UserData
                                      select new { msagl_edge       = n,
                                                   layout_connector = lc,
                                                   bezier_node      = (VA.DOM.BezierCurve)lc.DOMNode };

            foreach (var i in edge_pairs)
            {
                if (i.layout_connector.Cells != null)
                {
                    i.bezier_node.Cells = i.layout_connector.Cells.ShallowCopy();
                }
            }

            foreach (var i in edge_pairs.Where(item => !string.IsNullOrEmpty(item.layout_connector.Label)))
            {
                // this is a bezier connector
                // draw a manual box instead
                var label_bb = ToDocumentCoordinates(VA.Internal.MSAGLUtil.ToVARectangle(i.msagl_edge.Label.BoundingBox));
                var vshape   = new VA.DOM.Rectangle(label_bb);
                domshapes.Add(vshape);

                vshape.Cells = DefaultBezierConnectorShapeCells.ShallowCopy();
                vshape.Text  = new VA.Text.Markup.TextElement(i.layout_connector.Label);
            }
        }
コード例 #11
0
        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);
        }
コード例 #12
0
        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);
        }
コード例 #13
0
        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);
        }
コード例 #14
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);
        }
コード例 #15
0
        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);
            }
        }
コード例 #16
0
        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);
            }
        }
コード例 #17
0
        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);
        }
コード例 #18
0
        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);
        }
コード例 #19
0
        private void CreateDOMShapes(VA.DOM.ShapeList domshapeslist, MG.GeometryGraph msagl_graph, IVisio.Application app)
        {
            var node_centerpoints = msagl_graph.NodeMap.Values
                                    .Select(n => ToDocumentCoordinates(VA.Internal.MSAGLUtil.ToVAPoint(n.Center)))
                                    .ToArray();

            // Load up all the stencil docs
            var app_documents = app.Documents;
            var nodes         = msagl_graph.NodeMap.Values.Select(get_shape);
            var stencil_names = nodes.Select(s => s.StencilName.ToUpper()).Distinct().ToList();

            var stencil_map = new Dictionary <string, IVisio.Document>();

            foreach (var stencil_name in stencil_names)
            {
                if (!stencil_map.ContainsKey(stencil_name))
                {
                    var stencil = app_documents.OpenStencil(stencil_name);
                    stencil_map[stencil_name] = stencil;
                }
            }

            var master_map = new Dictionary <string, IVisio.Master>();

            foreach (var nv in nodes)
            {
                var key = nv.StencilName.ToLower() + "+" + nv.MasterName;
                if (!master_map.ContainsKey(key))
                {
                    var stencil = stencil_map[nv.StencilName.ToUpper()];
                    var masters = stencil.Masters;
                    var master  = masters[nv.MasterName];
                    master_map[key] = master;
                }
            }

            // Create DOM Shapes for each AutoLayoutShape

            int count = 0;

            foreach (var layout_shape in nodes)
            {
                var key        = layout_shape.StencilName.ToLower() + "+" + layout_shape.MasterName;
                var master     = master_map[key];
                var shape_node = new VA.DOM.Shape(master, node_centerpoints[count]);
                layout_shape.DOMNode = shape_node;
                domshapeslist.Add(shape_node);
                count++;
            }

            var shape_pairs = from n in msagl_graph.NodeMap.Values
                              let layout_shape = (DGMODEL.Shape)n.UserData
                                                 select new
            {
                layout_shape,
                shape_node = (VA.DOM.BaseShape)layout_shape.DOMNode
            };

            // FORMAT EACH SHAPE
            foreach (var i in shape_pairs)
            {
                format_shape(i.layout_shape, i.shape_node);
            }
        }
コード例 #20
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);
        }