コード例 #1
0
        private Model.ConfigTemplate GetModel()
        {
            string templateName  = this.tbTemplateName.Text;
            string directoryName = this.tbDirectoryName.Text;
            string targetName    = this.tbTargetName.Text;
            string targetPostfix = this.tbTargetPostfix.Text;
            string isActive      = this.cbIsActive.Text;

            if (templateName.IsNullOrEmpty())
            {
                MessageBox.Show("模板名不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(null);
            }
            if (directoryName.IsNullOrEmpty())
            {
                MessageBox.Show("目录名不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(null);
            }
            if (targetName.IsNullOrEmpty())
            {
                MessageBox.Show("生成文件名不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(null);
            }

            Model.ConfigTemplate template = new Model.ConfigTemplate();
            template.TemplateName  = templateName.Trim();
            template.DirectoryName = directoryName.Trim();
            template.TargetName    = targetName.Trim();
            template.TargetPostfix = targetPostfix.Trim();
            template.IsActive      = isActive;
            return(template);
        }
コード例 #2
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     Model.ConfigTemplate template = GetModel();
     if (template != null)
     {
         if (Info.Add(template))
         {
             MessageBox.Show("添加成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
             ShowList();
         }
         else
         {
             MessageBox.Show("添加失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
 }
コード例 #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            var items = listView1.SelectedItems;

            if (items.Count == 0)
            {
                return;
            }
            var item = items[0];

            Model.ConfigTemplate cnsc = GetModel();
            if (cnsc != null)
            {
                if (Info.Save(cnsc, item.SubItems[0].Text))
                {
                    MessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    ShowList();
                }
                else
                {
                    MessageBox.Show("保存失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }