Ejemplo n.º 1
0
        public RemoteControl_ssh(ContentControl contentControl)
            : base(contentControl)
        {
            InitializeComponent();

            try
            {
                _putty               = new Putty();
                _event_error         = Error_Event;
                _event_securityAlert = SecurityAlert_Event;
                _event_connected     = Connected_Event;
                _event_verifyhostkey = VerifyHostKey_Event;
                _event_storehostkey  = StoreHostKey_Event;
                _event_keydown       = KeyDown_Event;
                _event_mousemove     = MouseMove_Event;
                _event_debug         = Debug_Event;

                _putty.SetCallback(_event_error, _event_connected, _event_securityAlert, _event_verifyhostkey,
                                   _event_storehostkey, _event_keydown, _event_mousemove, _event_debug);
                if (!_putty.Init())
                {
                    string errorText = Marshal.PtrToStringAnsi(_putty.GetError());
                    throw new Exception(errorText);
                }
            }
            catch (Exception e)
            {
                throw new Exception($"加载putty失败,{e.Message}。");
            }
        }
        public RemoteControl_telnet(ContentControl contentControl)
            : base(contentControl)
        {
            InitializeComponent();
            try
            {
                _putty           = new Putty();
                _event_error     = Error_Event;
                _event_connected = Connected_Event;
                _event_keydown   = KeyDown_Event;
                _event_mousemove = MouseMove_Event;
                _event_debug     = OnDebug;

                _putty.SetCallback(_event_error, _event_connected, null, null, null, _event_keydown, _event_mousemove, _event_debug);
                if (!_putty.Init())
                {
                    string errorText = Marshal.PtrToStringAnsi(_putty.GetError());
                    throw new Exception(errorText);
                }
            }
            catch (Exception e)
            {
                throw new Exception($"加载putty失败,{e.Message}。");
            }
        }