panelServerSetting.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. using System;
  2. using System.ComponentModel;
  3. using System.Configuration;
  4. using System.Drawing;
  5. using System.Windows.Forms;
  6. namespace prBrowser.Weblogic
  7. {
  8. public class panelServerSetting : Form
  9. {
  10. private IContainer components = null;
  11. private Label label1;
  12. private Label label2;
  13. private TextBox textBoxDefaultUrl;
  14. private TextBox textBoxInsecureUrl;
  15. private Button BtnServerConfirm;
  16. private Button BtnServerCancel;
  17. private Label label3;
  18. private TextBox textBoxUpdateUrl;
  19. private CheckBox checkBoxAutoUpdate;
  20. private Label label5;
  21. private TextBox textBoxDefaultZoom;
  22. private Label label6;
  23. private Label label4;
  24. public panelServerSetting()
  25. {
  26. InitializeComponent();
  27. }
  28. private void BtnServerConfirm_Click(object sender, EventArgs e)
  29. {
  30. SetConfigValue("DefaultUrl", textBoxDefaultUrl.Text);
  31. SetConfigValue("InsecureUrl", textBoxInsecureUrl.Text);
  32. SetConfigValue("UpdateUrl", textBoxUpdateUrl.Text);
  33. SetConfigValue("DefaultZoom", textBoxDefaultZoom.Text);
  34. if (checkBoxAutoUpdate.Checked)
  35. {
  36. SetConfigValue("AutoUpdate", "Y");
  37. }
  38. else
  39. {
  40. SetConfigValue("AutoUpdate", "N");
  41. }
  42. Close();
  43. }
  44. private void BtnServerCancel_Click(object sender, EventArgs e)
  45. {
  46. Close();
  47. }
  48. private void panelServerSetting_Load(object sender, EventArgs e)
  49. {
  50. textBoxDefaultUrl.Text = ConfigurationManager.AppSettings["DefaultUrl"];
  51. textBoxInsecureUrl.Text = ConfigurationManager.AppSettings["InsecureUrl"];
  52. textBoxUpdateUrl.Text = ConfigurationManager.AppSettings["UpdateUrl"];
  53. textBoxDefaultZoom.Text = ConfigurationManager.AppSettings["DefaultZoom"];
  54. try
  55. {
  56. if (Convert.ToInt32(textBoxDefaultZoom.Text)>100 || Convert.ToInt32(textBoxDefaultZoom.Text)<50) {
  57. textBoxDefaultZoom.Text = "100";
  58. }
  59. }catch(Exception ex)
  60. {
  61. textBoxDefaultZoom.Text = "100";
  62. }
  63. string autoUpdate = ConfigurationManager.AppSettings["AutoUpdate"];
  64. if (autoUpdate == "Y")
  65. {
  66. checkBoxAutoUpdate.Checked = true;
  67. }
  68. else
  69. {
  70. checkBoxAutoUpdate.Checked = false;
  71. }
  72. textBoxDefaultUrl.Focus();
  73. if (textBoxDefaultUrl.Text.Length > 0)
  74. {
  75. textBoxDefaultUrl.SelectionStart = textBoxDefaultUrl.Text.Length;
  76. }
  77. }
  78. public static bool SetConfigValue(string key, string value)
  79. {
  80. try
  81. {
  82. Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
  83. if (config.AppSettings.Settings[key] != null)
  84. {
  85. config.AppSettings.Settings[key].Value = value;
  86. }
  87. else
  88. {
  89. config.AppSettings.Settings.Add(key, value);
  90. }
  91. config.Save(ConfigurationSaveMode.Modified);
  92. ConfigurationManager.RefreshSection("appSettings");
  93. return true;
  94. }
  95. catch
  96. {
  97. return false;
  98. }
  99. }
  100. private void textBoxDefaultUrl_KeyUp(object sender, KeyEventArgs e)
  101. {
  102. if (e.KeyValue == 13)
  103. {
  104. textBoxInsecureUrl.Focus();
  105. if (textBoxInsecureUrl.Text.Length > 0)
  106. {
  107. textBoxInsecureUrl.SelectionStart = textBoxInsecureUrl.Text.Length;
  108. }
  109. }
  110. }
  111. private void textBoxInsecureUrl_KeyUp(object sender, KeyEventArgs e)
  112. {
  113. if (e.KeyValue == 13)
  114. {
  115. BtnServerConfirm.Focus();
  116. }
  117. }
  118. protected override void Dispose(bool disposing)
  119. {
  120. if (disposing && components != null)
  121. {
  122. components.Dispose();
  123. }
  124. base.Dispose(disposing);
  125. }
  126. private void InitializeComponent()
  127. {
  128. this.label1 = new System.Windows.Forms.Label();
  129. this.label2 = new System.Windows.Forms.Label();
  130. this.textBoxDefaultUrl = new System.Windows.Forms.TextBox();
  131. this.textBoxInsecureUrl = new System.Windows.Forms.TextBox();
  132. this.BtnServerConfirm = new System.Windows.Forms.Button();
  133. this.BtnServerCancel = new System.Windows.Forms.Button();
  134. this.label3 = new System.Windows.Forms.Label();
  135. this.textBoxUpdateUrl = new System.Windows.Forms.TextBox();
  136. this.checkBoxAutoUpdate = new System.Windows.Forms.CheckBox();
  137. this.label4 = new System.Windows.Forms.Label();
  138. this.label5 = new System.Windows.Forms.Label();
  139. this.textBoxDefaultZoom = new System.Windows.Forms.TextBox();
  140. this.label6 = new System.Windows.Forms.Label();
  141. this.SuspendLayout();
  142. //
  143. // label1
  144. //
  145. this.label1.AutoSize = true;
  146. this.label1.Location = new System.Drawing.Point(39, 42);
  147. this.label1.Name = "label1";
  148. this.label1.Size = new System.Drawing.Size(101, 12);
  149. this.label1.TabIndex = 0;
  150. this.label1.Text = "默认服务器地址:";
  151. //
  152. // label2
  153. //
  154. this.label2.AutoSize = true;
  155. this.label2.Location = new System.Drawing.Point(41, 93);
  156. this.label2.Name = "label2";
  157. this.label2.Size = new System.Drawing.Size(101, 12);
  158. this.label2.TabIndex = 1;
  159. this.label2.Text = "允许流媒体地址:";
  160. //
  161. // textBoxDefaultUrl
  162. //
  163. this.textBoxDefaultUrl.Location = new System.Drawing.Point(146, 39);
  164. this.textBoxDefaultUrl.Name = "textBoxDefaultUrl";
  165. this.textBoxDefaultUrl.Size = new System.Drawing.Size(165, 21);
  166. this.textBoxDefaultUrl.TabIndex = 2;
  167. this.textBoxDefaultUrl.KeyUp += new System.Windows.Forms.KeyEventHandler(this.textBoxDefaultUrl_KeyUp);
  168. //
  169. // textBoxInsecureUrl
  170. //
  171. this.textBoxInsecureUrl.Location = new System.Drawing.Point(146, 90);
  172. this.textBoxInsecureUrl.Multiline = true;
  173. this.textBoxInsecureUrl.Name = "textBoxInsecureUrl";
  174. this.textBoxInsecureUrl.Size = new System.Drawing.Size(163, 79);
  175. this.textBoxInsecureUrl.TabIndex = 3;
  176. this.textBoxInsecureUrl.KeyUp += new System.Windows.Forms.KeyEventHandler(this.textBoxInsecureUrl_KeyUp);
  177. //
  178. // BtnServerConfirm
  179. //
  180. this.BtnServerConfirm.Location = new System.Drawing.Point(65, 290);
  181. this.BtnServerConfirm.Name = "BtnServerConfirm";
  182. this.BtnServerConfirm.Size = new System.Drawing.Size(75, 23);
  183. this.BtnServerConfirm.TabIndex = 4;
  184. this.BtnServerConfirm.Text = "确认";
  185. this.BtnServerConfirm.UseVisualStyleBackColor = true;
  186. this.BtnServerConfirm.Click += new System.EventHandler(this.BtnServerConfirm_Click);
  187. //
  188. // BtnServerCancel
  189. //
  190. this.BtnServerCancel.Location = new System.Drawing.Point(236, 290);
  191. this.BtnServerCancel.Name = "BtnServerCancel";
  192. this.BtnServerCancel.Size = new System.Drawing.Size(75, 23);
  193. this.BtnServerCancel.TabIndex = 5;
  194. this.BtnServerCancel.Text = "取消";
  195. this.BtnServerCancel.UseVisualStyleBackColor = true;
  196. this.BtnServerCancel.Click += new System.EventHandler(this.BtnServerCancel_Click);
  197. //
  198. // label3
  199. //
  200. this.label3.AutoSize = true;
  201. this.label3.Location = new System.Drawing.Point(39, 216);
  202. this.label3.Name = "label3";
  203. this.label3.Size = new System.Drawing.Size(101, 12);
  204. this.label3.TabIndex = 6;
  205. this.label3.Text = "更新服务器地址:";
  206. //
  207. // textBoxUpdateUrl
  208. //
  209. this.textBoxUpdateUrl.Location = new System.Drawing.Point(146, 213);
  210. this.textBoxUpdateUrl.Name = "textBoxUpdateUrl";
  211. this.textBoxUpdateUrl.Size = new System.Drawing.Size(165, 21);
  212. this.textBoxUpdateUrl.TabIndex = 7;
  213. //
  214. // checkBoxAutoUpdate
  215. //
  216. this.checkBoxAutoUpdate.AutoSize = true;
  217. this.checkBoxAutoUpdate.Location = new System.Drawing.Point(239, 268);
  218. this.checkBoxAutoUpdate.Name = "checkBoxAutoUpdate";
  219. this.checkBoxAutoUpdate.Size = new System.Drawing.Size(72, 16);
  220. this.checkBoxAutoUpdate.TabIndex = 8;
  221. this.checkBoxAutoUpdate.Text = "自动更新";
  222. this.checkBoxAutoUpdate.UseVisualStyleBackColor = true;
  223. //
  224. // label4
  225. //
  226. this.label4.AutoSize = true;
  227. this.label4.ForeColor = System.Drawing.Color.Red;
  228. this.label4.Location = new System.Drawing.Point(157, 172);
  229. this.label4.Name = "label4";
  230. this.label4.Size = new System.Drawing.Size(143, 12);
  231. this.label4.TabIndex = 9;
  232. this.label4.Text = "多条记录使用逗号\",\"分割";
  233. //
  234. // label5
  235. //
  236. this.label5.AutoSize = true;
  237. this.label5.Location = new System.Drawing.Point(51, 244);
  238. this.label5.Name = "label5";
  239. this.label5.Size = new System.Drawing.Size(89, 12);
  240. this.label5.TabIndex = 10;
  241. this.label5.Text = "默认缩放比例:";
  242. //
  243. // textBoxDefaultZoom
  244. //
  245. this.textBoxDefaultZoom.Location = new System.Drawing.Point(146, 238);
  246. this.textBoxDefaultZoom.Name = "textBoxDefaultZoom";
  247. this.textBoxDefaultZoom.Size = new System.Drawing.Size(28, 21);
  248. this.textBoxDefaultZoom.TabIndex = 11;
  249. this.textBoxDefaultZoom.Text = "100";
  250. this.textBoxDefaultZoom.TextChanged += new System.EventHandler(this.textBoxDefaultZoom_TextChanged);
  251. //
  252. // label6
  253. //
  254. this.label6.AutoSize = true;
  255. this.label6.ForeColor = System.Drawing.Color.Red;
  256. this.label6.Location = new System.Drawing.Point(180, 244);
  257. this.label6.Name = "label6";
  258. this.label6.Size = new System.Drawing.Size(53, 12);
  259. this.label6.TabIndex = 12;
  260. this.label6.Text = "重启生效";
  261. this.label6.Click += new System.EventHandler(this.label6_Click);
  262. //
  263. // panelServerSetting
  264. //
  265. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
  266. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  267. this.BackColor = System.Drawing.Color.White;
  268. this.ClientSize = new System.Drawing.Size(371, 325);
  269. this.Controls.Add(this.label6);
  270. this.Controls.Add(this.textBoxDefaultZoom);
  271. this.Controls.Add(this.label5);
  272. this.Controls.Add(this.label4);
  273. this.Controls.Add(this.checkBoxAutoUpdate);
  274. this.Controls.Add(this.textBoxUpdateUrl);
  275. this.Controls.Add(this.label3);
  276. this.Controls.Add(this.BtnServerCancel);
  277. this.Controls.Add(this.BtnServerConfirm);
  278. this.Controls.Add(this.textBoxInsecureUrl);
  279. this.Controls.Add(this.textBoxDefaultUrl);
  280. this.Controls.Add(this.label2);
  281. this.Controls.Add(this.label1);
  282. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
  283. this.MaximizeBox = false;
  284. this.MinimizeBox = false;
  285. this.Name = "panelServerSetting";
  286. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
  287. this.Text = "服务器设置";
  288. this.Load += new System.EventHandler(this.panelServerSetting_Load);
  289. this.ResumeLayout(false);
  290. this.PerformLayout();
  291. }
  292. private void label6_Click(object sender, EventArgs e)
  293. {
  294. }
  295. private void textBoxDefaultZoom_TextChanged(object sender, EventArgs e)
  296. {
  297. }
  298. }
  299. }