Пример #1
0
        public void Open(DbItemRemoteLink linkSettings, DbItemSetting itemSetting, bool jump)
        {
            _itemRemoteLink = linkSettings;
            if (linkSettings.Password == null)
            {
                linkSettings.Password = "";
            }

            Title = linkSettings.Name;
            Window mainWindow = Application.Current.MainWindow;

            Width  = linkSettings.ExternalWindowWidth > MinWidth ? linkSettings.ExternalWindowWidth : mainWindow.Width;
            Height = linkSettings.ExternalWindowHeight > MinHeight ? linkSettings.ExternalWindowHeight : mainWindow.Height;

            try
            {
                Show();
                FinalItemSetting finalItemSetting = null;
                if (linkSettings.Type == (int)RemoteType.rdp)
                {
                    _remoteControl   = new RemoteControl_rdp(this);
                    finalItemSetting = new FinalItemSetting_rdp((DbItemSetting_rdp)itemSetting);
                }
                if (linkSettings.Type == (int)RemoteType.ssh)
                {
                    _remoteControl   = new RemoteControl_ssh(this);
                    finalItemSetting = new FinalItemSetting_ssh((DbItemSetting_ssh)itemSetting);
                }
                if (linkSettings.Type == (int)RemoteType.telnet)
                {
                    _remoteControl   = new RemoteControl_telnet(this);
                    finalItemSetting = new FinalItemSetting_telnet((DbItemSetting_telnet)itemSetting);
                }
                if (_remoteControl == null)
                {
                    throw new Exception("可能是不支持的远程连接类型。");
                }
                _remoteControl.Visibility  = Visibility.Collapsed;
                Panel_Animation.Visibility = Visibility.Visible;
                Grid.Children.Add(_remoteControl);

                _remoteControl.OnConnected  = _remoteControl_OnConnected;
                _remoteControl.OnFatalError = OnFatalError;
                _remoteControl.OnNonfatal   = OnNonfatal;
                _remoteControl.Closed       = Remove;
                _remoteControl.FullScreen   = FullScreen;

                _remoteControl.Connect(linkSettings, finalItemSetting);
                _startFullScreen = finalItemSetting.FullScreen;
            }
            catch (Exception e)
            {
                OnFatalError("错误", $"远程桌面连接失败。\n原因:{e.Message}");
            }
        }
Пример #2
0
        public void Open(DbItemRemoteLink linkSettings, DbItemSetting itemSetting, bool jump)
        {
            _tabItem = MainWindow.AddTabItem(linkSettings.Name, this, jump);
            if (linkSettings.Password == null)
            {
                linkSettings.Password = "";
            }
            _tabItem.Closed = _tabItem_Closed;

            try
            {
                FinalItemSetting finalItemSetting = null;
                if (linkSettings.Type == (int)RemoteType.rdp)
                {
                    _remoteControl   = new RemoteControl_rdp(this);
                    finalItemSetting = new FinalItemSetting_rdp((DbItemSetting_rdp)itemSetting);
                }
                if (linkSettings.Type == (int)RemoteType.ssh)
                {
                    _remoteControl   = new RemoteControl_ssh(this);
                    finalItemSetting = new FinalItemSetting_ssh((DbItemSetting_ssh)itemSetting);
                }
                if (linkSettings.Type == (int)RemoteType.telnet)
                {
                    _remoteControl   = new RemoteControl_telnet(this);
                    finalItemSetting = new FinalItemSetting_telnet((DbItemSetting_telnet)itemSetting);
                }
                if (_remoteControl == null)
                {
                    throw new Exception("可能是不支持的远程连接类型。");
                }
                _remoteControl.Visibility  = Visibility.Collapsed;
                Panel_Animation.Visibility = Visibility.Visible;
                Grid.Children.Add(_remoteControl);

                _remoteControl.OnConnected  = _remoteControl_OnConnected;
                _remoteControl.OnFatalError = OnFatalError;
                _remoteControl.OnNonfatal   = OnNonfatal;
                _remoteControl.Closed       = Remove;
                _remoteControl.FullScreen   = FullScreen;

                _remoteControl.Connect(linkSettings, finalItemSetting);
                _startFullScreen = finalItemSetting.FullScreen;
            }
            catch (Exception e)
            {
                OnFatalError("错误", $"远程桌面连接失败。\n原因:{e.Message}");
            }
        }