Example #1
0
        /////////////////////////////////////////////////////////////////////
        // Read user parameters
        /////////////////////////////////////////////////////////////////////
        private TestParam ReadScreen()
        {
            TestParam Param = new TestParam();

            Param.Type = TypeComboBox.SelectedIndex;
            Param.Host = HostTextBox.Text.Trim();
            int.TryParse(PortTextBox.Text.Trim(), out Param.Port);
            Param.UserName     = UserNameTextBox.Text.Trim();
            Param.UserPassword = UserPasswordTextBox.Text.Trim();
            Param.RefreshToken = RefreshTokenTextBox.Text.Trim();
            int.TryParse(TimeoutTextBox.Text.Trim(), out Param.Timeout);
            Param.FromName    = FromNameTextBox.Text.Trim();
            Param.FromAddress = FromAddressTextBox.Text.Trim();
            Param.ToName      = ToNameTextBox.Text.Trim();
            Param.ToAddress   = ToAddressTextBox.Text.Trim();

            if (TestParamArray == null)
            {
                TestParamArray    = new TestParam[1];
                TestParamArray[0] = Param;
            }
            else
            {
                int Index;
                for (Index = 0; Index < TestParamArray.Length && Param.CompareTo(TestParamArray[Index]) != 0; Index++)
                {
                    ;
                }
                if (Index == 0)
                {
                    return(Param);
                }

                List <TestParam> TestParamList = new List <TestParam>(TestParamArray);
                if (Index < TestParamArray.Length)
                {
                    TestParamList.RemoveAt(Index);
                }
                TestParamList.Insert(0, Param);
                if (TestParamList.Count > 20)
                {
                    TestParamList.RemoveRange(20, TestParamList.Count - 20);
                }
                TestParamArray = TestParamList.ToArray();
            }
            TestParam.SaveTestParam(TestParamArray, TestParamFileName);
            NextButton.Enabled     = true;
            PreviousButton.Enabled = true;
            ScrollIndex            = 0;
            return(Param);
        }