Exemple #1
0
        private void addConnectionsToComboBox()
        {
            comboBoxServers.Items.Clear();
            ConnectionWrapperWithMoreStuff master = null;

            foreach (ConnectionWrapperWithMoreStuff wrappedConnection in connections)
            {
                wrappedConnection.Refresh();
                if (wrappedConnection.CanBeMaster)
                {
                    comboBoxServers.Items.Add(wrappedConnection);
                    if (wrappedConnection.WillBeMaster)
                    {
                        master = wrappedConnection;
                    }
                }
            }
            if (master != null)
            {
                comboBoxServers.SelectedItem = master;
            }
            else if (comboBoxServers.Items.Count > 0)
            {
                ConnectionWrapperWithMoreStuff defaultMaster = comboBoxServers.Items[0] as ConnectionWrapperWithMoreStuff;
                setAsMaster(defaultMaster);
                comboBoxServers.SelectedItem = defaultMaster;
            }
            addConnectionsToListBox();
            updateButtons();
        }
Exemple #2
0
        private void addConnectionsToListBox()
        {
            ConnectionWrapperWithMoreStuff master = (comboBoxServers.Items.Count > 0 ? (ConnectionWrapperWithMoreStuff)comboBoxServers.SelectedItem : null);

            foreach (ConnectionWrapperWithMoreStuff c in connections)
            {
                c.TheMaster = master;
                c.Refresh();
            }
            customTreeViewServers.BeginUpdate();
            try
            {
                customTreeViewServers.ClearAllNodes();
                foreach (ConnectionWrapperWithMoreStuff c in connections)
                {
                    customTreeViewServers.AddNode(c);
                }
                customTreeViewServers.Resort();
            }
            finally
            {
                customTreeViewServers.EndUpdate();
                customTreeViewServers.Invalidate();
            }
        }
Exemple #3
0
        private void setAsMaster(ConnectionWrapperWithMoreStuff defaultMaster)
        {
            foreach (ConnectionWrapperWithMoreStuff connectionWrapper in connections)
            {
                connectionWrapper.TheMaster = defaultMaster;
            }

            comboBoxServers.SelectedItem = defaultMaster;
            addConnectionsToListBox();
        }
Exemple #4
0
        private Host getMaster()
        {
            ConnectionWrapperWithMoreStuff connectionToMaster = null;

            foreach (ConnectionWrapperWithMoreStuff connection in connections)
            {
                if (connection.WillBeMaster)
                {
                    connectionToMaster = connection;
                    break;
                }
            }
            return(connectionToMaster != null?Helpers.GetMaster(connectionToMaster.Connection) : null);
        }
Exemple #5
0
        private void getAllCurrentConnections()
        {
            List <IXenConnection> toRemove = new List <IXenConnection>();

            foreach (IXenConnection connection in ConnectionsManager.XenConnectionsCopy)
            {
                if (connection != null && connection.IsConnected)
                {
                    bool contains = false;
                    foreach (ConnectionWrapperWithMoreStuff cw in connections)
                    {
                        if (cw.Connection == connection)
                        {
                            contains = true;
                            break;
                        }
                    }
                    if (!contains)
                    {
                        ConnectionWrapperWithMoreStuff c = new ConnectionWrapperWithMoreStuff(connection);
                        connections.Add(c);
                        connection.CachePopulated         -= Connection_CachePopulated;
                        connection.CachePopulated         += Connection_CachePopulated;
                        connection.ConnectionStateChanged -= connection_ConnectionStateChanged;
                        connection.ConnectionStateChanged += connection_ConnectionStateChanged;
                        if (newConnections.Contains(connection))
                        {
                            c.State = CheckState.Checked;
                            toRemove.Add(connection);
                        }
                    }
                }
            }
            foreach (IXenConnection connection in toRemove)
            {
                newConnections.Remove(connection);
            }
            connections.RemoveAll((Predicate <ConnectionWrapperWithMoreStuff>) delegate(ConnectionWrapperWithMoreStuff c)
            {
                return(!ConnectionsManager.XenConnectionsCopy.Contains(c.Connection));
            });
            addConnectionsToComboBox();
        }
Exemple #6
0
        private void setAsMaster(ConnectionWrapperWithMoreStuff defaultMaster)
        {
            foreach (ConnectionWrapperWithMoreStuff connectionWrapper in connections)
                connectionWrapper.TheMaster = defaultMaster;

            comboBoxServers.SelectedItem = defaultMaster;
            addConnectionsToListBox();
        }
Exemple #7
0
 private void getAllCurrentConnections()
 {
     List<IXenConnection> toRemove = new List<IXenConnection>();
     foreach (IXenConnection connection in ConnectionsManager.XenConnectionsCopy)
     {
         if (connection != null&&connection.IsConnected)
         {
             bool contains = false;
             foreach (ConnectionWrapperWithMoreStuff cw in connections)
             {
                 if (cw.Connection == connection)
                 {
                     contains = true;
                     break;
                 }
             }
             if (!contains)
             {
                 ConnectionWrapperWithMoreStuff c = new ConnectionWrapperWithMoreStuff(connection);
                 connections.Add(c);
                 connection.CachePopulated -= Connection_CachePopulated;
                 connection.CachePopulated += Connection_CachePopulated;
                 connection.ConnectionStateChanged -= connection_ConnectionStateChanged;
                 connection.ConnectionStateChanged += connection_ConnectionStateChanged;
                 if (newConnections.Contains(connection))
                 {
                     c.State = CheckState.Checked;
                     toRemove.Add(connection);
                 }
             }
         }
     }
     foreach (IXenConnection connection in toRemove)
     {
         newConnections.Remove(connection);
     }
     connections.RemoveAll((Predicate<ConnectionWrapperWithMoreStuff>)delegate(ConnectionWrapperWithMoreStuff c)
     {
         return !ConnectionsManager.XenConnectionsCopy.Contains(c.Connection);
     });
     addConnectionsToComboBox();
 }