Example #1
0
        private void AddFile(string ext)
        {
            InputForm frm = new InputForm();

            frm.Title = string.Format("请输入文件名称 (.{0})", ext);
            frm.Value = "test";
            if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (string.IsNullOrEmpty(frm.Value))
                {
                    MessageBoxMessage.Alert("文件名称不能为空。");
                    frm.ShowDialog();
                    return;
                }

                DirectoryInfo rootFolder = tvTemplates.SelectedNode.Tag as DirectoryInfo;
                string        path       = string.Format("{0}\\{1}.{2}", rootFolder.FullName, frm.Value, ext);
                if (File.Exists(path))
                {
                    MessageBoxMessage.Alert("文件已存在。");
                    frm.ShowDialog();
                    return;
                }

                Helper.WriteFile(path, "");
                LoadFiles(tvTemplates.SelectedNode);
            }
        }
Example #2
0
        private void mnuAddTemplate_Click(object sender, EventArgs e)
        {
            InputForm frm = new InputForm();

            frm.Title = "请输入模板名称";
            frm.Value = "新模板";
            if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (string.IsNullOrEmpty(frm.Value))
                {
                    MessageBoxMessage.Alert("模板名称不能为空。");
                    frm.ShowDialog();
                    return;
                }

                DirectoryInfo rootFolder = rootNode.Tag as DirectoryInfo;
                string        path       = rootFolder.FullName + "\\" + frm.Value;
                if (Directory.Exists(path))
                {
                    MessageBoxMessage.Alert("模板已存在。");
                    frm.ShowDialog();
                    return;
                }

                Helper.CopyFolder(Application.StartupPath + "\\Config\\NewTemplate", path);
                LoadTempates();
                if (TemplateChanged != null)
                {
                    TemplateChanged();
                }
            }
        }