OSDN Git Service

通知方法を設定可能にする
authorKazuhiro Fujieda <fujieda@users.sourceforge.jp>
Sun, 5 Jan 2014 05:27:57 +0000 (14:27 +0900)
committerKazuhiro Fujieda <fujieda@users.sourceforge.jp>
Sun, 5 Jan 2014 11:56:45 +0000 (20:56 +0900)
KancolleSniffer/Config.cs [new file with mode: 0644]
KancolleSniffer/ConfigDialog.Designer.cs [new file with mode: 0644]
KancolleSniffer/ConfigDialog.cs [new file with mode: 0644]
KancolleSniffer/ConfigDialog.resx [new file with mode: 0644]
KancolleSniffer/KancolleSniffer.csproj
KancolleSniffer/MainForm.cs

diff --git a/KancolleSniffer/Config.cs b/KancolleSniffer/Config.cs
new file mode 100644 (file)
index 0000000..a5b1b48
--- /dev/null
@@ -0,0 +1,70 @@
+// Copyright (C) 2014 Kazuhiro Fujieda <fujieda@users.sourceforge.jp>\r
+// \r
+// This program is part of KancolleSniffer.\r
+//\r
+// KancolleSniffer is free software: you can redistribute it and/or modify\r
+// it under the terms of the GNU General Public License as published by\r
+// the Free Software Foundation, either version 3 of the License, or\r
+// (at your option) any later version.\r
+//\r
+// This program is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+// GNU General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU General Public License\r
+// along with this program; if not, see <http://www.gnu.org/licenses/>.\r
+\r
+using System.IO;\r
+using System.Windows.Forms;\r
+using Codeplex.Data;\r
+\r
+namespace KancolleSniffer\r
+{\r
+    public class Config\r
+    {\r
+        private readonly string _configFileName = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "config.json");\r
+\r
+        public bool FlashWindow { get; set; }\r
+        public bool ShowBaloonTip { get; set; }\r
+        public bool PlaySound { get; set; }\r
+        public int MarginShips { get; set; }\r
+        public int SoundVolume { get; set; }\r
+        public string MissionSoundFile { get; set; }\r
+        public string NDockSoundFile { get; set; }\r
+        public string KDockSoundFile { get; set; }\r
+        public string MaxShipsSoundFile { get; set; }\r
+\r
+        public Config()\r
+        {\r
+            FlashWindow = ShowBaloonTip = PlaySound = true;\r
+            MarginShips = 4;\r
+            SoundVolume = 100;\r
+            var dir = Path.GetDirectoryName(Application.ExecutablePath);\r
+// ReSharper disable AssignNullToNotNullAttribute\r
+            MissionSoundFile = Path.Combine(dir, "ensei.mp3");\r
+            NDockSoundFile = Path.Combine(dir, "nyuukyo.mp3");\r
+            KDockSoundFile = Path.Combine(dir, "kenzou.mp3");\r
+            MaxShipsSoundFile = Path.Combine(dir, "kanmusu.mp3");\r
+// ReSharper restore AssignNullToNotNullAttribute\r
+        }\r
+\r
+        public void Load()\r
+        {\r
+            try\r
+            {\r
+                var config = (Config)DynamicJson.Parse(File.ReadAllText(_configFileName));\r
+                foreach (var property in GetType().GetProperties())\r
+                    property.SetValue(this, property.GetValue(config, null), null);\r
+            }\r
+            catch (FileNotFoundException)\r
+            {\r
+            }\r
+        }\r
+\r
+        public void Save()\r
+        {\r
+            File.WriteAllText(_configFileName, DynamicJson.Serialize(this));\r
+        }\r
+    }\r
+}
\ No newline at end of file
diff --git a/KancolleSniffer/ConfigDialog.Designer.cs b/KancolleSniffer/ConfigDialog.Designer.cs
new file mode 100644 (file)
index 0000000..15bf15a
--- /dev/null
@@ -0,0 +1,370 @@
+namespace KancolleSniffer\r
+{\r
+    partial class ConfigDialog\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.groupBoxNotification = new System.Windows.Forms.GroupBox();\r
+            this.numericUpDownMarginShips = new System.Windows.Forms.NumericUpDown();\r
+            this.label2 = new System.Windows.Forms.Label();\r
+            this.label1 = new System.Windows.Forms.Label();\r
+            this.checkBoxSound = new System.Windows.Forms.CheckBox();\r
+            this.checkBoxBalloon = new System.Windows.Forms.CheckBox();\r
+            this.checkBoxFlash = new System.Windows.Forms.CheckBox();\r
+            this.groupBoxSound = new System.Windows.Forms.GroupBox();\r
+            this.numericUpDownSoundVolume = new System.Windows.Forms.NumericUpDown();\r
+            this.label3 = new System.Windows.Forms.Label();\r
+            this.buttonMaxShipsOpenFile = new System.Windows.Forms.Button();\r
+            this.textBoxMaxShipsSoundFile = new System.Windows.Forms.TextBox();\r
+            this.label7 = new System.Windows.Forms.Label();\r
+            this.buttonKDockOpenFile = new System.Windows.Forms.Button();\r
+            this.textBoxKDockSoundFile = new System.Windows.Forms.TextBox();\r
+            this.label6 = new System.Windows.Forms.Label();\r
+            this.buttonNDockOpenFile = new System.Windows.Forms.Button();\r
+            this.textBoxNDockSoundFile = new System.Windows.Forms.TextBox();\r
+            this.label5 = new System.Windows.Forms.Label();\r
+            this.buttonMissionOpenFile = new System.Windows.Forms.Button();\r
+            this.textBoxMissionSoundFile = new System.Windows.Forms.TextBox();\r
+            this.label4 = new System.Windows.Forms.Label();\r
+            this.buttonOk = new System.Windows.Forms.Button();\r
+            this.buttonCancel = new System.Windows.Forms.Button();\r
+            this.openFileDialog = new System.Windows.Forms.OpenFileDialog();\r
+            this.groupBoxNotification.SuspendLayout();\r
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMarginShips)).BeginInit();\r
+            this.groupBoxSound.SuspendLayout();\r
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSoundVolume)).BeginInit();\r
+            this.SuspendLayout();\r
+            // \r
+            // groupBoxNotification\r
+            // \r
+            this.groupBoxNotification.Controls.Add(this.numericUpDownMarginShips);\r
+            this.groupBoxNotification.Controls.Add(this.label2);\r
+            this.groupBoxNotification.Controls.Add(this.label1);\r
+            this.groupBoxNotification.Controls.Add(this.checkBoxSound);\r
+            this.groupBoxNotification.Controls.Add(this.checkBoxBalloon);\r
+            this.groupBoxNotification.Controls.Add(this.checkBoxFlash);\r
+            this.groupBoxNotification.Location = new System.Drawing.Point(12, 12);\r
+            this.groupBoxNotification.Name = "groupBoxNotification";\r
+            this.groupBoxNotification.Padding = new System.Windows.Forms.Padding(8);\r
+            this.groupBoxNotification.Size = new System.Drawing.Size(248, 119);\r
+            this.groupBoxNotification.TabIndex = 0;\r
+            this.groupBoxNotification.TabStop = false;\r
+            this.groupBoxNotification.Text = "通知";\r
+            // \r
+            // numericUpDownMarginShips\r
+            // \r
+            this.numericUpDownMarginShips.Location = new System.Drawing.Point(125, 89);\r
+            this.numericUpDownMarginShips.Margin = new System.Windows.Forms.Padding(0, 3, 0, 3);\r
+            this.numericUpDownMarginShips.Maximum = new decimal(new int[] {\r
+            99,\r
+            0,\r
+            0,\r
+            0});\r
+            this.numericUpDownMarginShips.Name = "numericUpDownMarginShips";\r
+            this.numericUpDownMarginShips.Size = new System.Drawing.Size(36, 19);\r
+            this.numericUpDownMarginShips.TabIndex = 6;\r
+            this.numericUpDownMarginShips.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;\r
+            // \r
+            // label2\r
+            // \r
+            this.label2.AutoSize = true;\r
+            this.label2.Location = new System.Drawing.Point(161, 91);\r
+            this.label2.Margin = new System.Windows.Forms.Padding(0, 3, 3, 3);\r
+            this.label2.Name = "label2";\r
+            this.label2.Size = new System.Drawing.Size(70, 12);\r
+            this.label2.TabIndex = 5;\r
+            this.label2.Text = "隻で通知する";\r
+            // \r
+            // label1\r
+            // \r
+            this.label1.AutoSize = true;\r
+            this.label1.Location = new System.Drawing.Point(11, 91);\r
+            this.label1.Margin = new System.Windows.Forms.Padding(3, 3, 0, 3);\r
+            this.label1.Name = "label1";\r
+            this.label1.Size = new System.Drawing.Size(116, 12);\r
+            this.label1.TabIndex = 3;\r
+            this.label1.Text = "最大保有艦数まで残り";\r
+            // \r
+            // checkBoxSound\r
+            // \r
+            this.checkBoxSound.AutoSize = true;\r
+            this.checkBoxSound.Location = new System.Drawing.Point(11, 67);\r
+            this.checkBoxSound.Name = "checkBoxSound";\r
+            this.checkBoxSound.Size = new System.Drawing.Size(113, 16);\r
+            this.checkBoxSound.TabIndex = 2;\r
+            this.checkBoxSound.Text = "サウンドを再生する";\r
+            this.checkBoxSound.UseVisualStyleBackColor = true;\r
+            this.checkBoxSound.CheckedChanged += new System.EventHandler(this.checkBoxSound_CheckedChanged);\r
+            // \r
+            // checkBoxBalloon\r
+            // \r
+            this.checkBoxBalloon.AutoSize = true;\r
+            this.checkBoxBalloon.Location = new System.Drawing.Point(11, 45);\r
+            this.checkBoxBalloon.Name = "checkBoxBalloon";\r
+            this.checkBoxBalloon.Size = new System.Drawing.Size(172, 16);\r
+            this.checkBoxBalloon.TabIndex = 1;\r
+            this.checkBoxBalloon.Text = "通知領域にバルーンを表示する";\r
+            this.checkBoxBalloon.UseVisualStyleBackColor = true;\r
+            // \r
+            // checkBoxFlash\r
+            // \r
+            this.checkBoxFlash.AutoSize = true;\r
+            this.checkBoxFlash.Location = new System.Drawing.Point(11, 23);\r
+            this.checkBoxFlash.Name = "checkBoxFlash";\r
+            this.checkBoxFlash.Size = new System.Drawing.Size(127, 16);\r
+            this.checkBoxFlash.TabIndex = 0;\r
+            this.checkBoxFlash.Text = "ウィンドウを点滅させる";\r
+            this.checkBoxFlash.UseVisualStyleBackColor = true;\r
+            // \r
+            // groupBoxSound\r
+            // \r
+            this.groupBoxSound.Controls.Add(this.numericUpDownSoundVolume);\r
+            this.groupBoxSound.Controls.Add(this.label3);\r
+            this.groupBoxSound.Controls.Add(this.buttonMaxShipsOpenFile);\r
+            this.groupBoxSound.Controls.Add(this.textBoxMaxShipsSoundFile);\r
+            this.groupBoxSound.Controls.Add(this.label7);\r
+            this.groupBoxSound.Controls.Add(this.buttonKDockOpenFile);\r
+            this.groupBoxSound.Controls.Add(this.textBoxKDockSoundFile);\r
+            this.groupBoxSound.Controls.Add(this.label6);\r
+            this.groupBoxSound.Controls.Add(this.buttonNDockOpenFile);\r
+            this.groupBoxSound.Controls.Add(this.textBoxNDockSoundFile);\r
+            this.groupBoxSound.Controls.Add(this.label5);\r
+            this.groupBoxSound.Controls.Add(this.buttonMissionOpenFile);\r
+            this.groupBoxSound.Controls.Add(this.textBoxMissionSoundFile);\r
+            this.groupBoxSound.Controls.Add(this.label4);\r
+            this.groupBoxSound.Location = new System.Drawing.Point(12, 146);\r
+            this.groupBoxSound.Margin = new System.Windows.Forms.Padding(3, 12, 3, 12);\r
+            this.groupBoxSound.Name = "groupBoxSound";\r
+            this.groupBoxSound.Padding = new System.Windows.Forms.Padding(8);\r
+            this.groupBoxSound.Size = new System.Drawing.Size(248, 155);\r
+            this.groupBoxSound.TabIndex = 1;\r
+            this.groupBoxSound.TabStop = false;\r
+            this.groupBoxSound.Text = "サウンド";\r
+            // \r
+            // numericUpDownSoundVolume\r
+            // \r
+            this.numericUpDownSoundVolume.Location = new System.Drawing.Point(46, 23);\r
+            this.numericUpDownSoundVolume.Name = "numericUpDownSoundVolume";\r
+            this.numericUpDownSoundVolume.Size = new System.Drawing.Size(44, 19);\r
+            this.numericUpDownSoundVolume.TabIndex = 1;\r
+            this.numericUpDownSoundVolume.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;\r
+            // \r
+            // label3\r
+            // \r
+            this.label3.AutoSize = true;\r
+            this.label3.Location = new System.Drawing.Point(11, 25);\r
+            this.label3.Name = "label3";\r
+            this.label3.Size = new System.Drawing.Size(29, 12);\r
+            this.label3.TabIndex = 0;\r
+            this.label3.Text = "音量";\r
+            // \r
+            // buttonMaxShipsOpenFile\r
+            // \r
+            this.buttonMaxShipsOpenFile.Location = new System.Drawing.Point(196, 121);\r
+            this.buttonMaxShipsOpenFile.Name = "buttonMaxShipsOpenFile";\r
+            this.buttonMaxShipsOpenFile.Size = new System.Drawing.Size(41, 23);\r
+            this.buttonMaxShipsOpenFile.TabIndex = 13;\r
+            this.buttonMaxShipsOpenFile.Text = "参照";\r
+            this.buttonMaxShipsOpenFile.UseVisualStyleBackColor = true;\r
+            this.buttonMaxShipsOpenFile.Click += new System.EventHandler(this.buttonMaxShipsOpenFile_Click);\r
+            // \r
+            // textBoxMaxShipsSoundFile\r
+            // \r
+            this.textBoxMaxShipsSoundFile.Location = new System.Drawing.Point(46, 123);\r
+            this.textBoxMaxShipsSoundFile.Name = "textBoxMaxShipsSoundFile";\r
+            this.textBoxMaxShipsSoundFile.Size = new System.Drawing.Size(144, 19);\r
+            this.textBoxMaxShipsSoundFile.TabIndex = 12;\r
+            // \r
+            // label7\r
+            // \r
+            this.label7.AutoSize = true;\r
+            this.label7.Location = new System.Drawing.Point(11, 126);\r
+            this.label7.Name = "label7";\r
+            this.label7.Size = new System.Drawing.Size(29, 12);\r
+            this.label7.TabIndex = 11;\r
+            this.label7.Text = "艦数";\r
+            // \r
+            // buttonKDockOpenFile\r
+            // \r
+            this.buttonKDockOpenFile.Location = new System.Drawing.Point(196, 96);\r
+            this.buttonKDockOpenFile.Name = "buttonKDockOpenFile";\r
+            this.buttonKDockOpenFile.Size = new System.Drawing.Size(41, 23);\r
+            this.buttonKDockOpenFile.TabIndex = 10;\r
+            this.buttonKDockOpenFile.Text = "参照";\r
+            this.buttonKDockOpenFile.UseVisualStyleBackColor = true;\r
+            this.buttonKDockOpenFile.Click += new System.EventHandler(this.buttonKDockOpenFile_Click);\r
+            // \r
+            // textBoxKDockSoundFile\r
+            // \r
+            this.textBoxKDockSoundFile.Location = new System.Drawing.Point(46, 98);\r
+            this.textBoxKDockSoundFile.Name = "textBoxKDockSoundFile";\r
+            this.textBoxKDockSoundFile.Size = new System.Drawing.Size(144, 19);\r
+            this.textBoxKDockSoundFile.TabIndex = 9;\r
+            // \r
+            // label6\r
+            // \r
+            this.label6.AutoSize = true;\r
+            this.label6.Location = new System.Drawing.Point(11, 101);\r
+            this.label6.Name = "label6";\r
+            this.label6.Size = new System.Drawing.Size(29, 12);\r
+            this.label6.TabIndex = 8;\r
+            this.label6.Text = "建造";\r
+            // \r
+            // buttonNDockOpenFile\r
+            // \r
+            this.buttonNDockOpenFile.Location = new System.Drawing.Point(196, 71);\r
+            this.buttonNDockOpenFile.Name = "buttonNDockOpenFile";\r
+            this.buttonNDockOpenFile.Size = new System.Drawing.Size(41, 23);\r
+            this.buttonNDockOpenFile.TabIndex = 7;\r
+            this.buttonNDockOpenFile.Text = "参照";\r
+            this.buttonNDockOpenFile.UseVisualStyleBackColor = true;\r
+            this.buttonNDockOpenFile.Click += new System.EventHandler(this.buttonNDockOpenFile_Click);\r
+            // \r
+            // textBoxNDockSoundFile\r
+            // \r
+            this.textBoxNDockSoundFile.Location = new System.Drawing.Point(46, 73);\r
+            this.textBoxNDockSoundFile.Name = "textBoxNDockSoundFile";\r
+            this.textBoxNDockSoundFile.Size = new System.Drawing.Size(144, 19);\r
+            this.textBoxNDockSoundFile.TabIndex = 6;\r
+            // \r
+            // label5\r
+            // \r
+            this.label5.AutoSize = true;\r
+            this.label5.Location = new System.Drawing.Point(11, 76);\r
+            this.label5.Name = "label5";\r
+            this.label5.Size = new System.Drawing.Size(29, 12);\r
+            this.label5.TabIndex = 5;\r
+            this.label5.Text = "入渠";\r
+            // \r
+            // buttonMissionOpenFile\r
+            // \r
+            this.buttonMissionOpenFile.Location = new System.Drawing.Point(196, 46);\r
+            this.buttonMissionOpenFile.Name = "buttonMissionOpenFile";\r
+            this.buttonMissionOpenFile.Size = new System.Drawing.Size(41, 23);\r
+            this.buttonMissionOpenFile.TabIndex = 4;\r
+            this.buttonMissionOpenFile.Text = "参照";\r
+            this.buttonMissionOpenFile.UseVisualStyleBackColor = true;\r
+            this.buttonMissionOpenFile.Click += new System.EventHandler(this.buttonMissionOpenFile_Click);\r
+            // \r
+            // textBoxMissionSoundFile\r
+            // \r
+            this.textBoxMissionSoundFile.Location = new System.Drawing.Point(46, 48);\r
+            this.textBoxMissionSoundFile.Name = "textBoxMissionSoundFile";\r
+            this.textBoxMissionSoundFile.Size = new System.Drawing.Size(144, 19);\r
+            this.textBoxMissionSoundFile.TabIndex = 3;\r
+            // \r
+            // label4\r
+            // \r
+            this.label4.AutoSize = true;\r
+            this.label4.Location = new System.Drawing.Point(11, 51);\r
+            this.label4.Name = "label4";\r
+            this.label4.Size = new System.Drawing.Size(29, 12);\r
+            this.label4.TabIndex = 2;\r
+            this.label4.Text = "遠征";\r
+            // \r
+            // buttonOk\r
+            // \r
+            this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK;\r
+            this.buttonOk.Location = new System.Drawing.Point(104, 316);\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(185, 316);\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
+            // openFileDialog\r
+            // \r
+            this.openFileDialog.Filter = "オーディオファイル (*.wav;*.aif;*.aifc;*.aiff;*.wma;*.mp2;*.mp3)|*.wav;*.aif;*.aifc;*.aiff" +\r
+    ";*.wma;*.mp2;*.mp3";\r
+            this.openFileDialog.Title = "オーディオファイルを選択する";\r
+            // \r
+            // ConfigDialog\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(272, 351);\r
+            this.ControlBox = false;\r
+            this.Controls.Add(this.buttonCancel);\r
+            this.Controls.Add(this.buttonOk);\r
+            this.Controls.Add(this.groupBoxSound);\r
+            this.Controls.Add(this.groupBoxNotification);\r
+            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;\r
+            this.Name = "ConfigDialog";\r
+            this.Text = "設定";\r
+            this.Load += new System.EventHandler(this.ConfigDialog_Load);\r
+            this.groupBoxNotification.ResumeLayout(false);\r
+            this.groupBoxNotification.PerformLayout();\r
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMarginShips)).EndInit();\r
+            this.groupBoxSound.ResumeLayout(false);\r
+            this.groupBoxSound.PerformLayout();\r
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSoundVolume)).EndInit();\r
+            this.ResumeLayout(false);\r
+\r
+        }\r
+\r
+        #endregion\r
+\r
+        private System.Windows.Forms.GroupBox groupBoxNotification;\r
+        private System.Windows.Forms.CheckBox checkBoxFlash;\r
+        private System.Windows.Forms.CheckBox checkBoxBalloon;\r
+        private System.Windows.Forms.CheckBox checkBoxSound;\r
+        private System.Windows.Forms.GroupBox groupBoxSound;\r
+        private System.Windows.Forms.Button buttonKDockOpenFile;\r
+        private System.Windows.Forms.TextBox textBoxKDockSoundFile;\r
+        private System.Windows.Forms.Label label6;\r
+        private System.Windows.Forms.Button buttonNDockOpenFile;\r
+        private System.Windows.Forms.TextBox textBoxNDockSoundFile;\r
+        private System.Windows.Forms.Label label5;\r
+        private System.Windows.Forms.Button buttonMissionOpenFile;\r
+        private System.Windows.Forms.TextBox textBoxMissionSoundFile;\r
+        private System.Windows.Forms.Label label4;\r
+        private System.Windows.Forms.Button buttonMaxShipsOpenFile;\r
+        private System.Windows.Forms.TextBox textBoxMaxShipsSoundFile;\r
+        private System.Windows.Forms.Label label7;\r
+        private System.Windows.Forms.Button buttonOk;\r
+        private System.Windows.Forms.Button buttonCancel;\r
+        private System.Windows.Forms.Label label1;\r
+        private System.Windows.Forms.Label label2;\r
+        private System.Windows.Forms.NumericUpDown numericUpDownSoundVolume;\r
+        private System.Windows.Forms.Label label3;\r
+        private System.Windows.Forms.OpenFileDialog openFileDialog;\r
+        private System.Windows.Forms.NumericUpDown numericUpDownMarginShips;\r
+    }\r
+}
\ No newline at end of file
diff --git a/KancolleSniffer/ConfigDialog.cs b/KancolleSniffer/ConfigDialog.cs
new file mode 100644 (file)
index 0000000..ef4060f
--- /dev/null
@@ -0,0 +1,96 @@
+// Copyright (C) 2014 Kazuhiro Fujieda <fujieda@users.sourceforge.jp>\r
+// \r
+// This program is part of KancolleSniffer.\r
+//\r
+// KancolleSniffer is free software: you can redistribute it and/or modify\r
+// it under the terms of the GNU General Public License as published by\r
+// the Free Software Foundation, either version 3 of the License, or\r
+// (at your option) any later version.\r
+//\r
+// This program is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+// GNU General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU General Public License\r
+// along with this program; if not, see <http://www.gnu.org/licenses/>.\r
+\r
+using System;\r
+using System.IO;\r
+using System.Windows.Forms;\r
+\r
+namespace KancolleSniffer\r
+{\r
+    public partial class ConfigDialog : Form\r
+    {\r
+        public ConfigDialog()\r
+        {\r
+            InitializeComponent();\r
+        }\r
+\r
+        private void ConfigDialog_Load(object sender, EventArgs e)\r
+        {\r
+            var config = (Config)Tag;\r
+\r
+            checkBoxFlash.Checked = config.FlashWindow;\r
+            checkBoxBalloon.Checked = config.ShowBaloonTip;\r
+            groupBoxSound.Enabled = checkBoxSound.Checked = config.PlaySound;\r
+            numericUpDownMarginShips.Value = config.MarginShips;\r
+\r
+            numericUpDownSoundVolume.Value = config.SoundVolume;\r
+            textBoxMissionSoundFile.Text = config.MissionSoundFile;\r
+            textBoxNDockSoundFile.Text = config.NDockSoundFile;\r
+            textBoxKDockSoundFile.Text = config.KDockSoundFile;\r
+            textBoxMaxShipsSoundFile.Text = config.MaxShipsSoundFile;\r
+        }\r
+\r
+        private void buttonOk_Click(object sender, EventArgs e)\r
+        {\r
+            var config = (Config)Tag;\r
+\r
+            config.FlashWindow = checkBoxFlash.Checked;\r
+            config.ShowBaloonTip = checkBoxBalloon.Checked;\r
+            config.PlaySound = checkBoxSound.Checked;\r
+            config.MarginShips = (int)numericUpDownMarginShips.Value;\r
+\r
+            config.SoundVolume = (int)numericUpDownSoundVolume.Value;\r
+            config.MissionSoundFile = textBoxMissionSoundFile.Text;\r
+            config.NDockSoundFile = textBoxNDockSoundFile.Text;\r
+            config.KDockSoundFile = textBoxKDockSoundFile.Text;\r
+            config.MaxShipsSoundFile = textBoxMaxShipsSoundFile.Text;\r
+        }\r
+\r
+        private void checkBoxSound_CheckedChanged(object sender, EventArgs e)\r
+        {\r
+            groupBoxSound.Enabled = checkBoxSound.Checked;\r
+        }\r
+\r
+        private void buttonMissionOpenFile_Click(object sender, EventArgs e)\r
+        {\r
+            ChooseSoundFile(textBoxMissionSoundFile);\r
+        }\r
+\r
+        private void buttonNDockOpenFile_Click(object sender, EventArgs e)\r
+        {\r
+            ChooseSoundFile(textBoxNDockSoundFile);\r
+        }\r
+\r
+        private void buttonKDockOpenFile_Click(object sender, EventArgs e)\r
+        {\r
+            ChooseSoundFile(textBoxKDockSoundFile);\r
+        }\r
+\r
+        private void buttonMaxShipsOpenFile_Click(object sender, EventArgs e)\r
+        {\r
+            ChooseSoundFile(textBoxMaxShipsSoundFile);\r
+        }\r
+\r
+        private void ChooseSoundFile(TextBox textBox)\r
+        {\r
+            openFileDialog.FileName = textBox.Text;\r
+            openFileDialog.InitialDirectory = Path.GetDirectoryName(textBox.Text) ?? "";\r
+            if (openFileDialog.ShowDialog() == DialogResult.OK)\r
+                textBox.Text = openFileDialog.FileName;\r
+        }\r
+    }\r
+}
\ No newline at end of file
diff --git a/KancolleSniffer/ConfigDialog.resx b/KancolleSniffer/ConfigDialog.resx
new file mode 100644 (file)
index 0000000..a3d5a63
--- /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="openFileDialog.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
index cc6a5dc..11bf465 100644 (file)
     <Reference Include="System.Windows.Forms" />\r
   </ItemGroup>\r
   <ItemGroup>\r
+    <Compile Include="Config.cs" />\r
+    <Compile Include="ConfigDialog.cs">\r
+      <SubType>Form</SubType>\r
+    </Compile>\r
+    <Compile Include="ConfigDialog.Designer.cs">\r
+      <DependentUpon>ConfigDialog.cs</DependentUpon>\r
+    </Compile>\r
     <Compile Include="MainForm.cs">\r
       <SubType>Form</SubType>\r
     </Compile>\r
@@ -69,6 +76,9 @@
     <Compile Include="Sniffer.cs" />\r
     <Compile Include="ItemInfo.cs" />\r
     <Compile Include="Win32API.cs" />\r
+    <EmbeddedResource Include="ConfigDialog.resx">\r
+      <DependentUpon>ConfigDialog.cs</DependentUpon>\r
+    </EmbeddedResource>\r
     <EmbeddedResource Include="MainForm.resx">\r
       <DependentUpon>MainForm.cs</DependentUpon>\r
     </EmbeddedResource>\r
index a31d9f9..1f3e32a 100644 (file)
@@ -28,12 +28,15 @@ namespace KancolleSniffer
     {\r
         private readonly Sniffer _sniffer = new Sniffer();\r
         private readonly dynamic _wmp = Activator.CreateInstance(Type.GetTypeFromProgID("WMPlayer.OCX.7"));\r
+        private readonly Config _config = new Config();\r
+        private readonly ConfigDialog _configDialog = new ConfigDialog();\r
 \r
         public MainForm()\r
         {\r
             InitializeComponent();\r
             FiddlerApplication.AfterSessionComplete += FiddlerApplication_AfterSessionComplete;\r
             _wmp.PlayStateChange += new EventHandler(_wmp_PlayStateChange);\r
+            _configDialog.Tag = _config;\r
         }\r
 \r
         private void FiddlerApplication_AfterSessionComplete(Session oSession)\r
@@ -64,6 +67,9 @@ namespace KancolleSniffer
         private void MainForm_Load(object sender, EventArgs e)\r
         {\r
             _sniffer.LoadNames();\r
+            _config.Load();\r
+            _wmp.settings.volume = _config.SoundVolume;\r
+            _sniffer.Item.MarginShips = _config.MarginShips;\r
             FiddlerApplication.Startup(0, FiddlerCoreStartupFlags.RegisterAsSystemProxy);\r
         }\r
 \r
@@ -71,6 +77,7 @@ namespace KancolleSniffer
         {\r
             FiddlerApplication.Shutdown();\r
             _sniffer.SaveNames();\r
+            _config.Save();\r
         }\r
 \r
         private void notifyIconMain_MouseDoubleClick(object sender, MouseEventArgs e)\r
@@ -85,8 +92,13 @@ namespace KancolleSniffer
             Application.Exit();\r
         }\r
 \r
+\r
         private void ConfigToolStripMenuItem_Click(object sender, EventArgs e)\r
         {\r
+            if (_configDialog.ShowDialog() != DialogResult.OK)\r
+                return;\r
+            _wmp.settings.volume = _config.SoundVolume;\r
+            _sniffer.Item.MarginShips = _config.MarginShips;\r
         }\r
 \r
         private void timerMain_Tick(object sender, EventArgs e)\r
@@ -102,7 +114,7 @@ namespace KancolleSniffer
             if (item.NeedRing)\r
             {\r
                 var message = string.Format("残り{0:D}隻", _sniffer.Item.MaxShips - _sniffer.Item.NowShips);\r
-                Ring("艦娘が多すぎます", message, "kanmusu.mp3");\r
+                Ring("艦娘が多すぎます", message, _config.MaxShipsSoundFile);\r
                 item.NeedRing = false;\r
             }\r
             labelNumOfEquips.Text = string.Format("{0:D}/{1:D}", item.NowItems, item.MaxItems);\r
@@ -171,7 +183,7 @@ namespace KancolleSniffer
                 SetTimerLabel(timer, mission[i]);\r
                 if (!timer.NeedRing)\r
                     continue;\r
-                Ring("遠征が終わりました", _sniffer.Missions[i].Name, "ensei.mp3");\r
+                Ring("遠征が終わりました", _sniffer.Missions[i].Name, _config.MissionSoundFile);\r
                 timer.NeedRing = false;\r
             }\r
             var ndock = new[] {labelRepair1, labelRepair2, labelRepair3, labelRepair4};\r
@@ -182,7 +194,7 @@ namespace KancolleSniffer
                 SetTimerLabel(timer, ndock[i]);\r
                 if (!timer.NeedRing)\r
                     continue;\r
-                Ring("入渠が終わりました", _sniffer.NDock[i].Name, "nyuukyo.mp3");\r
+                Ring("入渠が終わりました", _sniffer.NDock[i].Name, _config.NDockSoundFile);\r
                 timer.NeedRing = false;\r
             }\r
             var kdock = new[] {labelConstruct1, labelConstruct2, labelConstruct3, labelConstruct4};\r
@@ -193,7 +205,7 @@ namespace KancolleSniffer
                 SetTimerLabel(timer, kdock[i]);\r
                 if (!timer.NeedRing)\r
                     continue;\r
-                Ring("建造が終わりました", string.Format("第{0:D}ドック", i + 1), "kenzou.mp3");\r
+                Ring("建造が終わりました", string.Format("第{0:D}ドック", i + 1), _config.KDockSoundFile);\r
                 timer.NeedRing = false;\r
             }\r
             UpdateCondTimers();\r
@@ -240,11 +252,15 @@ namespace KancolleSniffer
 \r
         private void Ring(string baloonTitle, string baloonMessage, string soundFile)\r
         {\r
-            Win32API.FlashWindow(Handle);\r
-            notifyIconMain.ShowBalloonTip(20000, baloonTitle, baloonMessage, ToolTipIcon.Info);\r
-// ReSharper disable once AssignNullToNotNullAttribute\r
-            _wmp.URL = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), soundFile);\r
-            _wmp.controls.play();\r
+            if (_config.FlashWindow)\r
+                Win32API.FlashWindow(Handle);\r
+            if (_config.ShowBaloonTip)\r
+                notifyIconMain.ShowBalloonTip(20000, baloonTitle, baloonMessage, ToolTipIcon.Info);\r
+            if (_config.PlaySound && File.Exists(soundFile))\r
+            {\r
+                _wmp.URL = soundFile;\r
+                _wmp.controls.play();\r
+            }\r
         }\r
 \r
         private void _wmp_PlayStateChange(object sender, EventArgs e)\r