DebrisCalipersSetDialog.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. if (config.calipersSetModel.isExport == 1)
  55. this.checkBox1.Checked = true;
  56. else
  57. this.checkBox2.Checked = true;
  58. //this.checkBox1.Checked = config.calipersSetModel.isExport == 1 ? true: false; //1是2否
  59. this.comboBox1.Text = config.calipersSetModel.sort;
  60. if (config.calipersSetModel.sortMode == 1)
  61. this.checkBox4.Checked = true;
  62. else
  63. this.checkBox3.Checked = true;
  64. //this.checkBox4.Checked = config.calipersSetModel.sortMode == 1 ? true : false; //1倒2正
  65. this.textBox1.Text = config.calipersSetModel.exportRecord + "";
  66. }
  67. }
  68. private bool Inspect()
  69. {
  70. bool chek = false;
  71. if (this.comboBox1.Text.Trim() == "" || this.textBox1.Text.Trim() == "") chek = true;
  72. return chek;
  73. }
  74. //private void checkBox1_CheckedChanged1(object sender, EventArgs e)
  75. //{
  76. // if (this.checkBox1.Checked) this.checkBox2.Checked = false;
  77. // else this.checkBox2.Checked = true;
  78. //}
  79. //private void checkBox4_CheckedChanged1(object sender, EventArgs e)
  80. //{
  81. // if (this.checkBox4.Checked) this.checkBox3.Checked = false;
  82. // else this.checkBox3.Checked = true;
  83. //}
  84. //private void checkBox2_CheckedChanged1(object sender, EventArgs e)
  85. //{
  86. // if (this.checkBox2.Checked) this.checkBox1.Checked = false;
  87. // else this.checkBox1.Checked = true;
  88. //}
  89. //private void checkBox3_CheckedChanged(object sender, EventArgs e)
  90. //{
  91. // if (this.checkBox3.Checked) this.checkBox4.Checked = false;
  92. // else this.checkBox4.Checked = true;
  93. //}
  94. }
  95. }