Beispiel #1
0
        private void AddAttributeDataInputHelper_Load(object sender, EventArgs e)
        {
            textBoxType.Text = m_type.FullName;
            textBoxCtor.Text = m_ctor.ToString();

            m_parameterControlList = new List <Control>();

            ParameterInfo[] parameters = m_ctor.GetParameters();
            for (int i = 0; i < parameters.Length; i++)
            {
                Type type = parameters[i].ParameterType;
                // Type Label
                Label label = new Label();
                label.Text     = type.Name + ":";
                label.Location = new Point(TYPE_LABEL_X, i * TYPE_ITEM_HEIGHT + 1);
                label.Width    = TYPE_LABEL_WIDTH;
                panelParameters.Controls.Add(label);
                // Input Item: TextBox or ComboBox
                if (type == typeof(Boolean))
                {
                    ComboBox combo = new ComboBox();
                    combo.Items.Add(Boolean.TrueString);
                    combo.Items.Add(Boolean.FalseString);
                    combo.SelectedIndex = 0;
                    combo.DropDownStyle = ComboBoxStyle.DropDownList;
                    combo.Location      = new Point(TYPE_CONTROL_X, i * TYPE_ITEM_HEIGHT);
                    combo.Width         = TYPE_CONTROL_WIDTH;
                    panelParameters.Controls.Add(combo);
                    m_parameterControlList.Add(combo);
                }
                else if (type.IsEnum)
                {
                    ComboBox combo = new ComboBox();
                    foreach (string enumName in Enum.GetNames(type))
                    {
                        combo.Items.Add(enumName);
                    }
                    if (combo.Items.Count > 0)
                    {
                        combo.SelectedIndex = 0;
                    }
                    combo.DropDownStyle = ComboBoxStyle.DropDownList;
                    combo.Location      = new Point(TYPE_CONTROL_X, i * TYPE_ITEM_HEIGHT);
                    combo.Width         = TYPE_CONTROL_WIDTH;
                    panelParameters.Controls.Add(combo);
                    m_parameterControlList.Add(combo);
                }
                else if (type == typeof(Type))
                {
                    TextBox text = new TextBox();
                    text.Location = new Point(TYPE_CONTROL_X, i * TYPE_ITEM_HEIGHT);
                    text.Width    = TYPE_CONTROL_WIDTH;
                    panelParameters.Controls.Add(text);
                    m_parameterControlList.Add(text);
                    // Type Selector
                    ManagedTypeSelectButton button = new ManagedTypeSelectButton(text);
                    button.Location = new Point(TYPE_CONTROL_X + TYPE_CONTROL_WIDTH + 2, i * TYPE_ITEM_HEIGHT);
                    button.Text     = "...";
                    button.Width    = 28;
                    button.Height   = 22;
                    panelParameters.Controls.Add(button);
                }
                else
                {
                    TextBox text = new TextBox();
                    text.Location = new Point(TYPE_CONTROL_X, i * TYPE_ITEM_HEIGHT);
                    text.Width    = TYPE_CONTROL_WIDTH;
                    panelParameters.Controls.Add(text);
                    m_parameterControlList.Add(text);
                }
            }
            if (!(m_data.Equals("") || m_data.Equals("01 00 00 00")))
            {
                try
                {
                    ParseData();
                }
                catch (Exception)
                {
                    MessageBox.Show(Resource.FormatString("Wrn_ParseDataFailed", m_ctor.ToString()));
                }
            }
        }
        private void AddAttributeDataInputHelper_Load(object sender, EventArgs e)
        {
            textBoxType.Text = m_type.FullName;
            textBoxCtor.Text = m_ctor.ToString();

            m_parameterControlList = new List<Control>();

            ParameterInfo[] parameters = m_ctor.GetParameters();
            for (int i = 0; i < parameters.Length; i++)
            {
                Type type = parameters[i].ParameterType;
                // Type Label
                Label label = new Label();
                label.Text = type.Name + ":";
                label.Location = new Point(TYPE_LABEL_X, i * TYPE_ITEM_HEIGHT + 1);
                label.Width = TYPE_LABEL_WIDTH;
                panelParameters.Controls.Add(label);
                // Input Item: TextBox or ComboBox
                if (type == typeof(Boolean))
                {
                    ComboBox combo = new ComboBox();
                    combo.Items.Add(Boolean.TrueString);
                    combo.Items.Add(Boolean.FalseString);
                    combo.SelectedIndex = 0;
                    combo.DropDownStyle = ComboBoxStyle.DropDownList;
                    combo.Location = new Point(TYPE_CONTROL_X, i * TYPE_ITEM_HEIGHT);
                    combo.Width = TYPE_CONTROL_WIDTH;
                    panelParameters.Controls.Add(combo);
                    m_parameterControlList.Add(combo);
                }
                else if (type.IsEnum)
                {
                    ComboBox combo = new ComboBox();
                    foreach (string enumName in Enum.GetNames(type))
                    {
                        combo.Items.Add(enumName);
                    }
                    if (combo.Items.Count > 0)
                        combo.SelectedIndex = 0;
                    combo.DropDownStyle = ComboBoxStyle.DropDownList;
                    combo.Location = new Point(TYPE_CONTROL_X, i * TYPE_ITEM_HEIGHT);
                    combo.Width = TYPE_CONTROL_WIDTH;
                    panelParameters.Controls.Add(combo);
                    m_parameterControlList.Add(combo);
                }
                else if (type == typeof(Type))
                {
                    TextBox text = new TextBox();
                    text.Location = new Point(TYPE_CONTROL_X, i * TYPE_ITEM_HEIGHT);
                    text.Width = TYPE_CONTROL_WIDTH;
                    panelParameters.Controls.Add(text);
                    m_parameterControlList.Add(text);
                    // Type Selector
                    ManagedTypeSelectButton button = new ManagedTypeSelectButton(text);
                    button.Location = new Point(TYPE_CONTROL_X + TYPE_CONTROL_WIDTH + 2, i * TYPE_ITEM_HEIGHT);
                    button.Text = "...";
                    button.Width = 28;
                    button.Height = 22;
                    panelParameters.Controls.Add(button);
                }
                else
                {
                    TextBox text = new TextBox();
                    text.Location = new Point(TYPE_CONTROL_X, i * TYPE_ITEM_HEIGHT);
                    text.Width = TYPE_CONTROL_WIDTH;
                    panelParameters.Controls.Add(text);
                    m_parameterControlList.Add(text);
                }
            }
            if (!(m_data.Equals("") || m_data.Equals("01 00 00 00")))
            {
                try
                {
                    ParseData();
                }
                catch (Exception)
                {
                    MessageBox.Show(Resource.FormatString("Wrn_ParseDataFailed", m_ctor.ToString()));
                }
            }
        }