예제 #1
0
        public Favorites(MainForm.ConnectionDelegate connectionDelegate, SecureString password)
        {
            _connectionDelegate = connectionDelegate;
            _password = password;

            if (File.Exists(_favoritesFileName))
            {
                XmlDocument favorites = new XmlDocument();
                favorites.Load(_favoritesFileName);

                _rootFolder.Favorites.Clear();
                _rootFolder.ChildFolders.Clear();

                InitializeTreeView(favorites.SelectSingleNode("/favorites"), _rootFolder);
            }
        }
예제 #2
0
        public HistoryWindow(MainForm.ConnectionDelegate connectionDelegate, Favorites favoritesWindow, SecureString password)
        {
            _connectionDelegate = connectionDelegate;
            _favoritesWindow = favoritesWindow;
            _password = password;

            InitializeComponent();

            if (File.Exists(_historyFileName))
            {
                XmlDocument history = new XmlDocument();
                history.Load(_historyFileName);

                foreach (XmlNode node in history.SelectNodes("/history/connection"))
                {
                    HistoricalConnection historyEntry = new HistoricalConnection(node, _password);
                    TreeNode newTreeNode = new TreeNode((String.IsNullOrEmpty(historyEntry.Name) ? historyEntry.Host : historyEntry.Name), 2, 2);

                    if (historyEntry.LastConnection.DayOfYear == DateTime.Now.DayOfYear && historyEntry.LastConnection.Year == DateTime.Now.Year)
                        AddTreeNode(historyTreeView.Nodes[0].Nodes[0].Nodes, newTreeNode);

                    else if (historyEntry.LastConnection.DayOfYear == DateTime.Now.DayOfYear - 1 && historyEntry.LastConnection.Year == DateTime.Now.Year)
                        AddTreeNode(historyTreeView.Nodes[0].Nodes[1].Nodes, newTreeNode);

                    else if (historyEntry.LastConnection.DayOfYear >= DateTime.Now.DayOfYear - (int)DateTime.Now.DayOfWeek && historyEntry.LastConnection.Year == DateTime.Now.Year)
                        AddTreeNode(historyTreeView.Nodes[0].Nodes[2].Nodes, newTreeNode);

                    else if (historyEntry.LastConnection.Month == DateTime.Now.Month && historyEntry.LastConnection.Year == DateTime.Now.Year)
                        AddTreeNode(historyTreeView.Nodes[0].Nodes[3].Nodes, newTreeNode);

                    else if (historyEntry.LastConnection.Year == DateTime.Now.Year)
                        AddTreeNode(historyTreeView.Nodes[0].Nodes[4].Nodes, newTreeNode);

                    else
                        continue;

                    _connections[newTreeNode] = historyEntry;
                }
            }
        }
예제 #3
0
        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;
                }
            }
        }