public static List <List <UserDefinedCell> > Get(IVisio.Page page, IList <IVisio.Shape> shapes)
        {
            if (page == null)
            {
                throw new System.ArgumentNullException(nameof(page));
            }

            if (shapes == null)
            {
                throw new System.ArgumentNullException(nameof(shapes));
            }

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

            var list_data = UserDefinedCell.GetCells(page, shapeids);

            var list_list = new List <List <UserDefinedCell> >(shapeids.Count);

            for (int i = 0; i < shapes.Count; i++)
            {
                var shape      = shapes[i];
                var shape_data = list_data[i];
                var prop_names = UserDefinedCellHelper.GetNames(shape);

                var list = new List <UserDefinedCell>(shape_data.Count);
                list_list.Add(list);
                for (int j = 0; j < shape_data.Count; j++)
                {
                    shape_data[j].Name = prop_names[j];
                    list.Add(shape_data[j]);
                }
            }

            return(list_list);
        }
        /// <summary>
        /// Gets all the user properties defined on a shape
        /// </summary>
        /// <remarks>
        /// If there are no user properties then null will be returned</remarks>
        /// <param name="shape"></param>
        /// <returns>A list of user  properties</returns>
        public static List <UserDefinedCell> Get(IVisio.Shape shape)
        {
            if (shape == null)
            {
                throw new System.ArgumentNullException(nameof(shape));
            }

            var prop_count = UserDefinedCellHelper.GetCount(shape);

            if (prop_count < 1)
            {
                return(new List <UserDefinedCell>(0));
            }

            var prop_names = UserDefinedCellHelper.GetNames(shape);

            if (prop_names.Count != prop_count)
            {
                throw new InternalAssertionException("Unexpected number of prop names");
            }

            var shape_data = UserDefinedCell.GetCells(shape);

            var list = new List <UserDefinedCell>(prop_count);

            for (int i = 0; i < prop_count; i++)
            {
                shape_data[i].Name = prop_names[i];
                list.Add(shape_data[i]);
            }

            return(list);
        }
Exemple #3
0
            public UserDefinedCell GetCells(VA.ShapeSheet.CellData <string>[] row)
            {
                var cells = new UserDefinedCell();

                cells.Value  = row[Value.Ordinal];
                cells.Prompt = row[Prompt.Ordinal];
                return(cells);
            }
Exemple #4
0
        public void UserDefinedCells_SetAdditionalProperties()
        {
            var page1 = GetNewPage();
            var s1    = page1.DrawRectangle(0, 0, 2, 2);

            Assert.AreEqual(0, VAUSERCELL.UserDefinedCellsHelper.GetCount(s1));

            var prop = new VAUSERCELL.UserDefinedCell("foo");

            prop.Prompt = "Some Prompt";
            VAUSERCELL.UserDefinedCellsHelper.Set(s1, "foo", null, "Some prompt");
            Assert.AreEqual(1, VAUSERCELL.UserDefinedCellsHelper.GetCount(s1));
            page1.Delete(0);
        }
        public void Set(TargetShapes targets, VA_UDC.UserDefinedCell userdefinedcell)
        {
            this._client.Application.AssertApplicationAvailable();
            this._client.Document.AssertDocumentAvailable();

            targets = targets.ResolveShapes(this._client);

            if (targets.Shapes.Count < 1)
            {
                return;
            }

            using (var undoscope = this._client.Application.NewUndoScope("Set User-Defined Cell"))
            {
                foreach (var shape in targets.Shapes)
                {
                    VA_UDC.UserDefinedCellHelper.Set(shape, userdefinedcell.Name, userdefinedcell.Value.Formula.Value, userdefinedcell.Prompt.Formula.Value);
                }
            }
        }
        public void Set(IList <IVisio.Shape> target_shapes, VA_UDC.UserDefinedCell userdefinedcell)
        {
            this._client.Application.AssertApplicationAvailable();
            this._client.Document.AssertDocumentAvailable();

            var shapes = this.GetTargetShapes(target_shapes);

            if (shapes.Count < 1)
            {
                return;
            }

            var application = this._client.Application.Get();

            using (var undoscope = this._client.Application.NewUndoScope("Set User-Defined Cell"))
            {
                foreach (var shape in shapes)
                {
                    VA_UDC.UserDefinedCellsHelper.Set(shape, userdefinedcell.Name, userdefinedcell.Value.Formula.Value, userdefinedcell.Prompt.Formula.Value);
                }
            }
        }
        public void UserDefinedCells_SetAdditionalProperties()
        {
            var page1 = this.GetNewPage();
            var s1 = page1.DrawRectangle(0, 0, 2, 2);
            Assert.AreEqual(0, VAUSERCELL.UserDefinedCellsHelper.GetCount(s1));

            var prop = new VAUSERCELL.UserDefinedCell("foo");
            prop.Prompt = "Some Prompt";
            VAUSERCELL.UserDefinedCellsHelper.Set(s1, "foo", null, "Some prompt");
            Assert.AreEqual(1, VAUSERCELL.UserDefinedCellsHelper.GetCount(s1));
            page1.Delete(0);
        }
        public void Set(IList<IVisio.Shape> target_shapes, UserDefinedCell userdefinedcell)
        {
            this.AssertApplicationAvailable();
            this.AssertDocumentAvailable();

            var shapes = GetTargetShapes(target_shapes);
            if (shapes.Count < 1)
            {
                return;
            }

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

            var application = this.Client.VisioApplication;
            using (var undoscope = new VA.Application.UndoScope(this.Client.VisioApplication,"Set User-Defined Cell"))
            {
                foreach (var shape in shapes)
                {
                    UserDefinedCellsHelper.Set(shape, userdefinedcell.Name, userdefinedcell.Value.Formula.Value, userdefinedcell.Prompt.Formula.Value);
                }
            }
        }
 public UserDefinedCell GetCells(VA.ShapeSheet.CellData<string>[] row)
 {
     var cells = new UserDefinedCell();
     cells.Value = row[Value.Ordinal];
     cells.Prompt = row[Prompt.Ordinal];
     return cells;
 }