Ejemplo n.º 1
0
 private void cbServer_SelectedIndexChanged(object sender, EventArgs e)
 {
     this._selected_server = this.cbServer.SelectedItem as ServerInfo;
 }
Ejemplo n.º 2
0
 private void btnSet_Click(object sender, EventArgs e)
 {
     try
     {
         ServerInfo si;
         if (this._adding)
             si = new ServerInfo("", 0, "", false);
         else
             si = this._selected;
         si.Host = this.tbHost.Text;
         if (si.Host == "")
             throw new HostFieldEmpty();
         si.Port = UInt16.Parse(this.tbPort.Text);
         if (si.Port == 0)
             throw new OverflowException();
         si.Name = this.tbName.Text;
         if (this._adding)
         {
             this.btnAdd.Enabled = true;
             this._adding = false;
             this._servers.Add(si);
             this._selected = si;
         }
         this.UpdateItems();
         this.SelectServer(si);
     }
     catch (FormatException)
     {
         MessageBox.Show("Please enter valid port value");
         this.tbPort.Focus();
     }
     catch (OverflowException)
     {
         MessageBox.Show("Please enter valid port value");
         this.tbPort.Focus();
     }
     catch (HostFieldEmpty)
     {
         MessageBox.Show("Host field can not be empty");
         this.tbHost.Focus();
     }
     catch (Exception exc)
     {
         this._main_form.Log.PostHead("Exception", "Server set, exc: " + exc);
         MessageBox.Show(exc.Message);
     }
 }
Ejemplo n.º 3
0
 void SelectServer(ServerInfo server)
 {
     if (server == null)
     {
         this.tbHost.Text = "";
         this.tbHost.Enabled = false;
         this.tbPort.Text = "";
         this.tbPort.Enabled = false;
         this.tbName.Text = "";
         this.tbName.Enabled = false;
         this.btnRemove.Enabled = false;
         this.btnSet.Enabled = false;
     } else
     {
         this.tbHost.Enabled = !server.ReadOnly;
         this.tbPort.Enabled = !server.ReadOnly;
         this.tbName.Enabled = !server.ReadOnly;
         this.btnSet.Enabled = !server.ReadOnly;
         this.btnRemove.Enabled = !server.ReadOnly;
         this.tbHost.Text = server.Host;
         this.tbPort.Text = server.Port.ToString();
         this.tbName.Text = server.Name;
     }
 }
Ejemplo n.º 4
0
 public ServersConfigForm(MainForm main_form, ServerInfo[] servers)
 {
     InitializeComponent();
     this._main_form = main_form;
     this._servers = new List<ServerInfo>(servers);
 }
Ejemplo n.º 5
0
 private void lbServers_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (this._adding)
     {
         this.btnAdd.Enabled = true;
         this._adding = false;
     }
     this._selected = this.lbServers.SelectedItem as ServerInfo;
     this.SelectServer(this._selected);
 }