/// <summary>
        /// An event handler called when the state of a server connection has changed.
        /// </summary>
        /// <param name="sender">The sender object.</param>
        /// <param name="e">The event arguments.</param>
        void OnServerStateChanged(object sender, DbServerStateEventArgs e)
        {
            // Execute the code on the UI thread.
            this.Invoke(() =>
                {
                    // If there are no controls for this server, ignore the event.
                    if (!this.items.ContainsKey(e.Server.Id)) return;

                    // Get the controls corresponding to this server.
                    ServerControls controls = this.items[e.Server.Id];

                    // Update the list view item.
                    controls.Item.SubItems[2].Text = e.Server.State.ToString();
                    controls.Item.SubItems[3].Text = e.Server.Version;
                    controls.Item.ImageKey = ControlServersSql.imageKeys[(int)e.Server.State];

                    // Update the tree node.
                    controls.Node.ImageKey = ControlServersSql.imageKeys[(int)e.Server.State];
                    controls.Node.SelectedImageKey = ControlServersSql.imageKeys[(int)e.Server.State];

                    // Call the selected item change event to update the buttons.
                    this.OnServerSelectionChanged(this, e);
                });
        }
 /// <summary>
 /// An event handler called when the server state has changed.
 /// </summary>
 /// <param name="sender">The sender object.</param>
 /// <param name="e">The event arguments.</param>
 private void OnServerStateChanged(object sender, DbServerStateEventArgs e)
 {
     // Update the control state.
     this.control.StateChanged(e.Server);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// An event handler called when the state of a server connection has changed.
 /// </summary>
 /// <param name="sender">The sender object.</param>
 /// <param name="e">The event arguments.</param>
 private void OnServerStateChanged(object sender, DbServerStateEventArgs e)
 {
     // Execute the code on the UI thread.
     this.Invoke(() =>
         {
             this.buttonConnect.Enabled =
                 (this.server.State == DbServerSql.ServerState.Disconnected) ||
                 (this.server.State == DbServerSql.ServerState.Failed);
             this.buttonDisconnect.Enabled = this.server.State == DbServerSql.ServerState.Connected;
             this.buttonChangePassword.Enabled =
                 (this.server.State == DbServerSql.ServerState.Disconnected) ||
                 (this.server.State == DbServerSql.ServerState.Failed);
             this.pictureBox.Image = ControlServerSql.images[(int)this.server.State];
             this.tabControl.Enabled =
                 (this.server.State != DbServerSql.ServerState.Connecting) &&
                 (this.server.State != DbServerSql.ServerState.Disconnecting);
         });
 }
 // Private methods.
 /// <summary>
 /// An event handler called when the state of a server connection has changed.
 /// </summary>
 /// <param name="sender">The sender object.</param>
 /// <param name="e">The event arguments.</param>
 private void OnServerStateChanged(object sender, DbServerStateEventArgs e)
 {
     // Execute the code on the UI thread.
     this.Invoke(() =>
         {
             this.buttonConnect.Enabled =
                 (this.server.State == DbServerSql.ServerState.Disconnected) ||
                 (this.server.State == DbServerSql.ServerState.Failed);
             this.buttonDisconnect.Enabled = this.server.State == DbServerSql.ServerState.Connected;
         });
 }