Ejemplo n.º 1
0
        private void tlbtnEdit_Click(object sender, EventArgs e)
        {
            if (lstItems.SelectedItems.Count == 0)
            {
                MessageBoxHelper.ShowExclamation("请选择一个远程连接。");
                return;
            }

            var item   = lstItems.SelectedItems[0];
            var groups = connections.Select(s => s.group).Distinct().ToList();
            var conn   = (Remoter.Connection)item.Tag;
            var group  = conn.group;

            using (var frm = new frmRemoteEdit {
                Groups = groups, Connection = conn
            })
            {
                if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    SaveData();

                    if (group != frm.Connection.group)
                    {
                        item.Group = frm.Connection.group;
                        lstItems.Grouping(true);
                    }
                    else if (groups.IndexOf(frm.Connection.group) == -1)
                    {
                        LoadData();
                    }
                    else
                    {
                        item.Text           = frm.Connection.name;
                        item.Cells[1].Value = frm.Connection.host;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void tlbtnAdd_Click(object sender, EventArgs e)
        {
            var groups = connections.Select(s => (string)s.group).Distinct().ToList();

            using (var frm = new frmRemoteEdit {
                Groups = groups
            })
            {
                if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    connections.Add(frm.Connection);
                    SaveData();

                    var item = new TreeListItem(frm.Connection.name);
                    item.Tag        = frm.Connection;
                    item.ImageIndex = 0;
                    item.Group      = frm.Connection.group;
                    lstItems.Items.Add(item);
                    item.Cells[1].Value = frm.Connection.host;
                    lstItems.Grouping(true);
                }
            }
        }