private void ExportTemp(object sender, EventArgs e) //将目前输入框内容导出为模板
 {
     if (checkInput())                               //先检查输入信息
     {
         MessageBox.Show("输入有误,请检查出错的输入框", "失败");
         return;
     }
     else
     {
         setDic();
         string name = Interaction.InputBox("请给你即将导出的模板参数值组起个名字", "提示信息", "", -1, -1);
         if (name.Length != 0)
         {
             string          path = @"./";
             DirectoryInfo   d    = new DirectoryInfo(path);
             List <FileInfo> list = new List <FileInfo>(d.GetFiles());
             foreach (FileInfo f in list)//对名字进行判断
             {
                 if (f.Name.Remove(0, f.Name.Length - 4) == ".xml")
                 {
                     if (name + ".xml" == f.Name)
                     {
                         MessageBox.Show("命名重复,请重新命名", "失败");
                         return;
                     }
                 }
             }
             OsManager.Export(name + ".xml", dic);
             MessageBox.Show("导出成功");
             //Form1.Import("test3.xml");
         }
     }
 }
示例#2
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)//显示模板细节
        {
            string path = comboBox_chooseTemp.SelectedItem.ToString() + ".xml";

            dic = OsManager.Import(path);
            listBox_showAllTemplate.Items.Clear();
            listBox_showAllTemplate.Items.Add("Available:  " + dic["SA"] + "," + dic["SB"] + "," + dic["SC"]);
            for (int i = 0; i < 5; i++)
            {
                string str = $"{"P" + i}:  {dic[i + "A"]},{dic[i + "B"]},{dic[i + "C"]}";
                listBox_showAllTemplate.Items.Add(str);
            }
        }