OSDN Git Service

プロキシ設定ダイアログを実装する
authorKazuhiro Fujieda <fujieda@users.sourceforge.jp>
Sun, 28 Sep 2014 01:27:57 +0000 (10:27 +0900)
committerKazuhiro Fujieda <fujieda@users.sourceforge.jp>
Sun, 5 Oct 2014 04:35:09 +0000 (13:35 +0900)
KancolleSniffer/Config.cs
KancolleSniffer/ConfigDialog.Designer.cs
KancolleSniffer/ConfigDialog.cs
KancolleSniffer/KancolleSniffer.csproj
KancolleSniffer/MainForm.cs
KancolleSniffer/ProxyDialog.Designer.cs [new file with mode: 0644]
KancolleSniffer/ProxyDialog.cs [new file with mode: 0644]
KancolleSniffer/ProxyDialog.resx [new file with mode: 0644]

index b99a852..ca8a0a8 100644 (file)
@@ -23,6 +23,22 @@ using Codeplex.Data;
 \r
 namespace KancolleSniffer\r
 {\r
+    public class ProxyConfig\r
+    {\r
+        public bool Auto { get; set; }\r
+        public int Listen { get; set; }\r
+        public bool UseUpstream { get; set; }\r
+        public int UpstreamPort { get; set; }\r
+\r
+        public ProxyConfig()\r
+        {\r
+            Auto = true;\r
+            Listen = 8080;\r
+            UseUpstream = false;\r
+            UpstreamPort = 8888;\r
+        }\r
+    }\r
+\r
     public class Config\r
     {\r
         private readonly string _configFileName = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "config.json");\r
@@ -42,6 +58,7 @@ namespace KancolleSniffer
         public string DamagedShipSoundFile { get; set; }\r
         public bool Logging { get; set; }\r
         public string LogFile { get; set; }\r
+        public ProxyConfig Proxy { get; set; }\r
 \r
         public Config()\r
         {\r
@@ -59,6 +76,7 @@ namespace KancolleSniffer
             DamagedShipSoundFile = Path.Combine(dir, "taiha.mp3");\r
             LogFile = Path.Combine(dir, "log.txt");\r
 // ReSharper restore AssignNullToNotNullAttribute\r
+            Proxy = new ProxyConfig();\r
         }\r
 \r
         public void Load()\r
index d760076..3803662 100644 (file)
@@ -77,12 +77,13 @@ namespace KancolleSniffer
             this.groupBoxShow = new System.Windows.Forms.GroupBox();\r
             this.checkBoxTopMost = new System.Windows.Forms.CheckBox();\r
             this.groupBoxAchievement = new System.Windows.Forms.GroupBox();\r
+            this.buttonResetAchievement = new System.Windows.Forms.Button();\r
             this.label8 = new System.Windows.Forms.Label();\r
             this.checkBoxReset14 = new System.Windows.Forms.CheckBox();\r
             this.checkBoxReset02 = new System.Windows.Forms.CheckBox();\r
             this.contextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);\r
+            this.ProxyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();\r
             this.DebugToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();\r
-            this.buttonResetAchievement = new System.Windows.Forms.Button();\r
             this.groupBoxNotification.SuspendLayout();\r
             ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMarginShips)).BeginInit();\r
             this.groupBoxSound.SuspendLayout();\r
@@ -408,6 +409,16 @@ namespace KancolleSniffer
             this.groupBoxAchievement.TabStop = false;\r
             this.groupBoxAchievement.Text = "戦果";\r
             // \r
+            // buttonResetAchievement\r
+            // \r
+            this.buttonResetAchievement.Location = new System.Drawing.Point(179, 14);\r
+            this.buttonResetAchievement.Name = "buttonResetAchievement";\r
+            this.buttonResetAchievement.Size = new System.Drawing.Size(44, 22);\r
+            this.buttonResetAchievement.TabIndex = 4;\r
+            this.buttonResetAchievement.Text = "今すぐ";\r
+            this.buttonResetAchievement.UseVisualStyleBackColor = true;\r
+            this.buttonResetAchievement.Click += new System.EventHandler(this.buttonResetAchievement_Click);\r
+            // \r
             // label8\r
             // \r
             this.label8.AutoSize = true;\r
@@ -440,27 +451,25 @@ namespace KancolleSniffer
             // contextMenuStrip\r
             // \r
             this.contextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {\r
+            this.ProxyToolStripMenuItem,\r
             this.DebugToolStripMenuItem});\r
             this.contextMenuStrip.Name = "contextMenuStrip";\r
-            this.contextMenuStrip.Size = new System.Drawing.Size(149, 26);\r
+            this.contextMenuStrip.Size = new System.Drawing.Size(168, 70);\r
+            // \r
+            // ProxyToolStripMenuItem\r
+            // \r
+            this.ProxyToolStripMenuItem.Name = "ProxyToolStripMenuItem";\r
+            this.ProxyToolStripMenuItem.Size = new System.Drawing.Size(165, 22);\r
+            this.ProxyToolStripMenuItem.Text = "プロキシ設定(&P)";\r
+            this.ProxyToolStripMenuItem.Click += new System.EventHandler(this.ProxyToolStripMenuItem_Click);\r
             // \r
             // DebugToolStripMenuItem\r
             // \r
             this.DebugToolStripMenuItem.Name = "DebugToolStripMenuItem";\r
-            this.DebugToolStripMenuItem.Size = new System.Drawing.Size(148, 22);\r
-            this.DebugToolStripMenuItem.Text = "デバッグ設定";\r
+            this.DebugToolStripMenuItem.Size = new System.Drawing.Size(167, 22);\r
+            this.DebugToolStripMenuItem.Text = "デバッグ設定(&D)";\r
             this.DebugToolStripMenuItem.Click += new System.EventHandler(this.DebugToolStripMenuItem_Click);\r
             // \r
-            // buttonResetAchievement\r
-            // \r
-            this.buttonResetAchievement.Location = new System.Drawing.Point(179, 14);\r
-            this.buttonResetAchievement.Name = "buttonResetAchievement";\r
-            this.buttonResetAchievement.Size = new System.Drawing.Size(44, 22);\r
-            this.buttonResetAchievement.TabIndex = 4;\r
-            this.buttonResetAchievement.Text = "今すぐ";\r
-            this.buttonResetAchievement.UseVisualStyleBackColor = true;\r
-            this.buttonResetAchievement.Click += new System.EventHandler(this.buttonResetAchievement_Click);\r
-            // \r
             // ConfigDialog\r
             // \r
             this.AcceptButton = this.buttonOk;\r
@@ -536,5 +545,6 @@ namespace KancolleSniffer
         private System.Windows.Forms.ContextMenuStrip contextMenuStrip;\r
         private System.Windows.Forms.ToolStripMenuItem DebugToolStripMenuItem;\r
         private System.Windows.Forms.Button buttonResetAchievement;\r
+        private System.Windows.Forms.ToolStripMenuItem ProxyToolStripMenuItem;\r
     }\r
 }
\ No newline at end of file
index a8ef443..20831d4 100644 (file)
@@ -24,16 +24,16 @@ namespace KancolleSniffer
 {\r
     public partial class ConfigDialog : Form\r
     {\r
-        private readonly DebugDialog _debugDialog;\r
         private readonly Config _config;\r
         private readonly MainForm _main;\r
+        private DebugDialog _debugDialog;\r
+        private ProxyDialog _proxyDialog;\r
 \r
         public ConfigDialog(Config config, MainForm main)\r
         {\r
             InitializeComponent();\r
             _config = config;\r
             _main = main;\r
-            _debugDialog = new DebugDialog(config, main);\r
         }\r
 \r
         private void ConfigDialog_Load(object sender, EventArgs e)\r
@@ -117,6 +117,8 @@ namespace KancolleSniffer
 \r
         private void DebugToolStripMenuItem_Click(object sender, EventArgs e)\r
         {\r
+            if (_debugDialog == null)\r
+                _debugDialog = new DebugDialog(_config, _main);\r
             _debugDialog.ShowDialog(this);\r
         }\r
 \r
@@ -124,5 +126,12 @@ namespace KancolleSniffer
         {\r
             _main.ResetAchievemnt();\r
         }\r
+\r
+        private void ProxyToolStripMenuItem_Click(object sender, EventArgs e)\r
+        {\r
+            if (_proxyDialog == null)\r
+                _proxyDialog = new ProxyDialog(_config.Proxy, _main);\r
+            _proxyDialog.ShowDialog(this);\r
+        }\r
     }\r
 }
\ No newline at end of file
index 0a93ce5..2e81d2d 100644 (file)
     <Compile Include="MissionInfo.cs" />\r
     <Compile Include="Program.cs" />\r
     <Compile Include="Properties\AssemblyInfo.cs" />\r
+    <Compile Include="ProxyDialog.cs">\r
+      <SubType>Form</SubType>\r
+    </Compile>\r
+    <Compile Include="ProxyDialog.Designer.cs">\r
+      <DependentUpon>ProxyDialog.cs</DependentUpon>\r
+    </Compile>\r
     <Compile Include="QuestInfo.cs" />\r
     <Compile Include="ConditionTimer.cs" />\r
     <Compile Include="ShipInfo.cs" />\r
       <DependentUpon>Resources.resx</DependentUpon>\r
       <DesignTime>True</DesignTime>\r
     </Compile>\r
+    <EmbeddedResource Include="ProxyDialog.resx">\r
+      <DependentUpon>ProxyDialog.cs</DependentUpon>\r
+    </EmbeddedResource>\r
     <None Include="Properties\Settings.settings">\r
       <Generator>SettingsSingleFileGenerator</Generator>\r
       <LastGenOutput>Settings.Designer.cs</LastGenOutput>\r
index 3658b3c..6f82549 100644 (file)
@@ -533,7 +533,7 @@ namespace KancolleSniffer
             if (num == 0)\r
             {\r
                 parent.Size = new Size(width, 19);\r
-                var labels =_damagedShipList[0];\r
+                var labels = _damagedShipList[0];\r
                 labels[fleet].Text = "";\r
                 SetShipName(labels[name], "なし");\r
                 labels[time].Text = "";\r
diff --git a/KancolleSniffer/ProxyDialog.Designer.cs b/KancolleSniffer/ProxyDialog.Designer.cs
new file mode 100644 (file)
index 0000000..2a1562f
--- /dev/null
@@ -0,0 +1,224 @@
+namespace KancolleSniffer\r
+{\r
+    partial class ProxyDialog\r
+    {\r
+        /// <summary>\r
+        /// Required designer variable.\r
+        /// </summary>\r
+        private System.ComponentModel.IContainer components = null;\r
+\r
+        /// <summary>\r
+        /// Clean up any resources being used.\r
+        /// </summary>\r
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>\r
+        protected override void Dispose(bool disposing)\r
+        {\r
+            if (disposing && (components != null))\r
+            {\r
+                components.Dispose();\r
+            }\r
+            base.Dispose(disposing);\r
+        }\r
+\r
+        #region Windows Form Designer generated code\r
+\r
+        /// <summary>\r
+        /// Required method for Designer support - do not modify\r
+        /// the contents of this method with the code editor.\r
+        /// </summary>\r
+        private void InitializeComponent()\r
+        {\r
+            this.components = new System.ComponentModel.Container();\r
+            this.labelListen = new System.Windows.Forms.Label();\r
+            this.textBoxListen = new System.Windows.Forms.TextBox();\r
+            this.groupBoxAutoConfig = new System.Windows.Forms.GroupBox();\r
+            this.radioButtonAutoConfigOff = new System.Windows.Forms.RadioButton();\r
+            this.radioButtonAutoConfigOn = new System.Windows.Forms.RadioButton();\r
+            this.groupBoxUpstream = new System.Windows.Forms.GroupBox();\r
+            this.radioButtonUpstreamOff = new System.Windows.Forms.RadioButton();\r
+            this.radioButtonUpstreamOn = new System.Windows.Forms.RadioButton();\r
+            this.textBoxPort = new System.Windows.Forms.TextBox();\r
+            this.labelPort = new System.Windows.Forms.Label();\r
+            this.buttonOk = new System.Windows.Forms.Button();\r
+            this.buttonCancel = new System.Windows.Forms.Button();\r
+            this.toolTipError = new System.Windows.Forms.ToolTip(this.components);\r
+            this.groupBoxAutoConfig.SuspendLayout();\r
+            this.groupBoxUpstream.SuspendLayout();\r
+            this.SuspendLayout();\r
+            // \r
+            // labelListen\r
+            // \r
+            this.labelListen.AutoSize = true;\r
+            this.labelListen.Location = new System.Drawing.Point(114, 21);\r
+            this.labelListen.Name = "labelListen";\r
+            this.labelListen.Size = new System.Drawing.Size(59, 12);\r
+            this.labelListen.TabIndex = 2;\r
+            this.labelListen.Text = "受信ポート:";\r
+            // \r
+            // textBoxListen\r
+            // \r
+            this.textBoxListen.Location = new System.Drawing.Point(175, 18);\r
+            this.textBoxListen.Name = "textBoxListen";\r
+            this.textBoxListen.Size = new System.Drawing.Size(36, 19);\r
+            this.textBoxListen.TabIndex = 3;\r
+            this.textBoxListen.Enter += new System.EventHandler(this.textBox_Enter);\r
+            // \r
+            // groupBoxAutoConfig\r
+            // \r
+            this.groupBoxAutoConfig.Controls.Add(this.radioButtonAutoConfigOff);\r
+            this.groupBoxAutoConfig.Controls.Add(this.radioButtonAutoConfigOn);\r
+            this.groupBoxAutoConfig.Controls.Add(this.textBoxListen);\r
+            this.groupBoxAutoConfig.Controls.Add(this.labelListen);\r
+            this.groupBoxAutoConfig.Location = new System.Drawing.Point(6, 6);\r
+            this.groupBoxAutoConfig.Name = "groupBoxAutoConfig";\r
+            this.groupBoxAutoConfig.Size = new System.Drawing.Size(218, 48);\r
+            this.groupBoxAutoConfig.TabIndex = 0;\r
+            this.groupBoxAutoConfig.TabStop = false;\r
+            this.groupBoxAutoConfig.Text = "自動設定";\r
+            // \r
+            // radioButtonAutoConfigOff\r
+            // \r
+            this.radioButtonAutoConfigOff.AutoSize = true;\r
+            this.radioButtonAutoConfigOff.Location = new System.Drawing.Point(59, 19);\r
+            this.radioButtonAutoConfigOff.Name = "radioButtonAutoConfigOff";\r
+            this.radioButtonAutoConfigOff.Size = new System.Drawing.Size(47, 16);\r
+            this.radioButtonAutoConfigOff.TabIndex = 1;\r
+            this.radioButtonAutoConfigOff.TabStop = true;\r
+            this.radioButtonAutoConfigOff.Text = "無効";\r
+            this.radioButtonAutoConfigOff.UseVisualStyleBackColor = true;\r
+            // \r
+            // radioButtonAutoConfigOn\r
+            // \r
+            this.radioButtonAutoConfigOn.AutoSize = true;\r
+            this.radioButtonAutoConfigOn.Location = new System.Drawing.Point(6, 19);\r
+            this.radioButtonAutoConfigOn.Name = "radioButtonAutoConfigOn";\r
+            this.radioButtonAutoConfigOn.Size = new System.Drawing.Size(47, 16);\r
+            this.radioButtonAutoConfigOn.TabIndex = 0;\r
+            this.radioButtonAutoConfigOn.TabStop = true;\r
+            this.radioButtonAutoConfigOn.Text = "有効";\r
+            this.radioButtonAutoConfigOn.UseVisualStyleBackColor = true;\r
+            this.radioButtonAutoConfigOn.CheckedChanged += new System.EventHandler(this.radioButtonAutoConfigOn_CheckedChanged);\r
+            // \r
+            // groupBoxUpstream\r
+            // \r
+            this.groupBoxUpstream.Controls.Add(this.radioButtonUpstreamOff);\r
+            this.groupBoxUpstream.Controls.Add(this.radioButtonUpstreamOn);\r
+            this.groupBoxUpstream.Controls.Add(this.textBoxPort);\r
+            this.groupBoxUpstream.Controls.Add(this.labelPort);\r
+            this.groupBoxUpstream.Location = new System.Drawing.Point(6, 60);\r
+            this.groupBoxUpstream.Name = "groupBoxUpstream";\r
+            this.groupBoxUpstream.Size = new System.Drawing.Size(218, 48);\r
+            this.groupBoxUpstream.TabIndex = 1;\r
+            this.groupBoxUpstream.TabStop = false;\r
+            this.groupBoxUpstream.Text = "ツール連携";\r
+            // \r
+            // radioButtonUpstreamOff\r
+            // \r
+            this.radioButtonUpstreamOff.AutoSize = true;\r
+            this.radioButtonUpstreamOff.Location = new System.Drawing.Point(59, 18);\r
+            this.radioButtonUpstreamOff.Name = "radioButtonUpstreamOff";\r
+            this.radioButtonUpstreamOff.Size = new System.Drawing.Size(47, 16);\r
+            this.radioButtonUpstreamOff.TabIndex = 1;\r
+            this.radioButtonUpstreamOff.Text = "無効";\r
+            this.radioButtonUpstreamOff.UseVisualStyleBackColor = true;\r
+            this.radioButtonUpstreamOff.CheckedChanged += new System.EventHandler(this.radioButtonUpstreamOff_CheckedChanged);\r
+            // \r
+            // radioButtonUpstreamOn\r
+            // \r
+            this.radioButtonUpstreamOn.AutoSize = true;\r
+            this.radioButtonUpstreamOn.Location = new System.Drawing.Point(6, 18);\r
+            this.radioButtonUpstreamOn.Name = "radioButtonUpstreamOn";\r
+            this.radioButtonUpstreamOn.Size = new System.Drawing.Size(47, 16);\r
+            this.radioButtonUpstreamOn.TabIndex = 0;\r
+            this.radioButtonUpstreamOn.TabStop = true;\r
+            this.radioButtonUpstreamOn.Text = "有効";\r
+            this.radioButtonUpstreamOn.UseVisualStyleBackColor = true;\r
+            // \r
+            // textBoxPort\r
+            // \r
+            this.textBoxPort.Location = new System.Drawing.Point(175, 17);\r
+            this.textBoxPort.Name = "textBoxPort";\r
+            this.textBoxPort.Size = new System.Drawing.Size(36, 19);\r
+            this.textBoxPort.TabIndex = 3;\r
+            this.textBoxPort.Enter += new System.EventHandler(this.textBox_Enter);\r
+            // \r
+            // labelPort\r
+            // \r
+            this.labelPort.AutoSize = true;\r
+            this.labelPort.Location = new System.Drawing.Point(114, 20);\r
+            this.labelPort.Name = "labelPort";\r
+            this.labelPort.Size = new System.Drawing.Size(59, 12);\r
+            this.labelPort.TabIndex = 2;\r
+            this.labelPort.Text = "送信ポート:";\r
+            // \r
+            // buttonOk\r
+            // \r
+            this.buttonOk.Location = new System.Drawing.Point(68, 114);\r
+            this.buttonOk.Name = "buttonOk";\r
+            this.buttonOk.Size = new System.Drawing.Size(75, 23);\r
+            this.buttonOk.TabIndex = 2;\r
+            this.buttonOk.Text = "OK";\r
+            this.buttonOk.UseVisualStyleBackColor = true;\r
+            this.buttonOk.Click += new System.EventHandler(this.buttonOk_Click);\r
+            // \r
+            // buttonCancel\r
+            // \r
+            this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;\r
+            this.buttonCancel.Location = new System.Drawing.Point(149, 114);\r
+            this.buttonCancel.Name = "buttonCancel";\r
+            this.buttonCancel.Size = new System.Drawing.Size(75, 23);\r
+            this.buttonCancel.TabIndex = 3;\r
+            this.buttonCancel.Text = "キャンセル";\r
+            this.buttonCancel.UseVisualStyleBackColor = true;\r
+            // \r
+            // toolTipError\r
+            // \r
+            this.toolTipError.AutomaticDelay = 0;\r
+            this.toolTipError.ToolTipIcon = System.Windows.Forms.ToolTipIcon.Error;\r
+            this.toolTipError.ToolTipTitle = "入力エラー";\r
+            // \r
+            // ProxyDialog\r
+            // \r
+            this.AcceptButton = this.buttonOk;\r
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);\r
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\r
+            this.CancelButton = this.buttonCancel;\r
+            this.ClientSize = new System.Drawing.Size(230, 146);\r
+            this.Controls.Add(this.buttonCancel);\r
+            this.Controls.Add(this.buttonOk);\r
+            this.Controls.Add(this.groupBoxUpstream);\r
+            this.Controls.Add(this.groupBoxAutoConfig);\r
+            this.MaximizeBox = false;\r
+            this.MinimizeBox = false;\r
+            this.Name = "ProxyDialog";\r
+            this.ShowIcon = false;\r
+            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;\r
+            this.Text = "プロキシ設定";\r
+            this.Load += new System.EventHandler(this.ProxyDialog_Load);\r
+            this.groupBoxAutoConfig.ResumeLayout(false);\r
+            this.groupBoxAutoConfig.PerformLayout();\r
+            this.groupBoxUpstream.ResumeLayout(false);\r
+            this.groupBoxUpstream.PerformLayout();\r
+            this.ResumeLayout(false);\r
+\r
+        }\r
+\r
+        #endregion\r
+\r
+        private System.Windows.Forms.Label labelListen;\r
+        private System.Windows.Forms.TextBox textBoxListen;\r
+        private System.Windows.Forms.GroupBox groupBoxAutoConfig;\r
+        private System.Windows.Forms.RadioButton radioButtonAutoConfigOff;\r
+        private System.Windows.Forms.RadioButton radioButtonAutoConfigOn;\r
+        private System.Windows.Forms.GroupBox groupBoxUpstream;\r
+        private System.Windows.Forms.TextBox textBoxPort;\r
+        private System.Windows.Forms.Label labelPort;\r
+        private System.Windows.Forms.Button buttonOk;\r
+        private System.Windows.Forms.Button buttonCancel;\r
+        private System.Windows.Forms.ToolTip toolTipError;\r
+        private System.Windows.Forms.RadioButton radioButtonUpstreamOff;\r
+        private System.Windows.Forms.RadioButton radioButtonUpstreamOn;\r
+\r
+\r
+    }\r
+}
\ No newline at end of file
diff --git a/KancolleSniffer/ProxyDialog.cs b/KancolleSniffer/ProxyDialog.cs
new file mode 100644 (file)
index 0000000..112ffa3
--- /dev/null
@@ -0,0 +1,87 @@
+using System;\r
+using System.Windows.Forms;\r
+\r
+namespace KancolleSniffer\r
+{\r
+    public partial class ProxyDialog : Form\r
+    {\r
+        private readonly ProxyConfig _config;\r
+        private MainForm _main;\r
+\r
+        public ProxyDialog(ProxyConfig config, MainForm main)\r
+        {\r
+            InitializeComponent();\r
+            _config = config;\r
+            _main = main;\r
+        }\r
+\r
+        private void ProxyDialog_Load(object sender, EventArgs e)\r
+        {\r
+            (_config.Auto ? radioButtonAutoConfigOn : radioButtonAutoConfigOff).PerformClick();\r
+            textBoxListen.Text = _config.Listen.ToString("D");\r
+            (_config.UseUpstream ? radioButtonUpstreamOn : radioButtonUpstreamOff).PerformClick();\r
+            textBoxPort.Text = _config.UpstreamPort.ToString("D");\r
+        }\r
+\r
+        private void radioButtonAutoConfigOn_CheckedChanged(object sender, EventArgs e)\r
+        {\r
+            var on = ((RadioButton)sender).Checked;\r
+            textBoxListen.Enabled = !on;\r
+            labelListen.Enabled = !on;\r
+        }\r
+\r
+        private void radioButtonUpstreamOff_CheckedChanged(object sender, EventArgs e)\r
+        {\r
+            var off = ((RadioButton)sender).Checked;\r
+            textBoxPort.Enabled = !off;\r
+        }\r
+\r
+        private void buttonOk_Click(object sender, EventArgs e)\r
+        {\r
+            var listen = -1;\r
+            var port = -1;\r
+            if (radioButtonAutoConfigOff.Checked && !ValidatePortNumber(textBoxListen, out listen))\r
+                return;\r
+            if (radioButtonUpstreamOn.Checked && !ValidatePortNumber(textBoxPort, out port))\r
+                return;\r
+            if (radioButtonAutoConfigOff.Checked && radioButtonUpstreamOn.Checked && listen == port)\r
+            {\r
+                ShowToolTip("受信と送信に同じポートは使えません。", textBoxPort);\r
+                return;\r
+            }\r
+            _config.Auto = radioButtonAutoConfigOn.Checked;\r
+            if (!_config.Auto)\r
+                _config.Listen = listen;\r
+            _config.UseUpstream = radioButtonUpstreamOn.Checked;\r
+            if (_config.UseUpstream)\r
+                _config.UpstreamPort = port;\r
+            DialogResult = DialogResult.OK;\r
+        }\r
+\r
+        private bool ValidatePortNumber(TextBox textBox, out int result)\r
+        {\r
+            var s = textBox.Text;\r
+            if (!int.TryParse(s, out result))\r
+            {\r
+                ShowToolTip("数字を入力してください。", textBox);\r
+                return false;\r
+            }\r
+            if (result <= 0)\r
+            {\r
+                ShowToolTip("0より大きい数字を入力してください。", textBox);\r
+                return false;\r
+            }\r
+            return true;\r
+        }\r
+\r
+        private void ShowToolTip(string message, Control control)\r
+        {\r
+            toolTipError.Show(message, control, 0, control.Height, 3000);\r
+        }\r
+\r
+        private void textBox_Enter(object sender, EventArgs e)\r
+        {\r
+            toolTipError.Hide((Control)sender);\r
+        }\r
+    }\r
+}
\ No newline at end of file
diff --git a/KancolleSniffer/ProxyDialog.resx b/KancolleSniffer/ProxyDialog.resx
new file mode 100644 (file)
index 0000000..e9a8c85
--- /dev/null
@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<root>\r
+  <!-- \r
+    Microsoft ResX Schema \r
+    \r
+    Version 2.0\r
+    \r
+    The primary goals of this format is to allow a simple XML format \r
+    that is mostly human readable. The generation and parsing of the \r
+    various data types are done through the TypeConverter classes \r
+    associated with the data types.\r
+    \r
+    Example:\r
+    \r
+    ... ado.net/XML headers & schema ...\r
+    <resheader name="resmimetype">text/microsoft-resx</resheader>\r
+    <resheader name="version">2.0</resheader>\r
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\r
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\r
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>\r
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>\r
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">\r
+        <value>[base64 mime encoded serialized .NET Framework object]</value>\r
+    </data>\r
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">\r
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>\r
+        <comment>This is a comment</comment>\r
+    </data>\r
+                \r
+    There are any number of "resheader" rows that contain simple \r
+    name/value pairs.\r
+    \r
+    Each data row contains a name, and value. The row also contains a \r
+    type or mimetype. Type corresponds to a .NET class that support \r
+    text/value conversion through the TypeConverter architecture. \r
+    Classes that don't support this are serialized and stored with the \r
+    mimetype set.\r
+    \r
+    The mimetype is used for serialized objects, and tells the \r
+    ResXResourceReader how to depersist the object. This is currently not \r
+    extensible. For a given mimetype the value must be set accordingly:\r
+    \r
+    Note - application/x-microsoft.net.object.binary.base64 is the format \r
+    that the ResXResourceWriter will generate, however the reader can \r
+    read any of the formats listed below.\r
+    \r
+    mimetype: application/x-microsoft.net.object.binary.base64\r
+    value   : The object must be serialized with \r
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter\r
+            : and then encoded with base64 encoding.\r
+    \r
+    mimetype: application/x-microsoft.net.object.soap.base64\r
+    value   : The object must be serialized with \r
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\r
+            : and then encoded with base64 encoding.\r
+\r
+    mimetype: application/x-microsoft.net.object.bytearray.base64\r
+    value   : The object must be serialized into a byte array \r
+            : using a System.ComponentModel.TypeConverter\r
+            : and then encoded with base64 encoding.\r
+    -->\r
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">\r
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />\r
+    <xsd:element name="root" msdata:IsDataSet="true">\r
+      <xsd:complexType>\r
+        <xsd:choice maxOccurs="unbounded">\r
+          <xsd:element name="metadata">\r
+            <xsd:complexType>\r
+              <xsd:sequence>\r
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />\r
+              </xsd:sequence>\r
+              <xsd:attribute name="name" use="required" type="xsd:string" />\r
+              <xsd:attribute name="type" type="xsd:string" />\r
+              <xsd:attribute name="mimetype" type="xsd:string" />\r
+              <xsd:attribute ref="xml:space" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+          <xsd:element name="assembly">\r
+            <xsd:complexType>\r
+              <xsd:attribute name="alias" type="xsd:string" />\r
+              <xsd:attribute name="name" type="xsd:string" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+          <xsd:element name="data">\r
+            <xsd:complexType>\r
+              <xsd:sequence>\r
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />\r
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />\r
+              </xsd:sequence>\r
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />\r
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />\r
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />\r
+              <xsd:attribute ref="xml:space" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+          <xsd:element name="resheader">\r
+            <xsd:complexType>\r
+              <xsd:sequence>\r
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />\r
+              </xsd:sequence>\r
+              <xsd:attribute name="name" type="xsd:string" use="required" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+        </xsd:choice>\r
+      </xsd:complexType>\r
+    </xsd:element>\r
+  </xsd:schema>\r
+  <resheader name="resmimetype">\r
+    <value>text/microsoft-resx</value>\r
+  </resheader>\r
+  <resheader name="version">\r
+    <value>2.0</value>\r
+  </resheader>\r
+  <resheader name="reader">\r
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+  </resheader>\r
+  <resheader name="writer">\r
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+  </resheader>\r
+  <metadata name="toolTipError.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
+    <value>17, 17</value>\r
+  </metadata>\r
+</root>
\ No newline at end of file