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); }
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); }
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); }
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); }
/// <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 Set(IVisio.Shape shape, string name, string value, string prompt) { var cells = new UserDefinedCellCells(); cells.Value = value; cells.Prompt = prompt; cells.EncodeValues(); Set(shape, name, cells); }
public static void Set(IVisio.Shape shape, string name, UserDefinedCellCells cells) { if (shape == null) { throw new System.ArgumentNullException(nameof(shape)); } if (cells == null) { throw new System.ArgumentNullException(nameof(cells)); } UserDefinedCellHelper.CheckValidName(name); if (UserDefinedCellHelper.Contains(shape, name)) { // The user-defined cell already exists string full_udcell_name = UserDefinedCellHelper.__GetRowName(name); if (cells.Value.HasValue) { string value_cell_name = full_udcell_name; var cell = shape.CellsU[value_cell_name]; cell.FormulaU = cells.Value.Value; } if (cells.Prompt.HasValue) { string prompt_cell_name = full_udcell_name + ".Prompt"; var cell = shape.CellsU[prompt_cell_name]; cell.FormulaU = cells.Prompt.Value; } } else { // The user-defined cell doesn't already exist short row = shape.AddNamedRow(_udcell_section, name, (short)IVisio.VisRowIndices.visRowUser); var src_value = new ShapeSheet.Src(_udcell_section, row, (short)IVisio.VisCellIndices.visUserValue); var src_prompt = new ShapeSheet.Src(_udcell_section, row, (short)IVisio.VisCellIndices.visUserPrompt); var writer = new VisioAutomation.ShapeSheet.Writers.SrcWriter(); if (cells.Value.HasValue) { writer.SetValue(src_value, cells.Value.Value); } if (cells.Prompt.HasValue) { writer.SetValue(src_prompt, cells.Prompt.Value); } writer.CommitFormulas(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); }