using Helper;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace DeveloperTools
{
    public partial class FrmCodeGenerator : Form
    {
        public FrmCodeGenerator()
        {
            InitializeComponent();
        }

        private void FrmCodeGenerator_Load(object sender, EventArgs e)
        {
            Console.WriteLine(Properties.Resources.模板);
        }

        private void btnGenearte_Click(object sender, EventArgs e)
        {
            string 类名 = txtClassName.Text.Trim();
            string left = CommonHelper.GenerateCode(txtLeft.Text);
            string right = CommonHelper.GenerateCode(txtRight.Text);
            string search = CommonHelper.GenerateCode(txtSearchApi.Text);
            string id = CommonHelper.GenerateCode(txtId.Text);
            string name = CommonHelper.GenerateCode(txtName.Text);
            string album = CommonHelper.GenerateCode(txtAlbum.Text);
            string artist = CommonHelper.GenerateCode(txtArtist.Text);
            string picid = CommonHelper.GenerateCode(txtPicId.Text);
            string getdata = CommonHelper.GenerateCode(txtGetDataApi.Text);
            string picurl = CommonHelper.GenerateCode(txtPicUrl.Text);
            string url = CommonHelper.GenerateCode(txtUrl.Text);
            string code = Properties.Resources.模板;
            string result = string.Format(code
                ,类名,search,left,right,id,name,album,artist,picid,getdata,picurl,url);
            File.WriteAllText(string.Format("{0}\\{1}.cs",Application.StartupPath,类名),result);
        }
    }
}
