private static List <UserDefinedCellNameCellsPair> __GetPairs(IVisio.Shape shape, VASS.CellValueType type)
        {
            var listof_udcellcells = UserDefinedCellCells.GetCells(shape, type);


            int num_udcells = listof_udcellcells.Count;

            var udcell_names = UserDefinedCellHelper.GetNames(shape);

            if (udcell_names.Count != num_udcells)
            {
                throw new VisioAutomation.Exceptions.InternalAssertionException("Unexpected number of user-define cell names");
            }

            int shapeid     = shape.ID16;
            var pairs       = new List <UserDefinedCellNameCellsPair>(num_udcells);
            var udcell_rows = Enumerable.Range(0, num_udcells);

            foreach (int udcell_row in udcell_rows)
            {
                var pair = new UserDefinedCellNameCellsPair(shapeid, udcell_row, udcell_names[udcell_row], listof_udcellcells[udcell_row]);
                pairs.Add(pair);
            }

            return(pairs);
        }
        /// <summary>
        /// Returns all the Names of the user-defined cells
        /// </summary>
        /// <remarks>
        /// names of user defined cells are not queryable get GetResults & GetFormulas
        /// </remarks>
        /// <param name="shape"></param>
        /// <returns></returns>
        public static List <string> GetNames(IVisio.Shape shape)
        {
            if (shape == null)
            {
                throw new System.ArgumentNullException(nameof(shape));
            }

            int udcell_count = UserDefinedCellHelper.GetCount(shape);

            if (udcell_count < 1)
            {
                return(new List <string>(0));
            }

            var udcell_names   = new List <string>(udcell_count);
            var udcell_section = shape.Section[UserDefinedCellHelper._udcell_section];
            var query_names    = udcell_section.ToEnumerable().Select(row => row.NameU);

            udcell_names.AddRange(query_names);

            if (udcell_count != udcell_names.Count)
            {
                throw new VisioAutomation.Exceptions.InternalAssertionException("Unexpected number of user-defined-cell names");
            }

            return(udcell_names);
        }
Пример #3
0
        public static List <Dictionary <string, UserDefinedCellCells> > GetDictionary(IVisio.Page page, IList <IVisio.Shape> shapes, ShapeSheet.CellValueType type)
        {
            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_list_customprops = UserDefinedCellCells.GetCells(page, shapeids, CellValueType.Formula);

            var list_dic_customprops = new List <Dictionary <string, UserDefinedCellCells> >(shapeids.Count);

            for (int shape_index = 0; shape_index < shapes.Count; shape_index++)
            {
                var shape            = shapes[shape_index];
                var list_customprops = list_list_customprops[shape_index];
                var prop_names       = UserDefinedCellHelper.GetNames(shape);

                var dic_customprops = new Dictionary <string, UserDefinedCellCells>(list_customprops.Count);
                list_dic_customprops.Add(dic_customprops);
                for (int i = 0; i < list_customprops.Count; i++)
                {
                    var prop_name = prop_names[i];
                    dic_customprops[prop_name] = list_customprops[i];
                }
            }

            return(list_dic_customprops);
        }
Пример #4
0
        public static Dictionary <string, UserDefinedCellCells> GetDictionary(IVisio.Shape shape, ShapeSheet.CellValueType type)
        {
            if (shape == null)
            {
                throw new System.ArgumentNullException(nameof(shape));
            }

            var prop_count = UserDefinedCellHelper.GetCount(shape);

            if (prop_count < 1)
            {
                return(new Dictionary <string, UserDefinedCellCells>(0));
            }

            var prop_names = UserDefinedCellHelper.GetNames(shape);

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

            var shape_data = UserDefinedCellCells.GetCells(shape, type);

            var dic = new Dictionary <string, UserDefinedCellCells>(prop_count);

            for (int i = 0; i < prop_count; i++)
            {
                dic[prop_names[i]] = shape_data[i];
            }
            return(dic);
        }
Пример #5
0
        public static List <List <UserDefinedCellCells> > 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 = UserDefinedCellCells.GetCells(page, shapeids);

            var list_list = new List <List <UserDefinedCellCells> >(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 <UserDefinedCellCells>(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);
        }
Пример #6
0
        /// <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 <UserDefinedCellCells> 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 <UserDefinedCellCells>(0));
            }

            var prop_names = UserDefinedCellHelper.GetNames(shape);

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

            var shape_data = UserDefinedCellCells.GetCells(shape);

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

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

            return(list);
        }
 public static void CheckValidName(string name)
 {
     if (!UserDefinedCellHelper.IsValidName(name))
     {
         string msg = string.Format("Invalid Name for User-Defined Cell: \"{0}\"", name);
         throw new System.ArgumentException(msg);
     }
 }
Пример #8
0
        public UserDefinedCellCells(string name, string value)
        {
            UserDefinedCellHelper.CheckValidName(name);

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

            this.Name  = name;
            this.Value = value;
        }
Пример #9
0
        public static void Set(IVisio.Shape shape, string name, ShapeSheet.CellValueLiteral udfcell_value, ShapeSheet.CellValueLiteral udfcell_prompt)
        {
            if (shape == null)
            {
                throw new System.ArgumentNullException(nameof(shape));
            }

            UserDefinedCellHelper.CheckValidName(name);

            if (UserDefinedCellHelper.Contains(shape, name))
            {
                string full_prop_name = UserDefinedCellHelper.GetRowName(name);

                if (udfcell_value.HasValue)
                {
                    string value_cell_name = full_prop_name;
                    var    cell            = shape.CellsU[value_cell_name];
                    cell.FormulaU = VisioAutomation.Utilities.Convert.StringToFormulaString(udfcell_value.Value);
                }

                if (udfcell_prompt.HasValue)
                {
                    string prompt_cell_name = full_prop_name + ".Prompt";
                    var    cell             = shape.CellsU[prompt_cell_name];
                    cell.FormulaU = VisioAutomation.Utilities.Convert.StringToFormulaString(udfcell_prompt.Value);
                }
                return;
            }

            short row = shape.AddNamedRow(
                UserDefinedCellHelper._userdefinedcell_section,
                name,
                (short)IVisio.VisRowIndices.visRowUser);

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

            if (udfcell_value.HasValue)
            {
                var src     = new ShapeSheet.Src(UserDefinedCellHelper._userdefinedcell_section, row, (short)IVisio.VisCellIndices.visUserValue);
                var formula = VisioAutomation.Utilities.Convert.StringToFormulaString(udfcell_value.Value);
                writer.SetFormula(src, formula);
            }

            if (udfcell_prompt.HasValue)
            {
                var src     = new ShapeSheet.Src(UserDefinedCellHelper._userdefinedcell_section, row, (short)IVisio.VisCellIndices.visUserPrompt);
                var formula = VisioAutomation.Utilities.Convert.StringToFormulaString(udfcell_prompt.Value);
                writer.SetFormula(src, formula);
            }

            writer.Commit(shape);
        }
        private static List <List <UserDefinedCellNameCellsPair> > __GetPairs(IVisio.Page page, ShapeIDPairs shapeidpairs, VASS.CellValueType type)
        {
            var list_list_udcells = UserDefinedCellCells.GetCells(page, shapeidpairs, type);
            int num_shapes        = shapeidpairs.Count;
            var list_list_pairs   = new List <List <UserDefinedCellNameCellsPair> >(num_shapes);
            var shape_indices     = Enumerable.Range(0, num_shapes);

            foreach (int shape_index in shape_indices)
            {
                var shapeidpair  = shapeidpairs[shape_index];
                var udcell_names = UserDefinedCellHelper.GetNames(shapeidpair.Shape);
                var list_udcells = list_list_udcells[shape_index];
                var list_pairs   = __CreateNamePairs(shapeidpair.ShapeID, udcell_names, list_udcells);


                list_list_pairs.Add(list_pairs);
            }

            return(list_list_pairs);
        }
        public static bool Contains(IVisio.Shape shape, string name)
        {
            if (shape == null)
            {
                throw new System.ArgumentNullException(nameof(shape));
            }

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

            UserDefinedCellHelper.CheckValidName(name);

            string full_udcell_name = UserDefinedCellHelper.__GetRowName(name);

            var exists = (short)IVisio.VisExistsFlags.visExistsAnywhere;

            return(0 != (shape.CellExistsU[full_udcell_name, exists]));
        }
        public static void Delete(IVisio.Shape shape, string name)
        {
            if (shape == null)
            {
                throw new System.ArgumentNullException(nameof(shape));
            }

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

            UserDefinedCellHelper.CheckValidName(name);

            string full_udcell_name = UserDefinedCellHelper.__GetRowName(name);

            short row = shape.CellsU[full_udcell_name].Row;

            shape.DeleteRow(_udcell_section, row);
        }
Пример #13
0
 public UserDefinedCellCells(string name)
 {
     UserDefinedCellHelper.CheckValidName(name);
     this.Name = name;
 }
Пример #14
0
 public static void Set(IVisio.Shape shape, string name, ShapeSheet.CellData value, ShapeSheet.CellData prompt)
 {
     UserDefinedCellHelper.Set(shape, name, value.Formula.Value, prompt.Formula.Value);
 }