示例#1
0
        private void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            //Create New RDP Object
            rdp      = null;
            rdp      = new AxMSTSCLib.AxMsTscAxNotSafeForScripting();
            rdp.Size = new Size(1430, this.Height - 80);

            //Get Selected Node
            TreeNode nodClicked  = e.Node;
            RDP      selectedRDP = repo.Find(x => x.serverName == nodClicked.Text);

            if (selectedRDP.serverIP == "-1")
            {
                return;
            }

            try
            {
                //Check if connection is already open
                foreach (TabPage t in rdpTabs.TabPages)
                {
                    if (t.Text == nodClicked.Text)
                    {
                        throw new InvalidConstraintException("connection is already up");
                    }
                }

                //Building the tab
                TabPage tab = new TabPage(selectedRDP.serverName);

                tab.Controls.Add(rdp);
                rdpTabs.TabPages.Add(tab);

                rdpTabs.SelectedIndex = rdpTabs.TabPages.Count - 1;
                IMsTscNonScriptable secured = (IMsTscNonScriptable)rdp.GetOcx();
                rdp.Server   = selectedRDP.serverIP;
                rdp.UserName = selectedRDP.username;
                secured.ClearTextPassword = selectedRDP.password;

                rdp.Connect();
            }
            catch (InvalidConstraintException x)
            {
                MessageBox.Show(x.Message, x.Message + " for " + selectedRDP.serverName, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch {}

            /*
             * try
             * {
             *  // Check if connected before disconnecting
             *  if (rdp.Connected.ToString() == "1")
             *      rdp.Disconnect();
             * }
             * catch (Exception Ex)
             * {
             *  MessageBox.Show("Error Disconnecting", "Error disconnecting from remote desktop " + txtServer.Text + " Error:  " + Ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
             * }
             */
        }
        public Window1()
        {
            InitializeComponent();

            // Create the host and the ActiveX control
            WindowsFormsHost host = new WindowsFormsHost();

            termServ = new AxMSTSCLib.AxMsTscAxNotSafeForScripting();

            // Add the ActiveX control to the host, and the host to the WPF panel
            host.Child = termServ;
            panel.Children.Add(host);
        }
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (PartidasAbiertas.Contains(listBox1.SelectedItem.ToString()))
            {
                AxMSTSCLib.AxMsTscAxNotSafeForScripting temp = (AxMSTSCLib.AxMsTscAxNotSafeForScripting)tabControl1.TabPages[tabControl1.TabPages.IndexOfKey(listBox1.SelectedItem.ToString())].Controls[0];
                temp.Disconnect();
                tabControl1.TabPages[tabControl1.TabPages.IndexOfKey(listBox1.SelectedItem.ToString())].Controls.Remove(temp);
                tabControl1.TabPages.RemoveByKey(listBox1.SelectedItem.ToString());
                PartidasAbiertas.Remove(listBox1.SelectedItem.ToString());
            }
            else
            {
                List <string> obj = Conexiones.FirstOrDefault(x => x.Key == listBox1.SelectedItem.ToString()).Value;

                CrearComponente(obj[0], obj[1], obj[2]);
                PartidasAbiertas.Add(listBox1.SelectedItem.ToString());
            }
        }
 public void CrearComponente(string ip, string pass, string user)
 {
     try
     {
         TabPage tabPage;
         AxMSTSCLib.AxMsTscAxNotSafeForScripting remoto;
         tabPage = new TabPage();
         remoto  = new AxMSTSCLib.AxMsTscAxNotSafeForScripting();
         ComponentResourceManager recursos = new System.ComponentModel.ComponentResourceManager(typeof(RemoteDesktopFH));
         ((System.ComponentModel.ISupportInitialize)(remoto)).BeginInit();
         tabPage.Controls.Add(remoto);
         tabPage.Location = new System.Drawing.Point(4, 22);
         tabPage.Name     = listBox1.SelectedItem.ToString();
         tabPage.Padding  = new System.Windows.Forms.Padding(3);
         tabPage.Size     = new System.Drawing.Size(900, 602);
         tabPage.TabIndex = 2;
         tabPage.Text     = listBox1.SelectedItem.ToString();
         tabPage.UseVisualStyleBackColor = true;
         //
         // RDP
         //
         remoto.Dock     = DockStyle.Fill;
         remoto.Enabled  = true;
         remoto.Location = new System.Drawing.Point(3, 3);
         remoto.Name     = "RDP";
         remoto.OcxState = ((System.Windows.Forms.AxHost.State)(recursos.GetObject("RDP.OcxState")));
         remoto.Size     = new System.Drawing.Size(894, 596);
         remoto.TabIndex = 0;
         this.tabControl1.Controls.Add(tabPage);
         ((System.ComponentModel.ISupportInitialize)(remoto)).EndInit();
         remoto.Server   = ip;
         remoto.UserName = user;
         MSTSCLib.IMsTscNonScriptable secured = (MSTSCLib.IMsTscNonScriptable)remoto.GetOcx();
         secured.ClearTextPassword = pass;
         remoto.Connect();
     }
     catch (Exception ex)
     {
     }
 }
示例#5
0
        private void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            //Create New RDP Object
            rdp=null;
            rdp = new AxMSTSCLib.AxMsTscAxNotSafeForScripting();
            rdp.Size = new Size(1430, this.Height-80);

            //Get Selected Node
            TreeNode nodClicked = e.Node;
            RDP selectedRDP = repo.Find(x => x.serverName == nodClicked.Text);
            if (selectedRDP.serverIP == "-1")
                return;

            try
            {
                //Check if connection is already open
                foreach (TabPage t in rdpTabs.TabPages)
                    if (t.Text == nodClicked.Text)
                        throw new InvalidConstraintException("connection is already up");

                //Building the tab
                TabPage tab = new TabPage(selectedRDP.serverName);

                tab.Controls.Add(rdp);
                rdpTabs.TabPages.Add(tab);

                rdpTabs.SelectedIndex = rdpTabs.TabPages.Count - 1;
                IMsTscNonScriptable secured = (IMsTscNonScriptable)rdp.GetOcx();
                rdp.Server = selectedRDP.serverIP;
                rdp.UserName = selectedRDP.username;
                secured.ClearTextPassword = selectedRDP.password;

                rdp.Connect();
            }
            catch (InvalidConstraintException x)
            {
                MessageBox.Show(x.Message, x.Message + " for " + selectedRDP.serverName, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch{}
            /*
            try
            {
                // Check if connected before disconnecting
                if (rdp.Connected.ToString() == "1")
                    rdp.Disconnect();
            }
            catch (Exception Ex)
            {
                MessageBox.Show("Error Disconnecting", "Error disconnecting from remote desktop " + txtServer.Text + " Error:  " + Ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            */
        }