Esempio n. 1
0
        private void btnSetValue_Click(object sender, EventArgs e)
        {
            if (lstParameters.SelectedIndices.Count != 1) return;
            ParameterExpression p = (ParameterExpression)lstParameters.SelectedItems[0].Tag;
            //Check if the parameter is a base type if not we need another form.

            if (p.Type.IsPrimitive)
            {
                ParameterSetter setter = new ParameterSetter(p);
                if (setter.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    lstParameters.SelectedItems[0].SubItems[1].Tag = setter.SelectedValue;
                    lstParameters.SelectedItems[0].SubItems[1].Text = setter.SelectedValue.ToString();
                }
            }
            else
            {
                Object obj = lstParameters.SelectedItems[0].SubItems[1].Tag ?? Activator.CreateInstance(p.Type);
                ParameterSetterNotBaseType setter = new ParameterSetterNotBaseType(obj);
                if (setter.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    lstParameters.SelectedItems[0].SubItems[1].Tag = setter.SelectedValue;
                    lstParameters.SelectedItems[0].SubItems[1].Text = setter.SelectedValue.ToString();
                }
            }
        }
Esempio n. 2
0
        private void btnSetValue_Click(object sender, EventArgs e)
        {
            if (lstParameters.SelectedIndices.Count != 1)
            {
                return;
            }
            ParameterExpression p = (ParameterExpression)lstParameters.SelectedItems[0].Tag;

            //Check if the parameter is a base type if not we need another form.

            if (p.Type.IsPrimitive)
            {
                ParameterSetter setter = new ParameterSetter(p);
                if (setter.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    lstParameters.SelectedItems[0].SubItems[1].Tag  = setter.SelectedValue;
                    lstParameters.SelectedItems[0].SubItems[1].Text = setter.SelectedValue.ToString();
                }
            }
            else
            {
                Object obj = lstParameters.SelectedItems[0].SubItems[1].Tag ?? Activator.CreateInstance(p.Type);
                ParameterSetterNotBaseType setter = new ParameterSetterNotBaseType(obj);
                if (setter.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    lstParameters.SelectedItems[0].SubItems[1].Tag  = setter.SelectedValue;
                    lstParameters.SelectedItems[0].SubItems[1].Text = setter.SelectedValue.ToString();
                }
            }
        }