using System; using System.ComponentModel; using System.Configuration; using System.Drawing; using System.Windows.Forms; namespace prBrowser.Weblogic { public class panelServerSetting : Form { private IContainer components = null; private Label label1; private Label label2; private TextBox textBoxDefaultUrl; private TextBox textBoxInsecureUrl; private Button BtnServerConfirm; private Button BtnServerCancel; private Label label3; private TextBox textBoxUpdateUrl; private CheckBox checkBoxAutoUpdate; private Label label5; private TextBox textBoxDefaultZoom; private Label label6; private Label label4; public panelServerSetting() { InitializeComponent(); } private void BtnServerConfirm_Click(object sender, EventArgs e) { SetConfigValue("DefaultUrl", textBoxDefaultUrl.Text); SetConfigValue("InsecureUrl", textBoxInsecureUrl.Text); SetConfigValue("UpdateUrl", textBoxUpdateUrl.Text); SetConfigValue("DefaultZoom", textBoxDefaultZoom.Text); if (checkBoxAutoUpdate.Checked) { SetConfigValue("AutoUpdate", "Y"); } else { SetConfigValue("AutoUpdate", "N"); } Close(); } private void BtnServerCancel_Click(object sender, EventArgs e) { Close(); } private void panelServerSetting_Load(object sender, EventArgs e) { textBoxDefaultUrl.Text = ConfigurationManager.AppSettings["DefaultUrl"]; textBoxInsecureUrl.Text = ConfigurationManager.AppSettings["InsecureUrl"]; textBoxUpdateUrl.Text = ConfigurationManager.AppSettings["UpdateUrl"]; textBoxDefaultZoom.Text = ConfigurationManager.AppSettings["DefaultZoom"]; try { if (Convert.ToInt32(textBoxDefaultZoom.Text)>100 || Convert.ToInt32(textBoxDefaultZoom.Text)<50) { textBoxDefaultZoom.Text = "100"; } }catch(Exception ex) { textBoxDefaultZoom.Text = "100"; } string autoUpdate = ConfigurationManager.AppSettings["AutoUpdate"]; if (autoUpdate == "Y") { checkBoxAutoUpdate.Checked = true; } else { checkBoxAutoUpdate.Checked = false; } textBoxDefaultUrl.Focus(); if (textBoxDefaultUrl.Text.Length > 0) { textBoxDefaultUrl.SelectionStart = textBoxDefaultUrl.Text.Length; } } public static bool SetConfigValue(string key, string value) { try { Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); if (config.AppSettings.Settings[key] != null) { config.AppSettings.Settings[key].Value = value; } else { config.AppSettings.Settings.Add(key, value); } config.Save(ConfigurationSaveMode.Modified); ConfigurationManager.RefreshSection("appSettings"); return true; } catch { return false; } } private void textBoxDefaultUrl_KeyUp(object sender, KeyEventArgs e) { if (e.KeyValue == 13) { textBoxInsecureUrl.Focus(); if (textBoxInsecureUrl.Text.Length > 0) { textBoxInsecureUrl.SelectionStart = textBoxInsecureUrl.Text.Length; } } } private void textBoxInsecureUrl_KeyUp(object sender, KeyEventArgs e) { if (e.KeyValue == 13) { BtnServerConfirm.Focus(); } } protected override void Dispose(bool disposing) { if (disposing && components != null) { components.Dispose(); } base.Dispose(disposing); } private void InitializeComponent() { this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.textBoxDefaultUrl = new System.Windows.Forms.TextBox(); this.textBoxInsecureUrl = new System.Windows.Forms.TextBox(); this.BtnServerConfirm = new System.Windows.Forms.Button(); this.BtnServerCancel = new System.Windows.Forms.Button(); this.label3 = new System.Windows.Forms.Label(); this.textBoxUpdateUrl = new System.Windows.Forms.TextBox(); this.checkBoxAutoUpdate = new System.Windows.Forms.CheckBox(); this.label4 = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label(); this.textBoxDefaultZoom = new System.Windows.Forms.TextBox(); this.label6 = new System.Windows.Forms.Label(); this.SuspendLayout(); // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(39, 42); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(101, 12); this.label1.TabIndex = 0; this.label1.Text = "默认服务器地址:"; // // label2 // this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(41, 93); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(101, 12); this.label2.TabIndex = 1; this.label2.Text = "允许流媒体地址:"; // // textBoxDefaultUrl // this.textBoxDefaultUrl.Location = new System.Drawing.Point(146, 39); this.textBoxDefaultUrl.Name = "textBoxDefaultUrl"; this.textBoxDefaultUrl.Size = new System.Drawing.Size(165, 21); this.textBoxDefaultUrl.TabIndex = 2; this.textBoxDefaultUrl.KeyUp += new System.Windows.Forms.KeyEventHandler(this.textBoxDefaultUrl_KeyUp); // // textBoxInsecureUrl // this.textBoxInsecureUrl.Location = new System.Drawing.Point(146, 90); this.textBoxInsecureUrl.Multiline = true; this.textBoxInsecureUrl.Name = "textBoxInsecureUrl"; this.textBoxInsecureUrl.Size = new System.Drawing.Size(163, 79); this.textBoxInsecureUrl.TabIndex = 3; this.textBoxInsecureUrl.KeyUp += new System.Windows.Forms.KeyEventHandler(this.textBoxInsecureUrl_KeyUp); // // BtnServerConfirm // this.BtnServerConfirm.Location = new System.Drawing.Point(65, 290); this.BtnServerConfirm.Name = "BtnServerConfirm"; this.BtnServerConfirm.Size = new System.Drawing.Size(75, 23); this.BtnServerConfirm.TabIndex = 4; this.BtnServerConfirm.Text = "确认"; this.BtnServerConfirm.UseVisualStyleBackColor = true; this.BtnServerConfirm.Click += new System.EventHandler(this.BtnServerConfirm_Click); // // BtnServerCancel // this.BtnServerCancel.Location = new System.Drawing.Point(236, 290); this.BtnServerCancel.Name = "BtnServerCancel"; this.BtnServerCancel.Size = new System.Drawing.Size(75, 23); this.BtnServerCancel.TabIndex = 5; this.BtnServerCancel.Text = "取消"; this.BtnServerCancel.UseVisualStyleBackColor = true; this.BtnServerCancel.Click += new System.EventHandler(this.BtnServerCancel_Click); // // label3 // this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(39, 216); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(101, 12); this.label3.TabIndex = 6; this.label3.Text = "更新服务器地址:"; // // textBoxUpdateUrl // this.textBoxUpdateUrl.Location = new System.Drawing.Point(146, 213); this.textBoxUpdateUrl.Name = "textBoxUpdateUrl"; this.textBoxUpdateUrl.Size = new System.Drawing.Size(165, 21); this.textBoxUpdateUrl.TabIndex = 7; // // checkBoxAutoUpdate // this.checkBoxAutoUpdate.AutoSize = true; this.checkBoxAutoUpdate.Location = new System.Drawing.Point(239, 268); this.checkBoxAutoUpdate.Name = "checkBoxAutoUpdate"; this.checkBoxAutoUpdate.Size = new System.Drawing.Size(72, 16); this.checkBoxAutoUpdate.TabIndex = 8; this.checkBoxAutoUpdate.Text = "自动更新"; this.checkBoxAutoUpdate.UseVisualStyleBackColor = true; // // label4 // this.label4.AutoSize = true; this.label4.ForeColor = System.Drawing.Color.Red; this.label4.Location = new System.Drawing.Point(157, 172); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(143, 12); this.label4.TabIndex = 9; this.label4.Text = "多条记录使用逗号\",\"分割"; // // label5 // this.label5.AutoSize = true; this.label5.Location = new System.Drawing.Point(51, 244); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(89, 12); this.label5.TabIndex = 10; this.label5.Text = "默认缩放比例:"; // // textBoxDefaultZoom // this.textBoxDefaultZoom.Location = new System.Drawing.Point(146, 238); this.textBoxDefaultZoom.Name = "textBoxDefaultZoom"; this.textBoxDefaultZoom.Size = new System.Drawing.Size(28, 21); this.textBoxDefaultZoom.TabIndex = 11; this.textBoxDefaultZoom.Text = "100"; this.textBoxDefaultZoom.TextChanged += new System.EventHandler(this.textBoxDefaultZoom_TextChanged); // // label6 // this.label6.AutoSize = true; this.label6.ForeColor = System.Drawing.Color.Red; this.label6.Location = new System.Drawing.Point(180, 244); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(53, 12); this.label6.TabIndex = 12; this.label6.Text = "重启生效"; this.label6.Click += new System.EventHandler(this.label6_Click); // // panelServerSetting // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.White; this.ClientSize = new System.Drawing.Size(371, 325); this.Controls.Add(this.label6); this.Controls.Add(this.textBoxDefaultZoom); this.Controls.Add(this.label5); this.Controls.Add(this.label4); this.Controls.Add(this.checkBoxAutoUpdate); this.Controls.Add(this.textBoxUpdateUrl); this.Controls.Add(this.label3); this.Controls.Add(this.BtnServerCancel); this.Controls.Add(this.BtnServerConfirm); this.Controls.Add(this.textBoxInsecureUrl); this.Controls.Add(this.textBoxDefaultUrl); this.Controls.Add(this.label2); this.Controls.Add(this.label1); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "panelServerSetting"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "服务器设置"; this.Load += new System.EventHandler(this.panelServerSetting_Load); this.ResumeLayout(false); this.PerformLayout(); } private void label6_Click(object sender, EventArgs e) { } private void textBoxDefaultZoom_TextChanged(object sender, EventArgs e) { } } }