Пример #1
0
        private void CreateFormerOptions(IWorldFormer former)
        {
            var table = new TableLayoutPanel();
            table.Dock = DockStyle.Fill;
            table.Location = new Point(0, 0);

            Label lbl_Summary = new Label();
            lbl_Summary.Text = former.Summary;
            lbl_Summary.Dock = DockStyle.Fill;
            table.Controls.Add(lbl_Summary, 0, 0);
            table.SetColumnSpan(lbl_Summary, 2);

            int rowCount = 1;
            foreach (var prop in former.GetType().GetProperties().Where(p => p.Name != "Summary"))
            {
                Control valueCtrl = null;
                if (prop.PropertyType == typeof(int) || prop.PropertyType == typeof(short))
                {
                    NumericUpDown num = new NumericUpDown();
                    num.DecimalPlaces = 0;
                    num.DataBindings.Add("Value", former, prop.Name);
                    valueCtrl = num;
                }
                else if (prop.PropertyType == typeof(double))
                {
                    NumericUpDown num = new NumericUpDown();
                    num.DecimalPlaces = 2;
                    num.DataBindings.Add("Value", former, prop.Name);
                    valueCtrl = num;
                }
                else if (prop.PropertyType == typeof(string))
                {
                    TextBox tb = new TextBox();
                    tb.DataBindings.Add("Text", former, prop.Name);
                    valueCtrl = tb;
                }
                if (valueCtrl != null)
                {
                    valueCtrl.Enabled = prop.CanWrite;
                    table.RowStyles.Add(new RowStyle());//(SizeType.Absolute, 30F));
                    var lbl = new Label();
                    lbl.AutoSize = false;
                    lbl.Location = new Point(0, 5);
                    lbl.Text = prop.Name;

                    table.Controls.Add(lbl, 0, rowCount);
                    lbl.Location = new Point(0, 5);

                    table.Controls.Add(valueCtrl, 1, rowCount);
                    valueCtrl.Location = new Point(0, 0);
                    rowCount++;
                }
            }
            formerOptions.Controls.Clear();
            formerOptions.Controls.Add(table);
            table.Dock = DockStyle.Fill;
            table.Location = new Point(0, 0);
        }
Пример #2
0
        private void CreateFormerOptions(IWorldFormer former)
        {
            var table = new TableLayoutPanel();

            table.Dock     = DockStyle.Fill;
            table.Location = new Point(0, 0);

            Label lbl_Summary = new Label();

            lbl_Summary.Text = former.Summary;
            lbl_Summary.Dock = DockStyle.Fill;
            table.Controls.Add(lbl_Summary, 0, 0);
            table.SetColumnSpan(lbl_Summary, 2);

            int rowCount = 1;

            foreach (var prop in former.GetType().GetProperties().Where(p => p.Name != "Summary"))
            {
                Control valueCtrl = null;
                if (prop.PropertyType == typeof(int) || prop.PropertyType == typeof(short))
                {
                    NumericUpDown num = new NumericUpDown();
                    num.DecimalPlaces = 0;
                    num.DataBindings.Add("Value", former, prop.Name);
                    valueCtrl = num;
                }
                else if (prop.PropertyType == typeof(double))
                {
                    NumericUpDown num = new NumericUpDown();
                    num.DecimalPlaces = 2;
                    num.DataBindings.Add("Value", former, prop.Name);
                    valueCtrl = num;
                }
                else if (prop.PropertyType == typeof(string))
                {
                    TextBox tb = new TextBox();
                    tb.DataBindings.Add("Text", former, prop.Name);
                    valueCtrl = tb;
                }
                if (valueCtrl != null)
                {
                    valueCtrl.Enabled = prop.CanWrite;
                    table.RowStyles.Add(new RowStyle());//(SizeType.Absolute, 30F));
                    var lbl = new Label();
                    lbl.AutoSize = false;
                    lbl.Location = new Point(0, 5);
                    lbl.Text     = prop.Name;

                    table.Controls.Add(lbl, 0, rowCount);
                    lbl.Location = new Point(0, 5);

                    table.Controls.Add(valueCtrl, 1, rowCount);
                    valueCtrl.Location = new Point(0, 0);
                    rowCount++;
                }
            }
            formerOptions.Controls.Clear();
            formerOptions.Controls.Add(table);
            table.Dock     = DockStyle.Fill;
            table.Location = new Point(0, 0);
        }