public void SimpleCP() { var page1 = this.GetNewPage(); // Draw a shape var s1 = page1.DrawRectangle(1, 1, 4, 3); int cp_type = 0; // string type // Set some properties on it CustomPropertyHelper.Set(s1, "FOO1", "\"BAR1\"", cp_type); CustomPropertyHelper.Set(s1, "FOO2", "\"BAR2\"", cp_type); CustomPropertyHelper.Set(s1, "FOO3", "\"BAR3\"", cp_type); // Delete one of those properties CustomPropertyHelper.Delete(s1, "FOO2"); // Set the value of an existing properties CustomPropertyHelper.Set(s1, "FOO3", "\"BAR3updated\"", cp_type); // retrieve all the properties var props = CustomPropertyHelper.GetDictionary(s1, CellValueType.Formula); var cp_foo1 = props["FOO1"]; // var cp_foo2 = props["FOO2"]; there is no prop called FOO2 var cp_foo3 = props["FOO3"]; var app = this.GetVisioApplication(); var doc = app.ActiveDocument; if (doc != null) { doc.Close(true); } }
public void UserDefinedCells_SetMultipleTimes() { var page1 = this.GetNewPage(); var s1 = page1.DrawRectangle(0, 0, 2, 2); // By default a shape has ZERO custom Properties Assert.AreEqual(0, CustomPropertyHelper.Get(s1).Count); // Add the same one multiple times Custom Property UserDefinedCellHelper.Set(s1, "FOO1", "BAR1", null); // Asset that now we have ONE CustomProperty Assert.AreEqual(1, UserDefinedCellHelper.GetCount(s1)); // Check that it is called FOO1 Assert.AreEqual(true, UserDefinedCellHelper.Contains(s1, "FOO1")); // Try to SET the same property again many times UserDefinedCellHelper.Set(s1, "FOO1", "BAR2", null); UserDefinedCellHelper.Set(s1, "FOO1", "BAR3", null); UserDefinedCellHelper.Set(s1, "FOO1", "BAR4", null); // Asset that now we have ONE CustomProperty Assert.AreEqual(1, UserDefinedCellHelper.GetCount(s1)); // Check that it is called FOO1 Assert.AreEqual(true, UserDefinedCellHelper.Contains(s1, "FOO1")); page1.Delete(0); }
public void CustomProps_InvalidPropName() { bool caught = false; var page1 = this.GetNewPage(); var s1 = page1.DrawRectangle(0, 0, 2, 2); Assert.AreEqual(0, CustomPropertyHelper.GetDictionary(s1, CellValueType.Formula).Count); int cp_type = 0; // 0 for string try { CustomPropertyHelper.Set(s1, "FOO 1", "BAR1", cp_type); } catch (System.ArgumentException) { page1.Delete(0); caught = true; } if (!caught) { Assert.Fail("Did not catch expected exception"); } }
public void RenderDirectedGraphWithCustomProps() { var d = new VA.Models.DirectedGraph.Drawing(); var n0 = d.AddShape("n0", "Untitled Node", "basflo_u.vss", "Decision"); n0.Size = new VA.Drawing.Size(3, 2); n0.CustomProperties = new Dictionary <string, CustomPropertyCells>(); n0.CustomProperties["p1"] = new CustomPropertyCells("v1"); n0.CustomProperties["p2"] = new CustomPropertyCells("v2"); n0.CustomProperties["p3"] = new CustomPropertyCells("v3"); var options = new VA.Models.DirectedGraph.MSAGLLayoutOptions(); options.UseDynamicConnectors = true; var visapp = this.GetVisioApplication(); var doc = this.GetNewDoc(); var page1 = visapp.ActivePage; d.Render(page1, options); Assert.IsNotNull(n0.VisioShape); var props_dic = CustomPropertyHelper.Get(n0.VisioShape); Assert.IsTrue(props_dic.Count >= 3); Assert.AreEqual("\"v1\"", props_dic["p1"].Value.Formula); Assert.AreEqual("\"v2\"", props_dic["p2"].Value.Formula); Assert.AreEqual("\"v3\"", props_dic["p3"].Value.Formula); page1.Application.ActiveWindow.ViewFit = (short)IVisio.VisWindowFit.visFitPage; doc.Close(true); }
public void DeleteCustomPropertyWithName(TargetShapes targetshapes, string name) { if (name == null) { throw new System.ArgumentNullException(nameof(name)); } if (name.Length < 1) { throw new System.ArgumentException("name cannot be empty", nameof(name)); } targetshapes = targetshapes.ResolveToShapes(this._client); if (targetshapes.Shapes.Count < 1) { return; } using (var undoscope = this._client.Undo.NewUndoScope(nameof(DeleteCustomPropertyWithName))) { foreach (var shape in targetshapes.Shapes) { CustomPropertyHelper.Delete(shape, name); } } }
public static void SetCustomProperties() { var page = SampleEnvironment.Application.ActiveDocument.Pages.Add(); // Draw a shape var s1 = page.DrawRectangle(1, 1, 4, 3); int cp_type = 0; // string type // Set some properties on it CustomPropertyHelper.Set(s1, "FOO1", "BAR1", cp_type); CustomPropertyHelper.Set(s1, "FOO2", "BAR2", cp_type); CustomPropertyHelper.Set(s1, "FOO3", "BAR3", cp_type); // Delete one of those properties CustomPropertyHelper.Delete(s1, "FOO2"); // Set the value of an existing properties CustomPropertyHelper.Set(s1, "FOO3", "BAR3updated", cp_type); // retrieve all the properties var props = CustomPropertyHelper.GetCells(s1, CellValueType.Formula); var cp_foo1 = props["FOO1"]; var cp_foo2 = props["FOO2"]; var cp_foo3 = props["FOO3"]; }
private List <ExcelColumnInfo> GetDictionaryColumnInfo(IDictionary <string, object> dicString, IDictionary dic) { List <ExcelColumnInfo> props; var _props = new List <ExcelColumnInfo>(); if (dicString != null) { foreach (var key in dicString.Keys) { SetDictionaryColumnInfo(_props, key); } } else if (dic != null) { foreach (var key in dic.Keys) { SetDictionaryColumnInfo(_props, key); } } else { throw new NotSupportedException("SetDictionaryColumnInfo Error"); } props = CustomPropertyHelper.SortCustomProps(_props); return(props); }
public IDictionary <IVisio.Shape, CustomPropertyDictionary> Get(TargetShapes targets) { this._client.Application.AssertApplicationAvailable(); this._client.Document.AssertDocumentAvailable(); var prop_dic = new Dictionary <IVisio.Shape, CustomPropertyDictionary>(); targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return(prop_dic); } var application = this._client.Application.Get(); var page = application.ActivePage; var list_custom_props = CustomPropertyHelper.Get(page, targets.Shapes); for (int i = 0; i < targets.Shapes.Count; i++) { var shape = targets.Shapes[i]; var props = list_custom_props[i]; prop_dic[shape] = props; } return(prop_dic); }
public void CustomProps_GetFromMultipleShapes() { var page1 = this.GetNewPage(); var s1 = page1.DrawRectangle(0, 0, 2, 2); var s2 = page1.DrawRectangle(0, 0, 2, 2); var s3 = page1.DrawRectangle(0, 0, 2, 2); var s4 = page1.DrawRectangle(0, 0, 2, 2); int cp_type = 0; // 0 for string CustomPropertyHelper.Set(s1, "FOO1", "1", cp_type); CustomPropertyHelper.Set(s2, "FOO2", "2", cp_type); CustomPropertyHelper.Set(s2, "FOO3", "3", cp_type); CustomPropertyHelper.Set(s4, "FOO4", "4", cp_type); CustomPropertyHelper.Set(s4, "FOO5", "5", cp_type); CustomPropertyHelper.Set(s4, "FOO6", "6", cp_type); var shapes = new[] { s1, s2, s3, s4 }; var allprops = CustomPropertyHelper.GetCells(page1, shapes, CellValueType.Formula); Assert.AreEqual(4, allprops.Count); Assert.AreEqual(1, allprops[0].Count); Assert.AreEqual(2, allprops[1].Count); Assert.AreEqual(0, allprops[2].Count); Assert.AreEqual(3, allprops[3].Count); Assert.AreEqual("1", allprops[0]["FOO1"].Value.Value); Assert.AreEqual("2", allprops[1]["FOO2"].Value.Value); Assert.AreEqual("3", allprops[1]["FOO3"].Value.Value); Assert.AreEqual("4", allprops[3]["FOO4"].Value.Value); Assert.AreEqual("5", allprops[3]["FOO5"].Value.Value); Assert.AreEqual("6", allprops[3]["FOO6"].Value.Value); page1.Delete(0); }
public void Delete(TargetShapes targets, string name) { this._client.Application.AssertApplicationAvailable(); this._client.Document.AssertDocumentAvailable(); if (name == null) { throw new System.ArgumentNullException(nameof(name)); } if (name.Length < 1) { throw new System.ArgumentException("name cannot be empty", nameof(name)); } targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return; } using (var undoscope = this._client.Application.NewUndoScope("Delete Custom Property")) { foreach (var shape in targets.Shapes) { CustomPropertyHelper.Delete(shape, name); } } }
public IDictionary <IVisio.Shape, CustomPropertyDictionary> GetCustomProperties(Models.TargetShapes targets) { var cmdtarget = this._client.GetCommandTargetPage(); var dicof_shape_to_cpdic = new Dictionary <IVisio.Shape, CustomPropertyDictionary>(); targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return(dicof_shape_to_cpdic); } var listof_cpdic = CustomPropertyHelper.GetCellsAsDictionary(cmdtarget.ActivePage, targets.Shapes, CellValueType.Formula); for (int i = 0; i < targets.Shapes.Count; i++) { var shape = targets.Shapes[i]; var cpdic = listof_cpdic[i]; dicof_shape_to_cpdic[shape] = cpdic; } return(dicof_shape_to_cpdic); }
public static void Set_Custom_Property_on_multiple_Shapes(IVisio.Document doc) { // Set Custom Property_on_a_shape var page = doc.Pages.Add(); var s1 = page.DrawRectangle(0, 0, 1, 1); var s2 = page.DrawRectangle(2, 2, 4, 4); var cp1 = new CustomPropertyCells(); cp1.Value = "Hello"; CustomPropertyHelper.Set(s1, "Propname", cp1); var cp2 = new CustomPropertyCells(); cp2.Value = "World"; CustomPropertyHelper.Set(s2, "Propname", cp2); // Retrieve all the Custom properties from multiple shapes var shapes = new[] { s1, s2 }; var props = CustomPropertyHelper.Get(page, shapes); // Delete the properties from the shapes CustomPropertyHelper.Delete(s1, "Propname"); CustomPropertyHelper.Delete(s2, "Propname"); //cleanup page.Delete(0); }
public void Set(TargetShapes targets, string name, CustomPropertyCells customprop) { this._client.Application.AssertApplicationAvailable(); this._client.Document.AssertDocumentAvailable(); if (customprop == null) { throw new System.ArgumentNullException(nameof(customprop)); } targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return; } using (var undoscope = this._client.Application.NewUndoScope("Set Custom Property")) { foreach (var shape in targets.Shapes) { CustomPropertyHelper.Set(shape, name, customprop); } } }
public void CustomProps_GetFromMultipleShapes() { var page1 = this.GetNewPage(); var s1 = page1.DrawRectangle(0, 0, 2, 2); var s2 = page1.DrawRectangle(0, 0, 2, 2); var s3 = page1.DrawRectangle(0, 0, 2, 2); var s4 = page1.DrawRectangle(0, 0, 2, 2); CustomPropertyHelper.Set(s1, "FOO1", "1"); CustomPropertyHelper.Set(s2, "FOO2", "2"); CustomPropertyHelper.Set(s2, "FOO3", "3"); CustomPropertyHelper.Set(s4, "FOO4", "4"); CustomPropertyHelper.Set(s4, "FOO5", "5"); CustomPropertyHelper.Set(s4, "FOO6", "6"); var shapes = new[] { s1, s2, s3, s4 }; var allprops = CustomPropertyHelper.Get(page1, shapes); Assert.AreEqual(4, allprops.Count); Assert.AreEqual(1, allprops[0].Count); Assert.AreEqual(2, allprops[1].Count); Assert.AreEqual(0, allprops[2].Count); Assert.AreEqual(3, allprops[3].Count); Assert.AreEqual("\"1\"", allprops[0]["FOO1"].Value.Formula); Assert.AreEqual("\"2\"", allprops[1]["FOO2"].Value.Formula); Assert.AreEqual("\"3\"", allprops[1]["FOO3"].Value.Formula); Assert.AreEqual("\"4\"", allprops[3]["FOO4"].Value.Formula); Assert.AreEqual("\"5\"", allprops[3]["FOO5"].Value.Formula); Assert.AreEqual("\"6\"", allprops[3]["FOO6"].Value.Formula); page1.Delete(0); }
public void CustomProps_SetSamePropMultipleTimes() { var page1 = this.GetNewPage(); var s1 = page1.DrawRectangle(0, 0, 2, 2); // By default a shape has ZERO custom Properties Assert.AreEqual(0, CustomPropertyHelper.GetCount(s1)); int cp_type = 0; // string type // Add the same one multiple times Custom Property CustomPropertyHelper.Set(s1, "FOO1", "\"BAR1\"", cp_type); // Asset that now we have ONE CustomProperty Assert.AreEqual(1, CustomPropertyHelper.GetCount(s1)); // Check that it is called FOO1 Assert.AreEqual(true, CustomPropertyHelper.Contains(s1, "FOO1")); // Try to SET the same property again many times CustomPropertyHelper.Set(s1, "FOO1", "\"BAR2\"", cp_type); CustomPropertyHelper.Set(s1, "FOO1", "\"BAR3\"", cp_type); CustomPropertyHelper.Set(s1, "FOO1", "\"BAR4\"", cp_type); // Asset that now we have ONE CustomProperty Assert.AreEqual(1, CustomPropertyHelper.GetCount(s1)); // Check that it is called FOO1 Assert.AreEqual(true, CustomPropertyHelper.Contains(s1, "FOO1")); page1.Delete(0); }
public void CustomProps_SetCustomProps1() { var page1 = this.GetNewPage(); var s1 = page1.DrawRectangle(0, 0, 2, 2); // By default a shape has ZERO custom Properties Assert.AreEqual(0, CustomPropertyHelper.GetCount(s1)); // Add a Custom Property var cp = new CustomPropertyCells(); cp.Value = "\"BAR1\""; CustomPropertyHelper.Set(s1, "FOO1", cp); // Asset that now we have ONE CustomProperty Assert.AreEqual(1, CustomPropertyHelper.GetCount(s1)); // Check that it is called FOO1 Assert.AreEqual(true, CustomPropertyHelper.Contains(s1, "FOO1")); // Check that non-existent properties can't be found Assert.AreEqual(false, CustomPropertyHelper.Contains(s1, "FOOX")); // Delete that custom property CustomPropertyHelper.Delete(s1, "FOO1"); // Verify that we have zero Custom Properties Assert.AreEqual(0, CustomPropertyHelper.GetCount(s1)); page1.Delete(0); }
public void CustomProps_GetSet() { var page1 = this.GetNewPage(); var s1 = page1.DrawRectangle(0, 0, 1, 1); s1.Text = "Checking for Custom Properties"; // A new rectangle should have zero props var c0 = CustomPropertyHelper.Get(s1); Assert.AreEqual(0, c0.Count); // Set one property // Notice that the properties some back double-quoted CustomPropertyHelper.Set(s1, "PROP1", "VAL1"); var c1 = CustomPropertyHelper.Get(s1); Assert.AreEqual(1, c1.Count); Assert.IsTrue(c1.ContainsKey("PROP1")); Assert.AreEqual("\"VAL1\"", c1["PROP1"].Value.Formula); // Add another property CustomPropertyHelper.Set(s1, "PROP2", "VAL 2"); var c2 = CustomPropertyHelper.Get(s1); Assert.AreEqual(2, c2.Count); Assert.IsTrue(c2.ContainsKey("PROP1")); Assert.AreEqual("\"VAL1\"", c2["PROP1"].Value.Formula); Assert.IsTrue(c2.ContainsKey("PROP2")); Assert.AreEqual("\"VAL 2\"", c2["PROP2"].Value.Formula); // Modify the value of the second property CustomPropertyHelper.Set(s1, "PROP2", "\"VAL 2 MOD\""); var c3 = CustomPropertyHelper.Get(s1); Assert.AreEqual(2, c3.Count); Assert.IsTrue(c3.ContainsKey("PROP1")); Assert.AreEqual("\"VAL1\"", c3["PROP1"].Value.Formula); Assert.IsTrue(c3.ContainsKey("PROP2")); Assert.AreEqual("\"VAL 2 MOD\"", c3["PROP2"].Value.Formula); // Now delete all the custom properties foreach (string name in c3.Keys) { CustomPropertyHelper.Delete(s1, name); } var c4 = CustomPropertyHelper.Get(s1); Assert.AreEqual(0, c4.Count); var app = this.GetVisioApplication(); var doc = app.ActiveDocument; if (doc != null) { doc.Close(true); } }
public IEnumerable <IDictionary <string, object> > Query(bool useHeaderRow, string sheetName, string startCell) { if (startCell != "A1") { throw new NotImplementedException("CSV not Implement startCell"); } if (_stream.CanSeek) { _stream.Position = 0; } var reader = _config.StreamReaderFunc(_stream); { var row = string.Empty; string[] read; var firstRow = true; Dictionary <int, string> headRows = new Dictionary <int, string>(); while ((row = reader.ReadLine()) != null) { read = Split(row); //header if (useHeaderRow) { if (firstRow) { firstRow = false; for (int i = 0; i <= read.Length - 1; i++) { headRows.Add(i, read[i]); } continue; } var cell = CustomPropertyHelper.GetEmptyExpandoObject(headRows); for (int i = 0; i <= read.Length - 1; i++) { cell[headRows[i]] = read[i]; } yield return(cell); continue; } //body { var cell = CustomPropertyHelper.GetEmptyExpandoObject(read.Length - 1, 0); for (int i = 0; i <= read.Length - 1; i++) { cell[ColumnHelper.GetAlphabetColumnName(i)] = read[i]; } yield return(cell); } } } }
public void UserDefinedCells_GetSet() { var page1 = this.GetNewPage(); var s1 = page1.DrawRectangle(0, 0, 2, 2); // By default a shape has ZERO custom Properties Assert.AreEqual(0, UserDefinedCellHelper.GetCount(s1)); // Add a Custom Property UserDefinedCellHelper.Set(s1, "FOO1", "BAR", null); Assert.AreEqual(1, UserDefinedCellHelper.GetCount(s1)); // Check that it is called FOO1 Assert.AreEqual(true, UserDefinedCellHelper.Contains(s1, "FOO1")); // Check that non-existent properties can't be found Assert.AreEqual(false, CustomPropertyHelper.Contains(s1, "FOOX")); var udcs = UserDefinedCellHelper.Get(s1); Assert.AreEqual(1, udcs.Count); Assert.AreEqual("FOO1", udcs[0].Name); Assert.AreEqual("\"BAR\"", udcs[0].Value.Formula); Assert.AreEqual("\"\"", udcs[0].Prompt.Formula); // Verify that we can set the value without affecting the prompt UserDefinedCellHelper.Set(s1, "FOO1", "BEER", null); udcs = UserDefinedCellHelper.Get(s1); Assert.AreEqual(1, udcs.Count); Assert.AreEqual("FOO1", udcs[0].Name); Assert.AreEqual("\"BEER\"", udcs[0].Value.Formula); Assert.AreEqual("\"\"", udcs[0].Prompt.Formula); // Verify that we can set passing in nulls changes nothing UserDefinedCellHelper.Set(s1, "FOO1", null, null); udcs = UserDefinedCellHelper.Get(s1); Assert.AreEqual(1, udcs.Count); Assert.AreEqual("FOO1", udcs[0].Name); Assert.AreEqual("\"BEER\"", udcs[0].Value.Formula); Assert.AreEqual("\"\"", udcs[0].Prompt.Formula); // Verify that we can set the prompt without affecting the value UserDefinedCellHelper.Set(s1, "FOO1", null, "Prompt1"); udcs = UserDefinedCellHelper.Get(s1); Assert.AreEqual(1, udcs.Count); Assert.AreEqual("FOO1", udcs[0].Name); Assert.AreEqual("\"BEER\"", udcs[0].Value.Formula); Assert.AreEqual("\"Prompt1\"", udcs[0].Prompt.Formula); // Delete that custom property UserDefinedCellHelper.Delete(s1, "FOO1"); // Verify that we have zero Custom Properties Assert.AreEqual(0, UserDefinedCellHelper.GetCount(s1)); page1.Delete(0); }
public void CustomProps_Names() { Assert.IsFalse(CustomPropertyHelper.IsValidName(null)); Assert.IsFalse(CustomPropertyHelper.IsValidName(string.Empty)); Assert.IsFalse(CustomPropertyHelper.IsValidName(" foo ")); Assert.IsFalse(CustomPropertyHelper.IsValidName("foo ")); Assert.IsFalse(CustomPropertyHelper.IsValidName("foo\t")); Assert.IsFalse(CustomPropertyHelper.IsValidName("fo bar")); Assert.IsTrue(CustomPropertyHelper.IsValidName("foobar")); }
private void SetGenericTypePropertiesMode(Type genericType, ref string mode, out int maxColumnIndex, out List <ExcelColumnInfo> props) { mode = "Properties"; if (genericType.IsValueType) { throw new NotImplementedException($"MiniExcel not support only {genericType.Name} value generic type"); } else if (genericType == typeof(string) || genericType == typeof(DateTime) || genericType == typeof(Guid)) { throw new NotImplementedException($"MiniExcel not support only {genericType.Name} generic type"); } props = CustomPropertyHelper.GetSaveAsProperties(genericType, _configuration); maxColumnIndex = props.Count; }
public List <CustomPropertyDictionary> GetCustomProperties(TargetShapes targetshapes, VASS.CellValueType type) { targetshapes = targetshapes.ResolveToShapes(this._client); if (targetshapes.Shapes.Count < 1) { return(new List <CustomPropertyDictionary>(0)); } var page = targetshapes.Shapes[0].ContainingPage; var shapeidpairs = targetshapes.ToShapeIDPairs(); var listof_cpdic = CustomPropertyHelper.GetDictionary(page, shapeidpairs, type); return(listof_cpdic); }
private void SetCustomProperties(RenderContext context) { var shapes_with_custom_props = this._shapes.Where(s => s.CustomProperties != null); foreach (var shape in shapes_with_custom_props) { var vshape = context.GetShape(shape.VisioShapeID); foreach (var kv in shape.CustomProperties) { string cp_name = kv.Key; CustomPropertyCells cp_cells = kv.Value; CustomPropertyHelper.Set(vshape, cp_name, cp_cells); } } }
public void ShapeSheet_Query_SectionRowHandling() { var page1 = this.GetNewPage(); var s1 = page1.DrawRectangle(0, 0, 2, 2); var s2 = page1.DrawRectangle(2, 1, 3, 3); var s3 = page1.DrawRectangle(3, 1, 4, 2); var s4 = page1.DrawRectangle(4, -1, 5, 1); CustomPropertyHelper.Set(s1, "S1P1", "1"); CustomPropertyHelper.Set(s2, "S2P1", "2"); CustomPropertyHelper.Set(s2, "S2P2", "3"); //set nothing for s3 CustomPropertyHelper.Set(s4, "S3P1", "4"); CustomPropertyHelper.Set(s4, "S3P2", "5"); CustomPropertyHelper.Set(s4, "S3P3", "6"); var query = new ShapeSheetQuery(); var prop_sec = query.AddSubQuery(IVisio.VisSectionIndices.visSectionProp); var value_col = prop_sec.AddCell(VA.ShapeSheet.SrcConstants.CustomPropValue, "Value"); var shapeids = new[] { s1.ID, s2.ID, s3.ID, s4.ID }; var data = query.GetFormulasAndResults(page1, shapeids); Assert.AreEqual(4, data.Count); Assert.AreEqual(1, data[0].Sections[prop_sec].Rows.Count); Assert.AreEqual(2, data[1].Sections[prop_sec].Rows.Count); Assert.AreEqual(0, data[2].Sections[prop_sec].Rows.Count); Assert.AreEqual(3, data[3].Sections[prop_sec].Rows.Count); Assert.AreEqual("\"1\"", data[0].Sections[prop_sec].Rows[0].Cells[0].Formula); Assert.AreEqual("\"2\"", data[1].Sections[prop_sec].Rows[0].Cells[0].Formula); Assert.AreEqual("\"3\"", data[1].Sections[prop_sec].Rows[1].Cells[0].Formula); Assert.AreEqual("\"4\"", data[3].Sections[prop_sec].Rows[0].Cells[0].Formula); Assert.AreEqual("\"5\"", data[3].Sections[prop_sec].Rows[1].Cells[0].Formula); Assert.AreEqual("\"6\"", data[3].Sections[prop_sec].Rows[2].Cells[0].Formula); Assert.AreEqual("1", data[0].Sections[prop_sec].Rows[0].Cells[0].Result); Assert.AreEqual("2", data[1].Sections[prop_sec].Rows[0].Cells[0].Result); Assert.AreEqual("3", data[1].Sections[prop_sec].Rows[1].Cells[0].Result); Assert.AreEqual("4", data[3].Sections[prop_sec].Rows[0].Cells[0].Result); Assert.AreEqual("5", data[3].Sections[prop_sec].Rows[1].Cells[0].Result); Assert.AreEqual("6", data[3].Sections[prop_sec].Rows[2].Cells[0].Result); page1.Delete(0); }
public List <bool> ContainCustomPropertyWithName(TargetShapes targetshapes, string name) { if (name == null) { throw new System.ArgumentNullException(nameof(name)); } targetshapes = targetshapes.ResolveToShapes(this._client); var results = new List <bool>(targetshapes.Shapes.Count); var values = targetshapes.Shapes.Select(shape => CustomPropertyHelper.Contains(shape, name)); results.AddRange(values); return(results); }
public static void Counting_properties(IVisio.Document doc) { // Set Custom Property_on_a_shape var page = doc.Pages.Add(); var s1 = page.DrawRectangle(0, 0, 1, 1); var cp1 = new CustomPropertyCells(); cp1.Value = "Hello"; CustomPropertyHelper.Set(s1, "Propname", cp1); int num_custom_props = CustomPropertyHelper.GetCount(s1); var custom_prop_names = CustomPropertyHelper.GetNames(s1); //cleanup page.Delete(0); }
public List <bool> Contains(TargetShapes targets, string name) { if (name == null) { throw new System.ArgumentNullException(nameof(name)); } targets = targets.ResolveShapes(this._client); var results = new List <bool>(targets.Shapes.Count); foreach (var shape in targets.Shapes) { results.Add(CustomPropertyHelper.Contains(shape, name)); } return(results); }
public void CustomProps_PropertyNames() { var page1 = this.GetNewPage(); var s1 = page1.DrawRectangle(0, 0, 2, 2); int cp_type = 0; // 0 for string Assert.AreEqual(0, CustomPropertyHelper.GetCount(s1)); CustomPropertyHelper.Set(s1, "FOO1", "\"BAR1\"", cp_type); Assert.AreEqual(1, CustomPropertyHelper.GetCount(s1)); CustomPropertyHelper.Set(s1, "FOO1", "\"BAR2\"", cp_type); Assert.AreEqual(1, CustomPropertyHelper.GetCount(s1)); CustomPropertyHelper.Set(s1, "FOO2", "\"BAR3\"", cp_type); var names1 = CustomPropertyHelper.GetNames(s1); Assert.AreEqual(2, names1.Count); Assert.IsTrue(names1.Contains("FOO1")); Assert.IsTrue(names1.Contains("FOO2")); Assert.AreEqual(2, CustomPropertyHelper.GetCount(s1)); CustomPropertyHelper.Delete(s1, "FOO1"); var names2 = CustomPropertyHelper.GetNames(s1); Assert.AreEqual(1, names2.Count); Assert.IsTrue(names2.Contains("FOO2")); CustomPropertyHelper.Set(s1, "FOO3", "\"BAR1\"", cp_type); var names3 = CustomPropertyHelper.GetNames(s1); Assert.AreEqual(2, names3.Count); Assert.IsTrue(names3.Contains("FOO3")); Assert.IsTrue(names3.Contains("FOO2")); CustomPropertyHelper.Delete(s1, "FOO3"); Assert.AreEqual(1, CustomPropertyHelper.GetCount(s1)); CustomPropertyHelper.Delete(s1, "FOO2"); Assert.AreEqual(0, CustomPropertyHelper.GetCount(s1)); page1.Delete(0); }
public void CustomProps_VerifyCustomPropAttributes() { var page1 = this.GetNewPage(); var s1 = page1.DrawRectangle(0, 0, 2, 2); var in_cp = new CustomPropertyCells(); in_cp.Label = "\"The Foo property\""; in_cp.Value = "\"Some value\""; in_cp.Prompt = "\"Some Prompt\""; in_cp.LangID = 1034; in_cp.Type = 0; // 0 = string. see: http://msdn.microsoft.com/en-us/library/aa200980(v=office.10).aspx in_cp.Calendar = (int)IVisio.VisCellVals.visCalWestern; in_cp.Invisible = 0; CustomPropertyHelper.Set(s1, "foo", in_cp); var out_cp = CustomPropertyHelper.GetCells(s1, CellValueType.Formula); Assert.AreEqual(1, out_cp.Count); page1.Delete(0); }
public void CustomProps_TryAllTypes() { var page1 = this.GetNewPage(); var s1 = page1.DrawRectangle(0, 0, 2, 2); // string var cp_string = new CustomPropertyCells(); cp_string.Value = "Hello World"; cp_string.Type = 0; var cp_int = new CustomPropertyCells(); cp_int.Value = 1024; cp_int.Type = 2; var cp_dt = new CustomPropertyCells(); cp_dt.Value = "DATETIME(\"03/31/1979\")"; cp_dt.Type = 5; var cp_bool = new CustomPropertyCells(); cp_bool.Value = "TRUE"; cp_bool.Type = 2; var cp_float = new CustomPropertyCells(); cp_float.Value = 3.14; cp_float.Type = 2; CustomPropertyHelper.Set(s1, "PropertyString", cp_string); CustomPropertyHelper.Set(s1, "PropertyInt", cp_int); CustomPropertyHelper.Set(s1, "PropertyFloat", cp_float); CustomPropertyHelper.Set(s1, "PropertyDateTime", cp_dt); CustomPropertyHelper.Set(s1, "PropertyBool", cp_bool); page1.Delete(0); }