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); }
/// <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); }
/// <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); }