using PaintDotNet; using PaintDotNet.Base.CommTool; using PaintDotNet.Base.SettingModel; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Metis.GeneralAnalysis { public partial class DebrisCalipersSetDialog : Form { private ConfigModel config = Startup.instance.configModel; public DebrisCalipersSetDialog() { InitializeComponent(); DataInitialization(); } private void btn_Save_Click(object sender, EventArgs e) { if (Inspect()) { MessageBox.Show("参数不能为空!"); return; } if (config.calipersSetModel == null) config.calipersSetModel = new CalipersSetModel(); config.calipersSetModel.isExport = this.checkBox1.Checked ? 1 : 2; //1是2否 config.calipersSetModel.sort = this.comboBox1.Text.Trim(); config.calipersSetModel.sortMode = this.checkBox4.Checked ? 1 : 2; //1倒2正 config.calipersSetModel.exportRecord = int.Parse(this.textBox1.Text.Trim()); string configXml = XmlSerializeHelper.XmlSerialize(config); string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Config.xml"; if (!FileOperationHelper.WriteStringToFile(configXml, filePath, FileMode.Create)) MessageBox.Show(PdnResources.GetString("Menu.mingconventionsavefailed.text")); this.Close(); } private void btn_Close_Click(object sender, EventArgs e) { this.Close(); } private void DataInitialization() { var vs = InvariantData.debrisSelectionparameters.Values; string[] lst = vs.Select(a => a.ToString()).ToArray(); this.comboBox1.DataSource = lst; if (config.calipersSetModel != null) { if (config.calipersSetModel.isExport == 1) this.checkBox1.Checked = true; else this.checkBox2.Checked = true; //this.checkBox1.Checked = config.calipersSetModel.isExport == 1 ? true: false; //1是2否 this.comboBox1.Text = config.calipersSetModel.sort; if (config.calipersSetModel.sortMode == 1) this.checkBox4.Checked = true; else this.checkBox3.Checked = true; //this.checkBox4.Checked = config.calipersSetModel.sortMode == 1 ? true : false; //1倒2正 this.textBox1.Text = config.calipersSetModel.exportRecord + ""; } } private bool Inspect() { bool chek = false; if (this.comboBox1.Text.Trim() == "" || this.textBox1.Text.Trim() == "") chek = true; return chek; } //private void checkBox1_CheckedChanged1(object sender, EventArgs e) //{ // if (this.checkBox1.Checked) this.checkBox2.Checked = false; // else this.checkBox2.Checked = true; //} //private void checkBox4_CheckedChanged1(object sender, EventArgs e) //{ // if (this.checkBox4.Checked) this.checkBox3.Checked = false; // else this.checkBox3.Checked = true; //} //private void checkBox2_CheckedChanged1(object sender, EventArgs e) //{ // if (this.checkBox2.Checked) this.checkBox1.Checked = false; // else this.checkBox1.Checked = true; //} //private void checkBox3_CheckedChanged(object sender, EventArgs e) //{ // if (this.checkBox3.Checked) this.checkBox4.Checked = false; // else this.checkBox4.Checked = true; //} } }