frmAddValue.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using DevExpress.XtraEditors;
  9. using System.IO;
  10. using SWGDBHelper;
  11. namespace SWGDBSysManager
  12. {
  13. public partial class frmAddValue : DevExpress.XtraEditors.XtraForm
  14. {
  15. Dictionary<string, string> mpGBCodes;
  16. string mstrValue = "";
  17. string mstrDescri = "";
  18. string mstrStylePath = "";
  19. public frmAddValue(Dictionary<string, string> pGBCodes)
  20. {
  21. InitializeComponent();
  22. mpGBCodes = pGBCodes;
  23. chB_DefaultStyle_CheckedChanged(null,null);
  24. }
  25. private void txtValue_EditValueChanged(object sender, EventArgs e)
  26. {
  27. string value = this.txtValue.Text.Trim();
  28. if (mpGBCodes.ContainsKey(value))
  29. this.txtDescri.Text = mpGBCodes[value];
  30. }
  31. private void btnOk_Click(object sender, EventArgs e)
  32. {
  33. mstrValue = this.txtValue.Text.Trim();
  34. mstrDescri = this.txtDescri.Text.Trim();
  35. if (this.btnEdStyle.Text == "")
  36. {
  37. DevHelper.ShowInfo(this, "请选择符号库!");
  38. return;
  39. }
  40. mstrStylePath = this.btnEdStyle.Text;
  41. this.DialogResult = DialogResult.OK;
  42. this.Close();
  43. }
  44. private void btnCancel_Click(object sender, EventArgs e)
  45. {
  46. this.DialogResult = DialogResult.Cancel;
  47. this.Close();
  48. }
  49. /// <summary>
  50. /// 符号化字段的值
  51. /// </summary>
  52. public string FieldValue
  53. {
  54. get
  55. {
  56. return mstrValue;
  57. }
  58. }
  59. /// <summary>
  60. /// 字段值得描述
  61. /// </summary>
  62. public string ValueDesci
  63. {
  64. get
  65. {
  66. return mstrDescri;
  67. }
  68. }
  69. /// <summary>
  70. /// 符号库路径
  71. /// </summary>
  72. public string StylePath
  73. {
  74. get
  75. {
  76. return mstrStylePath;
  77. }
  78. }
  79. private void btnEdStyle_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  80. {
  81. OpenFileDialog dlg = new OpenFileDialog();
  82. //dlg.RestoreDirectory = true;
  83. dlg.InitialDirectory = Application.StartupPath + "\\Style\\";
  84. dlg.CheckFileExists = true;
  85. dlg.Multiselect = false;
  86. dlg.ShowHelp = false;
  87. dlg.Filter = "符号库文件(*.style)|*.style";
  88. if (dlg.ShowDialog() == DialogResult.OK)
  89. {
  90. this.btnEdStyle.Text = dlg.FileName;
  91. }
  92. }
  93. private void chB_DefaultStyle_CheckedChanged(object sender, EventArgs e)
  94. {
  95. btnEdStyle.Text = "";
  96. if (chB_DefaultStyle.Checked)
  97. {
  98. if (File.Exists(Application.StartupPath + "\\Style\\DLGQ10K.style"))
  99. {
  100. btnEdStyle.Text = Application.StartupPath + "\\Style\\DLGQ10K.style";
  101. }
  102. else
  103. {
  104. DevHelper.ShowWaring("缺失系统文件:" + Application.StartupPath + "\\Style\\DLGQ10K.style");
  105. chB_DefaultStyle.Checked = false;
  106. }
  107. }
  108. btnEdStyle.Enabled = !chB_DefaultStyle.Checked;
  109. }
  110. }
  111. }