Exemple #1
0
        private void CallByOrdinalButton_Click(object sender, EventArgs e)
        {
            if (ModuleNameTextBox.Text.Equals(string.Empty) || OrdinalTextBox.Text.Equals(string.Empty))
            {
                MessageBox.Show("Error", "Please enter a module name and ordinal value!");
                return;
            }

            string moduleName    = ModuleNameTextBox.Text;
            int    ordinalNumber = OrdinalTextBox.Text.Contains("0x") ? Convert.ToInt32(OrdinalTextBox.Text, 16) : Convert.ToInt32(OrdinalTextBox.Text, 10);

            if (CallByOrdinalReturnTypeComboBox.Text.Equals(string.Empty))
            {
                MessageBox.Show("Error", "Please select a return type before calling the function!");
                return;
            }

            try {
                if (CallByOrdinalReturnTypeComboBox.SelectedIndex == 0)
                {
                    xbCon.ExecuteRPC <Int64>(XDRPCMode.System, moduleName, ordinalNumber, GetParameters());
                    ByOridinalReturnValueTextBox.Text = "No Return";
                }
                else if (CallByOrdinalReturnTypeComboBox.SelectedIndex == 1)
                {
                    Int64 returnVal = xbCon.ExecuteRPC <Int64>(XDRPCMode.System, moduleName, ordinalNumber, GetParameters());
                    ByOridinalReturnValueTextBox.Text = "0x" + returnVal.ToString("X");
                }
                else if (CallByOrdinalReturnTypeComboBox.SelectedIndex == 2)
                {
                    string returnVal = xbCon.CallString(moduleName, ordinalNumber, GetParameters());
                    ByOridinalReturnValueTextBox.Text = returnVal;
                }
                else if (CallByOrdinalReturnTypeComboBox.SelectedIndex == 3)
                {
                    float returnVal = xbCon.ExecuteRPC <float>(XDRPCMode.System, moduleName, ordinalNumber, GetParameters());
                    ByOridinalReturnValueTextBox.Text = returnVal.ToString();
                }
            }
            catch {
                MessageBox.Show("Error", "Make sure you have set values and types for all parameters being used!");
            }
        }