public void VDX_CustomProperties() { string filename = TestGlobals.TestHelper.GetTestMethodOutputFilename(".vdx"); var template = new VisioAutomation.VDX.Template(); var doc_node = new VisioAutomation.VDX.Elements.Drawing(template); int rect_id = doc_node.GetMasterMetaData("REctAngle").ID; var node_page = new VisioAutomation.VDX.Elements.Page(8, 5); doc_node.Pages.Add(node_page); var node_shape = new VisioAutomation.VDX.Elements.Shape(rect_id, 4, 2, 3, 2); node_shape.CustomProps = new VisioAutomation.VDX.Elements.CustomProps(); var node_custprop0 = new VisioAutomation.VDX.Elements.CustomProp("PROP1"); node_custprop0.Value = "VALUE1"; node_shape.CustomProps.Add(node_custprop0); var node_custprop1 = new VisioAutomation.VDX.Elements.CustomProp("PROP2"); node_custprop1.Value = "123"; node_custprop1.Type.Result = VisioAutomation.VDX.Enums.CustomPropType.String; node_shape.CustomProps.Add(node_custprop1); var node_custprop2 = new VisioAutomation.VDX.Elements.CustomProp("PROP3"); node_custprop2.Value = "456"; node_custprop2.Type.Result = VisioAutomation.VDX.Enums.CustomPropType.Number; node_shape.CustomProps.Add(node_custprop2); node_page.Shapes.Add(node_shape); doc_node.Save(filename); var app = new IVisio.Application(); var docs = app.Documents; var doc = docs.Add(filename); var page = app.ActivePage; var shapes = page.Shapes; Assert.AreEqual(1,page.Shapes.Count); var shape = page.Shapes[1]; var customprops = VACUSTPROP.CustomPropertyHelper.Get(shape); Assert.IsTrue(customprops.ContainsKey("PROP1")); Assert.AreEqual("\"VALUE1\"",customprops["PROP1"].Value.Formula); Assert.IsTrue(customprops.ContainsKey("PROP2")); Assert.AreEqual("\"123\"", customprops["PROP2"].Value.Formula); Assert.AreEqual("0", customprops["PROP2"].Type.Formula); Assert.IsTrue(customprops.ContainsKey("PROP3")); Assert.AreEqual("\"456\"", customprops["PROP3"].Value.Formula); Assert.AreEqual("2", customprops["PROP3"].Type.Formula); app.Quit(true); }
public void VDX_CustomProperties() { string filename = TestGlobals.TestHelper.GetTestMethodOutputFilename(".vdx"); var template = new VisioAutomation.VDX.Template(); var doc_node = new VisioAutomation.VDX.Elements.Drawing(template); int rect_id = doc_node.GetMasterMetaData("REctAngle").ID; var node_page = new VisioAutomation.VDX.Elements.Page(8, 5); doc_node.Pages.Add(node_page); var node_shape = new VisioAutomation.VDX.Elements.Shape(rect_id, 4, 2, 3, 2); node_shape.CustomProps = new VisioAutomation.VDX.Elements.CustomProps(); var node_custprop0 = new VisioAutomation.VDX.Elements.CustomProp("PROP1"); node_custprop0.Value = "VALUE1"; node_shape.CustomProps.Add(node_custprop0); var node_custprop1 = new VisioAutomation.VDX.Elements.CustomProp("PROP2"); node_custprop1.Value = "123"; node_custprop1.Type.Result = VisioAutomation.VDX.Enums.CustomPropType.String; node_shape.CustomProps.Add(node_custprop1); var node_custprop2 = new VisioAutomation.VDX.Elements.CustomProp("PROP3"); node_custprop2.Value = "456"; node_custprop2.Type.Result = VisioAutomation.VDX.Enums.CustomPropType.Number; node_shape.CustomProps.Add(node_custprop2); node_page.Shapes.Add(node_shape); doc_node.Save(filename); var app = new IVisio.Application(); var docs = app.Documents; var doc = docs.Add(filename); var page = app.ActivePage; var shapes = page.Shapes; Assert.AreEqual(1, page.Shapes.Count); var shape = page.Shapes[1]; var customprops = VACUSTPROP.CustomPropertyHelper.Get(shape); Assert.IsTrue(customprops.ContainsKey("PROP1")); Assert.AreEqual("\"VALUE1\"", customprops["PROP1"].Value.Formula); Assert.IsTrue(customprops.ContainsKey("PROP2")); Assert.AreEqual("\"123\"", customprops["PROP2"].Value.Formula); Assert.AreEqual("0", customprops["PROP2"].Type.Formula); Assert.IsTrue(customprops.ContainsKey("PROP3")); Assert.AreEqual("\"456\"", customprops["PROP3"].Value.Formula); Assert.AreEqual("2", customprops["PROP3"].Type.Formula); app.Quit(true); }