示例#1
0
        protected override void ProcessRecord()
        {
            var ctrl = new VA.Shapes.ControlCells();

            ctrl.XDynamics = this.XDynamics;
            ctrl.YDynamics = this.YDynamics;
            ctrl.XBehavior = this.XBehavior;
            ctrl.YBehavior = this.YBehavior;
            ctrl.X         = this.X;
            ctrl.Y         = this.Y;
            ctrl.CanGlue   = this.CanGlue;
            ctrl.Tip       = this.Tip;

            var targetshapes = new VisioScripting.TargetShapes(this.Shape);

            this.Client.Control.AddControlToShapes(targetshapes, ctrl);
        }
        public void ShapeSheet_Query_NonExistentSections()
        {
            var page1 = this.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);

            var shapes   = new[] { s1, s2, s3, s4 };
            var shapeids = shapes.Select(s => s.ID).ToList();

            // First verify that none of the shapes have the controls section locally or otherwise
            foreach (var s in shapes)
            {
                Assert.AreEqual(0, s.SectionExists[(short)IVisio.VisSectionIndices.visSectionControls, 1]);
                Assert.AreEqual(0, s.SectionExists[(short)IVisio.VisSectionIndices.visSectionControls, 0]);
            }

            // Try to retrieve the control cells rows for each shape, every shape should return zero rows
            foreach (var s in shapes)
            {
                var r1 = VA.Shapes.ControlCells.GetCells(s, CellValueType.Formula);
                Assert.AreEqual(0, r1.Count);
            }

            // Try to retrieve the control cells rows for all shapes at once, every shape should return a collection of zero rows
            var r2 = VA.Shapes.ControlCells.GetCells(page1, shapeids, CellValueType.Formula);

            Assert.AreEqual(shapes.Length, r2.Count);
            for (int i = 0; i < shapes.Length; i++)
            {
                Assert.AreEqual(0, r2[i].Count);
            }

            // Add a Controls row to shape2
            var cc = new VA.Shapes.ControlCells();

            VA.Shapes.ControlHelper.Add(s2, cc);

            // Now verify that none of the shapes *except s2* have the controls section locally or otherwise
            foreach (var s in shapes)
            {
                if (s != s2)
                {
                    Assert.AreEqual(0, s.SectionExists[(short)IVisio.VisSectionIndices.visSectionControls, 1]);
                    Assert.AreEqual(0, s.SectionExists[(short)IVisio.VisSectionIndices.visSectionControls, 0]);
                }
                else
                {
                    Assert.AreEqual(-1, s.SectionExists[(short)IVisio.VisSectionIndices.visSectionControls, 1]);
                    Assert.AreEqual(-1, s.SectionExists[(short)IVisio.VisSectionIndices.visSectionControls, 0]);
                }
            }

            // Try to retrieve the control cells rows for each shape, every shape should return zero rows *except for s2*
            foreach (var s in shapes)
            {
                if (s != s2)
                {
                    var r1 = VA.Shapes.ControlCells.GetCells(s, CellValueType.Formula);
                    Assert.AreEqual(0, r1.Count);
                }
                else
                {
                    var r1 = VA.Shapes.ControlCells.GetCells(s, CellValueType.Formula);
                    Assert.AreEqual(1, r1.Count);
                }
            }

            // Try to retrieve the control cells rows for all shapes at once, every shape *except s2* should return a collection of zero rows
            var r3 = VA.Shapes.ControlCells.GetCells(page1, shapeids, CellValueType.Formula);

            Assert.AreEqual(shapes.Length, r3.Count);
            for (int i = 0; i < shapes.Length; i++)
            {
                if (shapes[i] != s2)
                {
                    Assert.AreEqual(0, r3[i].Count);
                }
                else
                {
                    Assert.AreEqual(1, r3[i].Count);
                }
            }

            page1.Delete(0);
        }