Beispiel #1
0
        private void BtnStartStopEncode_Click(object sender, RoutedEventArgs e)
        {
            if (lstFilesToEncode.Count != 0)
            {
                if (!bCurrentlyEncoding)
                {
                    strPassword = string.Empty;
                    PasswordPrompt passPrompt = new PasswordPrompt();
                    if (passPrompt.ShowDialog().Value)
                    {
                        strPassword = passPrompt.strPassword;
                    }
                    else
                    {
                        passPrompt = null;
                        return;
                    }
                    passPrompt = null;

                    selectedPreset         = (Preset)comboPresets.SelectedValue;
                    comboPresets.IsEnabled = false;

                    btnStartStopEncode.Content = "STOP";
                    btnBack.IsEnabled          = false;
                    workerEncode = new BackgroundWorker();
                    workerEncode.WorkerReportsProgress      = true;
                    workerEncode.WorkerSupportsCancellation = true;
                    workerEncode.DoWork             += worker_DoEncode;
                    workerEncode.ProgressChanged    += worker_ProgressChanged;
                    workerEncode.RunWorkerCompleted += worker_EncodeCompleted;
                    workerEncode.RunWorkerAsync();
                }
                else if (bCurrentlyEncoding)
                {
                    btnBack.IsEnabled      = true;
                    comboPresets.IsEnabled = true;
                    workerEncode.CancelAsync();
                }
            }
        }
        /// <summary> Tests IP address (ping with 10s timeout) </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnTestIP_Click(object sender, RoutedEventArgs e)
        {
            string         password   = string.Empty;
            PasswordPrompt passPrompt = new PasswordPrompt();

            if (passPrompt.ShowDialog().Value)
            {
                password = passPrompt.strPassword;
            }
            else
            {
                passPrompt = null;
                return;
            }
            passPrompt = null;
            try
            {
                using (var testClient = new SshClient(xmlConfig.PlexIP, xmlConfig.Username, password))
                {
                    testClient.ConnectionInfo.Timeout = TimeSpan.FromSeconds(10);
                    testClient.Connect();
                    if (testClient.IsConnected)
                    {
                        MessageBox.Show("Connection was successful", "SUCCESS", MessageBoxButton.OK);
                        testClient.Disconnect();
                        return;
                    }
                    else
                    {
                        MessageBox.Show("Test Connection Failed", "CONNECTION FAILED", MessageBoxButton.OK);
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($"ERROR \n Test Connection Failed: {ex.Message}", "ERROR (CONNECTION FAILED)", MessageBoxButton.OK);
            }
        }