锐腾搅拌上料功能
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
3.6 KiB

5 months ago
  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 ICSSoft.Base.Config.AppConfig;
  11. using ICSSoft.Base.Language.Tool;
  12. using ICSSoft.Base.UserControl.MessageControl;
  13. namespace ICSSoft.Frame.Main.Entrance
  14. {
  15. public partial class FormConfigService : DevExpress.XtraEditors.XtraForm
  16. {
  17. public FormConfigService(string titleContent)
  18. {
  19. InitializeComponent();
  20. lblTitle.Text = titleContent;
  21. txtBaseServiceUrl.Text = AppConfig.BaseServiceUri;
  22. }
  23. private void btnSave_Click(object sender, EventArgs e)
  24. {
  25. string urlValue = txtBaseServiceUrl.Text.Trim();
  26. List<LangObj> langList=new List<LangObj>();
  27. if (urlValue == "")
  28. {
  29. LangObj langObj = new LangObj();
  30. langObj.LConvertString = "{0} 不可以为空{1}";
  31. langObj.LParameters = new object[] {"基础服务URL","!" };
  32. langList.Add(langObj);
  33. }
  34. if (langList.Count > 0)
  35. {
  36. MessageDialog messBox = new MessageDialog(1, langList);
  37. messBox.ShowDialog();
  38. return;
  39. }
  40. using (StreamWriter sWrite = new StreamWriter(AppConfig.BaseServiceFile))
  41. {
  42. sWrite.WriteLine(urlValue);
  43. }
  44. AppConfig.BaseServiceUri = urlValue;
  45. this.DialogResult = DialogResult.OK;
  46. }
  47. private void btnExit_Click(object sender, EventArgs e)
  48. {
  49. AppConfig.CloseFormShow(this.Text);
  50. this.DialogResult = DialogResult.Cancel;
  51. }
  52. private void btnClose_Click(object sender, EventArgs e)
  53. {
  54. AppConfig.CloseFormShow(this.Text);
  55. this.DialogResult = DialogResult.Cancel;
  56. }
  57. #region 移动窗体
  58. private const int WM_NCHITTEST = 0x84;
  59. private const int HTCLIENT = 0x1;
  60. private const int HTCAPTION = 0x2;
  61. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  62. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  63. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  64. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  65. //重写窗体,使窗体可以不通过自带标题栏实现移动
  66. protected override void WndProc(ref Message m)
  67. {
  68. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  69. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  70. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  71. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  72. switch (m.Msg)
  73. {
  74. case WM_NCHITTEST:
  75. base.WndProc(ref m);
  76. if ((int)m.Result == HTCLIENT)
  77. m.Result = (IntPtr)HTCAPTION;
  78. return;
  79. }
  80. //拦截双击标题栏、移动窗体的系统消息
  81. if (m.Msg != 0xA3)
  82. {
  83. base.WndProc(ref m);
  84. }
  85. }
  86. #endregion
  87. }
  88. }