wfrm_Route.cs
上传用户:horngjaan
上传日期:2009-12-12
资源大小:2882k
文件大小:14k
源码类别:

Email服务器

开发平台:

C#

  1. using System;
  2. using System.Data;
  3. using System.Drawing;
  4. using System.Collections;
  5. using System.ComponentModel;
  6. using System.Windows.Forms;
  7. namespace LumiSoft.MailServer
  8. {
  9. /// <summary>
  10. /// Summary description for Route_Frm.
  11. /// </summary>
  12. public class wfrm_Route : System.Windows.Forms.Form
  13. {
  14. private LumiSoft.UI.Controls.WLabel wLabel1;
  15. private LumiSoft.UI.Controls.WLabel wLabel2;
  16. private LumiSoft.UI.Controls.WLabel wLabel3;
  17. private LumiSoft.UI.Controls.WEditBox m_pPattern;
  18. private LumiSoft.UI.Controls.WEditBox m_pDescription;
  19. private LumiSoft.UI.Controls.WButton m_pOk;
  20. private LumiSoft.UI.Controls.WComboBox m_pRouteTo;
  21. private LumiSoft.UI.Controls.WComboBox m_pDomains;
  22. private LumiSoft.UI.Controls.WLabel mt_symbolAT;
  23. private LumiSoft.UI.Controls.WButton m_pCancel;
  24. /// <summary>
  25. /// Required designer variable.
  26. /// </summary>
  27. private System.ComponentModel.Container components = null;
  28. private ServerAPI m_ServerAPI   = null;
  29. private string    m_Pattern     = "";
  30. private string    m_MailBox     = "";
  31. private string    m_Description = "";
  32. private string    m_DomainID    = "";
  33. private string    m_DomainName  = "";
  34. /// <summary>
  35. /// Add new constructor.
  36. /// </summary>
  37. /// <param name="serverAPI"></param>
  38. public wfrm_Route(ServerAPI serverAPI) : this(serverAPI,null)
  39. {
  40. }
  41. /// <summary>
  42. /// Edit constructor.
  43. /// </summary>
  44. /// <param name="serverAPI"></param>
  45. /// <param name="dr"></param>
  46. public wfrm_Route(ServerAPI serverAPI,DataRow dr)
  47. {
  48. //
  49. // Required for Windows Form Designer support
  50. //
  51. InitializeComponent();
  52. //
  53. // TODO: Add any constructor code after InitializeComponent call
  54. //
  55. m_ServerAPI = serverAPI;
  56. foreach(DataRowView drV in serverAPI.GetDomainList()){
  57. m_pDomains.Items.Add(drV["DomainName"].ToString(),drV["DomainID"].ToString());
  58. }
  59. if(dr != null){
  60. m_pDomains.SelectItemByTag(dr["DomainID"].ToString());
  61. m_pPattern.Text     = dr["Pattern"].ToString();
  62. m_pRouteTo.Text     = dr["Mailbox"].ToString();
  63. m_pDescription.Text = dr["Description"].ToString();
  64. }
  65. }
  66. #region function Dispose
  67. /// <summary>
  68. /// Clean up any resources being used.
  69. /// </summary>
  70. protected override void Dispose( bool disposing )
  71. {
  72. if( disposing )
  73. {
  74. if(components != null)
  75. {
  76. components.Dispose();
  77. }
  78. }
  79. base.Dispose( disposing );
  80. }
  81. #endregion
  82. #region Windows Form Designer generated code
  83. /// <summary>
  84. /// Required method for Designer support - do not modify
  85. /// the contents of this method with the code editor.
  86. /// </summary>
  87. private void InitializeComponent()
  88. {
  89. System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(wfrm_Route));
  90. this.wLabel1 = new LumiSoft.UI.Controls.WLabel();
  91. this.m_pPattern = new LumiSoft.UI.Controls.WEditBox();
  92. this.wLabel2 = new LumiSoft.UI.Controls.WLabel();
  93. this.wLabel3 = new LumiSoft.UI.Controls.WLabel();
  94. this.m_pDescription = new LumiSoft.UI.Controls.WEditBox();
  95. this.m_pOk = new LumiSoft.UI.Controls.WButton();
  96. this.m_pRouteTo = new LumiSoft.UI.Controls.WComboBox();
  97. this.m_pDomains = new LumiSoft.UI.Controls.WComboBox();
  98. this.mt_symbolAT = new LumiSoft.UI.Controls.WLabel();
  99. this.m_pCancel = new LumiSoft.UI.Controls.WButton();
  100. ((System.ComponentModel.ISupportInitialize)(this.m_pPattern)).BeginInit();
  101. ((System.ComponentModel.ISupportInitialize)(this.m_pDescription)).BeginInit();
  102. ((System.ComponentModel.ISupportInitialize)(this.m_pOk)).BeginInit();
  103. ((System.ComponentModel.ISupportInitialize)(this.m_pRouteTo)).BeginInit();
  104. ((System.ComponentModel.ISupportInitialize)(this.m_pDomains)).BeginInit();
  105. ((System.ComponentModel.ISupportInitialize)(this.m_pCancel)).BeginInit();
  106. this.SuspendLayout();
  107. // 
  108. // wLabel1
  109. // 
  110. this.wLabel1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
  111. this.wLabel1.Location = new System.Drawing.Point(8, 8);
  112. this.wLabel1.Name = "wLabel1";
  113. this.wLabel1.Size = new System.Drawing.Size(150, 16);
  114. this.wLabel1.TabIndex = 6;
  115. this.wLabel1.Text = "Match Pattern";
  116. this.wLabel1.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
  117. this.wLabel1.UseStaticViewStyle = true;
  118. // 
  119. // m_pPattern
  120. // 
  121. this.m_pPattern.DecimalPlaces = 2;
  122. this.m_pPattern.DecMaxValue = new System.Decimal(new int[] {
  123.    999999999,
  124.    0,
  125.    0,
  126.    0});
  127. this.m_pPattern.DecMinValue = new System.Decimal(new int[] {
  128.    999999999,
  129.    0,
  130.    0,
  131.    -2147483648});
  132. this.m_pPattern.Lines = new string[0];
  133. this.m_pPattern.Location = new System.Drawing.Point(8, 24);
  134. this.m_pPattern.Mask = LumiSoft.UI.Controls.WEditBox_Mask.Text;
  135. this.m_pPattern.MaxLength = 32767;
  136. this.m_pPattern.Multiline = false;
  137. this.m_pPattern.Name = "m_pPattern";
  138. this.m_pPattern.PasswordChar = '';
  139. this.m_pPattern.ReadOnly = false;
  140. this.m_pPattern.ScrollBars = System.Windows.Forms.ScrollBars.None;
  141. this.m_pPattern.Size = new System.Drawing.Size(152, 20);
  142. this.m_pPattern.TabIndex = 1;
  143. this.m_pPattern.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
  144. this.m_pPattern.UseStaticViewStyle = true;
  145. // 
  146. // wLabel2
  147. // 
  148. this.wLabel2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
  149. this.wLabel2.Location = new System.Drawing.Point(8, 48);
  150. this.wLabel2.Name = "wLabel2";
  151. this.wLabel2.Size = new System.Drawing.Size(144, 16);
  152. this.wLabel2.TabIndex = 7;
  153. this.wLabel2.Text = "Route to MailBox";
  154. this.wLabel2.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
  155. this.wLabel2.UseStaticViewStyle = true;
  156. // 
  157. // wLabel3
  158. // 
  159. this.wLabel3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
  160. this.wLabel3.Location = new System.Drawing.Point(8, 88);
  161. this.wLabel3.Name = "wLabel3";
  162. this.wLabel3.Size = new System.Drawing.Size(150, 16);
  163. this.wLabel3.TabIndex = 8;
  164. this.wLabel3.Text = "Description";
  165. this.wLabel3.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
  166. this.wLabel3.UseStaticViewStyle = true;
  167. // 
  168. // m_pDescription
  169. // 
  170. this.m_pDescription.DecimalPlaces = 2;
  171. this.m_pDescription.DecMaxValue = new System.Decimal(new int[] {
  172.    999999999,
  173.    0,
  174.    0,
  175.    0});
  176. this.m_pDescription.DecMinValue = new System.Decimal(new int[] {
  177.    999999999,
  178.    0,
  179.    0,
  180.    -2147483648});
  181. this.m_pDescription.Lines = new string[0];
  182. this.m_pDescription.Location = new System.Drawing.Point(8, 104);
  183. this.m_pDescription.Mask = LumiSoft.UI.Controls.WEditBox_Mask.Text;
  184. this.m_pDescription.MaxLength = 32767;
  185. this.m_pDescription.Multiline = false;
  186. this.m_pDescription.Name = "m_pDescription";
  187. this.m_pDescription.PasswordChar = '';
  188. this.m_pDescription.ReadOnly = false;
  189. this.m_pDescription.ScrollBars = System.Windows.Forms.ScrollBars.None;
  190. this.m_pDescription.Size = new System.Drawing.Size(312, 20);
  191. this.m_pDescription.TabIndex = 4;
  192. this.m_pDescription.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
  193. this.m_pDescription.UseStaticViewStyle = true;
  194. // 
  195. // m_pOk
  196. // 
  197. this.m_pOk.Location = new System.Drawing.Point(160, 136);
  198. this.m_pOk.Name = "m_pOk";
  199. this.m_pOk.Size = new System.Drawing.Size(72, 24);
  200. this.m_pOk.TabIndex = 5;
  201. this.m_pOk.Text = "OK";
  202. this.m_pOk.UseStaticViewStyle = true;
  203. this.m_pOk.ButtonPressed += new LumiSoft.UI.Controls.ButtonPressedEventHandler(this.m_pOk_ButtonPressed);
  204. // 
  205. // m_pRouteTo
  206. // 
  207. this.m_pRouteTo.AcceptsPlussKey = true;
  208. this.m_pRouteTo.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(228)), ((System.Byte)(224)), ((System.Byte)(220)));
  209. this.m_pRouteTo.ButtonIcon = ((System.Drawing.Icon)(resources.GetObject("m_pRouteTo.ButtonIcon")));
  210. this.m_pRouteTo.ButtonWidth = 18;
  211. this.m_pRouteTo.DropDownWidth = 152;
  212. this.m_pRouteTo.Location = new System.Drawing.Point(8, 64);
  213. this.m_pRouteTo.Mask = LumiSoft.UI.Controls.WEditBox_Mask.Text;
  214. this.m_pRouteTo.MaxLength = 32767;
  215. this.m_pRouteTo.Name = "m_pRouteTo";
  216. this.m_pRouteTo.ReadOnly = true;
  217. this.m_pRouteTo.SelectedIndex = -1;
  218. this.m_pRouteTo.Size = new System.Drawing.Size(152, 20);
  219. this.m_pRouteTo.TabIndex = 3;
  220. this.m_pRouteTo.UseStaticViewStyle = true;
  221. this.m_pRouteTo.VisibleItems = 10;
  222. // 
  223. // m_pDomains
  224. // 
  225. this.m_pDomains.AcceptsPlussKey = true;
  226. this.m_pDomains.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(228)), ((System.Byte)(224)), ((System.Byte)(220)));
  227. this.m_pDomains.ButtonIcon = ((System.Drawing.Icon)(resources.GetObject("m_pDomains.ButtonIcon")));
  228. this.m_pDomains.ButtonWidth = 18;
  229. this.m_pDomains.DropDownWidth = 144;
  230. this.m_pDomains.Location = new System.Drawing.Point(176, 24);
  231. this.m_pDomains.Mask = LumiSoft.UI.Controls.WEditBox_Mask.Text;
  232. this.m_pDomains.MaxLength = 32767;
  233. this.m_pDomains.Name = "m_pDomains";
  234. this.m_pDomains.ReadOnly = true;
  235. this.m_pDomains.SelectedIndex = -1;
  236. this.m_pDomains.Size = new System.Drawing.Size(144, 20);
  237. this.m_pDomains.TabIndex = 2;
  238. this.m_pDomains.UseStaticViewStyle = true;
  239. this.m_pDomains.VisibleItems = 5;
  240. this.m_pDomains.SelectedIndexChanged += new System.EventHandler(this.m_pDomains_SelectedIndexChanged);
  241. // 
  242. // mt_symbolAT
  243. // 
  244. this.mt_symbolAT.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
  245. this.mt_symbolAT.Location = new System.Drawing.Point(160, 24);
  246. this.mt_symbolAT.Name = "mt_symbolAT";
  247. this.mt_symbolAT.Size = new System.Drawing.Size(16, 24);
  248. this.mt_symbolAT.TabIndex = 9;
  249. this.mt_symbolAT.Text = "@";
  250. this.mt_symbolAT.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
  251. this.mt_symbolAT.UseStaticViewStyle = true;
  252. // 
  253. // m_pCancel
  254. // 
  255. this.m_pCancel.Location = new System.Drawing.Point(240, 136);
  256. this.m_pCancel.Name = "m_pCancel";
  257. this.m_pCancel.Size = new System.Drawing.Size(72, 24);
  258. this.m_pCancel.TabIndex = 0;
  259. this.m_pCancel.Text = "Cancel";
  260. this.m_pCancel.UseStaticViewStyle = true;
  261. this.m_pCancel.ButtonPressed += new LumiSoft.UI.Controls.ButtonPressedEventHandler(this.m_pCancel_ButtonPressed);
  262. // 
  263. // wfrm_Route
  264. // 
  265. this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
  266. this.ClientSize = new System.Drawing.Size(330, 167);
  267. this.Controls.AddRange(new System.Windows.Forms.Control[] {
  268.   this.m_pCancel,
  269.   this.m_pDomains,
  270.   this.mt_symbolAT,
  271.   this.m_pRouteTo,
  272.   this.m_pOk,
  273.   this.m_pDescription,
  274.   this.wLabel3,
  275.   this.wLabel2,
  276.   this.m_pPattern,
  277.   this.wLabel1});
  278. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
  279. this.MaximizeBox = false;
  280. this.MinimizeBox = false;
  281. this.Name = "wfrm_Route";
  282. this.ShowInTaskbar = false;
  283. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
  284. this.Text = "Routing Properties";
  285. ((System.ComponentModel.ISupportInitialize)(this.m_pPattern)).EndInit();
  286. ((System.ComponentModel.ISupportInitialize)(this.m_pDescription)).EndInit();
  287. ((System.ComponentModel.ISupportInitialize)(this.m_pOk)).EndInit();
  288. ((System.ComponentModel.ISupportInitialize)(this.m_pRouteTo)).EndInit();
  289. ((System.ComponentModel.ISupportInitialize)(this.m_pDomains)).EndInit();
  290. ((System.ComponentModel.ISupportInitialize)(this.m_pCancel)).EndInit();
  291. this.ResumeLayout(false);
  292. }
  293. #endregion
  294. #region Events handling
  295. #region function m_pOk_ButtonPressed
  296. private void m_pOk_ButtonPressed(object sender, System.EventArgs e)
  297. {
  298. if(m_pPattern.Text.Length < 2){
  299. m_pPattern.FlashControl();
  300. return;
  301. }
  302. if(m_pRouteTo.Text.Length < 2){
  303. m_pRouteTo.FlashControl();
  304. return;
  305. }
  306. m_Pattern     = m_pPattern.Text;
  307. m_MailBox     = m_pRouteTo.Text;
  308. m_Description = m_pDescription.Text;
  309. m_DomainID    = m_pDomains.SelectedItem.Tag.ToString();
  310. m_DomainName  = m_pDomains.SelectedItem.Text;
  311. this.DialogResult = DialogResult.OK;
  312. }
  313. #endregion
  314. #region function m_pCancel_ButtonPressed
  315. private void m_pCancel_ButtonPressed(object sender, System.EventArgs e)
  316. {
  317. this.DialogResult = DialogResult.Cancel;
  318. }
  319. #endregion
  320. #region function m_pDomains_SelectedIndexChanged
  321. private void m_pDomains_SelectedIndexChanged(object sender, System.EventArgs e)
  322. {
  323. FillMailboxList();
  324. }
  325. #endregion
  326. #endregion
  327. #region function FillMailboxList
  328. private void FillMailboxList()
  329. {
  330. if(m_pDomains.SelectedItem != null){
  331. m_pRouteTo.Items.Clear();
  332. foreach(DataRowView drV in m_ServerAPI.GetUserList(m_pDomains.SelectedItem.Tag.ToString())){
  333. m_pRouteTo.Items.Add(drV["UserName"].ToString());
  334. }
  335. }
  336. }
  337. #endregion
  338. #region Properties Implementation
  339. /// <summary>
  340. /// 
  341. /// </summary>
  342. public string Pattern
  343. {
  344. get{ return m_Pattern; }
  345. }
  346. /// <summary>
  347. /// 
  348. /// </summary>
  349. public string MailBox
  350. {
  351. get{ return m_MailBox; }
  352. }
  353. /// <summary>
  354. /// 
  355. /// </summary>
  356. public string Description
  357. {
  358. get{ return m_Description; }
  359. }
  360. /// <summary>
  361. /// 
  362. /// </summary>
  363. public string DomainID
  364. {
  365. get{ return m_DomainID; }
  366. }
  367. /// <summary>
  368. /// 
  369. /// </summary>
  370. public string DomainName
  371. {
  372. get{ return m_DomainName; }
  373. }
  374. #endregion
  375. }
  376. }