DebrisCalipersSetDialog.cs 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. using PaintDotNet;
  2. using PaintDotNet.Base.CommTool;
  3. using PaintDotNet.Base.SettingModel;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.Data;
  8. using System.Drawing;
  9. using System.IO;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using System.Windows.Forms;
  14. namespace Metis.GeneralAnalysis
  15. {
  16. public partial class DebrisCalipersSetDialog : Form
  17. {
  18. private ConfigModel config = Startup.instance.configModel;
  19. public DebrisCalipersSetDialog()
  20. {
  21. InitializeComponent();
  22. DataInitialization();
  23. }
  24. private void btn_Save_Click(object sender, EventArgs e)
  25. {
  26. if (Inspect())
  27. {
  28. MessageBox.Show("参数不能为空!");
  29. return;
  30. }
  31. if (config.calipersSetModel == null)
  32. config.calipersSetModel = new CalipersSetModel();
  33. config.calipersSetModel.isExport = this.checkBox1.Checked ? 1 : 2; //1是2否
  34. config.calipersSetModel.sort = this.comboBox1.Text.Trim();
  35. config.calipersSetModel.sortMode = this.checkBox4.Checked ? 1 : 2; //1倒2正
  36. config.calipersSetModel.exportRecord = int.Parse(this.textBox1.Text.Trim());
  37. string configXml = XmlSerializeHelper.XmlSerialize<ConfigModel>(config);
  38. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Config.xml";
  39. if (!FileOperationHelper.WriteStringToFile(configXml, filePath, FileMode.Create))
  40. MessageBox.Show(PdnResources.GetString("Menu.mingconventionsavefailed.text"));
  41. this.Close();
  42. }
  43. private void btn_Close_Click(object sender, EventArgs e)
  44. {
  45. this.Close();
  46. }
  47. private void DataInitialization()
  48. {
  49. var vs = InvariantData.debrisSelectionparameters.Values;
  50. string[] lst = vs.Select(a => a.ToString()).ToArray();
  51. this.comboBox1.DataSource = lst;
  52. if (config.calipersSetModel != null)
  53. {
  54. this.checkBox1.Checked = config.calipersSetModel.isExport == 1 ? true: false; //1是2否
  55. this.comboBox1.Text = config.calipersSetModel.sort;
  56. this.checkBox4.Checked = config.calipersSetModel.sortMode == 1 ? true : false; //1倒2正
  57. this.textBox1.Text = config.calipersSetModel.exportRecord + "";
  58. }
  59. }
  60. private bool Inspect()
  61. {
  62. bool chek = false;
  63. if (this.comboBox1.Text.Trim() == "" || this.textBox1.Text.Trim() == "") chek = true;
  64. return chek;
  65. }
  66. private void checkBox1_CheckedChanged(object sender, EventArgs e)
  67. {
  68. if (this.checkBox1.Checked) this.checkBox2.Checked = false;
  69. else this.checkBox2.Checked = true;
  70. }
  71. private void checkBox4_CheckedChanged(object sender, EventArgs e)
  72. {
  73. if (this.checkBox4.Checked) this.checkBox3.Checked = false;
  74. else this.checkBox3.Checked = true;
  75. }
  76. private void checkBox2_CheckedChanged(object sender, EventArgs e)
  77. {
  78. if (this.checkBox2.Checked) this.checkBox1.Checked = false;
  79. else this.checkBox1.Checked = true;
  80. }
  81. private void checkBox3_CheckedChanged(object sender, EventArgs e)
  82. {
  83. if (this.checkBox3.Checked) this.checkBox4.Checked = false;
  84. else this.checkBox4.Checked = true;
  85. }
  86. }
  87. }