FormSendMsgGroup.cs
上传用户:lqb116
上传日期:2014-04-04
资源大小:2712k
文件大小:17k
源码类别:

P2P编程

开发平台:

C#

  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Windows.Forms;
  6. using System.Data;
  7. namespace LanMsg
  8. {
  9. /// <summary>
  10. /// Form1 的摘要说明。
  11. /// </summary>
  12. public class FormSendMsgGroup : DevComponents.DotNetBar.Office2007RibbonForm 
  13. {
  14. private DevComponents.DotNetBar.RibbonControl ribbonControl1;
  15. private DevComponents.Editors.ComboItem comboItem1;
  16. private DevComponents.Editors.ComboItem comboItem2;
  17. private DevComponents.Editors.ComboItem comboItem3;
  18. private DevComponents.DotNetBar.Bar bar1;
  19. private DevComponents.DotNetBar.LabelItem labelItem1;
  20. private DevComponents.DotNetBar.ComboBoxItem comboBoxInfoClass;
  21. private DevComponents.Editors.ComboItem comb1;
  22. private DevComponents.Editors.ComboItem comb3;
  23. private DevComponents.DotNetBar.ButtonItem butSendMsg;
  24. private System.ComponentModel.IContainer components;
  25. private DevComponents.DotNetBar.ButtonItem butSave;
  26. private System.Windows.Forms.Panel panel1;
  27. private System.Windows.Forms.Panel panel2;
  28. private System.Windows.Forms.Panel panel3;
  29. private System.Windows.Forms.Panel panel4;
  30. private LanMsg.MyExtRichTextBox RTBSendContent;
  31. private DevComponents.DotNetBar.ButtonItem buttonItem1;
  32. private DevComponents.DotNetBar.DotNetBarManager dotNetBarManager1;
  33. private DevComponents.DotNetBar.DockSite barLeftDockSite;
  34. private DevComponents.DotNetBar.DockSite barRightDockSite;
  35. private DevComponents.DotNetBar.DockSite barTopDockSite;
  36. private DevComponents.DotNetBar.DockSite barBottomDockSite;
  37. private ClassFormMain FormMain =new ClassFormMain();
  38. public FormSendMsgGroup()
  39. {
  40. //
  41. // Windows 窗体设计器支持所必需的
  42. //
  43. InitializeComponent();
  44.             this.comboBoxInfoClass.SelectedIndex=0;
  45. //
  46. // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
  47. //
  48. }
  49. /// <summary>
  50. /// 清理所有正在使用的资源。
  51. /// </summary>
  52. protected override void Dispose( bool disposing )
  53. {
  54. FormMain.formMain.forms.Romove(this);
  55. if( disposing )
  56. {
  57. if (components != null) 
  58. {
  59. components.Dispose();
  60. }
  61. }
  62. base.Dispose( disposing );
  63. }
  64. #region Windows 窗体设计器生成的代码
  65. /// <summary>
  66. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  67. /// 此方法的内容。
  68. /// </summary>
  69. private void InitializeComponent()
  70. {
  71. this.components = new System.ComponentModel.Container();
  72. System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(FormSendMsgGroup));
  73. this.ribbonControl1 = new DevComponents.DotNetBar.RibbonControl();
  74. this.butSave = new DevComponents.DotNetBar.ButtonItem();
  75. this.buttonItem1 = new DevComponents.DotNetBar.ButtonItem();
  76. this.comboItem1 = new DevComponents.Editors.ComboItem();
  77. this.comboItem2 = new DevComponents.Editors.ComboItem();
  78. this.comboItem3 = new DevComponents.Editors.ComboItem();
  79. this.bar1 = new DevComponents.DotNetBar.Bar();
  80. this.labelItem1 = new DevComponents.DotNetBar.LabelItem();
  81. this.comboBoxInfoClass = new DevComponents.DotNetBar.ComboBoxItem();
  82. this.comb1 = new DevComponents.Editors.ComboItem();
  83. this.comb3 = new DevComponents.Editors.ComboItem();
  84. this.butSendMsg = new DevComponents.DotNetBar.ButtonItem();
  85. this.panel1 = new System.Windows.Forms.Panel();
  86. this.panel2 = new System.Windows.Forms.Panel();
  87. this.panel3 = new System.Windows.Forms.Panel();
  88. this.panel4 = new System.Windows.Forms.Panel();
  89. this.RTBSendContent = new LanMsg.MyExtRichTextBox();
  90. this.dotNetBarManager1 = new DevComponents.DotNetBar.DotNetBarManager(this.components);
  91. this.barLeftDockSite = new DevComponents.DotNetBar.DockSite();
  92. this.barRightDockSite = new DevComponents.DotNetBar.DockSite();
  93. this.barTopDockSite = new DevComponents.DotNetBar.DockSite();
  94. this.barBottomDockSite = new DevComponents.DotNetBar.DockSite();
  95. ((System.ComponentModel.ISupportInitialize)(this.bar1)).BeginInit();
  96. this.SuspendLayout();
  97. // 
  98. // ribbonControl1
  99. // 
  100. this.ribbonControl1.BackColor = System.Drawing.SystemColors.Control;
  101. this.ribbonControl1.CaptionVisible = true;
  102. this.ribbonControl1.Dock = System.Windows.Forms.DockStyle.Top;
  103. this.ribbonControl1.DockPadding.Bottom = 2;
  104. this.ribbonControl1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
  105. this.ribbonControl1.Items.AddRange(new DevComponents.DotNetBar.BaseItem[] {
  106.   this.butSave});
  107. this.ribbonControl1.KeyTipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
  108. this.ribbonControl1.Location = new System.Drawing.Point(2, 2);
  109. this.ribbonControl1.MdiSystemItemVisible = false;
  110. this.ribbonControl1.Name = "ribbonControl1";
  111. this.ribbonControl1.QuickToolbarItems.AddRange(new DevComponents.DotNetBar.BaseItem[] {
  112.   this.buttonItem1});
  113. this.ribbonControl1.RibbonStripIndent = 55;
  114. this.ribbonControl1.Size = new System.Drawing.Size(496, 22);
  115. this.ribbonControl1.Style = DevComponents.DotNetBar.eDotNetBarStyle.Office2007;
  116. this.ribbonControl1.TabGroupHeight = 15;
  117. this.ribbonControl1.TabIndex = 43;
  118. // 
  119. // butSave
  120. // 
  121. this.butSave.Icon = ((System.Drawing.Icon)(resources.GetObject("butSave.Icon")));
  122. this.butSave.Name = "butSave";
  123. this.butSave.Tooltip = "消息另存为";
  124. this.butSave.Click += new System.EventHandler(this.butSave_Click);
  125. // 
  126. // buttonItem1
  127. // 
  128. this.buttonItem1.Image = ((System.Drawing.Image)(resources.GetObject("buttonItem1.Image")));
  129. this.buttonItem1.Name = "buttonItem1";
  130. this.buttonItem1.Text = "buttonItem1";
  131. // 
  132. // comboItem1
  133. // 
  134. this.comboItem1.Text = "通知";
  135. // 
  136. // comboItem2
  137. // 
  138. this.comboItem2.Text = "消息(需要回复内容)";
  139. // 
  140. // comboItem3
  141. // 
  142. this.comboItem3.Text = "通知(需要确认收到)";
  143. // 
  144. // bar1
  145. // 
  146. this.bar1.AccessibleDescription = "DotNetBar Bar (bar1)";
  147. this.bar1.AccessibleName = "DotNetBar Bar";
  148. this.bar1.AccessibleRole = System.Windows.Forms.AccessibleRole.StatusBar;
  149. this.bar1.AntiAlias = true;
  150. this.bar1.Dock = System.Windows.Forms.DockStyle.Bottom;
  151. this.bar1.GrabHandleStyle = DevComponents.DotNetBar.eGrabHandleStyle.ResizeHandle;
  152. this.bar1.Items.AddRange(new DevComponents.DotNetBar.BaseItem[] {
  153. this.labelItem1,
  154. this.comboBoxInfoClass,
  155. this.butSendMsg});
  156. this.bar1.ItemSpacing = 2;
  157. this.bar1.Location = new System.Drawing.Point(2, 323);
  158. this.bar1.Name = "bar1";
  159. this.bar1.Size = new System.Drawing.Size(496, 25);
  160. this.bar1.Stretch = true;
  161. this.bar1.Style = DevComponents.DotNetBar.eDotNetBarStyle.Office2007;
  162. this.bar1.TabIndex = 48;
  163. this.bar1.TabStop = false;
  164. this.bar1.Text = "barStatus";
  165. // 
  166. // labelItem1
  167. // 
  168. this.labelItem1.BorderType = DevComponents.DotNetBar.eBorderType.None;
  169. this.labelItem1.Name = "labelItem1";
  170. this.labelItem1.PaddingLeft = 4;
  171. this.labelItem1.Text = "发送类别:";
  172. // 
  173. // comboBoxInfoClass
  174. // 
  175. this.comboBoxInfoClass.ItemHeight = 14;
  176. this.comboBoxInfoClass.Items.AddRange(new object[] {
  177.    this.comb1,
  178.    this.comb3});
  179. this.comboBoxInfoClass.Name = "comboBoxInfoClass";
  180. this.comboBoxInfoClass.Stretch = true;
  181. // 
  182. // comb1
  183. // 
  184. this.comb1.Text = "通知";
  185. // 
  186. // comb3
  187. // 
  188. this.comb3.Text = "普通消息";
  189. // 
  190. // butSendMsg
  191. // 
  192. this.butSendMsg.Name = "butSendMsg";
  193. this.butSendMsg.Text = " 发送(&S)";
  194. this.butSendMsg.Click += new System.EventHandler(this.butSendMsg_Click);
  195. // 
  196. // panel1
  197. // 
  198. this.panel1.Dock = System.Windows.Forms.DockStyle.Left;
  199. this.panel1.Location = new System.Drawing.Point(2, 24);
  200. this.panel1.Name = "panel1";
  201. this.panel1.Size = new System.Drawing.Size(8, 299);
  202. this.panel1.TabIndex = 49;
  203. // 
  204. // panel2
  205. // 
  206. this.panel2.Dock = System.Windows.Forms.DockStyle.Right;
  207. this.panel2.Location = new System.Drawing.Point(490, 24);
  208. this.panel2.Name = "panel2";
  209. this.panel2.Size = new System.Drawing.Size(8, 299);
  210. this.panel2.TabIndex = 50;
  211. // 
  212. // panel3
  213. // 
  214. this.panel3.Dock = System.Windows.Forms.DockStyle.Top;
  215. this.panel3.Location = new System.Drawing.Point(10, 24);
  216. this.panel3.Name = "panel3";
  217. this.panel3.Size = new System.Drawing.Size(480, 8);
  218. this.panel3.TabIndex = 51;
  219. // 
  220. // panel4
  221. // 
  222. this.panel4.Dock = System.Windows.Forms.DockStyle.Bottom;
  223. this.panel4.Location = new System.Drawing.Point(10, 315);
  224. this.panel4.Name = "panel4";
  225. this.panel4.Size = new System.Drawing.Size(480, 8);
  226. this.panel4.TabIndex = 52;
  227. // 
  228. // RTBSendContent
  229. // 
  230. this.dotNetBarManager1.SetContextMenuEx(this.RTBSendContent, "ButtonItem1");
  231. this.RTBSendContent.Dock = System.Windows.Forms.DockStyle.Fill;
  232. this.RTBSendContent.Font = new System.Drawing.Font("宋体", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
  233. this.RTBSendContent.HiglightColor = LanMsg.RtfColor.White;
  234. this.RTBSendContent.Location = new System.Drawing.Point(10, 32);
  235. this.RTBSendContent.MaxLength = 1000;
  236. this.RTBSendContent.Name = "RTBSendContent";
  237. this.RTBSendContent.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical;
  238. this.RTBSendContent.Size = new System.Drawing.Size(480, 283);
  239. this.RTBSendContent.TabIndex = 53;
  240. this.RTBSendContent.Text = "";
  241. this.RTBSendContent.TextColor = LanMsg.RtfColor.Black;
  242. this.RTBSendContent.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.RTBSendContent_LinkClicked);
  243. // 
  244. // dotNetBarManager1
  245. // 
  246. this.dotNetBarManager1.AutoDispatchShortcuts.Add(DevComponents.DotNetBar.eShortcut.F1);
  247. this.dotNetBarManager1.AutoDispatchShortcuts.Add(DevComponents.DotNetBar.eShortcut.CtrlC);
  248. this.dotNetBarManager1.AutoDispatchShortcuts.Add(DevComponents.DotNetBar.eShortcut.CtrlA);
  249. this.dotNetBarManager1.AutoDispatchShortcuts.Add(DevComponents.DotNetBar.eShortcut.CtrlV);
  250. this.dotNetBarManager1.AutoDispatchShortcuts.Add(DevComponents.DotNetBar.eShortcut.CtrlX);
  251. this.dotNetBarManager1.AutoDispatchShortcuts.Add(DevComponents.DotNetBar.eShortcut.CtrlZ);
  252. this.dotNetBarManager1.AutoDispatchShortcuts.Add(DevComponents.DotNetBar.eShortcut.CtrlY);
  253. this.dotNetBarManager1.AutoDispatchShortcuts.Add(DevComponents.DotNetBar.eShortcut.Del);
  254. this.dotNetBarManager1.AutoDispatchShortcuts.Add(DevComponents.DotNetBar.eShortcut.Ins);
  255. this.dotNetBarManager1.BottomDockSite = this.barBottomDockSite;
  256. this.dotNetBarManager1.DefinitionName = "FormSendMsgGroup.dotNetBarManager1.xml";
  257. this.dotNetBarManager1.EnableFullSizeDock = false;
  258. this.dotNetBarManager1.LeftDockSite = this.barLeftDockSite;
  259. this.dotNetBarManager1.ParentForm = this;
  260. this.dotNetBarManager1.RightDockSite = this.barRightDockSite;
  261. this.dotNetBarManager1.Style = DevComponents.DotNetBar.eDotNetBarStyle.Office2003;
  262. this.dotNetBarManager1.ThemeAware = false;
  263. this.dotNetBarManager1.TopDockSite = this.barTopDockSite;
  264. this.dotNetBarManager1.ItemClick += new System.EventHandler(this.dotNetBarManager1_ItemClick);
  265. // 
  266. // barLeftDockSite
  267. // 
  268. this.barLeftDockSite.AccessibleRole = System.Windows.Forms.AccessibleRole.Window;
  269. this.barLeftDockSite.Dock = System.Windows.Forms.DockStyle.Left;
  270. this.barLeftDockSite.Location = new System.Drawing.Point(2, 2);
  271. this.barLeftDockSite.Name = "barLeftDockSite";
  272. this.barLeftDockSite.NeedsLayout = false;
  273. this.barLeftDockSite.Size = new System.Drawing.Size(0, 346);
  274. this.barLeftDockSite.TabIndex = 54;
  275. this.barLeftDockSite.TabStop = false;
  276. // 
  277. // barRightDockSite
  278. // 
  279. this.barRightDockSite.AccessibleRole = System.Windows.Forms.AccessibleRole.Window;
  280. this.barRightDockSite.Dock = System.Windows.Forms.DockStyle.Right;
  281. this.barRightDockSite.Location = new System.Drawing.Point(498, 2);
  282. this.barRightDockSite.Name = "barRightDockSite";
  283. this.barRightDockSite.NeedsLayout = false;
  284. this.barRightDockSite.Size = new System.Drawing.Size(0, 346);
  285. this.barRightDockSite.TabIndex = 55;
  286. this.barRightDockSite.TabStop = false;
  287. // 
  288. // barTopDockSite
  289. // 
  290. this.barTopDockSite.AccessibleRole = System.Windows.Forms.AccessibleRole.Window;
  291. this.barTopDockSite.Dock = System.Windows.Forms.DockStyle.Top;
  292. this.barTopDockSite.Location = new System.Drawing.Point(2, 2);
  293. this.barTopDockSite.Name = "barTopDockSite";
  294. this.barTopDockSite.NeedsLayout = false;
  295. this.barTopDockSite.Size = new System.Drawing.Size(496, 0);
  296. this.barTopDockSite.TabIndex = 56;
  297. this.barTopDockSite.TabStop = false;
  298. // 
  299. // barBottomDockSite
  300. // 
  301. this.barBottomDockSite.AccessibleRole = System.Windows.Forms.AccessibleRole.Window;
  302. this.barBottomDockSite.Dock = System.Windows.Forms.DockStyle.Bottom;
  303. this.barBottomDockSite.Location = new System.Drawing.Point(2, 348);
  304. this.barBottomDockSite.Name = "barBottomDockSite";
  305. this.barBottomDockSite.NeedsLayout = false;
  306. this.barBottomDockSite.Size = new System.Drawing.Size(496, 0);
  307. this.barBottomDockSite.TabIndex = 57;
  308. this.barBottomDockSite.TabStop = false;
  309. // 
  310. // FormSendMsgGroup
  311. // 
  312. this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
  313. this.ClientSize = new System.Drawing.Size(500, 350);
  314. this.Controls.Add(this.RTBSendContent);
  315. this.Controls.Add(this.panel4);
  316. this.Controls.Add(this.panel3);
  317. this.Controls.Add(this.panel2);
  318. this.Controls.Add(this.panel1);
  319. this.Controls.Add(this.bar1);
  320. this.Controls.Add(this.ribbonControl1);
  321. this.Controls.Add(this.barLeftDockSite);
  322. this.Controls.Add(this.barRightDockSite);
  323. this.Controls.Add(this.barTopDockSite);
  324. this.Controls.Add(this.barBottomDockSite);
  325. this.DockPadding.Bottom = 2;
  326. this.DockPadding.Left = 2;
  327. this.DockPadding.Right = 2;
  328. this.DockPadding.Top = 2;
  329. this.MinimumSize = new System.Drawing.Size(500, 350);
  330. this.Name = "FormSendMsgGroup";
  331. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
  332. this.Text = "消息群发";
  333. this.TopMost = true;
  334. this.Closing += new System.ComponentModel.CancelEventHandler(this.FormSendMsgGroup_Closing);
  335. ((System.ComponentModel.ISupportInitialize)(this.bar1)).EndInit();
  336. this.ResumeLayout(false);
  337. }
  338. #endregion
  339. private void butSendMsg_Click(object sender, System.EventArgs e)
  340. {
  341. if(this.RTBSendContent.Text.Trim()=="")
  342. {
  343. MessageBox.Show("不能发送空消息。","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
  344.     return;
  345. }
  346. this.FormMain.formMain.MsgAddToDB(this.RTBSendContent.Text.TrimEnd(),this.FormMain.formMain.selfInfo.ID,"",this.FormMain.formMain.selfInfo.AssemblyVersion ,System.DateTime.Now.ToString(),"",false);
  347.             this.FormMain.formMain.sendNotice(new Controls.ClassMsg(7,"",System.Text.Encoding.Unicode.GetBytes(this.RTBSendContent.Text.TrimEnd())));
  348. MessageBox.Show("消息已经发送。","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
  349. this.RTBSendContent.Clear();
  350. this.Close();
  351. this.Dispose();
  352. }
  353. private void butSave_Click(object sender, System.EventArgs e)
  354. {
  355.    System.Windows.Forms.SaveFileDialog fd=new SaveFileDialog ();
  356. fd.Filter="写字板文档(*.rtf)|*.rtf";
  357. if(fd.ShowDialog()==System.Windows.Forms.DialogResult.OK)
  358. {
  359.                 this.RTBSendContent.SaveFile(fd.FileName,System.Windows.Forms.RichTextBoxStreamType.RichText );
  360. }
  361. }
  362. private void FormSendMsgGroup_Closing(object sender, System.ComponentModel.CancelEventArgs e)
  363. {
  364. FormMain.formMain.TvUsers.CheckBoxes=false;
  365. }
  366. private void RTBSendContent_LinkClicked(object sender, System.Windows.Forms.LinkClickedEventArgs e)
  367. {
  368. try
  369. {
  370. System.Diagnostics.Process.Start(e.LinkText);
  371. }
  372. catch 
  373. {
  374. MessageBox.Show("无法打开链接。","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
  375. }
  376. }
  377. private void dotNetBarManager1_ItemClick(object sender, System.EventArgs e)
  378. {
  379. switch((sender as DevComponents.DotNetBar.ButtonItem ).Name )
  380. {
  381. case "复制" :
  382. if(this.RTBSendContent.Focus())
  383. this.RTBSendContent.Copy (); 
  384. break;
  385. case "粘贴" :
  386. if(this.RTBSendContent.Focus())
  387. this.RTBSendContent.Paste (); 
  388. break;
  389. case "全选" :
  390. if(this.RTBSendContent.Focus())
  391. this.RTBSendContent.SelectAll (); 
  392. break;
  393. case "剪切" :
  394. if(this.RTBSendContent.Focus())
  395. this.RTBSendContent.Cut (); 
  396. break;
  397. }
  398. }
  399. /// <summary>
  400. /// 应用程序的主入口点。
  401. /// </summary>
  402. }
  403. }