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 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 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 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 Dom_CustomProperties() { // Create the doc var shape_nodes = new ShapeList(); var vrect1 = new Rectangle(1, 1, 9, 9); vrect1.Text = new VisioAutomation.Models.Text.Element("HELLO WORLD"); vrect1.CustomProperties = new CustomPropertyDictionary(); var cp1 = new CustomPropertyCells(); cp1.Value = "\"FOOVALUE\""; cp1.Label = "\"Foo Label\""; var cp2 = new CustomPropertyCells(); cp2.Value = "\"BARVALUE\""; cp2.Label = "\"Bar Label\""; vrect1.CustomProperties["FOO"] = cp1; vrect1.CustomProperties["BAR"] = cp2; shape_nodes.Add(vrect1); // Render it var app = this.GetVisioApplication(); var doc = this.GetNewDoc(); shape_nodes.Render(app.ActivePage); // Verify Assert.IsNotNull(vrect1.VisioShape); Assert.AreEqual("HELLO WORLD", vrect1.VisioShape.Text); Assert.IsTrue(CustomPropertyHelper.Contains(vrect1.VisioShape, "FOO")); Assert.IsTrue(CustomPropertyHelper.Contains(vrect1.VisioShape, "BAR")); doc.Close(true); }