public static void AddHost(string ip, string name, string desc, bool use, bool addLine) { List <HostItem> hosts = HostsDal.GetHosts(""); HostItem item = new HostItem(ip, name, desc, use, addLine); hosts.Add(item); HostsDal.SaveHosts("", hosts); }
private void SaveHistoryToolStripMenuItem_Click(object sender, EventArgs e) { string name = ((ToolStripMenuItem)sender).Text.Split(new char[] { ' ' })[1]; List <HostItem> gridHost = this.GetGridHost(); if (gridHost != null) { HostsDal.SaveHosts(name, gridHost); } }
private void SaveToolStripMenuItem_Click(object sender, EventArgs e) { List <HostItem> gridHost = this.GetGridHost(); if (gridHost != null) { HostsDal.SaveHosts(string.Empty, gridHost); this.BindHosts(string.Empty); MessageBox.Show("应用成功"); } }
private void SaveAsToolStripMenuItem_Click(object sender, EventArgs e) { string str = Interaction.InputBox("请输入快捷方式名", "请输入快捷方式名", "", 100, 100); if (!string.IsNullOrEmpty(str) && (!File.Exists(HostsDal.GetFileName(str)) || (MessageBox.Show("快捷方式文件已存在,是否覆盖?", "文件已存在", MessageBoxButtons.YesNo) == DialogResult.Yes))) { List <HostItem> gridHost = this.GetGridHost(); if (gridHost != null) { HostsDal.SaveHosts(str, gridHost); this.BindHistory(); } } }