Beispiel #1
0
 public Host(HostInfo info, Config config, PuttyProfile profile)
 {
     Info       = info;
     _config    = config;
     _profile   = profile;
     _puttyLink = new PuttyLink(Info, config, profile);
 }
        public OptionsDialog(PuttyProfile puttyProfile)
        {
            InitializeComponent();

            PuttyProfile = puttyProfile;

            buttonApply.Enabled = false;

            checkGroupBoxAutoRestart.Checked           = Settings.Default.Config_RestartEnabled;
            numericUpDownRestartDelay.Value            = Settings.Default.Config_RestartDelay;
            numericUpDownMaxAttemptsCount.Value        = Settings.Default.Config_MaxAttemptsCount;
            radioButtonMakeDelay.Checked               = Settings.Default.Config_AfterMaxAttemptsMakeDelay;
            checkBoxTraceDebug.Checked                 = Settings.Default.Config_TraceDebug;
            checkGroupBoxRestartHostsWithWarns.Checked = Settings.Default.Config_RestartHostsWithWarnings;
            numericUpDownRestartHWWInterval.Value      = Settings.Default.Config_RestartHostsWithWarningsInterval;
            chbxRunAtWindowsStartup.Checked            = Settings.Default.Config_RunAtWindowsStartup;
            chbxStartHostsBeingActiveLastTime.Checked  = Settings.Default.Config_StartHostsBeingActiveLastTime;
            if (PuttyProfile != null)
            {
                checkBoxLocalPortAcceptAll.Checked  = PuttyProfile.LocalPortAcceptAll;
                checkBoxRemotePortAcceptAll.Checked = PuttyProfile.RemotePortAcceptAll;
                checkGroupBoxProxy.Checked          = PuttyProfile.ProxyMethod != PuttyProfile.ProxyType.None;
                comboBoxProxyType.SelectedIndex     = PuttyProfile.ProxyMethod == PuttyProfile.ProxyType.Http ? 0
                    : PuttyProfile.ProxyMethod == PuttyProfile.ProxyType.Socks4 ? 1
                    : PuttyProfile.ProxyMethod == PuttyProfile.ProxyType.Socks5 ? 2
                    : 0;
                textBoxHostname.Text           = PuttyProfile.ProxyHost;
                textBoxPort.Text               = PuttyProfile.ProxyPort.ToString();
                textBoxUsername.Text           = PuttyProfile.ProxyUsername;
                textBoxPassword.Text           = PuttyProfile.ProxyPassword;
                checkBoxAuthReq.Checked        = !string.IsNullOrEmpty(PuttyProfile.ProxyUsername);
                checkBoxProxyLocalhost.Checked = PuttyProfile.ProxyLocalhost;
                textBoxProxyExcludes.Text      = PuttyProfile.ProxyExcludeList;
            }
            else
            {
                checkBoxLocalPortAcceptAll.Enabled  = false;
                checkBoxRemotePortAcceptAll.Enabled = false;
                checkGroupBoxProxy.Enabled          = false;
            }

            _validator = new Validator(theErrorProvider);
            _validator.AddControl(textBoxHostname, validateHostname);
            _validator.AddControl(textBoxPort, validatePort);
            _validator.AddControl(textBoxUsername, validateUsername);
            _validator.AddControl(textBoxPassword, validatePassword);

            var controls = new List <Control>();

            collectControls(Controls, ref controls);
            foreach (var textBox in controls.OfType <TextBox>())
            {
                textBox.TextChanged += controlChanged;
            }
            foreach (var textBox in controls.OfType <CheckBox>())
            {
                textBox.CheckedChanged += controlChanged;
            }
            foreach (var textBox in controls.OfType <RadioButton>())
            {
                textBox.CheckedChanged += controlChanged;
            }
            foreach (var textBox in controls.OfType <ComboBox>())
            {
                textBox.SelectedIndexChanged += controlChanged;
            }
            foreach (var textBox in controls.OfType <CheckGroupBox>())
            {
                textBox.CheckedChanged += controlChanged;
            }
            foreach (var textBox in controls.OfType <NumericUpDown>())
            {
                textBox.ValueChanged += controlChanged;
            }
        }