/// <summary>
 ///
 /// </summary>
 /// <param name="resultOutputControl"></param>
 /// <param name="speedTestForm"></param>
 public SpeedTestsInput
 (
     Control resultOutputControl,
     SpeedTestForm speedTestForm)
 {
     this.MethodsInputs       = new List <SpeedTestInput>( );
     this.ResultOutputControl = resultOutputControl;
     this.SpeedTestForm       = speedTestForm;
 }
        /// <summary>
        ///
        /// </summary>
        public SpeedTestForm
        (
            [CanBeNull] string speedTestExecutable,
            [CanBeNull] List <string> speedTestProgrammFilesList
        )
        {
            this.InitializeComponent( );
            this.OnExecutableFinish += this.WatchDog;

            var settings = Properties.Settings.Default;

            if (settings != null)
            {
                this.SpeedTestType = settings.UseSerialSpeedTestType
                            ? SpeedTestInput.TestType.Serial
                            : SpeedTestInput.TestType.Parallel;

                switch (this.SpeedTestType)
                {
                case SpeedTestInput.TestType.Parallel:

                    SpeedTestForm.SpeedTestProgramArguments =
                        SpeedTestForm.InitializeWithString
                        (
                            settings,
                            settings.SpeedTestProgramParallelTypeArguments,
                            SpeedTestForm.C_IperfWithParallelTestArguments
                        );
                    break;

                case SpeedTestInput.TestType.Serial:
                    SpeedTestForm.SpeedTestProgramArguments =
                        SpeedTestForm.InitializeWithString
                        (
                            settings,
                            settings.SpeedTestProgramSerialTypeArguments,
                            SpeedTestForm.C_IperfWithSerialTestArguments
                        );

                    break;

                default:
                    goto case SpeedTestInput.TestType.Parallel;
                }
            }

            this.SpeedTestProgram = new ProcessExecuteParameters
                                    (
                speedTestExecutable,
                SpeedTestForm.SpeedTestProgramArguments,
                speedTestProgrammFilesList
                                    );
        }
 /// <summary>
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void DoTestSpeedButton_Click
 (
     object sender,
     EventArgs e)
 {
     SpeedTestForm.ViewSpeedTestResult
     (
         this.SpeedTestResulTextBox,
         this.DoTestSpeedButton,
         this.DoCloseButton,
         this.TestingProcessProgressBar,
         this
     );
 }
 /// <summary>
 /// </summary>
 private void PerformSpeedTest( )
 {
     if (this._initializeComplete)
     {
         if (Handler.SpeedTestProgram != null)
         {
             var speedTestForm = new SpeedTestForm
                                 (
                 Handler.SpeedTestProgram.ExecutableFile,
                 Handler.SpeedTestProgram.ProgramsFiles);
             speedTestForm.ShowDialog(this);
         }
     }
 }
 /// <summary>
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void SpeedTestForm_Shown
 (
     object sender,
     EventArgs e)
 {
     if (this._resultShown)
     {
         return;
     }
     this._resultShown = true;
     SpeedTestForm.ViewSpeedTestResult
     (
         this.SpeedTestResulTextBox,
         this.DoTestSpeedButton,
         this.DoCloseButton,
         this.TestingProcessProgressBar,
         this
     );
 }
        /// <summary>
        /// </summary>
        /// <param name="speedTestResultTextBox"></param>
        /// <param name="doTestSpeedButton"></param>
        /// <param name="doCloseButton"></param>
        /// <param name="testingProcessProgressBar"></param>
        /// <param name="outputForm"></param>
        private static void ViewSpeedTestResult
        (
            [CanBeNull] Control speedTestResultTextBox,
            [CanBeNull] Button doTestSpeedButton,
            [CanBeNull] Button doCloseButton,
            [CanBeNull] ProgressBar testingProcessProgressBar,
            [CanBeNull] SpeedTestForm outputForm
        )
        {
            if ((outputForm != null) &&
                (speedTestResultTextBox != null))
            {
                speedTestResultTextBox.Text = Handler.TestingNetworkSpeed;
                speedTestResultTextBox.Refresh( );

                var startControl = doTestSpeedButton;
                var stopControl  = doCloseButton;
                var progressBar  = testingProcessProgressBar;

                Handler.DisableStarProgressStopControls
                (
                    startControl
                    , stopControl
                    , progressBar
                );

                var networkAdaptersParameters =
                    Handler.GetNetworkAdaptersParameters( );
                {
                    var interfacesNumber = networkAdaptersParameters.Count;

                    if (interfacesNumber <= 0)
                    {
                        speedTestResultTextBox.Text =
                            Handler.DisconnectOrInvalidConnection;
                        var onOnExecutableFinish = outputForm.OnExecutableFinish;
                        onOnExecutableFinish?.Invoke( );
                    }
                    else
                    {
                        var progressControl = testingProcessProgressBar;
                        if (progressControl != null)
                        {
                            progressControl.Value = progressControl.Minimum;
                        }

                        var testParameters = new SpeedTestsInput
                                             (
                            speedTestResultTextBox,
                            outputForm);

                        testParameters.MethodsInputs?.Add
                        (
                            new SpeedTestInput
                        {
                            Program =
                                outputForm.SpeedTestProgram,
                            SpeedTestType = outputForm.SpeedTestType
                        });

                        var testConnectionThread = new Thread(SpeedTestForm.GetSpeedTestResult);
                        testConnectionThread.Start(testParameters);
                    }
                }
            }
        }