public void CheckHomogenousUpdates_ResultTypes()
        {
            var page1  = this.GetNewPage();
            var shape1 = page1.DrawRectangle(0, 0, 1, 1);

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

            update.SetResult(ShapeSheet_Update_Tests.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.AddCell(ShapeSheet_Update_Tests.src_linepat, "LinePattern");
            var col_pinx    = query.AddCell(VA.ShapeSheet.SRCConstants.PinX, "PinX");

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

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

            page1.Delete(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);
        }
        public void CheckHomogenousUpdates_Streams()
        {
            var update1 = new VA.ShapeSheet.Update();
            update1.SetResult(src_pinx, 5.0, IVisio.VisUnitCodes.visNumber);
            bool caught1 = false;
            try
            {
                update1.SetResult(1, src_pinx, 5.0, IVisio.VisUnitCodes.visNumber);

            }
            catch (VA.AutomationException)
            {
                caught1 = true;
            }

            if (!caught1)
            {
                Assert.Fail();
            }
        }
        public void CheckHomogenousUpdates_Streams()
        {
            var update1 = new VA.ShapeSheet.Update();

            update1.SetResult(ShapeSheet_Update_Tests.src_pinx, 5.0, IVisio.VisUnitCodes.visNumber);
            bool caught1 = false;

            try
            {
                update1.SetResult(1, ShapeSheet_Update_Tests.src_pinx, 5.0, IVisio.VisUnitCodes.visNumber);
            }
            catch (VA.AutomationException)
            {
                caught1 = true;
            }

            if (!caught1)
            {
                Assert.Fail();
            }
        }
        public void CheckHomogenousUpdates_FormulasResults()
        {
            var update1 = new VA.ShapeSheet.Update();
            update1.SetResult(ShapeSheet_Update_Tests.src_pinx, 5.0, IVisio.VisUnitCodes.visNumber);
            bool caught1 = false;
            try
            {
                update1.SetFormula(ShapeSheet_Update_Tests.src_pinx, "5.0");

            }
            catch (VA.AutomationException)
            {
                caught1 = true;
            }

            if (!caught1)
            {
                Assert.Fail();
            }
        }
Exemple #6
0
        public void CheckHomogenousUpdates_FormulasResults()
        {
            var update1 = new VA.ShapeSheet.Update();

            update1.SetResult(src_pinx, 5.0, IVisio.VisUnitCodes.visNumber);
            bool caught1 = false;

            try
            {
                update1.SetFormula(src_pinx, "5.0");
            }
            catch (VA.AutomationException)
            {
                caught1 = true;
            }

            if (!caught1)
            {
                Assert.Fail();
            }
        }
        public void ShapeSheet_Update_ResultsString_SingleShape()
        {
            var page1 = this.GetNewPage();
            var shape1 = page1.DrawRectangle(0, 0, 1, 1);

            // Setup the modifications to the cell values
            var update = new VA.ShapeSheet.Update();
            update.SetResult(ShapeSheet_Update_Tests.src_linepat, "7", IVisio.VisUnitCodes.visNumber);
            update.Execute(shape1);

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

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

            // Verify
            AssertVA.AreEqual("7", 7, data[col_linepat]);
            page1.Delete(0);
        }
Exemple #8
0
        public void ShapeSheet_Update_ResultsString_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);
        }
        public void ShapeSheet_Update_ResultsDouble_MultipleShapes()
        {
            var page1 = this.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.SetResult(shape1.ID16, ShapeSheet_Update_Tests.src_pinx, 0.5, IVisio.VisUnitCodes.visNumber);
            update.SetResult(shape1.ID16, ShapeSheet_Update_Tests.src_piny, 0.5, IVisio.VisUnitCodes.visNumber);
            update.SetResult(shape2.ID16, ShapeSheet_Update_Tests.src_pinx, 1.5, IVisio.VisUnitCodes.visNumber);
            update.SetResult(shape2.ID16, ShapeSheet_Update_Tests.src_piny, 1.5, IVisio.VisUnitCodes.visNumber);
            update.SetResult(shape3.ID16, ShapeSheet_Update_Tests.src_pinx, 2.5, IVisio.VisUnitCodes.visNumber);
            update.SetResult(shape3.ID16, ShapeSheet_Update_Tests.src_piny, 2.5, IVisio.VisUnitCodes.visNumber);
            update.Execute(page1);

            // Verify that the formulas were set
            var query    = new VA.ShapeSheet.Query.CellQuery();
            var col_pinx = query.AddCell(ShapeSheet_Update_Tests.src_pinx, "PinX");
            var col_piny = query.AddCell(ShapeSheet_Update_Tests.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], rr[0][col_pinx]);
            AssertVA.AreEqual("0.5 in", 0.5, rf[0][col_piny], rr[0][col_piny]);
            AssertVA.AreEqual("1.5 in", 1.5, rf[1][col_pinx], rr[1][col_pinx]);
            AssertVA.AreEqual("1.5 in", 1.5, rf[1][col_piny], rr[1][col_piny]);
            AssertVA.AreEqual("2.5 in", 2.5, rf[2][col_pinx], rr[2][col_pinx]);
            AssertVA.AreEqual("2.5 in", 2.5, rf[2][col_piny], rr[2][col_piny]);

            page1.Delete(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);
        }
        public void ShapeSheet_Update_ResultsDouble_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.SetResult(shape1.ID16, src_pinx, 0.5, IVisio.VisUnitCodes.visNumber);
            update.SetResult(shape1.ID16, src_piny, 0.5, IVisio.VisUnitCodes.visNumber);
            update.SetResult(shape2.ID16, src_pinx, 1.5, IVisio.VisUnitCodes.visNumber);
            update.SetResult(shape2.ID16, src_piny, 1.5, IVisio.VisUnitCodes.visNumber);
            update.SetResult(shape3.ID16, src_pinx, 2.5, IVisio.VisUnitCodes.visNumber);
            update.SetResult(shape3.ID16, src_piny, 2.5, IVisio.VisUnitCodes.visNumber);
            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);
        }
Exemple #12
0
        public void SetResult(
            IList <IVisio.Shape> target_shapes,
            IList <VA.ShapeSheet.SRC> srcs,
            IList <string> results, IVisio.VisGetSetArgs flags)
        {
            this.AssertApplicationAvailable();
            this.AssertDocumentAvailable();

            var shapes = this.GetTargetShapes(target_shapes);

            if (shapes.Count < 1)
            {
                this.Client.WriteVerbose("SetResult: Zero Shapes. Not performing Operation");
                return;
            }

            if (srcs == null)
            {
                throw new System.ArgumentNullException("srcs");
            }

            if (results == null)
            {
                throw new System.ArgumentNullException("results");
            }

            if (results.Any(f => f == null))
            {
                this.Client.WriteVerbose("SetResult: One of the Input Results is a NULL value");
                throw new System.ArgumentException("results contains a null value");
            }

            this.Client.WriteVerbose("SetResult: src count= {0} and result count = {1}", srcs.Count, results.Count);

            if (results.Count != srcs.Count)
            {
                string msg = string.Format("Must have the same number of srcs ({0}) and results ({1})", srcs.Count, results.Count);
                throw new System.ArgumentException(msg);
            }

            var shapeids = shapes.Select(s => s.ID).ToList();

            int num_results = results.Count;
            var update      = new VA.ShapeSheet.Update(shapes.Count * num_results);

            update.BlastGuards  = ((short)flags & (short)IVisio.VisGetSetArgs.visSetBlastGuards) != 0;
            update.TestCircular = ((short)flags & (short)IVisio.VisGetSetArgs.visSetTestCircular) != 0;

            foreach (var shapeid in shapeids)
            {
                for (int i = 0; i < num_results; i++)
                {
                    var src    = srcs[i];
                    var result = results[i];
                    update.SetResult((short)shapeid, src, result, IVisio.VisUnitCodes.visNumber);
                }
            }

            var surface = this.Client.Draw.GetDrawingSurfaceSafe();

            using (var undoscope = new VA.Application.UndoScope(this.Client.VisioApplication, "Set ShapeSheet Result"))
            {
                update.Execute(surface);
            }
        }