代码拉取完成,页面将自动刷新
using SqlBuildLib;
using System;
using System.IO;
using System.Windows.Forms;
namespace MySqlDataBuild
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
foreach (var item in Persist.I.datas)
dbcb.Items.Add(item.Key);
InitData();
}
public void InitData()
{
pathCb.Items.Clear();
exPathCb.Items.Clear();
foreach (var item1 in Persist.I.paths)
pathCb.Items.Add(item1);
foreach (var item1 in Persist.I.exPaths)
exPathCb.Items.Add(item1);
dbcb.SelectedItem = Persist.I.dbName;
pathCb.Text = Persist.I.path;
exPathCb.Text = Persist.I.exPath;
iptext.Text = Persist.I.ip;
porttext.Text = Persist.I.port;
usertext.Text = Persist.I.user;
pwdtext.Text = Persist.I.pwd;
comboBox1.SelectedIndex = Persist.I.namespaceIndex;
nameSpaceText.Enabled = comboBox1.SelectedIndex == 2;
checkBox1.Checked = Persist.I.clearOldFiles;
checkBox2.Checked = Persist.I.compatible;
checkBox3.Checked = Persist.I.creatDbPath;
comboBox2.SelectedIndex = Persist.I.incrementIdType;
}
private void button1_Click(object sender, EventArgs e)
{
var result = folderBrowserDialog1.ShowDialog();
if (result == DialogResult.OK)
{
pathCb.Text = folderBrowserDialog1.SelectedPath;
pathCb_Leave(null, null);
}
}
private void button2_Click(object sender, EventArgs e)
{
if (checkBox1.Checked)
{
string path;
if (string.IsNullOrEmpty(pathCb.Text))
path = AppDomain.CurrentDomain.BaseDirectory;
else
path = pathCb.Text;
var files = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories);
foreach (var file in files)
File.Delete(file);
}
var msg = GenerateCodeHelper.MySqlBuild(dbcb.Text, iptext.Text, porttext.Text, usertext.Text, pwdtext.Text, pathCb.Text, exPathCb.Text, comboBox1.SelectedIndex, nameSpaceText.Text, checkBox3.Checked, checkBox2.Checked, comboBox2.Text, true);
MessageBox.Show(msg);
}
private void iptext_TextChanged(object sender, EventArgs e)
{
Persist.I.ip = ((TextBox)sender).Text;
Persist.SaveData();
}
private void porttext_TextChanged(object sender, EventArgs e)
{
Persist.I.port = ((TextBox)sender).Text;
Persist.SaveData();
}
private void usertext_TextChanged(object sender, EventArgs e)
{
Persist.I.user = ((TextBox)sender).Text;
Persist.SaveData();
}
private void pwdtext_TextChanged(object sender, EventArgs e)
{
Persist.I.pwd = ((TextBox)sender).Text;
Persist.SaveData();
}
private void comboBox1_Leave(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(dbcb.Text))
return;
if (Persist.I.datas.ContainsKey(dbcb.Text))
return;
dbcb.Items.Add(dbcb.Text);
Persist.I.dbName = dbcb.Text;
Persist.I.datas.Add(dbcb.Text, new DataEntity());
InitData();
Persist.SaveData();
}
private void dbcb_SelectedIndexChanged(object sender, EventArgs e)
{
Persist.I.dbName = dbcb.Text;
InitData();
Persist.SaveData();
}
private void dbcb_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Delete)
{
if (dbcb.SelectedIndex == -1)
return;
Persist.I.datas.Remove(dbcb.Text);
dbcb.Items.RemoveAt(dbcb.SelectedIndex);
Persist.SaveData();
}
else if (e.KeyCode == Keys.Enter)
{
comboBox1_Leave(sender, e);
}
}
private void pathCb_SelectedIndexChanged(object sender, EventArgs e)
{
Persist.I.pathIndex = pathCb.SelectedIndex;
Persist.SaveData();
}
private void pathCb_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Delete)
{
if (pathCb.SelectedIndex == -1)
return;
Persist.I.paths.RemoveAt(pathCb.SelectedIndex);
pathCb.Items.RemoveAt(pathCb.SelectedIndex);
Persist.I.pathIndex = -1;
Persist.SaveData();
}
else if (e.KeyCode == Keys.Enter)
{
pathCb_Leave(sender, e);
}
}
private void pathCb_Leave(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(pathCb.Text))
return;
if (Persist.I.paths.Contains(pathCb.Text))
return;
pathCb.Items.Add(pathCb.Text);
Persist.I.paths.Add(pathCb.Text);
Persist.SaveData();
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
nameSpaceText.Enabled = comboBox1.SelectedIndex == 2;
Persist.I.namespaceIndex = comboBox1.SelectedIndex;
Persist.SaveData();
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
Persist.I.clearOldFiles = checkBox1.Checked;
Persist.SaveData();
}
private void checkBox2_CheckedChanged(object sender, EventArgs e)
{
Persist.I.compatible = checkBox2.Checked;
Persist.SaveData();
}
private void checkBox3_CheckedChanged(object sender, EventArgs e)
{
Persist.I.creatDbPath = checkBox3.Checked;
Persist.SaveData();
}
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
{
Persist.I.incrementIdType = comboBox2.SelectedIndex;
Persist.SaveData();
}
private void button3_Click(object sender, EventArgs e)
{
var result = folderBrowserDialog1.ShowDialog();
if (result == DialogResult.OK)
{
exPathCb.Text = folderBrowserDialog1.SelectedPath;
exCb_Leave(null, null);
}
}
private void exCb_SelectedIndexChanged(object sender, EventArgs e)
{
Persist.I.exPathIndex = exPathCb.SelectedIndex;
Persist.SaveData();
}
private void exCb_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Delete)
{
if (exPathCb.SelectedIndex == -1)
return;
Persist.I.exPaths.RemoveAt(exPathCb.SelectedIndex);
exPathCb.Items.RemoveAt(exPathCb.SelectedIndex);
Persist.I.exPathIndex = -1;
Persist.SaveData();
}
else if (e.KeyCode == Keys.Enter)
{
exCb_Leave(sender, e);
}
}
private void exCb_Leave(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(exPathCb.Text))
return;
if (Persist.I.exPaths.Contains(exPathCb.Text))
return;
exPathCb.Items.Add(exPathCb.Text);
Persist.I.exPaths.Add(exPathCb.Text);
Persist.SaveData();
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。