コード例 #1
0
        void AddNumberBox(FieldBind field)
        {
            string         name = field.GetEditorName();
            LabeledTextbox c    = new LabeledTextbox(name);

            c.Name = name + "_TB";

            c.Text = field.GetValue().ToString();

            field.GetDataAction = () => {
                if (int.TryParse(c.Text, out int r))
                {
                    return(r);
                }
                else
                {
                    return(0);
                }
            };
            field.Reverted += (object o) => { c.Text = o.ToString(); };
            //c.TextChanged += (object sender, EventArgs e) =>
            //{
            //    field.data = c.Text;
            //};
            this.flowPanel.Controls.Add(c);
        }
コード例 #2
0
        void AddEnumComboBox(FieldBind field)
        {
            string   name = field.GetEditorName();
            ComboBox c    = new ComboBox();

            c.Name = name + "_TB";

            var names = Enum.GetNames(field.field.FieldType);

            if (names.Length > 0)
            {
                c.Items.AddRange(names);
                c.Text = Enum.GetName(field.field.FieldType, field.GetValue());
                field.GetDataAction = () => {
                    return(Enum.Parse(field.field.FieldType, c.Text));
                };
            }
            else
            {
                field.GetDataAction = () => {
                    return(Activator.CreateInstance(field.field.FieldType));
                };
            }



            field.Reverted += (object o) => { c.Text = Enum.GetName(field.field.FieldType, o); };
            //c.TextChanged += (object sender, EventArgs e) =>
            //{
            //    field.data = c.Text;
            //};
            this.flowPanel.Controls.Add(c);
        }
コード例 #3
0
        void AddTextBox(FieldBind field)
        {
            string         name = field.GetEditorName();
            LabeledTextbox c    = new LabeledTextbox(name);

            c.Name = name + "_TB";

            c.Text = (string)field.GetValue();

            field.GetDataAction = () => { return(c.Text); };
            field.Reverted     += (object o) => { c.Text = (string)o; };
            //c.TextChanged += (object sender, EventArgs e) =>
            //{
            //    field.data = c.Text;
            //};
            this.flowPanel.Controls.Add(c);
        }
コード例 #4
0
        void AddCheckbox(FieldBind field)
        {
            string   name = field.GetEditorName();
            CheckBox c    = new CheckBox();

            c.Name    = name + "_CB";
            c.Text    = name;
            c.Checked = (bool)field.GetValue();

            field.GetDataAction = () => { return(c.Checked); };
            field.Reverted     += (object o) => { c.Checked = (bool)o; };

            //c.CheckedChanged += (object sender, EventArgs e) =>
            //{
            //    field.data = c.Checked;
            //};
            this.flowPanel.Controls.Add(c);
        }