OSDN Git Service

戦果のリセットボタンを設定ダイアログに移動する
[kancollesniffer/KancolleSniffer.git] / KancolleSniffer / ConfigDialog.cs
1 // Copyright (C) 2014 Kazuhiro Fujieda <fujieda@users.sourceforge.jp>\r
2 // \r
3 // This program is part of KancolleSniffer.\r
4 //\r
5 // KancolleSniffer is free software: you can redistribute it and/or modify\r
6 // it under the terms of the GNU General Public License as published by\r
7 // the Free Software Foundation, either version 3 of the License, or\r
8 // (at your option) any later version.\r
9 //\r
10 // This program is distributed in the hope that it will be useful,\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13 // GNU General Public License for more details.\r
14 //\r
15 // You should have received a copy of the GNU General Public License\r
16 // along with this program; if not, see <http://www.gnu.org/licenses/>.\r
17 \r
18 using System;\r
19 using System.IO;\r
20 using System.Linq;\r
21 using System.Windows.Forms;\r
22 \r
23 namespace KancolleSniffer\r
24 {\r
25     public partial class ConfigDialog : Form\r
26     {\r
27         private readonly DebugDialog _debugDialog = new DebugDialog();\r
28         private readonly Config _config;\r
29         private readonly MainForm _main;\r
30 \r
31         public ConfigDialog(Config config, MainForm main)\r
32         {\r
33             InitializeComponent();\r
34             _config = config;\r
35             _main = main;\r
36         }\r
37 \r
38         private void ConfigDialog_Load(object sender, EventArgs e)\r
39         {\r
40             checkBoxTopMost.Checked = _config.TopMost;\r
41             checkBoxFlash.Checked = _config.FlashWindow;\r
42             checkBoxBalloon.Checked = _config.ShowBaloonTip;\r
43             groupBoxSound.Enabled = checkBoxSound.Checked = _config.PlaySound;\r
44             numericUpDownMarginShips.Value = _config.MarginShips;\r
45 \r
46             checkBoxReset02.Checked = _config.ResetHours.Any(x => x == 2);\r
47             checkBoxReset14.Checked = _config.ResetHours.Any(x => x == 14);\r
48 \r
49             numericUpDownSoundVolume.Value = _config.SoundVolume;\r
50             textBoxMissionSoundFile.Text = _config.MissionSoundFile;\r
51             textBoxNDockSoundFile.Text = _config.NDockSoundFile;\r
52             textBoxKDockSoundFile.Text = _config.KDockSoundFile;\r
53             textBoxMaxShipsSoundFile.Text = _config.MaxShipsSoundFile;\r
54             textBoxDamagedShipSoundFile.Text = _config.DamagedShipSoundFile;\r
55 \r
56             _debugDialog.Logging = _config.Logging;\r
57             _debugDialog.LogFile = _config.LogFile;\r
58         }\r
59 \r
60         private void buttonOk_Click(object sender, EventArgs e)\r
61         {\r
62             _config.TopMost = checkBoxTopMost.Checked;\r
63             _config.FlashWindow = checkBoxFlash.Checked;\r
64             _config.ShowBaloonTip = checkBoxBalloon.Checked;\r
65             _config.PlaySound = checkBoxSound.Checked;\r
66             _config.MarginShips = (int)numericUpDownMarginShips.Value;\r
67 \r
68             _config.ResetHours.Clear();\r
69             if (checkBoxReset02.Checked)\r
70                 _config.ResetHours.Add(2);\r
71             if (checkBoxReset14.Checked)\r
72                 _config.ResetHours.Add(14);\r
73 \r
74             _config.SoundVolume = (int)numericUpDownSoundVolume.Value;\r
75             _config.MissionSoundFile = textBoxMissionSoundFile.Text;\r
76             _config.NDockSoundFile = textBoxNDockSoundFile.Text;\r
77             _config.KDockSoundFile = textBoxKDockSoundFile.Text;\r
78             _config.MaxShipsSoundFile = textBoxMaxShipsSoundFile.Text;\r
79             _config.DamagedShipSoundFile = textBoxDamagedShipSoundFile.Text;\r
80 \r
81             _config.Logging = _debugDialog.Logging;\r
82             _config.LogFile = _debugDialog.LogFile;\r
83         }\r
84 \r
85         private void checkBoxSound_CheckedChanged(object sender, EventArgs e)\r
86         {\r
87             groupBoxSound.Enabled = checkBoxSound.Checked;\r
88         }\r
89 \r
90         private void buttonMissionOpenFile_Click(object sender, EventArgs e)\r
91         {\r
92             ChooseSoundFile(textBoxMissionSoundFile);\r
93         }\r
94 \r
95         private void buttonNDockOpenFile_Click(object sender, EventArgs e)\r
96         {\r
97             ChooseSoundFile(textBoxNDockSoundFile);\r
98         }\r
99 \r
100         private void buttonKDockOpenFile_Click(object sender, EventArgs e)\r
101         {\r
102             ChooseSoundFile(textBoxKDockSoundFile);\r
103         }\r
104 \r
105         private void buttonMaxShipsOpenFile_Click(object sender, EventArgs e)\r
106         {\r
107             ChooseSoundFile(textBoxMaxShipsSoundFile);\r
108         }\r
109 \r
110         private void buttonDamagedShipOpenFile_Click(object sender, EventArgs e)\r
111         {\r
112             ChooseSoundFile(textBoxDamagedShipSoundFile);\r
113         }\r
114 \r
115         private void ChooseSoundFile(TextBox textBox)\r
116         {\r
117             openFileDialog.FileName = textBox.Text;\r
118             openFileDialog.InitialDirectory = Path.GetDirectoryName(textBox.Text) ?? "";\r
119             if (openFileDialog.ShowDialog() == DialogResult.OK)\r
120                 textBox.Text = openFileDialog.FileName;\r
121         }\r
122 \r
123         private void DebugToolStripMenuItem_Click(object sender, EventArgs e)\r
124         {\r
125             _debugDialog.ShowDialog(this);\r
126         }\r
127 \r
128         private void buttonResetAchievement_Click(object sender, EventArgs e)\r
129         {\r
130             _main.ResetAchievemnt();\r
131         }\r
132     }\r
133 }