public CustomPropertyNameCellsPair(int shapeid, int row, string name, CustomPropertyCells cells) { this.ShapeID = shapeid; this.Row = row; this.Name = name; this.Cells = cells; }
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 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 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 static DGShapeInfo FromXml(Client client, SXL.XElement shape_el) { var info = new DGShapeInfo(); info.ID = shape_el.Attribute("id").Value; client.WriteVerbose("Reading shape id={0}", info.ID); info.Label = shape_el.Attribute("label").Value; info.Stencil = shape_el.Attribute("stencil").Value; info.Master = shape_el.Attribute("master").Value; info.Element = shape_el; info.URL = shape_el.GetAttributeValue("url", null); info.custprops = new CustomPropertyDictionary(); foreach (var customprop_el in shape_el.Elements("customprop")) { string cp_name = customprop_el.Attribute("name").Value; string cp_value = customprop_el.Attribute("value").Value; var cp = new CustomPropertyCells(); cp.Value = cp_value; info.custprops.Add(cp_name, cp); } return(info); }
private void SetFromParameters() { var cp = new CustomPropertyCells(); cp.Value = this.Value; if (this.Label != null) { cp.Label = this.Label; } if (this.Format != null) { cp.Format = this.Format; } if (this.Prompt != null) { cp.Prompt = this.Prompt; } if (this.LangId >= 0) { cp.LangID = this.LangId; } if (this.SortKey >= 0) { cp.SortKey = this.SortKey; } if (this.Type >= 0) { cp.Type = this.Type; } if (this.Ask >= 0) { cp.Ask = this.Ask; } if (this.Calendar >= 0) { cp.Calendar = this.Calendar; } if (this.Invisible >= 0) { cp.Invisible = this.Invisible; } var targets = new VisioScripting.Models.TargetShapes(this.Shapes); this.Client.CustomProp.Set(targets, this.Name, cp); }
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); } } }
internal CustomProperty(int id, string name, CustomPropertyCells cells) { this.ShapeID = id; this.Name = name; this.Value = cells.Value.Value; this.Format = cells.Format.Value; this.Invisible = cells.Invisible.Value; this.Label = cells.Label.Value; this.LangId = cells.LangID.Value; this.Prompt = cells.Prompt.Value; this.SortKey = cells.SortKey.Value; this.Type = cells.Type.Value; this.Ask = cells.Ask.Value; this.Calendar = cells.Calendar.Value; }
internal CustomProperty(int id, string propname, CustomPropertyCells propcells) { this.ShapeID = id; this.Name = propname; this.Value = propcells.Value.Formula.Value; this.Format = propcells.Format.Formula.Value; this.Invisible = propcells.Invisible.Formula.Value; this.Label = propcells.Label.Formula.Value; this.LangId = propcells.LangID.Formula.Value; this.Prompt = propcells.Prompt.Formula.Value; this.SortKey = propcells.SortKey.Formula.Value; this.Type = propcells.Type.Formula.Value; this.Ask = propcells.Ask.Formula.Value; this.Calendar = propcells.Calendar.Formula.Value; }
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 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); }
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); }
public static void Set_Custom_Property_on_Shape(IVisio.Document doc) { // Set Custom Property_on_a_shape var page = doc.Pages.Add(); var s1 = page.DrawRectangle(0, 0, 1, 1); var cp = new CustomPropertyCells(); cp.Value = "Hello World"; CustomPropertyHelper.Set(s1, "Propname", cp); // Retrieve all the Custom properties from a shape var props = CustomPropertyHelper.Get(s1); // Delete the property from the shape CustomPropertyHelper.Delete(s1, "Propname"); //cleanup page.Delete(0); }
private void SetFromHashTable() { var targets = new VisioScripting.Models.TargetShapes(this.Shapes); if (this.HashTable.Count < 1) { return; } foreach (object key in this.HashTable.Keys) { if (!(key is string)) { string msg = "Property Names must be strings"; throw new ArgumentOutOfRangeException(msg); } string key_string = (string)key; object value = this.HashTable[key]; var cp = CustomPropertyCells.FromValue(value); this.Client.CustomProp.Set(targets, key_string, cp); } }
public void SetCustomProperty(TargetShapes targetshapes, string name, CustomPropertyCells customprop) { if (customprop == null) { throw new System.ArgumentNullException(nameof(customprop)); } targetshapes = targetshapes.ResolveToShapes(this._client); if (targetshapes.Shapes.Count < 1) { return; } customprop.EncodeValues(); using (var undoscope = this._client.Undo.NewUndoScope(nameof(SetCustomProperty))) { foreach (var shape in targetshapes.Shapes) { CustomPropertyHelper.Set(shape, name, customprop); } } }
public void CustomProps_AllTypes() { var page1 = this.GetNewPage(); var s1 = page1.DrawRectangle(0, 0, 1, 1); s1.Text = "Checking for Custom Properties"; // String Custom Property var prop_string_in = new CustomPropertyCells(); prop_string_in.Format = "\"Format\""; prop_string_in.Label = "\"Label\""; prop_string_in.Prompt = "\"Prompt\""; prop_string_in.Type = CustomPropertyCells.CustomPropertyTypeToInt(CustomPropertyType.String); prop_string_in.Value = "1"; // Boolean var prop_bool_in = new CustomPropertyCells(); prop_bool_in.Format = "\"Format\""; prop_bool_in.Label = "\"Label\""; prop_bool_in.Prompt = "\"Prompt\""; prop_bool_in.Type = CustomPropertyCells.CustomPropertyTypeToInt(CustomPropertyType.Boolean); prop_bool_in.Value = true; // Date var dt = new System.DateTime(2017, 3, 31, 14, 5, 6); var st = dt.ToString(CultureInfo.InvariantCulture); var prop_date_in = new CustomPropertyCells(); prop_date_in.Format = "\"Format\""; prop_date_in.Label = "\"Label\""; prop_date_in.Prompt = "\"Prompt\""; prop_date_in.Type = CustomPropertyCells.CustomPropertyTypeToInt(CustomPropertyType.Date); prop_date_in.Value = string.Format("DATETIME(\"{0}\")", st);; // Boolean var prop_number_in = new CustomPropertyCells(); prop_number_in.Format = "\"Format\""; prop_number_in.Label = "\"Label\""; prop_number_in.Prompt = "\"Prompt\""; prop_number_in.Type = CustomPropertyCells.CustomPropertyTypeToInt(CustomPropertyType.Number); prop_number_in.Value = "3.14"; CustomPropertyHelper.Set(s1, "PROP_STRING", prop_string_in); CustomPropertyHelper.Set(s1, "PROP_BOOLEAN", prop_bool_in); CustomPropertyHelper.Set(s1, "PROP_DATE", prop_date_in); CustomPropertyHelper.Set(s1, "PROP_NUMBER", prop_number_in); var props_dic = CustomPropertyHelper.GetDictionary(s1, CellValueType.Formula); var prop_string_out = props_dic["PROP_STRING"]; Assert.AreEqual("\"Format\"", prop_string_out.Format.Value); Assert.AreEqual("\"Label\"", prop_string_out.Label.Value); Assert.AreEqual("\"Prompt\"", prop_string_out.Prompt.Value); Assert.AreEqual("0", prop_string_out.Type.Value); Assert.AreEqual("1", prop_string_out.Value.Value); var prop_bool_out = props_dic["PROP_BOOLEAN"]; Assert.AreEqual("\"Format\"", prop_bool_out.Format.Value); Assert.AreEqual("\"Label\"", prop_bool_out.Label.Value); Assert.AreEqual("\"Prompt\"", prop_bool_out.Prompt.Value); Assert.AreEqual("3", prop_bool_out.Type.Value); Assert.AreEqual("TRUE", prop_bool_out.Value.Value); var prop_date_out = props_dic["PROP_DATE"]; Assert.AreEqual("\"Format\"", prop_date_out.Format.Value); Assert.AreEqual("\"Label\"", prop_date_out.Label.Value); Assert.AreEqual("\"Prompt\"", prop_date_out.Prompt.Value); Assert.AreEqual("5", prop_date_out.Type.Value); Assert.AreEqual("DATETIME(\"03/31/2017 14:05:06\")", prop_date_out.Value.Value); var prop_number_out = props_dic["PROP_NUMBER"]; Assert.AreEqual("\"Format\"", prop_number_out.Format.Value); Assert.AreEqual("\"Label\"", prop_number_out.Label.Value); Assert.AreEqual("\"Prompt\"", prop_number_out.Prompt.Value); Assert.AreEqual("2", prop_number_out.Type.Value); Assert.AreEqual("3.14", prop_number_out.Value.Value); var app = this.GetVisioApplication(); var doc = app.ActiveDocument; if (doc != null) { doc.Close(true); } }
public void CustomProps_GetSet2() { var page1 = this.GetNewPage(); var s1 = page1.DrawRectangle(0, 0, 1, 1); s1.Text = "Checking for Custom Properties"; var cp1 = new CustomPropertyCells(); cp1.Ask = "1"; cp1.Calendar = "0"; cp1.Format = "1"; cp1.Invisible = "0"; cp1.Label = "1"; cp1.LangID = "0"; cp1.Prompt = "1"; cp1.SortKey = "0"; cp1.Type = "0"; cp1.Value = "1"; CustomPropertyHelper.Set(s1, "PROP1", cp1); var props1 = CustomPropertyHelper.Get(s1); var cp2 = props1["PROP1"]; Assert.AreEqual("TRUE", cp2.Ask.Formula.Value); Assert.AreEqual("0", cp2.Calendar.Formula.Value); Assert.AreEqual("\"1\"", cp2.Format.Formula.Value); Assert.AreEqual("FALSE", cp2.Invisible.Formula.Value); Assert.AreEqual("\"1\"", cp2.Label.Formula.Value); Assert.AreEqual("0", cp2.LangID.Formula.Value); Assert.AreEqual("\"1\"", cp2.Prompt.Formula.Value); Assert.AreEqual("0", cp2.SortKey.Formula.Value); Assert.AreEqual("0", cp2.Type.Formula.Value); Assert.AreEqual("\"1\"", cp2.Value.Formula.Value); var cp3 = new CustomPropertyCells(); cp3.Ask = "0"; cp3.Calendar = "2"; cp3.Format = "0"; cp3.Invisible = "TRUE"; cp3.Label = "3"; cp3.LangID = "2"; cp3.Prompt = "3"; cp3.SortKey = "2"; cp3.Type = "3"; cp3.Value = "2"; CustomPropertyHelper.Set(s1, "PROP1", cp3); var props2 = CustomPropertyHelper.Get(s1); var cp4 = props2["PROP1"]; Assert.AreEqual("FALSE", cp4.Ask.Formula.Value); Assert.AreEqual("2", cp4.Calendar.Formula.Value); Assert.AreEqual("\"0\"", cp4.Format.Formula.Value); Assert.AreEqual("TRUE", cp4.Invisible.Formula.Value); Assert.AreEqual("\"3\"", cp4.Label.Formula.Value); Assert.AreEqual("2", cp4.LangID.Formula.Value); Assert.AreEqual("\"3\"", cp4.Prompt.Formula.Value); Assert.AreEqual("2", cp4.SortKey.Formula.Value); Assert.AreEqual("3", cp4.Type.Formula.Value); Assert.AreEqual("2", cp4.Value.Formula.Value); var app = this.GetVisioApplication(); var doc = app.ActiveDocument; if (doc != null) { doc.Close(true); } }
public void Scripting_CustomProps_Scenarios() { var client = this.GetScriptingClient(); client.Document.NewDocument(); client.Page.NewPage(VisioScripting.TargetDocument.Auto, new VA.Geometry.Size(4, 4), false); var s1 = client.Draw.DrawRectangle(VisioScripting.TargetPage.Auto, 1, 1, 1.25, 1.5); var s2 = client.Draw.DrawRectangle(VisioScripting.TargetPage.Auto, 2, 3, 2.5, 3.5); var s3 = client.Draw.DrawRectangle(VisioScripting.TargetPage.Auto, 4.5, 2.5, 6, 3.5); client.Selection.SelectNone(VisioScripting.TargetWindow.Auto); client.Selection.SelectShapesById(VisioScripting.TargetWindow.Auto, s1); client.Selection.SelectShapesById(VisioScripting.TargetWindow.Auto, s2); client.Selection.SelectShapesById(VisioScripting.TargetWindow.Auto, s3); var prop_dic0 = client.CustomProperty.GetCustomPropertiesAsShapeDictionary(VisioScripting.TargetShapes.Auto, VisioAutomation.ShapeSheet.CellValueType.Formula); Assert.AreEqual(3, prop_dic0.Count); Assert.AreEqual(0, prop_dic0[s1].Count); Assert.AreEqual(0, prop_dic0[s2].Count); Assert.AreEqual(0, prop_dic0[s3].Count); var cp = new CustomPropertyCells(); cp.Value = "\"BAR\""; client.CustomProperty.SetCustomProperty(VisioScripting.TargetShapes.Auto, "FOO", cp); var prop_dic1 = client.CustomProperty.GetCustomPropertiesAsShapeDictionary(VisioScripting.TargetShapes.Auto, VisioAutomation.ShapeSheet.CellValueType.Formula); Assert.AreEqual(3, prop_dic1.Count); Assert.AreEqual(1, prop_dic1[s1].Count); Assert.AreEqual(1, prop_dic1[s2].Count); Assert.AreEqual(1, prop_dic1[s3].Count); var cp1 = prop_dic1[s1]["FOO"]; var cp2 = prop_dic1[s2]["FOO"]; var cp3 = prop_dic1[s3]["FOO"]; Assert.AreEqual("\"BAR\"", cp1.Value.Value); Assert.AreEqual("\"BAR\"", cp2.Value.Value); Assert.AreEqual("\"BAR\"", cp3.Value.Value); var hasprops0 = client.CustomProperty.ContainCustomPropertyWithName(VisioScripting.TargetShapes.Auto, "FOO"); Assert.IsTrue(hasprops0.All(v => v == true)); client.CustomProperty.DeleteCustomPropertyWithName(VisioScripting.TargetShapes.Auto, "FOO"); var prop_dic2 = client.CustomProperty.GetCustomPropertiesAsShapeDictionary(VisioScripting.TargetShapes.Auto, VisioAutomation.ShapeSheet.CellValueType.Formula); Assert.AreEqual(3, prop_dic2.Count); Assert.AreEqual(0, prop_dic2[s1].Count); Assert.AreEqual(0, prop_dic2[s2].Count); Assert.AreEqual(0, prop_dic2[s3].Count); var hasprops1 = client.CustomProperty.ContainCustomPropertyWithName(VisioScripting.TargetShapes.Auto, "FOO"); Assert.IsTrue(hasprops1.All(v => v == false)); client.Document.CloseDocument(VisioScripting.TargetDocuments.Auto); }
public void Scripting_CustomProps_Scenarios() { var client = this.GetScriptingClient(); client.Document.New(); client.Page.New(new VA.Drawing.Size(4, 4), false); var s1 = client.Draw.Rectangle(1, 1, 1.25, 1.5); var s2 = client.Draw.Rectangle(2, 3, 2.5, 3.5); var s3 = client.Draw.Rectangle(4.5, 2.5, 6, 3.5); client.Selection.SelectNone(); client.Selection.Select(s1); client.Selection.Select(s2); client.Selection.Select(s3); var targets = new TargetShapes(); var prop_dic0 = client.CustomProp.Get(targets); Assert.AreEqual(3, prop_dic0.Count); Assert.AreEqual(0, prop_dic0[s1].Count); Assert.AreEqual(0, prop_dic0[s2].Count); Assert.AreEqual(0, prop_dic0[s3].Count); var cp = new CustomPropertyCells(); cp.Value = "BAR"; client.CustomProp.Set(targets, "FOO", cp); var prop_dic1 = client.CustomProp.Get(targets); Assert.AreEqual(3, prop_dic1.Count); Assert.AreEqual(1, prop_dic1[s1].Count); Assert.AreEqual(1, prop_dic1[s2].Count); Assert.AreEqual(1, prop_dic1[s3].Count); var cp1 = prop_dic1[s1]["FOO"]; var cp2 = prop_dic1[s2]["FOO"]; var cp3 = prop_dic1[s3]["FOO"]; Assert.AreEqual("\"BAR\"", cp1.Value.Formula); Assert.AreEqual("\"BAR\"", cp2.Value.Formula); Assert.AreEqual("\"BAR\"", cp3.Value.Formula); var hasprops0 = client.CustomProp.Contains(targets, "FOO"); Assert.IsTrue(hasprops0.All(v => v == true)); client.CustomProp.Delete(targets, "FOO"); var prop_dic2 = client.CustomProp.Get(targets); Assert.AreEqual(3, prop_dic2.Count); Assert.AreEqual(0, prop_dic2[s1].Count); Assert.AreEqual(0, prop_dic2[s2].Count); Assert.AreEqual(0, prop_dic2[s3].Count); var hasprops1 = client.CustomProp.Contains(targets, "FOO"); Assert.IsTrue(hasprops1.All(v => v == false)); client.Document.Close(true); }
public void Scripting_CustomProps_Scenarios() { var client = this.GetScriptingClient(); client.Document.NewDocument(); client.Page.NewPage(new VA.Geometry.Size(4, 4), false); var s1 = client.Draw.DrawRectangle(1, 1, 1.25, 1.5); var s2 = client.Draw.DrawRectangle(2, 3, 2.5, 3.5); var s3 = client.Draw.DrawRectangle(4.5, 2.5, 6, 3.5); client.Selection.SelectNone(); client.Selection.SelectShapesById(s1); client.Selection.SelectShapesById(s2); client.Selection.SelectShapesById(s3); var targets = new VisioScripting.Models.TargetShapes(); var prop_dic0 = client.CustomProperty.GetCustomProperties(targets); Assert.AreEqual(3, prop_dic0.Count); Assert.AreEqual(0, prop_dic0[s1].Count); Assert.AreEqual(0, prop_dic0[s2].Count); Assert.AreEqual(0, prop_dic0[s3].Count); var cp = new CustomPropertyCells(); cp.Value = "\"BAR\""; client.CustomProperty.SetCustomProperty(targets, "FOO", cp); var prop_dic1 = client.CustomProperty.GetCustomProperties(targets); Assert.AreEqual(3, prop_dic1.Count); Assert.AreEqual(1, prop_dic1[s1].Count); Assert.AreEqual(1, prop_dic1[s2].Count); Assert.AreEqual(1, prop_dic1[s3].Count); var cp1 = prop_dic1[s1]["FOO"]; var cp2 = prop_dic1[s2]["FOO"]; var cp3 = prop_dic1[s3]["FOO"]; Assert.AreEqual("\"BAR\"", cp1.Value.Value); Assert.AreEqual("\"BAR\"", cp2.Value.Value); Assert.AreEqual("\"BAR\"", cp3.Value.Value); var hasprops0 = client.CustomProperty.ContainCustomPropertyWithName(targets, "FOO"); Assert.IsTrue(hasprops0.All(v => v == true)); client.CustomProperty.DeleteCustomPropertyWithName(targets, "FOO"); var prop_dic2 = client.CustomProperty.GetCustomProperties(targets); Assert.AreEqual(3, prop_dic2.Count); Assert.AreEqual(0, prop_dic2[s1].Count); Assert.AreEqual(0, prop_dic2[s2].Count); Assert.AreEqual(0, prop_dic2[s3].Count); var hasprops1 = client.CustomProperty.ContainCustomPropertyWithName(targets, "FOO"); Assert.IsTrue(hasprops1.All(v => v == false)); client.Document.CloseActiveDocument(true); }
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 = CustomPropertyCells.CustomPropertyTypeToInt(CustomPropertyType.String); var cp_int = new CustomPropertyCells(); cp_int.Value = 1024; cp_int.Type = CustomPropertyCells.CustomPropertyTypeToInt(CustomPropertyType.Number); var cp_dt = new CustomPropertyCells(); cp_dt.Value = "DATETIME(\"03/31/1979\")"; cp_dt.Type = CustomPropertyCells.CustomPropertyTypeToInt(CustomPropertyType.Date); var cp_bool = new CustomPropertyCells(); cp_bool.Value = "TRUE"; cp_bool.Type = CustomPropertyCells.CustomPropertyTypeToInt(CustomPropertyType.Boolean); var cp_float = new CustomPropertyCells(); cp_float.Value = 3.14; cp_float.Type = CustomPropertyCells.CustomPropertyTypeToInt(CustomPropertyType.Number); 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); var cpdic = CustomPropertyHelper.GetDictionary(s1, CellValueType.Formula); var out_cpstring = cpdic["PropertyString"]; var out_cpint = cpdic["PropertyInt"]; var out_cpfloat = cpdic["PropertyFloat"]; var out_cpdatetime = cpdic["PropertyDateTime"]; var out_cpbool = cpdic["PropertyBool"]; Assert.AreEqual("\"Hello World\"", out_cpstring.Value.Value); Assert.AreEqual("0", out_cpstring.Type.Value); Assert.AreEqual("1024", out_cpint.Value.Value); Assert.AreEqual("2", out_cpint.Type.Value); Assert.AreEqual("3.14", out_cpfloat.Value.Value); Assert.AreEqual("2", out_cpfloat.Type.Value); Assert.AreEqual("DATETIME(\"03/31/1979\")", out_cpdatetime.Value.Value); Assert.AreEqual("5", out_cpdatetime.Type.Value); Assert.AreEqual("TRUE", out_cpbool.Value.Value); Assert.AreEqual("3", out_cpbool.Type.Value); page1.Delete(0); }
public CustomPropNameCellsPair(string name, CustomPropertyCells cells) { this.Name = name; this.Cells = cells; }