コード例 #1
0
        private static void TestResize(IVisio.Document doc,
                                       VA.Drawing.Size bottomleft_margin,
                                       VA.Drawing.Size upperright_margin,
                                       VA.Drawing.Size shape_size,
                                       VA.Drawing.Size padding_size,
                                       double expected_pinx,
                                       double expected_piny)
        {
            var page = doc.Pages.Add();

            var pagecells = new VA.Pages.PageCells();

            pagecells.PageTopMargin    = upperright_margin.Height;
            pagecells.PageBottomMargin = bottomleft_margin.Height;
            pagecells.PageLeftMargin   = bottomleft_margin.Width;
            pagecells.PageRightMargin  = upperright_margin.Width;

            var pageupdate = new VA.ShapeSheet.Update();

            pageupdate.SetFormulas(pagecells);
            pageupdate.Execute(page.PageSheet);


            var shape = page.DrawRectangle(5, 5, 5 + shape_size.Width, 5 + shape_size.Height);

            page.ResizeToFitContents(padding_size);
            var xform = VA.Shapes.XFormCells.GetCells(shape);

            AssertVA.AreEqual(expected_pinx, expected_piny, xform.Pin(), 0.1);
            page.Delete(0);
        }
コード例 #2
0
        public void Internal_ValidateSnappingGrid()
        {
            double delta = 0.000000001;

            var g1 = new VA.Drawing.SnappingGrid(1.0, 1.0);

            AssertVA.AssertSnap(0.0, 0.0, g1, 0.0, 0.0, delta);
            AssertVA.AssertSnap(0.0, 0.0, g1, 0.3, 0.3, delta);
            AssertVA.AssertSnap(0.0, 0.0, g1, 0.49999, 0.49999, delta);
            AssertVA.AssertSnap(1.0, 1.0, g1, 0.5, 0.5, delta);
            AssertVA.AssertSnap(1.0, 1.0, g1, 0.500001, 0.500001, delta);
            AssertVA.AssertSnap(1.0, 1.0, g1, 1.0, 1.0, delta);
            AssertVA.AssertSnap(1.0, 1.0, g1, 1.3, 1.3, delta);
            AssertVA.AssertSnap(1.0, 1.0, g1, 1.49999, 1.49999, delta);
            AssertVA.AssertSnap(2.0, 2.0, g1, 1.5, 1.5, delta);
            AssertVA.AssertSnap(2.0, 2.0, g1, 1.500001, 1.500001, delta);

            var g2 = new VA.Drawing.SnappingGrid(1.0, 0.3);

            AssertVA.AssertSnap(0.0, 0.0, g2, 0.0, 0.0, delta);
            AssertVA.AssertSnap(0.0, 0.0, g2, 0.3, 0.1, delta);
            AssertVA.AssertSnap(0.0, 0.0, g2, 0.49999, 0.149, delta);
            AssertVA.AssertSnap(1.0, 0.3, g2, 0.5, 0.3, delta);
            AssertVA.AssertSnap(1.0, 0.3, g2, 0.500001, 0.30001, delta);
        }
コード例 #3
0
        public void CheckHomogenousUpdates_ResultTypes()
        {
            var page1  = GetNewPage();
            var shape1 = page1.DrawRectangle(0, 0, 1, 1);

            // Setup the modifications to the cell values
            var update = new VA.ShapeSheet.Update();

            update.SetResult(src_linepat, "7", IVisio.VisUnitCodes.visNumber);
            update.SetResult(VA.ShapeSheet.SRCConstants.PinX, 2, IVisio.VisUnitCodes.visNumber);
            update.Execute(shape1);

            // Build the query
            var query       = new VA.ShapeSheet.Query.CellQuery();
            var col_linepat = query.Columns.Add(src_linepat, "LinePattern");
            var col_pinx    = query.Columns.Add(VA.ShapeSheet.SRCConstants.PinX, "PinX");

            // Retrieve the values
            var data = query.GetFormulasAndResults <double>(shape1);

            // Verify
            AssertVA.AreEqual("7", 7, data[col_linepat.Ordinal]);
            AssertVA.AreEqual("2 in", 2, data[col_pinx.Ordinal]);

            page1.Delete(0);
        }
コード例 #4
0
            public void Internal_TestBezierFromArcs()
            {
                // 0 width slice - 0 degrees
                var s1 = VA.Drawing.BezierSegment.FromArc(0.0, 0.0);

                Assert.AreEqual(1, s1.Count());
                AssertVA.AreEqual(s1[0].Start, s1[s1.Length - 1].End, delta);

                // 0 width slice - 45 degrees
                var s1x = VA.Drawing.BezierSegment.FromArc(piquarter, piquarter);

                Assert.AreEqual(1, s1x.Count());
                AssertVA.AreEqual(s1x[0].Start, s1x[s1.Length - 1].End, delta);

                // a circle
                var s2 = VA.Drawing.BezierSegment.FromArc(0.0, pi2);

                Assert.AreEqual(4, s2.Count());
                AssertVA.AreEqual(s2[0].Start, s2[s2.Length - 1].End, delta);

                // angles within first quadrant
                var s3 = VA.Drawing.BezierSegment.FromArc(piquarter - 0.1, piquarter + 0.2);

                Assert.AreEqual(1, s3.Count());

                // angles from first to 2nd quadrant
                var s4 = VA.Drawing.BezierSegment.FromArc(piquarter - 0.1, pihalf + piquarter);

                Assert.AreEqual(2, s4.Count());

                // half circle - top
                var s5 = VA.Drawing.BezierSegment.FromArc(0.0, System.Math.PI);

                Assert.AreEqual(2, s5.Count());

                // half circle - bottom
                var s6 = VA.Drawing.BezierSegment.FromArc(System.Math.PI, pi2);

                Assert.AreEqual(2, s6.Count());

                // half circle - bottom
                var s7 = VA.Drawing.BezierSegment.FromArc(pihalf, System.Math.PI + pihalf);

                Assert.AreEqual(2, s7.Count());

                // partial all quadrants
                var s8 = VA.Drawing.BezierSegment.FromArc(piquarter, pi2 - piquarter);

                Assert.AreEqual(4, s8.Count());

                // full circle
                var s9 = VA.Drawing.BezierSegment.FromArc(piquarter, pi2 * 10 + piquarter);

                Assert.AreEqual(4, s8.Count());
            }
コード例 #5
0
        public void ConnectionPoints_AddRemove()
        {
            var page1 = GetNewPage();

            var s1 = page1.DrawRectangle(0, 0, 4, 1);

            Assert.AreEqual(0, VACXN.ConnectionPointHelper.GetCount(s1));

            var cp_type = VACXN.ConnectionPointType.Inward;

            var cpd1 = new VACXN.ConnectionPointCells();

            cpd1.X    = "Width*0.25";
            cpd1.Y    = "Height*0";
            cpd1.Type = (int)cp_type;

            var cpd2 = new VACXN.ConnectionPointCells();

            cpd2.X    = "Width*0.75";
            cpd2.Y    = "Height*0";
            cpd2.Type = (int)cp_type;

            VACXN.ConnectionPointHelper.Add(s1, cpd1);
            Assert.AreEqual(1, VACXN.ConnectionPointHelper.GetCount(s1));

            VACXN.ConnectionPointHelper.Add(s1, cpd2);
            Assert.AreEqual(2, VACXN.ConnectionPointHelper.GetCount(s1));

            var controlpoints = VACXN.ConnectionPointCells.GetCells(s1);

            Assert.AreEqual(2, controlpoints.Count);
            var cp_0 = controlpoints[0];

            AssertVA.AreEqual("0 in", 0, cp_0.DirX);
            AssertVA.AreEqual("0 in", 0, cp_0.DirY);
            AssertVA.AreEqual("0", 0, cp_0.Type);
            AssertVA.AreEqual("Width*0.25", 1, cp_0.X);
            AssertVA.AreEqual("Height*0", 0, cp_0.Y);

            var cp_1 = controlpoints[1];

            AssertVA.AreEqual("0 in", 0, cp_1.DirX);
            AssertVA.AreEqual("0 in", 0, cp_1.DirY);
            AssertVA.AreEqual("0", 0, cp_1.Type);
            AssertVA.AreEqual("Width*0.75", 3, cp_1.X);
            AssertVA.AreEqual("Height*0", 0, cp_1.Y);

            VACXN.ConnectionPointHelper.Delete(s1, 1);
            Assert.AreEqual(1, VACXN.ConnectionPointHelper.GetCount(s1));
            VACXN.ConnectionPointHelper.Delete(s1, 0);
            Assert.AreEqual(0, VACXN.ConnectionPointHelper.GetCount(s1));

            page1.Delete(0);
        }
コード例 #6
0
        public void TreeLayout_MultiNode()
        {
            // Verify that a tree with multiple nodes can be drawn
            // Note that  the DefaultNodeSize option is being used

            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);

            t.LayoutOptions.DefaultNodeSize = new VA.Drawing.Size(1, 1);

            var app  = this.GetVisioApplication();
            var doc  = this.GetNewDoc();
            var page = app.ActivePage;

            t.Render(page);

            AssertVA.AreEqual(5.25, 8.0, VisioAutomationTest.GetPageSize(page), 0.05);

            Assert.AreEqual("Root", t.Root.VisioShape.Text);
            Assert.AreEqual("A", na.VisioShape.Text);
            Assert.AreEqual("B", nb.VisioShape.Text);

            Assert.AreEqual("A1", na1.VisioShape.Text);
            Assert.AreEqual("A2", na2.VisioShape.Text);

            Assert.AreEqual("B1", nb1.VisioShape.Text);
            Assert.AreEqual("B2", nb2.VisioShape.Text);

            doc.Close(true);
        }
コード例 #7
0
        public void TreeLayout_SingleNode()
        {
            // Verify that a tree with a single node can be drawn
            var t = new TREEMODEL.Drawing();

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

            var app  = this.GetVisioApplication();
            var doc  = this.GetNewDoc();
            var page = app.ActivePage;

            t.Render(page);

            AssertVA.AreEqual(3.0, 1.5, VisioAutomationTest.GetPageSize(page), 0.05);

            doc.Close(true);
        }
コード例 #8
0
        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;

            AssertVA.AreEqual(1.0, 1.0, 11, 6, n1.Rectangle, delta);
        }
コード例 #9
0
        public void ShapeSheet_Query_SectionRowHandling()
        {
            var page1 = GetNewPage();
            var s1    = page1.DrawRectangle(0, 0, 2, 2);
            var s2    = page1.DrawRectangle(2, 1, 3, 3);
            var s3    = page1.DrawRectangle(3, 1, 4, 2);
            var s4    = page1.DrawRectangle(4, -1, 5, 1);

            VACUSTOMPROP.CustomPropertyHelper.Set(s1, "S1P1", "1");
            VACUSTOMPROP.CustomPropertyHelper.Set(s2, "S2P1", "2");
            VACUSTOMPROP.CustomPropertyHelper.Set(s2, "S2P2", "3");
            //set nothing for s3
            VACUSTOMPROP.CustomPropertyHelper.Set(s4, "S3P1", "4");
            VACUSTOMPROP.CustomPropertyHelper.Set(s4, "S3P2", "5");
            VACUSTOMPROP.CustomPropertyHelper.Set(s4, "S3P3", "6");

            var query = new VA.ShapeSheet.Query.CellQuery();

            var sec = query.Sections.Add(IVisio.VisSectionIndices.visSectionProp);

            sec.Columns.Add(VA.ShapeSheet.SRCConstants.Prop_Value, "Value");

            var shapeids = new[] { s1.ID, s2.ID, s3.ID, s4.ID };

            var table = query.GetFormulasAndResults <double>(
                page1,
                shapeids);

            Assert.AreEqual(4, table.Count);
            Assert.AreEqual(1, table[0].SectionCells[sec.Ordinal].Count);
            Assert.AreEqual(2, table[1].SectionCells[sec.Ordinal].Count);
            Assert.AreEqual(0, table[2].SectionCells[sec.Ordinal].Count);
            Assert.AreEqual(3, table[3].SectionCells[sec.Ordinal].Count);

            AssertVA.AreEqual("\"1\"", 1.0, table[0].SectionCells[sec.Ordinal][0][0]);
            AssertVA.AreEqual("\"2\"", 2.0, table[1].SectionCells[sec.Ordinal][0][0]);
            AssertVA.AreEqual("\"3\"", 3.0, table[1].SectionCells[sec.Ordinal][1][0]);
            AssertVA.AreEqual("\"4\"", 4.0, table[3].SectionCells[sec.Ordinal][0][0]);
            AssertVA.AreEqual("\"5\"", 5.0, table[3].SectionCells[sec.Ordinal][1][0]);
            AssertVA.AreEqual("\"6\"", 6.0, table[3].SectionCells[sec.Ordinal][2][0]);

            page1.Delete(0);
        }
コード例 #10
0
        public void ShapeSheet_Update_ResultsInt_SingleShape()
        {
            var page1  = GetNewPage();
            var shape1 = page1.DrawRectangle(0, 0, 1, 1);

            // Setup the modifications to the cell values
            var update = new VA.ShapeSheet.Update();

            update.SetResult(src_linepat, 7, IVisio.VisUnitCodes.visNumber);
            update.Execute(shape1);

            // Build the query
            var query       = new VA.ShapeSheet.Query.CellQuery();
            var col_linepat = query.Columns.Add(src_linepat, "LinePattern");

            // Retrieve the values
            var data = query.GetFormulasAndResults <double>(shape1);

            // Verify
            AssertVA.AreEqual("7", 7, data[col_linepat.Ordinal]);
            page1.Delete(0);
        }
コード例 #11
0
        public void ShapeSheet_Update_Formulas_MultipleShapes()
        {
            var page1 = GetNewPage();

            var shape1 = page1.DrawRectangle(-1, -1, 0, 0);
            var shape2 = page1.DrawRectangle(-1, -1, 0, 0);
            var shape3 = page1.DrawRectangle(-1, -1, 0, 0);


            // Set the formulas
            var update = new VA.ShapeSheet.Update();

            update.SetFormula(shape1.ID16, src_pinx, 0.5);
            update.SetFormula(shape1.ID16, src_piny, 0.5);
            update.SetFormula(shape2.ID16, src_pinx, 1.5);
            update.SetFormula(shape2.ID16, src_piny, 1.5);
            update.SetFormula(shape3.ID16, src_pinx, 2.5);
            update.SetFormula(shape3.ID16, src_piny, 2.5);
            update.Execute(page1);

            // Verify that the formulas were set
            var query    = new VA.ShapeSheet.Query.CellQuery();
            var col_pinx = query.Columns.Add(src_pinx, "PinX");
            var col_piny = query.Columns.Add(src_piny, "PinY");

            var shapeids = new[] { shape1.ID, shape2.ID, shape3.ID };

            var rf = query.GetFormulas(page1, shapeids);
            var rr = query.GetResults <double>(page1, shapeids);

            AssertVA.AreEqual("0.5 in", 0.5, rf[0][col_pinx.Ordinal], rr[0][col_pinx.Ordinal]);
            AssertVA.AreEqual("0.5 in", 0.5, rf[0][col_piny.Ordinal], rr[0][col_piny.Ordinal]);
            AssertVA.AreEqual("1.5 in", 1.5, rf[1][col_pinx.Ordinal], rr[1][col_pinx.Ordinal]);
            AssertVA.AreEqual("1.5 in", 1.5, rf[1][col_piny.Ordinal], rr[1][col_piny.Ordinal]);
            AssertVA.AreEqual("2.5 in", 2.5, rf[2][col_pinx.Ordinal], rr[2][col_pinx.Ordinal]);
            AssertVA.AreEqual("2.5 in", 2.5, rf[2][col_piny.Ordinal], rr[2][col_piny.Ordinal]);

            page1.Delete(0);
        }
コード例 #12
0
 public static void AssertSnap(double ex, double ey, VADRAW.SnappingGrid g1, double ix, double iy, double delta)
 {
     AssertVA.AreEqual(ex, ey, g1.Snap(ix, iy), delta);
 }