Example #1
0
        private void btnAddServer_Click(object sender, EventArgs e)
        {
            // Get list of unique categories.
            string[] categories = _remoteServers
                                  .Select(server => server.Category)
                                  .Where(cat => !string.IsNullOrWhiteSpace(cat))
                                  .Distinct()
                                  .ToArray();

            var editDlg = new ServerConnEditor();

            editDlg.Init(categories, _remoteServers.Select(svr => svr.HostName), null);
            editDlg.ShowConnectButton = true;

            if (editDlg.ShowDialog() == DialogResult.OK)
            {
                var newRemoteServer = new RemoteServer(editDlg.NewServer);
                serverTree1.BeginUpdate();
                serverTree1.AddServerToTree(newRemoteServer, changeMasterList: true);
                serverTree1.EndUpdate();

                // Ask the user if he wants to connect to the new server.

                if (editDlg.DoConnect)
                {
                    serverTree1.SelectedServer = newRemoteServer;
                }
            }
        }
Example #2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            var editDlg = new ServerConnEditor();

            editDlg.Init(GetUniqueCategories(), GetDisplayNames(null), null);
            editDlg.ShowConnectButton = false;

            if (editDlg.ShowDialog() == DialogResult.OK)
            {
                AddServerItem(editDlg.NewServer);
                btnOK.Enabled = true;
            }
        }
Example #3
0
        void mnuEdit_Click(object sender, EventArgs e)
        {
            var  node              = contextMenuForServers.Tag as TreeNode;
            var  server            = node.Tag as RemoteServer;
            bool isUnderAllServers = node.Parent == _allNode;
            bool isSelectedServer  = server == SelectedServer;
            var  editableServer    = server.MakeSavedServer();
            var  dlg = new ServerConnEditor();

            // Get list of unique categories.
            string[] categories = _masterServerList
                                  .Select(svr => svr.Category)
                                  .Where(cat => !string.IsNullOrWhiteSpace(cat))
                                  .Distinct()
                                  .ToArray();

            var otherServers = _masterServerList.Where(svr => svr != server).Select(svr => svr.HostName);

            dlg.Init(categories, otherServers, editableServer, allowAddressEdit: !isSelectedServer);
            dlg.ShowConnectButton = !isSelectedServer;

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                // User may have changed the "display name" and/or category, both
                // of which affect the server's location in the tree.  The easiest way
                // to handle this is to remove the old server and replace it with the
                // new one. Note that we can be editing the currently SelectedServer.

                _ignoreSelectionEvents = true;

                RemoveServerFromTree(server);
                server.InitFromSavedServer(editableServer);
                AddServerToTree(server);
                SaveRemoteServers();

                // If we just edited, removed, and re-added the current SelectedServer, we must also re-select its TreeNode.

                if (isSelectedServer)
                {
                    SelectNodeForServer(server, forceAllServers: isUnderAllServers);
                }

                _ignoreSelectionEvents = false;

                if (dlg.DoConnect)
                {
                    SelectNodeForServer(server, forceAllServers: false);
                }
            }
        }
Example #4
0
        private void EditServerForItem(ServerListItem item)
        {
            var editDlg = new ServerConnEditor();

            editDlg.Init(GetUniqueCategories(), GetDisplayNames(item), item.Server);
            editDlg.ShowConnectButton = false;

            if (editDlg.ShowDialog() == DialogResult.OK)
            {
                item.SubItems[colDispName.Index].Text = item.Server.HostName;
                item.SubItems[colAddress.Index].Text  = item.Server.HostAndPort;
                item.SubItems[colCategory.Index].Text = item.Server.Category;
                item.SubItems[colUserID.Index].Text   = item.Server.UserId;

                btnOK.Enabled = true;
            }
        }