Пример #1
0
        private void InitUI()
        {
            for (int i = 1; i <= GApp.Options.SerialCount; i++)
            {
                _portBox.Items.Add(String.Format("COM{0}", i));
            }

            StringCollection c = GApp.ConnectionHistory.LogPaths;

            foreach (string p in c)
            {
                _logFileBox.Items.Add(p);
            }

            if (GApp.Options.DefaultLogType != LogType.None)
            {
                _logTypeBox.SelectedIndex = (int)GApp.Options.DefaultLogType;
                string t = GUtil.CreateLogFileName(null);
                _logFileBox.Items.Add(t);
                _logFileBox.Text = t;
            }
            else
            {
                _logTypeBox.SelectedIndex = 0;
            }

            AdjustUI();
        }
Пример #2
0
        private void InitializeLoginParams()
        {
            StringCollection c = _history.Hosts;

            foreach (string h in c)
            {
                _hostBox.Items.Add(h);
            }
            if (_hostBox.Items.Count > 0)
            {
                _hostBox.SelectedIndex = 0;
            }

            c = _history.Accounts;
            foreach (string a in c)
            {
                _userNameBox.Items.Add(a);
            }
            if (_userNameBox.Items.Count > 0)
            {
                _userNameBox.SelectedIndex = 0;
            }

            int[] ic = _history.Ports;
            foreach (int p in ic)
            {
                _portBox.Items.Add(PortDescription(p));
            }

            if (_hostBox.Items.Count > 0)
            {
                TCPTerminalParam last = _history.SearchByHost((string)_hostBox.Items[0]);
                if (last != null)
                {
                    ApplyParam(last);
                }
            }

            c = _history.LogPaths;
            foreach (string p in c)
            {
                _logFileBox.Items.Add(p);
            }

            if (GApp.Options.DefaultLogType != LogType.None)
            {
                _logTypeBox.SelectedIndex = (int)GApp.Options.DefaultLogType;
                string t = GUtil.CreateLogFileName(null);
                _logFileBox.Items.Add(t);
                _logFileBox.Text = t;
            }
            else
            {
                _logTypeBox.SelectedIndex = 0;
            }
        }
Пример #3
0
        private void InitUI()
        {
            _hostBox.Text   = _terminalParam.Host;
            _methodBox.Text = _terminalParam.Method.ToString();
            if (_terminalParam.Port != 22)
            {
                _methodBox.Text += String.Format(GApp.Strings.GetString("Caption.SSHShortcutLoginDialog.NotStandardPort"), _terminalParam.Port);
            }
            _accountBox.Text  = _terminalParam.Account;
            _authTypeBox.Text = EnumDescAttributeT.For(typeof(AuthType)).GetDescription(_terminalParam.AuthType);
            _encodingBox.Text = EnumDescAttributeT.For(typeof(EncodingType)).GetDescription(_terminalParam.EncodingProfile.Type);

            if (_terminalParam.AuthType == AuthType.Password)
            {
                _privateKeyBox.Enabled    = false;
                _privateKeySelect.Enabled = false;
            }
            else if (_terminalParam.AuthType == AuthType.PublicKey)
            {
                _privateKeyBox.Text = _terminalParam.IdentityFile;
            }
            else if (_terminalParam.AuthType == AuthType.KeyboardInteractive)
            {
                _privateKeyBox.Enabled    = false;
                _privateKeySelect.Enabled = false;
                _passphraseBox.Enabled    = false;
            }

            _passphraseBox.Text = _terminalParam.Passphrase;

            StringCollection c = GApp.ConnectionHistory.LogPaths;

            foreach (string p in c)
            {
                _logFileBox.Items.Add(p);
            }

            if (GApp.Options.DefaultLogType != LogType.None)
            {
                _logTypeBox.SelectedIndex = (int)GApp.Options.DefaultLogType;
                string t = GUtil.CreateLogFileName(_terminalParam.Host);
                _logFileBox.Items.Add(t);
                _logFileBox.Text = t;
            }
            else
            {
                _logTypeBox.SelectedIndex = 0;
            }

            AdjustUI();
        }
Пример #4
0
        private SerialTerminalParam ValidateParam()
        {
            SerialTerminalParam p = new SerialTerminalParam();

            try {
                p.LogType = (LogType)EnumDescAttributeT.For(typeof(LogType)).FromDescription(_logTypeBox.Text, LogType.None);
                if (p.LogType != LogType.None)
                {
                    p.LogPath = _logFileBox.Text;
                    if (p.LogPath == GUtil.CreateLogFileName(null))
                    {
                        p.LogPath = GUtil.CreateLogFileName(String.Format("com{0}", _portBox.SelectedIndex + 1));
                    }
                    LogFileCheckResult r = GCUtil.CheckLogFileName(p.LogPath, this);
                    if (r == LogFileCheckResult.Cancel || r == LogFileCheckResult.Error)
                    {
                        return(null);
                    }
                    p.LogAppend = (r == LogFileCheckResult.Append);
                }

                p.Port        = _portBox.SelectedIndex + 1;
                p.BaudRate    = Int32.Parse(_baudRateBox.Text);
                p.ByteSize    = (byte)(_dataBitsBox.SelectedIndex == 0? 7 : 8);
                p.StopBits    = (StopBits)_stopBitsBox.SelectedIndex;
                p.Parity      = (Parity)_parityBox.SelectedIndex;
                p.FlowControl = (FlowControl)_flowControlBox.SelectedIndex;

                p.EncodingProfile = EncodingProfile.Get((EncodingType)_encodingBox.SelectedIndex);

                p.LocalEcho  = _localEchoBox.SelectedIndex == 1;
                p.TransmitNL = (NewLine)EnumDescAttributeT.For(typeof(NewLine)).FromDescription(_newLineBox.Text, LogType.None);

                p.TransmitDelayPerChar = Int32.Parse(_transmitDelayPerCharBox.Text);
                p.TransmitDelayPerLine = Int32.Parse(_transmitDelayPerLineBox.Text);
                return(p);
            }
            catch (Exception ex) {
                GUtil.Warning(this, ex.Message);
                return(null);
            }
        }
Пример #5
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            if (_param == null)
            {
                _param = new CygwinTerminalParam();                 //デフォルト値で埋める
            }
            else
            {
                _param = (LocalShellTerminalParam)_param.Clone();
            }
            _param.RenderProfile = null;
            _param.Caption       = null;

            _homeDirectoryBox.Text = _param.Home;
            _shellBox.Text         = _param.Shell;

            StringCollection c = GApp.ConnectionHistory.LogPaths;

            foreach (string p in c)
            {
                _logFileBox.Items.Add(p);
            }

            if (GApp.Options.DefaultLogType != LogType.None)
            {
                _logTypeBox.SelectedIndex = (int)GApp.Options.DefaultLogType;
                string t = GUtil.CreateLogFileName("cygwin");
                _logFileBox.Items.Add(t);
                _logFileBox.Text = t;
            }
            else
            {
                _logTypeBox.SelectedIndex = 0;
            }

            AdjustUI();
        }
Пример #6
0
        //入力内容に誤りがあればそれを警告してnullを返す。なければ必要なところを埋めたTCPTerminalParamを返す
        private TCPTerminalParam ValidateContent()
        {
            string           msg = null;
            TCPTerminalParam p   = null;
            SSHTerminalParam sp  = null;

            try {
                ConnectionMethod m = ParseMethod(_methodBox.Text);
                if (m == ConnectionMethod.Telnet)
                {
                    p = new TelnetTerminalParam("");
                }
                else
                {
                    p          = sp = new SSHTerminalParam(ConnectionMethod.SSH2, "", "", "");
                    sp.Method  = m;
                    sp.Account = _userNameBox.Text;
                }

                p.Host = _hostBox.Text;
                try {
                    p.Port = ParsePort(_portBox.Text);
                }
                catch (FormatException ex) {
                    msg = ex.Message;
                }

                if (_hostBox.Text.Length == 0)
                {
                    msg = GApp.Strings.GetString("Message.LoginDialog.HostIsEmpty");
                }

                p.LogType = (LogType)EnumDescAttributeT.For(typeof(LogType)).FromDescription(_logTypeBox.Text, LogType.None);

                if (p.LogType != LogType.None)
                {
                    p.LogPath = _logFileBox.Text;
                    if (p.LogPath == GUtil.CreateLogFileName(null))
                    {
                        p.LogPath = GUtil.CreateLogFileName(_hostBox.Text);
                    }
                    LogFileCheckResult r = GCUtil.CheckLogFileName(p.LogPath, this);
                    if (r == LogFileCheckResult.Cancel || r == LogFileCheckResult.Error)
                    {
                        return(null);
                    }
                    p.LogAppend = (r == LogFileCheckResult.Append);
                }

                if (p.IsSSH)
                {
                    Debug.Assert(sp != null);
                    sp.AuthType = (AuthType)_authOptions.SelectedIndex;
                    if (sp.AuthType == AuthType.PublicKey)
                    {
                        if (!File.Exists(_privateKeyFile.Text))
                        {
                            msg = GApp.Strings.GetString("Message.LoginDialog.KeyFileNotExist");
                        }
                        else
                        {
                            sp.IdentityFile = _privateKeyFile.Text;
                        }
                    }
                }
                p.EncodingProfile = EncodingProfile.Get((EncodingType)_encodingBox.SelectedIndex);

                p.LocalEcho    = _localEchoBox.SelectedIndex == 1;
                p.TransmitNL   = (NewLine)EnumDescAttributeT.For(typeof(NewLine)).FromDescription(_newLineBox.Text, NewLine.CR);
                p.TerminalType = (TerminalType)_terminalTypeBox.SelectedIndex;

                if (msg != null)
                {
                    ShowError(msg);
                    return(null);
                }
                else
                {
                    return(p);
                }
            }
            catch (Exception ex) {
                GUtil.Warning(this, ex.Message);
                return(null);
            }
        }