public static List <CustomPropertyDictionary> GetDictionary(IVisio.Page page, ShapeIDPairs shapeidpairs, VASS.CellValueType type)
        {
            var listof_listof_custpropscells = CustomPropertyCells.GetCells(page, shapeidpairs, type);
            var listof_custpropdics          = _get_cells_as_list(shapeidpairs, listof_listof_custpropscells);

            return(listof_custpropdics);
        }
        public static List <CustomPropertyDictionary> GetCellsAsDictionary(IVisio.Page page, IList <IVisio.Shape> shapes, VASS.CellValueType type)
        {
            var shapeidpairs = ShapeIDPairs.FromShapes(shapes);

            var listof_listof_custpropscells = CustomPropertyCells.GetCells(page, shapeidpairs, type);
            var listof_custpropdics          = __GetListOfCpDic(shapeidpairs, listof_listof_custpropscells);

            return(listof_custpropdics);
        }
        // ----------------------------------------
        // ----------------------------------------
        // ----------------------------------------
        // ----------------------------------------

        private static List <CustomPropertyNameCellsPair> __GetPairs(IVisio.Shape shape, VASS.CellValueType type)
        {
            var shape_custprop_cells = CustomPropertyCells.GetCells(shape, type);
            var shape_custprop_names = CustomPropertyHelper.GetNames(shape);
            int shapeid = shape.ID16;
            var list    = __CreateListofPairs(shape_custprop_names, shape_custprop_cells, shapeid);

            return(list);
        }
        public static void Set(IVisio.Shape shape, short row, CustomPropertyCells cp)
        {
            if (shape == null)
            {
                throw new ArgumentNullException(nameof(shape));
            }

            var writer = new VisioAutomation.ShapeSheet.Writers.SrcWriter();

            writer.SetValues(cp, row);

            writer.CommitFormulas(shape);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Gets all the custom properties defined on a shape
        /// </summary>
        /// <remarks>
        /// If there are no custom properties then null will be returned</remarks>
        /// <param name="shape"></param>
        /// <returns>A list of custom properties</returns>
        public static CustomPropertyDictionary Get(IVisio.Shape shape)
        {
            var prop_names = CustomPropertyHelper.GetNames(shape);
            var dic        = new CustomPropertyDictionary(prop_names.Count);
            var cells      = CustomPropertyCells.GetCells(shape);

            for (int prop_index = 0; prop_index < prop_names.Count(); prop_index++)
            {
                string prop_name = prop_names[prop_index];
                dic[prop_name] = cells[prop_index];
            }

            return(dic);
        }
Exemplo n.º 6
0
        public static List <CustomPropertyDictionary> Get(IVisio.Page page, IList <IVisio.Shape> shapes)
        {
            if (page == null)
            {
                throw new ArgumentNullException(nameof(page));
            }

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

            var shapeids              = shapes.Select(s => s.ID).ToList();
            var customprops_dic       = new List <CustomPropertyDictionary>(shapeids.Count);
            var customprops_per_shape = CustomPropertyCells.GetCells(page, shapeids);

            if (customprops_per_shape.Count != shapeids.Count)
            {
                throw new InternalAssertionException();
            }

            for (int shape_index = 0; shape_index < shapeids.Count; shape_index++)
            {
                var shape = shapes[shape_index];
                var customprops_for_shape = customprops_per_shape[shape_index];
                var prop_names            = CustomPropertyHelper.GetNames(shape);

                if (customprops_for_shape.Count != prop_names.Count)
                {
                    throw new InternalAssertionException();
                }

                var dic = new CustomPropertyDictionary(prop_names.Count);

                for (int prop_index = 0; prop_index < prop_names.Count(); prop_index++)
                {
                    string prop_name = prop_names[prop_index];
                    dic[prop_name] = customprops_for_shape[prop_index];
                }

                customprops_dic.Add(dic);
            }

            return(customprops_dic);
        }
        public static List <CustomPropertyDictionary> GetCells(IVisio.Page page, IList <IVisio.Shape> shapes, CellValueType type)
        {
            if (page == null)
            {
                throw new ArgumentNullException(nameof(page));
            }

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

            var shapeids = shapes.Select(s => s.ID).ToList();
            var customprops_per_shape = CustomPropertyCells.GetCells(page, shapeids, type);
            var customprops_dic       = create_dic(shapes, shapeids, customprops_per_shape);

            return(customprops_dic);
        }
        public static void Set(IVisio.Shape shape, string name, string value, int type)
        {
            if (shape == null)
            {
                throw new ArgumentNullException(nameof(shape));
            }

            CustomPropertyHelper.__CheckValidCustomPropertyName(name);

            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            // create a new property
            var cp = new CustomPropertyCells();

            cp.Value = value;
            cp.Type  = type;

            CustomPropertyHelper.Set(shape, name, cp);
        }
        public static void Set(
            IVisio.Shape shape,
            string name,
            CustomPropertyCells cp)
        {
            if (shape == null)
            {
                throw new ArgumentNullException(nameof(shape));
            }

            CustomPropertyHelper.__CheckValidCustomPropertyName(name);

            if (CustomPropertyHelper.Contains(shape, name))
            {
                string full_prop_name = CustomPropertyHelper.__GetRowName(name);
                var    cell_propname  = shape.CellsU[full_prop_name];

                if (cell_propname == null)
                {
                    string msg = string.Format("Could not retrieve cell for custom property \"{0}\"", full_prop_name);
                    throw new Exceptions.InternalAssertionException(msg);
                }

                var writer = new VisioAutomation.ShapeSheet.Writers.SrcWriter();
                writer.SetValues(cp, cell_propname.Row);

                writer.CommitFormulas(shape);

                return;
            }

            short row = shape.AddNamedRow(
                vis_sec_prop,
                name,
                (short)IVisio.VisRowIndices.visRowProp);

            CustomPropertyHelper.Set(shape, row, cp);
        }