Form1.cs
上传用户:leiping82
上传日期:2014-09-05
资源大小:581k
文件大小:8k
源码类别:

邮电通讯系统

开发平台:

Visual Basic

  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. using ATLH323Lib;
  8. namespace H323_Voice
  9. {
  10. /// <summary>
  11. /// Summary description for Form1.
  12. /// </summary>
  13. public class Form1 : System.Windows.Forms.Form
  14. {
  15. private System.Windows.Forms.Button button1;
  16. private System.Windows.Forms.TextBox textBox1;
  17. private System.Windows.Forms.TextBox textBox2;
  18. private System.Windows.Forms.Button button2;
  19. private System.Windows.Forms.Button button3;
  20. private System.Windows.Forms.CheckBox checkBox1;
  21. private System.Windows.Forms.CheckBox checkBox2;
  22. private System.Windows.Forms.CheckBox checkBox3;
  23. private System.Windows.Forms.Label label1;
  24. private System.Windows.Forms.Label label2;
  25. /// <summary>
  26. /// Required designer variable.
  27. /// </summary>
  28. private System.ComponentModel.Container components = null;
  29. public Form1()
  30. {
  31. //
  32. // Required for Windows Form Designer support
  33. //
  34. InitializeComponent();
  35. //
  36. // TODO: Add any constructor code after InitializeComponent call
  37. //
  38. }
  39. /// <summary>
  40. /// Clean up any resources being used.
  41. /// </summary>
  42. protected override void Dispose( bool disposing )
  43. {
  44. if( disposing )
  45. {
  46. if (components != null) 
  47. {
  48. components.Dispose();
  49. }
  50. }
  51. base.Dispose( disposing );
  52. }
  53. #region Windows Form Designer generated code
  54. /// <summary>
  55. /// Required method for Designer support - do not modify
  56. /// the contents of this method with the code editor.
  57. /// </summary>
  58. private void InitializeComponent()
  59. {
  60. this.button1 = new System.Windows.Forms.Button();
  61. this.textBox1 = new System.Windows.Forms.TextBox();
  62. this.textBox2 = new System.Windows.Forms.TextBox();
  63. this.button2 = new System.Windows.Forms.Button();
  64. this.button3 = new System.Windows.Forms.Button();
  65. this.checkBox1 = new System.Windows.Forms.CheckBox();
  66. this.checkBox2 = new System.Windows.Forms.CheckBox();
  67. this.checkBox3 = new System.Windows.Forms.CheckBox();
  68. this.label1 = new System.Windows.Forms.Label();
  69. this.label2 = new System.Windows.Forms.Label();
  70. this.SuspendLayout();
  71. // 
  72. // button1
  73. // 
  74. this.button1.Location = new System.Drawing.Point(24, 32);
  75. this.button1.Name = "button1";
  76. this.button1.Size = new System.Drawing.Size(104, 23);
  77. this.button1.TabIndex = 0;
  78. this.button1.Text = "Call Using H323";
  79. this.button1.Click += new System.EventHandler(this.button1_Click);
  80. // 
  81. // textBox1
  82. // 
  83. this.textBox1.Location = new System.Drawing.Point(136, 32);
  84. this.textBox1.Name = "textBox1";
  85. this.textBox1.TabIndex = 1;
  86. this.textBox1.Text = "127.0.0.1";
  87. // 
  88. // textBox2
  89. // 
  90. this.textBox2.Enabled = false;
  91. this.textBox2.Location = new System.Drawing.Point(160, 216);
  92. this.textBox2.Name = "textBox2";
  93. this.textBox2.TabIndex = 2;
  94. this.textBox2.Text = "";
  95. // 
  96. // button2
  97. // 
  98. this.button2.Enabled = false;
  99. this.button2.Location = new System.Drawing.Point(24, 64);
  100. this.button2.Name = "button2";
  101. this.button2.TabIndex = 4;
  102. this.button2.Text = "HungUp";
  103. this.button2.Click += new System.EventHandler(this.button2_Click);
  104. // 
  105. // button3
  106. // 
  107. this.button3.Location = new System.Drawing.Point(112, 64);
  108. this.button3.Name = "button3";
  109. this.button3.TabIndex = 5;
  110. this.button3.Text = "Listen";
  111. this.button3.Click += new System.EventHandler(this.button3_Click);
  112. // 
  113. // checkBox1
  114. // 
  115. this.checkBox1.Checked = true;
  116. this.checkBox1.CheckState = System.Windows.Forms.CheckState.Checked;
  117. this.checkBox1.Location = new System.Drawing.Point(32, 120);
  118. this.checkBox1.Name = "checkBox1";
  119. this.checkBox1.Size = new System.Drawing.Size(144, 24);
  120. this.checkBox1.TabIndex = 6;
  121. this.checkBox1.Text = "Silence Detection";
  122. this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged_1);
  123. // 
  124. // checkBox2
  125. // 
  126. this.checkBox2.Checked = true;
  127. this.checkBox2.CheckState = System.Windows.Forms.CheckState.Checked;
  128. this.checkBox2.Location = new System.Drawing.Point(32, 152);
  129. this.checkBox2.Name = "checkBox2";
  130. this.checkBox2.Size = new System.Drawing.Size(144, 24);
  131. this.checkBox2.TabIndex = 7;
  132. this.checkBox2.Text = "Auto Answer";
  133. this.checkBox2.CheckedChanged += new System.EventHandler(this.checkBox2_CheckedChanged);
  134. // 
  135. // checkBox3
  136. // 
  137. this.checkBox3.Location = new System.Drawing.Point(24, 216);
  138. this.checkBox3.Name = "checkBox3";
  139. this.checkBox3.Size = new System.Drawing.Size(136, 24);
  140. this.checkBox3.TabIndex = 8;
  141. this.checkBox3.Text = "Use H323 Gateway";
  142. this.checkBox3.CheckedChanged += new System.EventHandler(this.checkBox3_CheckedChanged);
  143. // 
  144. // label1
  145. // 
  146. this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(178)));
  147. this.label1.Location = new System.Drawing.Point(208, 104);
  148. this.label1.Name = "label1";
  149. this.label1.Size = new System.Drawing.Size(128, 88);
  150. this.label1.TabIndex = 9;
  151. this.label1.Text = "H.323      Voice Over IP Caller";
  152. // 
  153. // label2
  154. // 
  155. this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(178)));
  156. this.label2.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(192)), ((System.Byte)(192)), ((System.Byte)(255)));
  157. this.label2.Location = new System.Drawing.Point(80, 256);
  158. this.label2.Name = "label2";
  159. this.label2.Size = new System.Drawing.Size(176, 24);
  160. this.label2.TabIndex = 10;
  161. this.label2.Text = "www.fadidotnet.org";
  162. // 
  163. // Form1
  164. // 
  165. this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
  166. this.ClientSize = new System.Drawing.Size(352, 286);
  167. this.Controls.Add(this.label2);
  168. this.Controls.Add(this.label1);
  169. this.Controls.Add(this.checkBox3);
  170. this.Controls.Add(this.checkBox2);
  171. this.Controls.Add(this.checkBox1);
  172. this.Controls.Add(this.button3);
  173. this.Controls.Add(this.button2);
  174. this.Controls.Add(this.textBox2);
  175. this.Controls.Add(this.textBox1);
  176. this.Controls.Add(this.button1);
  177. this.Name = "Form1";
  178. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
  179. this.Text = "H323 Voice Chat - By Fadi Abdelqader , www.fadidotnet.org";
  180. this.Load += new System.EventHandler(this.Form1_Load);
  181. this.ResumeLayout(false);
  182. }
  183. #endregion
  184. /// <summary>
  185. /// The main entry point for the application.
  186. /// </summary>
  187. [STAThread]
  188. static void Main() 
  189. {
  190. Application.Run(new Form1());
  191. }
  192. H323Class h323 = new H323Class ();
  193. private void Form1_Load(object sender, System.EventArgs e)
  194. {
  195. h323.AutoAnswer = true;
  196. h323.SilenceDetection = true;
  197. }
  198. private void checkBox1_CheckedChanged(object sender, System.EventArgs e)
  199. {
  200. }
  201. private void button1_Click(object sender, System.EventArgs e)
  202. {
  203. h323.RemoteHost = textBox1.Text;
  204. h323.Connect ();
  205. button1.Enabled = false;
  206. button2.Enabled = true;
  207. }
  208. private void button2_Click(object sender, System.EventArgs e)
  209. {
  210. h323.Hangup();
  211. button2.Enabled = false;
  212. button1.Enabled = true;
  213. }
  214. private void button3_Click(object sender, System.EventArgs e)
  215. {
  216. h323.Listen ();
  217. }
  218. private void checkBox1_CheckedChanged_1(object sender, System.EventArgs e)
  219. {
  220. if (checkBox1.Checked)
  221. {
  222. h323.SilenceDetection = true;
  223. }
  224. else
  225. h323.SilenceDetection = false;
  226. }
  227. private void checkBox2_CheckedChanged(object sender, System.EventArgs e)
  228. {
  229. if (checkBox2.Checked)
  230. {
  231. h323.AutoAnswer  = true;
  232. }
  233. else
  234. h323.AutoAnswer  = false;
  235. }
  236. private void checkBox3_CheckedChanged(object sender, System.EventArgs e)
  237. {
  238. if (checkBox3.Checked)
  239. {
  240. textBox2.Enabled = true;
  241. h323.UseGateway = true;
  242. h323.Gateway = textBox2.Text;
  243. }
  244. else
  245. {
  246. h323.UseGateway = false;
  247. textBox2.Enabled  = false;
  248. }
  249. }
  250. }
  251. }