private void m_pTabGeneral_SmartHosts_Toolbar_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            if (e.ClickedItem.Tag == null)
            {
            }
            else if (e.ClickedItem.Tag.ToString() == "add")
            {
                wfrm_System_SmartHost frm = new wfrm_System_SmartHost();
                if (frm.ShowDialog(this) == DialogResult.OK)
                {
                    ListViewItem it = new ListViewItem();
                    it.Text = frm.Host;
                    it.SubItems.Add(frm.Port.ToString());
                    it.SubItems.Add(frm.SslMode.ToString());
                    it.SubItems.Add(frm.UserName);
                    it.Tag = new Relay_SmartHost(frm.Host, frm.Port, frm.SslMode, frm.UserName, frm.Password);
                    m_pTabGeneral_SmartHosts.Items.Add(it);
                }
            }
            else if (e.ClickedItem.Tag.ToString() == "edit")
            {
                if (m_pTabGeneral_SmartHosts.SelectedItems.Count > 0)
                {
                    ListViewItem          it  = m_pTabGeneral_SmartHosts.SelectedItems[0];
                    wfrm_System_SmartHost frm = new wfrm_System_SmartHost((Relay_SmartHost)it.Tag);
                    if (frm.ShowDialog(this) == DialogResult.OK)
                    {
                        it.Text             = frm.Host;
                        it.SubItems[1].Text = frm.Port.ToString();
                        it.SubItems[2].Text = frm.SslMode.ToString();
                        it.SubItems[3].Text = frm.UserName;
                        it.Tag = new Relay_SmartHost(frm.Host, frm.Port, frm.SslMode, frm.UserName, frm.Password);
                    }
                }
            }
            else if (e.ClickedItem.Tag.ToString() == "delete")
            {
                if (m_pTabGeneral_SmartHosts.SelectedItems.Count > 0)
                {
                    if (MessageBox.Show(this, "Are you sure you want to delete smart host '" + m_pTabGeneral_SmartHosts.SelectedItems[0].Text + "' ?", "Confirm:", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        m_pTabGeneral_SmartHosts.SelectedItems[0].Remove();
                    }
                }
            }
            else if (e.ClickedItem.Tag.ToString() == "up")
            {
                if (m_pTabGeneral_SmartHosts.SelectedItems.Count > 0 && m_pTabGeneral_SmartHosts.SelectedItems[0].Index > 0)
                {
                    ListViewItem it1 = m_pTabGeneral_SmartHosts.SelectedItems[0];
                    ListViewItem it2 = m_pTabGeneral_SmartHosts.Items[it1.Index - 1];
                    m_pTabGeneral_SmartHosts.Items.Remove(it2);
                    m_pTabGeneral_SmartHosts.Items.Insert(it1.Index + 1, it2);
                }
            }
            else if (e.ClickedItem.Tag.ToString() == "down")
            {
                if (m_pTabGeneral_SmartHosts.SelectedItems.Count > 0 && m_pTabGeneral_SmartHosts.SelectedItems[0].Index < m_pTabGeneral_SmartHosts.Items.Count - 1)
                {
                    ListViewItem it1 = m_pTabGeneral_SmartHosts.SelectedItems[0];
                    ListViewItem it2 = m_pTabGeneral_SmartHosts.Items[it1.Index + 1];
                    m_pTabGeneral_SmartHosts.Items.Remove(it2);
                    m_pTabGeneral_SmartHosts.Items.Insert(it1.Index, it2);
                }
            }

            m_pTabGeneral_SmartHosts_SelectedIndexChanged(this, new EventArgs());
            AddNotifications();
        }
Пример #2
0
        private void m_pTabGeneral_SmartHosts_Toolbar_ItemClicked(object sender,ToolStripItemClickedEventArgs e)
        {
            if(e.ClickedItem.Tag == null){
            }
            else if(e.ClickedItem.Tag.ToString() == "add"){
                wfrm_System_SmartHost frm = new wfrm_System_SmartHost();
                if(frm.ShowDialog(this) == DialogResult.OK){
                    ListViewItem it = new ListViewItem();
                    it.Text = frm.Host;
                    it.SubItems.Add(frm.Port.ToString());
                    it.SubItems.Add(frm.SslMode.ToString());
                    it.SubItems.Add(frm.UserName);
                    it.Tag = new Relay_SmartHost(frm.Host,frm.Port,frm.SslMode,frm.UserName,frm.Password);
                    m_pTabGeneral_SmartHosts.Items.Add(it);
                }
            }
            else if(e.ClickedItem.Tag.ToString() == "edit"){
                if(m_pTabGeneral_SmartHosts.SelectedItems.Count > 0){
                    ListViewItem it = m_pTabGeneral_SmartHosts.SelectedItems[0];
                    wfrm_System_SmartHost frm = new wfrm_System_SmartHost((Relay_SmartHost)it.Tag);
                    if(frm.ShowDialog(this) == DialogResult.OK){
                        it.Text             = frm.Host;
                        it.SubItems[1].Text = frm.Port.ToString();
                        it.SubItems[2].Text = frm.SslMode.ToString();
                        it.SubItems[3].Text = frm.UserName;
                        it.Tag = new Relay_SmartHost(frm.Host,frm.Port,frm.SslMode,frm.UserName,frm.Password);
                    }
                }
            }
            else if(e.ClickedItem.Tag.ToString() == "delete"){
                if(m_pTabGeneral_SmartHosts.SelectedItems.Count > 0){
                    if(MessageBox.Show(this,"Are you sure you want to delete smart host '" + m_pTabGeneral_SmartHosts.SelectedItems[0].Text + "' ?","Confirm:",MessageBoxButtons.YesNo,MessageBoxIcon.Question) == DialogResult.Yes){                    
                        m_pTabGeneral_SmartHosts.SelectedItems[0].Remove();
                    }
                }
            }
            else if(e.ClickedItem.Tag.ToString() == "up"){
                if(m_pTabGeneral_SmartHosts.SelectedItems.Count > 0 && m_pTabGeneral_SmartHosts.SelectedItems[0].Index > 0){
                    ListViewItem it1 = m_pTabGeneral_SmartHosts.SelectedItems[0];
                    ListViewItem it2 = m_pTabGeneral_SmartHosts.Items[it1.Index - 1];
                    m_pTabGeneral_SmartHosts.Items.Remove(it2);
                    m_pTabGeneral_SmartHosts.Items.Insert(it1.Index + 1,it2);
                }
            }
            else if(e.ClickedItem.Tag.ToString() == "down"){
                if(m_pTabGeneral_SmartHosts.SelectedItems.Count > 0 && m_pTabGeneral_SmartHosts.SelectedItems[0].Index < m_pTabGeneral_SmartHosts.Items.Count - 1){
                    ListViewItem it1 = m_pTabGeneral_SmartHosts.SelectedItems[0];
                    ListViewItem it2 = m_pTabGeneral_SmartHosts.Items[it1.Index + 1];
                    m_pTabGeneral_SmartHosts.Items.Remove(it2);
                    m_pTabGeneral_SmartHosts.Items.Insert(it1.Index,it2);
                }
            }

            m_pTabGeneral_SmartHosts_SelectedIndexChanged(this,new EventArgs());
            AddNotifications();
        }