Ejemplo n.º 1
0
        public void FieldWithDictionary()
        {
            FormFlatSchema content = new FormFlatSchema
            {
                Title     = "Contact2",
                Questions = new List <FlatField>(),
            };
            var fields = new List <FlatField>
            {
                new FlatField {
                    Required = false, Title = "FirstName", Label = "First Name", Type = "String", Answer = 123
                },
                new FlatField {
                    Required = true, Title = "LastName", Label = "Last Name", Type = "String", Answer = true
                },
                new FlatField {
                    Required = true, Title = "Telephone", Label = "Telephone Number", Type = "Int", Answer = "Sinden"
                },
                new FlatField {
                    Required = false, Title = "Age", Label = "Age", Type = "Int", Answer = new [] { "A", "B", "C" }
                },
            };

            content.Questions.AddRange(fields);
            var multiOptions = new Dictionary <string, dynamic>
            {
                { "Multiple", true },
                { "MultiType", "Checkbox" },
                { "Options", new List <string> {
                      "Sales,Finance, Digital, HR, Engineering, Legal"
                  } }
            };

            var field = new FlatField
            {
                Label        = "Departments",
                Required     = false,
                Type         = "String",
                MultiOptions = multiOptions
            };

            content.Questions.Add(field);
            Console.WriteLine(content.ToJson());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            IGH_Goo goo   = null;
            Image   image = new Image();

            if (!DA.GetData(0, ref goo))
            {
                return;
            }
            if (!goo.TryGetImage(ref image))
            {
                return;
            }

            int mode = 0;

            DA.GetData(1, ref mode);

            IGH_Goo gooA    = null;
            Bitmap  overlay = new Bitmap(100, 100);

            if (DA.GetData(2, ref gooA))
            {
                if (goo.TryGetBitmap(ref overlay))
                {
                    ;
                }
            }

            double numVal = 1.0;

            DA.GetData(3, ref numVal);

            Filter filter = new Filter();

            switch ((FilterModes)mode)
            {
            case FilterModes.Add:
                filter = new Add(overlay);
                image.Filters.Add(new Add(overlay));
                break;

            case FilterModes.Subtract:
                filter = new Subtract(overlay);
                image.Filters.Add(new Subtract(overlay));
                break;

            case FilterModes.Multiply:
                filter = new Multiply(overlay);
                image.Filters.Add(new Multiply(overlay));
                break;

            case FilterModes.Divide:
                filter = new Divide(overlay);
                image.Filters.Add(new Divide(overlay));
                break;

            case FilterModes.Euclidean:
                filter = new Euclidean(overlay, (int)numVal);
                image.Filters.Add(new Euclidean(overlay, (int)numVal));
                break;

            case FilterModes.FlatField:
                filter = new FlatField(overlay);
                image.Filters.Add(new FlatField(overlay));
                break;

            case FilterModes.Intersect:
                filter = new Intersect(overlay);
                image.Filters.Add(new Intersect(overlay));
                break;

            case FilterModes.Merge:
                filter = new Merge(overlay);
                image.Filters.Add(new Merge(overlay));
                break;

            case FilterModes.Morph:
                filter = new Morph(overlay, numVal);
                image.Filters.Add(new Morph(overlay, numVal));
                break;

            case FilterModes.MoveTowards:
                filter = new MoveTowards(overlay, (int)numVal);
                image.Filters.Add(new MoveTowards(overlay, (int)numVal));
                break;

            case FilterModes.Simple:
                filter = new Simple(overlay, (int)numVal);
                image.Filters.Add(new Simple(overlay, (int)numVal));
                break;
            }

            message = ((FilterModes)mode).ToString();
            UpdateMessage();

            DA.SetData(0, image);
            DA.SetData(1, filter);
        }