Exemple #1
0
 private void init()
 {
     this.m_rdpview = new AxMSTSCLib.AxMsRdpClient8NotSafeForScripting();
     ((System.ComponentModel.ISupportInitialize)(this.m_rdpview)).BeginInit();
     this.m_rdpview.Enabled = true;
     this.m_rdpview.CreateControl();
     this.m_rdpview.OnConnecting    += new System.EventHandler(this.m_rdpview_OnConnecting);
     this.m_rdpview.OnConnected     += new System.EventHandler(this.m_rdpview_OnConnected);
     this.m_rdpview.OnLoginComplete += new System.EventHandler(this.m_rdpview_OnLoginComplete);
     this.m_rdpview.OnFatalError    += new AxMSTSCLib.IMsTscAxEvents_OnFatalErrorEventHandler(this.m_rdpview_OnFatalError);
     this.m_rdpview.OnWarning       += new AxMSTSCLib.IMsTscAxEvents_OnWarningEventHandler(this.m_rdpview_OnWarning);
     this.m_rdpview.OnAuthenticationWarningDisplayed += new System.EventHandler(this.m_rdpview_OnAuthenticationWarningDisplayed);
     this.m_rdpview.OnAuthenticationWarningDismissed += new System.EventHandler(this.m_rdpview_OnAuthenticationWarningDismissed);
     this.m_rdpview.OnLogonError += new AxMSTSCLib.IMsTscAxEvents_OnLogonErrorEventHandler(this.m_rdpview_OnLogonError);
     ((System.ComponentModel.ISupportInitialize)(this.m_rdpview)).EndInit();
 }
Exemple #2
0
        /// <summary>
        /// 节点双击连接远程服务器
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            try
            {
                if (e.Node.Level == 2)
                {
                    if (this.tabControl1.Controls.Find(e.Node.Name, true).Count() > 0)
                    {
                        MessageBox.Show("请不要重复连接", null, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    TabPage tp = new TabPage();
                    tp.Name = e.Node.Name;
                    tp.Text = e.Node.Text;
                    tp.UseVisualStyleBackColor = true;
                    tp.Height = this.tabControl1.Height - 20;
                    tp.Width  = this.tabControl1.Width - 20;

                    this.tabControl1.Controls.Add(tp);
                    this.tabControl1.SelectedTab = tp;
                    AxMSTSCLib.AxMsRdpClient8NotSafeForScripting rdpc = new AxMSTSCLib.AxMsRdpClient8NotSafeForScripting();
                    rdpc.Dock = DockStyle.Fill;
                    tp.Controls.Add(rdpc);
                    var currentServer = DataHelper.CurrentData.Servers.Where(p => p.ServerGuid == e.Node.Name).FirstOrDefault();
                    rdpc.Server   = currentServer.Ip;                                   //远程桌面的IP地址或者域名
                    rdpc.Domain   = currentServer.Domain;                               //远程服务器所在的域
                    rdpc.UserName = currentServer.UserName;                             //系统用户名
                    rdpc.AdvancedSettings2.ClearTextPassword = currentServer.Password;  //系统登录密码
                    rdpc.AdvancedSettings2.RDPPort           = 3389;
                    rdpc.AdvancedSettings2.RedirectDrives    = true;
                    rdpc.AdvancedSettings2.RedirectPrinters  = true;
                    rdpc.ConnectingText = "正在连接.....";
                    rdpc.ColorDepth     = 24;
                    rdpc.Name           = e.Node.Name;
                    rdpc.Connect();
                    rdpcArry.Add(rdpc);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, null, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }