Esempio n. 1
0
        public void ApplyParam(IAdaptable destination, ITerminalSettings terminal)
        {
            _initializing = true;
            Debug.Assert(destination != null);
            Debug.Assert(terminal != null);
            this.TerminalSettings = terminal.Clone();

            ITCPParameter      tcp_destination = (ITCPParameter)destination.GetAdapter(typeof(ITCPParameter));
            ISSHLoginParameter ssh_destination = (ISSHLoginParameter)destination.GetAdapter(typeof(ISSHLoginParameter));
            bool is_telnet = ssh_destination == null;

            _methodBox.SelectedIndex = is_telnet? 0 : ssh_destination.Method == SSHProtocol.SSH1? 1 : 2;
            _portBox.SelectedIndex   = _portBox.FindStringExact(PortDescription(tcp_destination.Port));
            if (ssh_destination != null)
            {
                _userNameBox.SelectedIndex = _userNameBox.FindStringExact(ssh_destination.Account);
                _passphraseBox.Text        = ssh_destination.PasswordOrPassphrase;

                if (ssh_destination.AuthenticationType == AuthenticationType.PublicKey)
                {
                    _privateKeyFile.Text = ssh_destination.IdentityFileName;
                }
                else
                {
                    _privateKeyFile.Text = "";
                }
                _authOptions.SelectedIndex = ToAuthenticationIndex(ssh_destination.AuthenticationType);
            }

            IAutoExecMacroParameter autoExecParams = destination.GetAdapter(typeof(IAutoExecMacroParameter)) as IAutoExecMacroParameter;

            if (autoExecParams != null && TelnetSSHPlugin.Instance.MacroEngine != null)
            {
                _autoExecMacroPathBox.Text = (autoExecParams.AutoExecMacroPath != null) ? autoExecParams.AutoExecMacroPath : String.Empty;
            }
            else
            {
                _autoExecMacroPathLabel.Enabled    = false;
                _autoExecMacroPathBox.Enabled      = false;
                _selectAutoExecMacroButton.Enabled = false;
            }

            _encodingBox.SelectedIndex     = (int)terminal.Encoding;
            _newLineBox.SelectedIndex      = (int)terminal.TransmitNL;
            _localEchoBox.SelectedIndex    = terminal.LocalEcho? 1 : 0;
            _terminalTypeBox.SelectedIndex = (int)terminal.TerminalType;
            _initializing = false;

            EnableValidControls();
        }
Esempio n. 2
0
        public override object FindElement(string id, IAdaptable source)
        {
            XNode node = source.GetAdapter <XNode>(typeof(XNode));

            if (node == null)
            {
                node = this.GetWorkbookElement();
            }
            return(GetAdaptableRegistry()
                   .GetAdaptable(id, node.Document));
        }
Esempio n. 3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="obj"></param>
 /// <returns></returns>
 public static ICommandTarget AsCommandTarget(IAdaptable obj)
 {
     if (obj == null)
     {
         return(null);
     }
     else
     {
         return((ICommandTarget)obj.GetAdapter(typeof(ICommandTarget)));
     }
 }
Esempio n. 4
0
        public static void FireConnectionFailure(IAdaptable param, string msg)
        {
            ITerminalParameter t = (ITerminalParameter)param.GetAdapter(typeof(ITerminalParameter));

            Debug.Assert(t != null);
            if (ProtocolsPlugin.Instance != null)
            {
                foreach (IConnectionResultEventHandler h in ProtocolsPlugin.Instance.ConnectionResultEventHandler.GetExtensions())
                {
                    h.OnFailed(t, msg);
                }
            }
        }
Esempio n. 5
0
        //“à•”‚Å‚ÍITCPParameter‚©ICygwinParameter‚Ì‚Ç‚Á‚¿‚©‚µ‚©ŒÄ‚΂ê‚È‚¢‚Í‚¸
        public static void FireConnectionSucceeded(IAdaptable param)
        {
            ITerminalParameter t = (ITerminalParameter)param.GetAdapter(typeof(ITerminalParameter));

            Debug.Assert(t != null);
            if (ConsoleMain.Instance != null)
            {
                foreach (IConnectionResultEventHandler h in ProtocolsPlugin.Instance.ConnectionResultEventHandler.GetExtensions())
                {
                    h.OnSucceeded(t);
                }
            }
        }
Esempio n. 6
0
        public void AllocateTabToControl(TabKey key, Control target)
        {
            IAdaptable ad = target as IAdaptable;

            if (ad == null)
            {
                return;
            }

            IPoderosaView view = (IPoderosaView)ad.GetAdapter(typeof(IPoderosaView));

            if (view == null)
            {
                return;
            }

            SessionManagerPlugin.Instance.AttachDocumentAndView(KeyToDocument(key), view);
        }
Esempio n. 7
0
        /// <summary>
        /// Converts a reference to the given type by first trying a CLR cast, and then
        /// trying to get an adapter</summary>
        /// <typeparam name="T">Desired type, must be ref type</typeparam>
        /// <param name="adaptable">Adaptable object</param>
        /// <returns>Converted reference for the given object or null</returns>
        public static T As <T>(this IAdaptable adaptable)
            where T : class
        {
            if (adaptable == null)
            {
                return(null);
            }

            // try a normal cast
            var converted = adaptable as T;

            // if that fails, try to get an adapter
            if (converted == null)
            {
                converted = adaptable.GetAdapter(typeof(T)) as T;
            }

            return(converted);
        }
Esempio n. 8
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="obj"></param>
 /// <returns></returns>
 public static ICommandTarget AsCommandTarget(IAdaptable obj)
 {
     if (obj == null)
         return null;
     else
         return (ICommandTarget)obj.GetAdapter(typeof(ICommandTarget));
 }
Esempio n. 9
0
 public Entry(int i, IAdaptable c)
 {
     index       = i;
     content     = c;
     designation = (IPositionDesignation)c.GetAdapter(typeof(IPositionDesignation));
 }
Esempio n. 10
0
 //内部ではITCPParameterかICygwinParameterのどっちかしか呼ばれないはず
 public static void FireConnectionSucceeded(IAdaptable param)
 {
     ITerminalParameter t = (ITerminalParameter)param.GetAdapter(typeof(ITerminalParameter));
     Debug.Assert(t != null);
     if (ProtocolsPlugin.Instance != null) {
         foreach (IConnectionResultEventHandler h in ProtocolsPlugin.Instance.ConnectionResultEventHandler.GetExtensions()) {
             h.OnSucceeded(t);
         }
     }
 }
Esempio n. 11
0
        public void ApplyParam(IAdaptable destination, ITerminalSettings terminal) {
            _initializing = true;
            Debug.Assert(destination != null);
            Debug.Assert(terminal != null);
            this.TerminalSettings = terminal.Clone();

            ITCPParameter tcp_destination = (ITCPParameter)destination.GetAdapter(typeof(ITCPParameter));
            ISSHLoginParameter ssh_destination = (ISSHLoginParameter)destination.GetAdapter(typeof(ISSHLoginParameter));
            bool is_telnet = ssh_destination == null;

            _methodBox.SelectedItem =
                is_telnet ? ConnectionMethod.Telnet :
                    ssh_destination.Method == SSHProtocol.SSH1 ? ConnectionMethod.SSH1 : ConnectionMethod.SSH2; // select ListItem<T> by T
            _portBox.SelectedIndex = _portBox.FindStringExact(PortDescription(tcp_destination.Port));
            if (ssh_destination != null) {
                _userNameBox.SelectedIndex = _userNameBox.FindStringExact(ssh_destination.Account);
                _passphraseBox.Text = ssh_destination.PasswordOrPassphrase;

                if (ssh_destination.AuthenticationType == AuthenticationType.PublicKey)
                    _privateKeyFile.Text = ssh_destination.IdentityFileName;
                else
                    _privateKeyFile.Text = "";
                _authOptions.SelectedItem = ToAuthType(ssh_destination.AuthenticationType); // select EnumListItem<T> by T
            }

            IAutoExecMacroParameter autoExecParams = destination.GetAdapter(typeof(IAutoExecMacroParameter)) as IAutoExecMacroParameter;
            if (autoExecParams != null && TelnetSSHPlugin.Instance.MacroEngine != null) {
                _autoExecMacroPathBox.Text = (autoExecParams.AutoExecMacroPath != null) ? autoExecParams.AutoExecMacroPath : String.Empty;
            }
            else {
                _autoExecMacroPathLabel.Enabled = false;
                _autoExecMacroPathBox.Enabled = false;
                _selectAutoExecMacroButton.Enabled = false;
            }

            if (is_telnet) {
                ITelnetParameter telnetParams = (ITelnetParameter)destination.GetAdapter(typeof(ITelnetParameter));
                _telnetNewLine.Checked = (telnetParams != null) ? telnetParams.TelnetNewLine : true;
            }
            else {
                _telnetNewLine.Checked = true;
            }

            _encodingBox.SelectedItem = terminal.Encoding;              // select EnumListItem<T> by T
            _newLineBox.SelectedItem = terminal.TransmitNL;             // select EnumListItem<T> by T
            _localEchoBox.SelectedItem = terminal.LocalEcho;            // select ListItem<T> by T
            _terminalTypeBox.SelectedItem = terminal.TerminalType;      // select EnumListItem<T> by T
            _initializing = false;

            EnableValidControls();
        }