Example #1
0
        //Start remote desktop
        private void btnRemoteDesktop_Click(object sender, EventArgs e)
        {
            try
            {
                if (lbConnectedClients.SelectedItems.Count < 0)
                {
                    MessageBox.Show("Please select a client!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                int ConnectionId = CurrentSelectedID;
                if (RDActive)
                {
                    MessageBox.Show("Remote desktop is already active!", "Error", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    return;
                }

                if (bwUpdateImage.IsBusy)
                {
                    return;
                }
                RDActive = true;
                MainServer.Send(ConnectionId, Encoding.ASCII.GetBytes("StartRD"));
                RDC = new RDC();
                RDC.ConnectionID = ConnectionId;
                RDC.Text         = "Remote Desktop Viewer - " + ConnectionId;
                RDC.Show();
                bwUpdateImage.RunWorkerAsync();
            }
            catch
            {
            }
        }
        public void NewRDC()
        {
            RDC rdc = _rdcInstanceManager.CreateNew();

            RDCs.Add(rdc);

            SelectedRDC = rdc;

            RDCSelected();
        }
 private void frm_RemoteDesktop_Load(object sender, EventArgs e)
 {
     try
     {
         this.Cursor  = Cursors.WaitCursor;
         RDC.Server   = "server";
         RDC.UserName = frm_Home.Username + "\\" + frm_RDCInput.user.ToString();
         IMsTscNonScriptable secured = (IMsTscNonScriptable)RDC.GetOcx();
         secured.ClearTextPassword = frm_RDCInput.password.ToString();
         RDC.Connect();
         this.Cursor = Cursors.Default;
     }
     catch (Exception E)
     {
         MessageBox.Show(E.ToString());
     }
 }
        protected override void OnActivate()
        {
            RDCGroups = new ObservableCollection <RDCGroup>(_rdcGroupManager.GetGroups());
            RDCGroups.Insert(0, new RDCGroup()
            {
                Name = "All", Id = Guid.NewGuid()
            });
            RDCGroups.Insert(1, new RDCGroup()
            {
                Name = "None", Id = Guid.Empty
            });

            var rdcs = _rdcInstanceManager.GetRDCs()
                       .OrderBy(x => _rdcGroups.FirstOrDefault(y => y.Id == x.GroupId)?.Name ?? "None");

            RDCs = new ObservableCollection <RDC>(rdcs);

            SelectedRDCGroup = RDCGroups.First();

            _groupView = CollectionViewSource.GetDefaultView(_rdcs);
            _groupView.GroupDescriptions.Add(new PropertyGroupDescription("GroupId", new GroupIdToNameConverter(_rdcGroups)));
            _groupView.Filter += (item) =>
            {
                RDC rdc = item as RDC;

                if (!_rdcGroups.Any(x => x.Id == rdc.GroupId))
                {
                    rdc.GroupId = Guid.Empty;
                }

                if ((rdc.GroupId == Guid.Empty && SelectedRDCGroup.Name == "None") ||
                    SelectedRDCGroup.Name == "All" ||
                    rdc.GroupId == SelectedRDCGroup.Id)
                {
                    return(true);
                }

                return(false);
            };
        }