Beispiel #1
0
        public Label AddParameter(IParameter parameter, IParameterEditor editor)
        {
            Panel p = new Panel();

            p.Size   = new Size(flowLayoutPanel2.Width, editor.AsControl.Height + 3);
            p.Anchor = AnchorStyles.Left | AnchorStyles.Right;
            p.Dock   = DockStyle.Top;
            editor.AsControl.Width  = p.Width;
            editor.AsControl.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
            p.Size = new Size(flowLayoutPanel2.Width, editor.AsControl.Height + 3);

            Label label = new Label();

            label.AutoSize  = false;
            label.TextAlign = ContentAlignment.MiddleLeft;
            label.Dock      = DockStyle.Top;
            label.Text      = parameter.Name;
            label.ForeColor = Scheme.Foreground;
            label.Size      = new Size(40, p.Height);

            editor.AsControl.SizeChanged += (a, args) =>
            {
                p.Height     = editor.AsControl.Height + 3;
                label.Height = p.Height;
            };
            p.Controls.Add(editor.AsControl);
            editor.AsControl.KeyDown += keyDown;
            foreach (var c in editor.AsControl.AllDescendants())
            {
                c.KeyDown += keyDown;
            }

            m_parameterEditors.Add(Tuple.Create(editor, parameter));

            flowLayoutPanel1.Controls.Add(label);
            flowLayoutPanel2.Controls.Add(p);

            return(label);
        }
Beispiel #2
0
        public void Property_Editors_Can_Be_Parameter_Editor()
        {
            var a      = JsonConvert.DeserializeObject <JArray>(@"[
    {
        alias: 'Test.Test1',
        name: 'Test 1',   
        isParameterEditor: true,     
        defaultConfig: { key1: 'some default val' },
        editor: {
            view: '~/App_Plugins/MyPackage/PropertyEditors/MyEditor.html',
            valueType: 'int',
            validation: {
                required : true,
                regex : '\\d*'
            }
        }
    },
    {
        alias: 'Test.Test2',
        name: 'Test 2',
        defaultConfig: { key1: 'some default pre val' },
        editor: {
            view: '~/App_Plugins/MyPackage/PropertyEditors/CsvEditor.html'
        }
    }
]");
            var parser = ManifestParser.GetPropertyEditors(a);

            Assert.AreEqual(1, parser.Count(x => x.IsParameterEditor));

            IParameterEditor parameterEditor = parser.First();

            Assert.AreEqual(1, parameterEditor.Configuration.Count);
            Assert.IsTrue(parameterEditor.Configuration.ContainsKey("key1"));
            Assert.AreEqual("some default val", parameterEditor.Configuration["key1"]);
        }