AutoPackage/AutoPekage/frmSettings.cs
2017-02-05 15:30:23 +08:00

123 lines
3.3 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace AutoPekage
{
public partial class frmSettings : Form
{
private SettingsDao dao;
public frmSettings()
{
InitializeComponent();
}
private void frmSettings_Load(object sender, EventArgs e)
{
dao = LiteDbHelper.Settings;
txtPackageName.Text = dao.DefaultFileName;
cbSendMail.Checked = dao.SendMail;
cbAskLoad.Checked = dao.AskAutoLoadFile;
cbAskDelete.Checked = dao.AskAutoDeleteFile;
rbLoad.Checked = dao.AutoLoadFile == 1 ? true : false;
rbUnload.Checked = dao.AutoLoadFile == 0 ? true : false;
rbDelete.Checked = dao.AutoDeleteFile == 1 ? true : false;
rbUnDelete.Checked = dao.AutoDeleteFile == 0 ? true : false;
rbCustom.Checked = dao.TitleModel == 1 ? true : false;
rbFileName.Checked = dao.TitleModel == 0 ? true : false;
if (rbCustom.Checked)
{
txtTitle.Text = dao.Title;
txtTitle.Enabled = true;
}
}
private void cbAskLoad_CheckedChanged(object sender, EventArgs e)
{
if (cbAskLoad.Checked)
{
rbLoad.Enabled = false;
rbUnload.Enabled = false;
}
else
{
rbLoad.Enabled = true;
rbUnload.Enabled = true;
}
}
private void cbAskDelete_CheckedChanged(object sender, EventArgs e)
{
if (cbAskDelete.Checked)
{
rbDelete.Enabled = false;
rbUnDelete.Enabled = false;
}
else
{
rbDelete.Enabled = true;
rbUnDelete.Enabled = true;
}
}
private void btnOK_Click(object sender, EventArgs e)
{
dao.DefaultFileName = txtPackageName.Text;
dao.SendMail = cbSendMail.Checked;
dao.AskAutoLoadFile = cbAskLoad.Checked;
dao.AskAutoDeleteFile = cbAskDelete.Checked;
if (rbLoad.Checked)
{
dao.AutoLoadFile = 1;
}
else
{
dao.AutoLoadFile = 0;
}
if (rbDelete.Checked)
{
dao.AutoDeleteFile = 1;
}
else
{
dao.AutoDeleteFile = 0;
}
if (rbFileName.Checked)
{
dao.TitleModel = 0;
}
else
{
dao.TitleModel = 1;
dao.Title = txtTitle.Text;
}
LiteDbHelper.Settings = dao;
Close();
}
private void btnCancel_Click(object sender, EventArgs e)
{
Close();
}
private void rbCustom_CheckedChanged(object sender, EventArgs e)
{
if (rbCustom.Checked)
{
txtTitle.Enabled = true;
}
else
{
txtTitle.Enabled = false;
}
}
}
}