Exemplo n.º 1
0
        private void HostsCB_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                if (HostsCB.SelectedIndex != 0)
                {
                    if (m_HostSelected != null)
                    {
                        m_HostSelected(this, new SelectHostCtrlEventArgs((string)HostsCB.SelectedItem));
                    }

                    m_selectedIndex = HostsCB.SelectedIndex;
                    return;
                }

                if (!m_selectDomains)
                {
                    // prompt user to select a host.
                    string hostname = new HostListDlg().ShowDialog(null);

                    if (hostname == null)
                    {
                        HostsCB.SelectedIndex = m_selectedIndex;
                        return;
                    }

                    // set the current selection.
                    m_selectedIndex = HostsCB.FindString(hostname);

                    if (m_selectedIndex == -1)
                    {
                        m_selectedIndex = HostsCB.Items.Add(hostname);
                    }
                }

                HostsCB.SelectedIndex = m_selectedIndex;
            }
            catch (Exception exception)
            {
                GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception);
            }
        }
Exemplo n.º 2
0
        private void HostsCB_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {   
                if (HostsCB.SelectedIndex != 0)
                {
                    if (m_HostSelected != null)
                    {
                        m_HostSelected(this, new SelectHostCtrlEventArgs((string)HostsCB.SelectedItem));
                    }

                    m_selectedIndex = HostsCB.SelectedIndex;
                    return;
                }

                if (!m_selectDomains)
                {
                    // prompt user to select a host.
                    string hostname = new HostListDlg().ShowDialog(null);

                    if (hostname == null)
                    {
                        HostsCB.SelectedIndex = m_selectedIndex;
                        return;
                    }
                    
                    // set the current selection.
                    m_selectedIndex = HostsCB.FindString(hostname);

                    if (m_selectedIndex == -1)
                    {
                        m_selectedIndex = HostsCB.Items.Add(hostname);
                    }
                }
                
                HostsCB.SelectedIndex = m_selectedIndex;
            }
            catch (Exception exception)
            {
				GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception);
            }
        }