public ConnectionWindow(Favorites favorites, RDCConnection connection, MainForm.ConnectionDelegate connectionDelegate, SecureString password) { InitializeComponent(); _connection = connection; _favorites = favorites; _connectionDelegate = connectionDelegate; _password = password; keyboardDropdown.SelectedIndex = 1; rdcImage.Parent = gradientBackground; rdcLabel1.Parent = gradientBackground; rdcLabel2.Parent = gradientBackground; DEVMODE devMode = new DEVMODE(); int modeNumber = 0; while (DisplayHelper.EnumDisplaySettings(null, modeNumber, ref devMode) > 0) { if (!_resolutions.Exists((DEVMODE d) => d.dmPelsWidth == devMode.dmPelsWidth && d.dmPelsHeight == devMode.dmPelsHeight)) _resolutions.Add(devMode); modeNumber++; } resolutionTrackBar.Maximum = _resolutions.Count; resolutionTrackBar.Value = _resolutions.Count; if (connection != null) { hostBox.Text = connection.Host; usernameTextBox.Text = connection.Username; passwordTextBox.SecureText = (connection.Password == null ? new SecureString() : connection.Password.Copy()); keyboardDropdown.SelectedIndex = (int)connection.KeyboardMode; printersCheckBox.Checked = connection.ConnectPrinters; clipboardCheckBox.Checked = connection.ConnectClipboard; drivesCheckBox.Checked = connection.ConnectDrives; desktopBackgroundCheckBox.Checked = connection.DesktopBackground; fontSmoothingCheckBox.Checked = connection.FontSmoothing; desktopCompositionCheckBox.Checked = connection.DesktopComposition; windowContentsCheckBox.Checked = connection.WindowContentsWhileDragging; animationCheckBox.Checked = connection.Animations; visualStylesCheckBox.Checked = connection.VisualStyles; bitmapCachingCheckBox.Checked = connection.PersistentBitmapCaching; if (connection.AudioMode == AudioMode.Remotely) playRemotelyRadioButton.Checked = true; else if (connection.AudioMode == AudioMode.None) dontPlayRadioButton.Checked = true; int resolutionIndex = _resolutions.FindIndex((DEVMODE d) => d.dmPelsWidth == connection.DesktopWidth && d.dmPelsHeight == connection.DesktopHeight); if (resolutionIndex != -1) resolutionTrackBar.Value = resolutionIndex; switch (connection.ColorDepth) { case 15: colorDepthDropdown.SelectedIndex = 0; break; case 16: colorDepthDropdown.SelectedIndex = 1; break; case 24: colorDepthDropdown.SelectedIndex = 2; break; case 32: colorDepthDropdown.SelectedIndex = 3; break; } } }
protected void Connect(RDCConnection connection) { _history.AddToHistory(connection); RDCWindow sessionWindow = new RDCWindow(_password); _addingWindow = true; Tabs.Add(new TitleBarTab(this) { Content = sessionWindow }); _addingWindow = false; sessionWindow.FormClosing += sessionWindow_FormClosing; sessionWindow.Connected += sessionWindow_Connected; sessionWindow.Connect(connection); TabbedThumbnail preview = new TabbedThumbnail(Handle, sessionWindow); preview.Title = sessionWindow.Text; preview.Tooltip = sessionWindow.Text; preview.SetWindowIcon(sessionWindow.Icon); preview.TabbedThumbnailActivated += new EventHandler<TabbedThumbnailEventArgs>(preview_TabbedThumbnailActivated); preview.TabbedThumbnailClosed += new EventHandler<TabbedThumbnailEventArgs>(preview_TabbedThumbnailClosed); preview.TabbedThumbnailBitmapRequested += new EventHandler<TabbedThumbnailBitmapRequestedEventArgs>(preview_TabbedThumbnailBitmapRequested); preview.PeekOffset = new Vector(sessionWindow.Location.X, sessionWindow.Location.Y); for (Control currentControl = sessionWindow.Parent; currentControl.Parent != null; currentControl = currentControl.Parent) preview.PeekOffset += new Vector(currentControl.Location.X, currentControl.Location.Y); TaskbarManager.Instance.TabbedThumbnail.AddThumbnailPreview(preview); TaskbarManager.Instance.TabbedThumbnail.SetActiveTab(preview); if (_recentConnections.FirstOrDefault((HistoryWindow.HistoricalConnection c) => c.Guid == connection.Guid) == null) { _recentCategory.AddJumpListItems(new JumpListLink(Application.ExecutablePath, sessionWindow.Text) { Arguments = "/openHistory:" + connection.Guid.ToString(), IconReference = new IconReference(Application.ExecutablePath, 0) }); _jumpList.Refresh(); _recentConnections.Enqueue(_history.Connections.First((HistoryWindow.HistoricalConnection c) => c.Guid == connection.Guid)); if (_recentConnections.Count > _jumpList.MaxSlotsInList) _recentConnections.Dequeue(); } }
private void connectButton_Click(object sender, EventArgs e) { RDCConnection newConnection = new RDCConnection(_password) { Name = _connection.Name }; _connection = newConnection; SaveConnection(); _connectionDelegate(_connection); Close(); }
public void Connect(RDCConnection connection) { DesktopWidth = (connection.DesktopWidth == 0 ? ClientSize.Width - borderLeft.Width - borderRight.Width : connection.DesktopWidth); DesktopHeight = (connection.DesktopHeight == 0 ? ClientSize.Height - borderBottom.Height - toolbarBackground.Height : connection.DesktopHeight); AudioMode = connection.AudioMode; KeyboardMode = connection.KeyboardMode; ConnectPrinters = connection.ConnectPrinters; ConnectClipboard = connection.ConnectClipboard; ConnectDrives = connection.ConnectDrives; DesktopBackground = connection.DesktopBackground; FontSmoothing = connection.FontSmoothing; DesktopComposition = connection.DesktopComposition; WindowContentsWhileDragging = connection.WindowContentsWhileDragging; Animations = connection.Animations; VisualStyles = connection.VisualStyles; PersistentBitmapCaching = connection.PersistentBitmapCaching; if (!String.IsNullOrEmpty(connection.Username)) Username = connection.Username; if (connection.Password != null && connection.Password.Length > 0) Password = connection.Password; Host = connection.Host; Text = (String.IsNullOrEmpty(connection.Name) ? connection.Host : connection.Name); urlTextBox.Text = connection.Host; _connection = connection; Connect(); }
public void AddToHistory(RDCConnection connection) { TreeNode connectionNode = FindConnectionNode(historyTreeView.Nodes, connection); HistoricalConnection historyEntry = new HistoricalConnection(connection, _password); if (connectionNode != null) { if (!String.IsNullOrEmpty(_connections[connectionNode].Name) && String.IsNullOrEmpty(connection.Name)) historyEntry.Name = _connections[connectionNode].Name; } historyEntry.LastConnection = DateTime.Now; if (FindConnectionNode(historyTreeView.Nodes[0].Nodes[0].Nodes, connection) == null) { if (connectionNode != null) { _connections.Remove(connectionNode); connectionNode.Remove(); } TreeNode newTreeNode = new TreeNode((String.IsNullOrEmpty(historyEntry.Name) ? historyEntry.Host : historyEntry.Name), 2, 2); AddTreeNode(historyTreeView.Nodes[0].Nodes[0].Nodes, newTreeNode); _connections[newTreeNode] = historyEntry; } else if (connectionNode != null) { TreeNode newTreeNode = new TreeNode((String.IsNullOrEmpty(historyEntry.Name) ? historyEntry.Host : historyEntry.Name), 2, 2); _connections.Remove(connectionNode); connectionNode.Remove(); AddTreeNode(historyTreeView.Nodes[0].Nodes[0].Nodes, newTreeNode); _connections[newTreeNode] = historyEntry; } Save(); }
public HistoricalConnection(RDCConnection connection, SecureString encryptionPassword) { Host = connection.Host; Username = connection.Username; DesktopWidth = connection.DesktopWidth; DesktopHeight = connection.DesktopHeight; ColorDepth = connection.ColorDepth; Name = connection.Name; IsFavorite = connection.IsFavorite; AudioMode = connection.AudioMode; KeyboardMode = connection.KeyboardMode; ConnectPrinters = connection.ConnectPrinters; ConnectClipboard = connection.ConnectClipboard; ConnectDrives = connection.ConnectDrives; DesktopBackground = connection.DesktopBackground; FontSmoothing = connection.FontSmoothing; DesktopComposition = connection.DesktopComposition; WindowContentsWhileDragging = connection.WindowContentsWhileDragging; Animations = connection.Animations; VisualStyles = connection.VisualStyles; PersistentBitmapCaching = connection.PersistentBitmapCaching; Password = connection.Password; Guid = connection.Guid; EncryptionPassword = encryptionPassword; }
protected TreeNode FindConnectionNode(TreeNodeCollection searchNodes, RDCConnection connection) { foreach (TreeNode node in searchNodes) { if (node.ImageIndex != 2) { TreeNode foundNode = FindConnectionNode(node.Nodes, connection); if (foundNode != null) return foundNode; } else { if (connection.Host == _connections[node].Host) return node; } } return null; }