Beispiel #1
0
        private void buttonDataInput_Click(object sender, EventArgs e)
        {
            if (m_selectedAttributeType == null)
            {
                MessageBox.Show(Resource.FormatString("Wrn_CannotUseByteDataInputHelper_TypeNotLoaded"));
                return;
            }
            if (listBoxCtor.SelectedItem == null)
            {
                MessageBox.Show(Resource.FormatString("Wrn_CannotUseByteDataInputHelper_CtorNotSelected"));
                return;
            }
            ConstructorInfo ctor = GetConstructor(m_selectedAttributeType.GetConstructors(),
                                                  listBoxCtor.SelectedItem.ToString());

            if (ctor == null)
            {
                MessageBox.Show(Resource.FormatString("Wrn_CannotUseByteDataInputHelper_CtorNotFound",
                                                      listBoxCtor.SelectedItem.ToString(), m_selectedAttributeType.FullName));
                return;
            }
            foreach (ParameterInfo param in ctor.GetParameters())
            {
                if (!SupportParameterType(param.ParameterType))
                {
                    MessageBox.Show(Resource.FormatString("Wrn_CannotUseByteDataInputHelper_ParameterNotSupported",
                                                          param.ParameterType.Name));
                    return;
                }
            }
            try
            {
                this.textBoxByteValue.Text = GetFormatedBytes(this.textBoxByteValue.Text);
            }
            catch (Exception)
            {
                MessageBox.Show(Resource.FormatString("Wrn_InvalidByteData"));
                this.textBoxByteValue.Focus();
                return;
            }
            AddAttributeDataInputHelper dlg = new AddAttributeDataInputHelper(m_selectedAttributeType,
                                                                              ctor, textBoxByteValue.Text);

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                textBoxByteValue.Text = dlg.GetEncodingData();
            }
        }
 private void buttonDataInput_Click(object sender, EventArgs e)
 {
     if (m_selectedAttributeType == null)
     {
         MessageBox.Show(Resource.FormatString("Wrn_CannotUseByteDataInputHelper_TypeNotLoaded"));
         return;
     }
     if (listBoxCtor.SelectedItem == null)
     {
         MessageBox.Show(Resource.FormatString("Wrn_CannotUseByteDataInputHelper_CtorNotSelected"));
         return;
     }
     ConstructorInfo ctor = GetConstructor(m_selectedAttributeType.GetConstructors(),
         listBoxCtor.SelectedItem.ToString());
     if (ctor == null)
     {
         MessageBox.Show(Resource.FormatString("Wrn_CannotUseByteDataInputHelper_CtorNotFound",
             listBoxCtor.SelectedItem.ToString(), m_selectedAttributeType.FullName));
         return;
     }
     foreach (ParameterInfo param in ctor.GetParameters())
     {
         if (!SupportParameterType(param.ParameterType))
         {
             MessageBox.Show(Resource.FormatString("Wrn_CannotUseByteDataInputHelper_ParameterNotSupported",
                 param.ParameterType.Name));
             return;
         }
     }
     try
     {
         this.textBoxByteValue.Text = GetFormatedBytes(this.textBoxByteValue.Text);
     }
     catch (Exception)
     {
         MessageBox.Show(Resource.FormatString("Wrn_InvalidByteData"));
         this.textBoxByteValue.Focus();
         return;
     }
     AddAttributeDataInputHelper dlg = new AddAttributeDataInputHelper(m_selectedAttributeType,
         ctor, textBoxByteValue.Text);
     if (dlg.ShowDialog() == DialogResult.OK)
     {
         textBoxByteValue.Text = dlg.GetEncodingData();
     }
 }