public static ShapeInfo FromXml(Client client, SXL.XElement shape_el)
        {
            var info = new ShapeInfo();
            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 = XmlUtil.GetAttributeValue(shape_el, "url", null);

            info.custprops = new Dictionary<string, VACUSTPROP.CustomPropertyCells>();
            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 VACUSTPROP.CustomPropertyCells();
                cp.Value = cp_value;

                info.custprops.Add(cp_name,cp);
            }

            return info;
        }
        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, VACUSTPROP.CustomPropertyHelper.Get(s1).Count);

            // Add a Custom Property
            var cp = new VACUSTPROP.CustomPropertyCells();
            cp.Value = "BAR1";
            VACUSTPROP.CustomPropertyHelper.Set(s1, "FOO1", cp);
            // Asset that now we have ONE CustomProperty
            Assert.AreEqual(1, VACUSTPROP.CustomPropertyHelper.Get(s1).Count);
            // Check that it is called FOO1
            Assert.AreEqual(true, VACUSTPROP.CustomPropertyHelper.Contains(s1, "FOO1"));

            // Check that non-existent properties can't be found
            Assert.AreEqual(false, VACUSTPROP.CustomPropertyHelper.Contains(s1, "FOOX"));

            // Delete that custom property
            VACUSTPROP.CustomPropertyHelper.Delete(s1, "FOO1");
            // Verify that we have zero Custom Properties
            Assert.AreEqual(0, VACUSTPROP.CustomPropertyHelper.Get(s1).Count);

            page1.Delete(0);
        }
Esempio n. 3
0
        public void CustomProps_SetCustomProps1()
        {
            var page1 = GetNewPage();

            var s1 = page1.DrawRectangle(0, 0, 2, 2);

            // By default a shape has ZERO custom Properties
            Assert.AreEqual(0, VACUSTPROP.CustomPropertyHelper.Get(s1).Count);

            // Add a Custom Property
            var cp = new VACUSTPROP.CustomPropertyCells();

            cp.Value = "BAR1";
            VACUSTPROP.CustomPropertyHelper.Set(s1, "FOO1", cp);
            // Asset that now we have ONE CustomProperty
            Assert.AreEqual(1, VACUSTPROP.CustomPropertyHelper.Get(s1).Count);
            // Check that it is called FOO1
            Assert.AreEqual(true, VACUSTPROP.CustomPropertyHelper.Contains(s1, "FOO1"));

            // Check that non-existent properties can't be found
            Assert.AreEqual(false, VACUSTPROP.CustomPropertyHelper.Contains(s1, "FOOX"));

            // Delete that custom property
            VACUSTPROP.CustomPropertyHelper.Delete(s1, "FOO1");
            // Verify that we have zero Custom Properties
            Assert.AreEqual(0, VACUSTPROP.CustomPropertyHelper.Get(s1).Count);

            page1.Delete(0);
        }
Esempio n. 4
0
        public static ShapeInfo FromXml(Client client, SXL.XElement shape_el)
        {
            var info = new ShapeInfo();

            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     = VA.Scripting.XmlUtil.GetAttributeValue(shape_el, "url", null);

            info.custprops = new Dictionary <string, VACUSTPROP.CustomPropertyCells>();
            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 VACUSTPROP.CustomPropertyCells();
                cp.Value = cp_value;

                info.custprops.Add(cp_name, cp);
            }

            return(info);
        }
Esempio n. 5
0
        public void Set(IList <IVisio.Shape> target_shapes, string name, CP.CustomPropertyCells customprop)
        {
            this.AssertApplicationAvailable();
            this.AssertDocumentAvailable();

            if (customprop == null)
            {
                throw new System.ArgumentNullException("customprop");
            }

            var shapes = GetTargetShapes(target_shapes);

            if (shapes.Count < 1)
            {
                return;
            }

            var application = this.Client.VisioApplication;

            using (var undoscope = new VA.Application.UndoScope(this.Client.VisioApplication, "Set Custom Property"))
            {
                foreach (var shape in shapes)
                {
                    CP.CustomPropertyHelper.Set(shape, name, customprop);
                }
            }
        }
        public void Set(IList <IVisio.Shape> target_shapes, string name, VACUSTPROP.CustomPropertyCells customprop)
        {
            this.Client.Application.AssertApplicationAvailable();
            this.Client.Document.AssertDocumentAvailable();

            if (customprop == null)
            {
                throw new System.ArgumentNullException(nameof(customprop));
            }

            var shapes = this.GetTargetShapes(target_shapes);

            if (shapes.Count < 1)
            {
                return;
            }

            var application = this.Client.Application.Get();

            using (var undoscope = this.Client.Application.NewUndoScope("Set Custom Property"))
            {
                foreach (var shape in shapes)
                {
                    VACUSTPROP.CustomPropertyHelper.Set(shape, name, customprop);
                }
            }
        }
        public void Set(TargetShapes targets, string name, VACUSTPROP.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)
                {
                    VACUSTPROP.CustomPropertyHelper.Set(shape, name, customprop);
                }
            }
        }
Esempio n. 8
0
        private void SetFromParameters()
        {
            var cp = new VACUSTPROP.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 VisioAutomation.Scripting.TargetShapes(this.Shapes);

            this.Client.CustomProp.Set(targets, this.Name, cp);
        }
        public static void Set(IVisio.Shape shape, short row, CustomPropertyCells cp)
        {
            if (shape == null)
            {
                throw new ArgumentNullException(nameof(shape));
            }

            var writer = new FormulaWriterSRC();
            cp.SetFormulas(writer, row);
            writer.Commit(shape);
        }
        public void Scripting_CustomProps_Scenarios()
        {
            var client = 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.None();
            client.Selection.Select(s1);
            client.Selection.Select(s2);
            client.Selection.Select(s3);

            var prop_dic0 = client.CustomProp.Get(null);
            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 VACUSTOMPROP.CustomPropertyCells();
            cp.Value = "BAR";
            client.CustomProp.Set(null,"FOO",cp);

            var prop_dic1 = client.CustomProp.Get(null);
            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(null,"FOO");
            Assert.IsTrue(hasprops0.All(v => v == true));

            client.CustomProp.Delete(null,"FOO");

            var prop_dic2 = client.CustomProp.Get(null);
            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(null,"FOO");
            Assert.IsTrue(hasprops1.All(v => v == false));

            client.Document.Close(true);
        }
        public static void Set(IVisio.Shape shape, short row, CustomPropertyCells cp)
        {
            if (shape == null)
            {
                throw new ArgumentNullException(nameof(shape));
            }

            var update = new ShapeSheet.Update();
            update.SetFormulas(cp, row);
            update.Execute(shape);
        }
        private void SetFromParameters()
        {
            var cp = new VACUSTPROP.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;
            }

            this.client.CustomProp.Set(this.Shapes, this.Name, cp);
        }
Esempio n. 13
0
        public static void Set(IVisio.Shape shape, short row, CustomPropertyCells cp)
        {
            if (shape == null)
            {
                throw new ArgumentNullException("shape");
            }

            var update = new VA.ShapeSheet.Update();

            update.SetFormulas(cp, row);
            update.Execute(shape);
        }
        /// <summary>
        /// Gets all the custom properties defined on a shape
        /// </summary>
        /// <remarks>
        /// If there are no custom properties then null will be returned</remarks>
        /// <param name="shape"></param>
        /// <returns>A list of custom properties</returns>
        public static CustomPropertyDictionary Get(IVisio.Shape shape)
        {
            var prop_names = CustomPropertyHelper.GetNames(shape);
            var dic        = new CustomPropertyDictionary(prop_names.Count);
            var cells      = CustomPropertyCells.GetCells(shape);

            for (int prop_index = 0; prop_index < prop_names.Count(); prop_index++)
            {
                string prop_name = prop_names[prop_index];
                dic[prop_name] = cells[prop_index];
            }

            return(dic);
        }
Esempio n. 15
0
 internal CustomPropertyValues(int id, string propname, VACUSTPROP.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;
 }
Esempio n. 16
0
        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;
                    VACUSTPROP.CustomPropertyCells cp_cells = kv.Value;
                    VACUSTPROP.CustomPropertyHelper.Set(vshape, cp_name, cp_cells);
                }
            }
        }
Esempio n. 17
0
        public CustomPropertyCells GetCells(VA.ShapeSheet.CellData <double>[] row)
        {
            var cells = new CustomPropertyCells();

            cells.Value     = row[Value.Ordinal];
            cells.Calendar  = row[Calendar.Ordinal].ToInt();
            cells.Format    = row[Format.Ordinal];
            cells.Invisible = row[Invis.Ordinal].ToInt();
            cells.Label     = row[Label.Ordinal];
            cells.LangId    = row[LangID.Ordinal].ToInt();
            cells.Prompt    = row[Prompt.Ordinal];
            cells.SortKey   = row[SortKey.Ordinal].ToInt();
            cells.Type      = row[Type.Ordinal].ToInt();
            cells.Ask       = row[Ask.Ordinal].ToBool();
            return(cells);
        }
        public static List <VisioAutomation.Shapes.CustomProperties.CustomPropertyDictionary> Get(IVisio.Page page, IList <IVisio.Shape> shapes)
        {
            if (page == null)
            {
                throw new ArgumentNullException(nameof(page));
            }

            if (shapes == null)
            {
                throw new ArgumentNullException(nameof(shapes));
            }

            var shapeids              = shapes.Select(s => s.ID).ToList();
            var customprops_dic       = new List <VisioAutomation.Shapes.CustomProperties.CustomPropertyDictionary>(shapeids.Count);
            var customprops_per_shape = CustomPropertyCells.GetCells(page, shapeids);

            if (customprops_per_shape.Count != shapeids.Count)
            {
                throw new InternalAssertionException();
            }

            for (int shape_index = 0; shape_index < shapeids.Count; shape_index++)
            {
                var shape = shapes[shape_index];
                var customprops_for_shape = customprops_per_shape[shape_index];
                var prop_names            = CustomPropertyHelper.GetNames(shape);

                if (customprops_for_shape.Count != prop_names.Count)
                {
                    throw new InternalAssertionException();
                }

                var dic = new VisioAutomation.Shapes.CustomProperties.CustomPropertyDictionary(prop_names.Count);

                for (int prop_index = 0; prop_index < prop_names.Count(); prop_index++)
                {
                    string prop_name = prop_names[prop_index];
                    dic[prop_name] = customprops_for_shape[prop_index];
                }

                customprops_dic.Add(dic);
            }

            return(customprops_dic);
        }
Esempio n. 19
0
        public static IList <Dictionary <string, CustomPropertyCells> > Get(IVisio.Page page, IList <IVisio.Shape> shapes)
        {
            if (page == null)
            {
                throw new ArgumentNullException("page");
            }

            if (shapes == null)
            {
                throw new ArgumentNullException("shapes");
            }

            var shapeids              = shapes.Select(s => s.ID).ToList();
            var customprops_dic       = new List <Dictionary <string, CustomPropertyCells> >(shapeids.Count);
            var customprops_per_shape = CustomPropertyCells.GetCells(page, shapeids);

            if (customprops_per_shape.Count != shapeids.Count)
            {
                throw new VA.AutomationException("1");
            }

            for (int shape_index = 0; shape_index < shapeids.Count; shape_index++)
            {
                var shape = shapes[shape_index];
                var customprops_for_shape = customprops_per_shape[shape_index];
                var prop_names            = GetNames(shape);

                if (customprops_for_shape.Count != prop_names.Count)
                {
                    throw new VA.AutomationException("2");
                }

                var dic = new Dictionary <string, CustomPropertyCells>(prop_names.Count);

                for (int prop_index = 0; prop_index < prop_names.Count(); prop_index++)
                {
                    string prop_name = prop_names[prop_index];
                    dic[prop_name] = customprops_for_shape[prop_index];
                }

                customprops_dic.Add(dic);
            }

            return(customprops_dic);
        }
Esempio n. 20
0
        public void CustomProps_VerifyCustomPropAttributes()
        {
            var page1 = GetNewPage();
            var s1    = page1.DrawRectangle(0, 0, 2, 2);

            var in_cp = new VACUSTPROP.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;
            VACUSTPROP.CustomPropertyHelper.Set(s1, "foo", in_cp);
            var out_cp = VACUSTPROP.CustomPropertyHelper.Get(s1);

            Assert.AreEqual(1, out_cp.Count);
            page1.Delete(0);
        }
        public static void Set(IVisio.Shape shape, string name, string val)
        {
            if (shape == null)
            {
                throw new ArgumentNullException(nameof(shape));
            }

            CustomPropertyHelper.CheckValidCustomPropertyName(name);

            if (val == null)
            {
                throw new ArgumentNullException(nameof(val));
            }

            // create a new property
            var cp = new CustomPropertyCells();
            cp.Value = val;
            cp.Type = 0; // 0 = string

            CustomPropertyHelper.Set(shape, name, cp);
        }
Esempio n. 22
0
        public void CustomProps_TryAllTypes()
        {
            var page1 = GetNewPage();

            var s1 = page1.DrawRectangle(0, 0, 2, 2);

            // string
            var cp_string = new VACUSTPROP.CustomPropertyCells();

            cp_string.Value = "Hello World";
            cp_string.Type  = 0;

            var cp_int = new VACUSTPROP.CustomPropertyCells();

            cp_int.Value = 1024;
            cp_int.Type  = 2;

            var cp_dt = new VACUSTPROP.CustomPropertyCells();

            cp_dt.Value = "DATETIME(\"03/31/1979\")";
            cp_dt.Type  = 5;

            var cp_bool = new VACUSTPROP.CustomPropertyCells();

            cp_bool.Value = "TRUE";
            cp_bool.Type  = 2;

            var cp_float = new VACUSTPROP.CustomPropertyCells();

            cp_float.Value = 3.14;
            cp_float.Type  = 2;

            VACUSTPROP.CustomPropertyHelper.Set(s1, "PropertyString", cp_string);
            VACUSTPROP.CustomPropertyHelper.Set(s1, "PropertyInt", cp_int);
            VACUSTPROP.CustomPropertyHelper.Set(s1, "PropertyFloat", cp_float);
            VACUSTPROP.CustomPropertyHelper.Set(s1, "PropertyDateTime", cp_dt);
            VACUSTPROP.CustomPropertyHelper.Set(s1, "PropertyBool", cp_bool);

            page1.Delete(0);
        }
        public static void Set(
            IVisio.Shape shape,
            string name,
            CustomPropertyCells cp)
        {
            if (shape == null)
            {
                throw new ArgumentNullException(nameof(shape));
            }

            CustomPropertyHelper.CheckValidCustomPropertyName(name);

            if (CustomPropertyHelper.Contains(shape, name))
            {
                string full_prop_name = CustomPropertyHelper.GetRowName(name);
                var    cell_propname  = shape.CellsU[full_prop_name];

                if (cell_propname == null)
                {
                    string msg = string.Format("Could not retrieve cell for custom property \"{0}\"", full_prop_name);
                    throw new InternalAssertionException(msg);
                }

                var writer = new VisioAutomation.ShapeSheet.Writers.SrcWriter();
                cp.SetFormulas(writer, cell_propname.Row);

                writer.Commit(shape);

                return;
            }

            short row = shape.AddNamedRow(
                (short)IVisio.VisSectionIndices.visSectionProp,
                name,
                (short)IVisio.VisRowIndices.visRowProp);

            CustomPropertyHelper.Set(shape, row, cp);
        }
        public static void Set(
            IVisio.Shape shape,
            string name,
            CustomPropertyCells cp)
        {
            if (shape == null)
            {
                throw new ArgumentNullException(nameof(shape));
            }

            CustomPropertyHelper.CheckValidCustomPropertyName(name);

            if (CustomPropertyHelper.Contains(shape, name))
            {
                string full_prop_name = CustomPropertyHelper.GetRowName(name);
                var cell_propname = shape.CellsU[full_prop_name];

                if (cell_propname == null)
                {
                    string msg = $"Could not retrieve cell for custom property \"{full_prop_name}\"";
                    throw new AutomationException(msg);
                }

                var update = new ShapeSheet.Update();
                update.SetFormulas(cp, cell_propname.Row);
                update.Execute(shape);

                return;

            }

            short row = shape.AddNamedRow(
                (short)IVisio.VisSectionIndices.visSectionProp,
                name,
                (short)IVisio.VisRowIndices.visRowProp);

            CustomPropertyHelper.Set(shape, row, cp);
        }
Esempio n. 25
0
        public static void Set(
            IVisio.Shape shape,
            string name,
            CustomPropertyCells cp)
        {
            if (shape == null)
            {
                throw new ArgumentNullException("shape");
            }

            CheckValidCustomPropertyName(name);

            if (Contains(shape, name))
            {
                string full_prop_name = GetRowName(name);
                var    cell_propname  = shape.CellsU[full_prop_name];

                if (cell_propname == null)
                {
                    string msg = String.Format("Could not retrieve cell for custom property \"{0}\"", full_prop_name);
                    throw new AutomationException(msg);
                }

                var update = new ShapeSheet.Update();
                update.SetFormulas(cp, cell_propname.Row);
                update.Execute(shape);

                return;
            }

            short row = shape.AddNamedRow(
                (short)IVisio.VisSectionIndices.visSectionProp,
                name,
                (short)IVisio.VisRowIndices.visRowProp);

            Set(shape, row, cp);
        }
        public static void Set(IVisio.Shape shape, string name, string val)
        {
            if (shape == null)
            {
                throw new ArgumentNullException(nameof(shape));
            }

            CustomPropertyHelper.CheckValidCustomPropertyName(name);

            if (val == null)
            {
                throw new ArgumentNullException(nameof(val));
            }

            // create a new property
            var cp = new CustomPropertyCells();
            cp.Value = val;
            cp.Type = 0; // 0 = string

            CustomPropertyHelper.Set(shape, name, cp);
        }
Esempio n. 27
0
        public void CustomProps_GetSet2()
        {
            var page1 = GetNewPage();

            var s1 = page1.DrawRectangle(0, 0, 1, 1);

            s1.Text = "Checking for Custom Properties";


            var cp1 = new VACUSTPROP.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";

            VACUSTPROP.CustomPropertyHelper.Set(s1, "PROP1", cp1);

            var props1 = VACUSTPROP.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 VACUSTPROP.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";

            VACUSTPROP.CustomPropertyHelper.Set(s1, "PROP1", cp3);
            var props2 = VACUSTPROP.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)
            {
                VA.Documents.DocumentHelper.Close(doc, true);
            }
        }
        public void CustomProps_VerifyCustomPropAttributes()
        {
            var page1 = this.GetNewPage();
            var s1 = page1.DrawRectangle(0, 0, 2, 2);

            var in_cp = new VACUSTPROP.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;
            VACUSTPROP.CustomPropertyHelper.Set(s1, "foo", in_cp);
            var out_cp = VACUSTPROP.CustomPropertyHelper.Get(s1);
            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 VACUSTPROP.CustomPropertyCells();
            cp_string.Value = "Hello World";
            cp_string.Type = 0;

            var cp_int = new VACUSTPROP.CustomPropertyCells();
            cp_int.Value = 1024;
            cp_int.Type = 2;

            var cp_dt = new VACUSTPROP.CustomPropertyCells();
            cp_dt.Value = "DATETIME(\"03/31/1979\")";
            cp_dt.Type = 5;

            var cp_bool = new VACUSTPROP.CustomPropertyCells();
            cp_bool.Value = "TRUE";
            cp_bool.Type = 2;

            var cp_float = new VACUSTPROP.CustomPropertyCells();
            cp_float.Value = 3.14;
            cp_float.Type = 2;

            VACUSTPROP.CustomPropertyHelper.Set(s1, "PropertyString", cp_string);
            VACUSTPROP.CustomPropertyHelper.Set(s1, "PropertyInt", cp_int);
            VACUSTPROP.CustomPropertyHelper.Set(s1, "PropertyFloat", cp_float);
            VACUSTPROP.CustomPropertyHelper.Set(s1, "PropertyDateTime", cp_dt);
            VACUSTPROP.CustomPropertyHelper.Set(s1, "PropertyBool", cp_bool);

            page1.Delete(0);
        }
        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.None();
            client.Selection.Select(s1);
            client.Selection.Select(s2);
            client.Selection.Select(s3);

            var prop_dic0 = client.CustomProp.Get(null);

            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 VACUSTPROP.CustomPropertyCells();

            cp.Value = "BAR";
            client.CustomProp.Set(null, "FOO", cp);

            var prop_dic1 = client.CustomProp.Get(null);

            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(null, "FOO");

            Assert.IsTrue(hasprops0.All(v => v == true));

            client.CustomProp.Delete(null, "FOO");

            var prop_dic2 = client.CustomProp.Get(null);

            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(null, "FOO");

            Assert.IsTrue(hasprops1.All(v => v == false));

            client.Document.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 VACUSTPROP.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";

            VACUSTPROP.CustomPropertyHelper.Set(s1, "PROP1", cp1);

            var props1 = VACUSTPROP.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 VACUSTPROP.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";

            VACUSTPROP.CustomPropertyHelper.Set(s1,"PROP1",cp3);
            var props2 = VACUSTPROP.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)
            {
                VA.Documents.DocumentHelper.Close(doc, true);
            }
        }
 public CustomPropertyCells GetCells(VA.ShapeSheet.CellData<double>[] row)
 {
     var cells = new CustomPropertyCells();
     cells.Value = row[Value.Ordinal];
     cells.Calendar = row[Calendar.Ordinal].ToInt();
     cells.Format = row[Format.Ordinal];
     cells.Invisible = row[Invis.Ordinal].ToInt();
     cells.Label = row[Label.Ordinal];
     cells.LangId = row[LangID.Ordinal].ToInt();
     cells.Prompt = row[Prompt.Ordinal];
     cells.SortKey = row[SortKey.Ordinal].ToInt();
     cells.Type = row[Type.Ordinal].ToInt();
     cells.Ask = row[Ask.Ordinal].ToBool();
     return cells;
 }