Ejemplo n.º 1
0
        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();
                }
            }
        }
Ejemplo n.º 2
0
        private void LinkItemStripMenuItem_Click(object sender, EventArgs e)
        {
            string text = ((ToolStripMenuItem)sender).Text;

            if (text == "当前应用")
            {
                text = string.Empty;
                this.SaveHistoryToolStripMenuItem.Visible = false;
            }
            else
            {
                this.SaveHistoryToolStripMenuItem.Visible = true;
                this.SaveHistoryToolStripMenuItem.Text    = "保存 " + text;
                if (HostsDal.LinkQuickUse && File.Exists(HostsDal.GetFileName(text)))
                {
                    File.Copy(HostsDal.GetFileName(text), HostsDal.HostsPath, true);
                    MessageBox.Show("应用成功");
                }
            }
            this.BindHosts(text);
        }