Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }