OSDN Git Service

enum Materialの順序を間違えているのを直す
[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.Collections.Generic;\r
20 using System.IO;\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 Config _config;\r
28         private readonly MainForm _main;\r
29         private DebugDialog _debugDialog;\r
30         private ProxyDialog _proxyDialog;\r
31         private LogDialog _logDialog;\r
32         private readonly Dictionary<string, string> _soundSetting = new Dictionary<string, string>();\r
33 \r
34         public ConfigDialog(Config config, MainForm main)\r
35         {\r
36             InitializeComponent();\r
37             _config = config;\r
38             _main = main;\r
39             listBoxSoundFile.Items.AddRange(new object[]\r
40             {\r
41                 "遠征終了", "入渠終了", "建造完了", "艦娘数超過", "装備数超過",\r
42                 "大破警告", "泊地修理20分経過", "泊地修理進行", "疲労回復"\r
43             });\r
44         }\r
45 \r
46         private void ConfigDialog_Load(object sender, EventArgs e)\r
47         {\r
48             checkBoxTopMost.Checked = _config.TopMost;\r
49             checkBoxHideOnMinimized.Checked = _config.HideOnMinimized;\r
50             checkBoxFlash.Checked = _config.FlashWindow;\r
51             checkBoxBalloon.Checked = _config.ShowBaloonTip;\r
52             groupBoxSound.Enabled = checkBoxSound.Checked = _config.PlaySound;\r
53             numericUpDownMarginShips.Value = _config.MarginShips;\r
54             numericUpDownMarginEquips.Value = _config.MarginEquips;\r
55             checkBoxCond40.Checked = _config.NotifyConditions.Contains(40);\r
56             checkBoxCond49.Checked = _config.NotifyConditions.Contains(49);\r
57             checkBoxReset02.Checked = _config.ResetHours.Contains(2);\r
58             checkBoxReset14.Checked = _config.ResetHours.Contains(14);\r
59 \r
60             numericUpDownSoundVolume.Value = _config.SoundVolume;\r
61 \r
62             _soundSetting["遠征終了"] = _config.MissionSoundFile;\r
63             _soundSetting["入渠終了"] = _config.NDockSoundFile;\r
64             _soundSetting["建造完了"] = _config.KDockSoundFile;\r
65             _soundSetting["艦娘数超過"] = _config.MaxShipsSoundFile;\r
66             _soundSetting["装備数超過"] = _config.MaxEquipsSoundFile;\r
67             _soundSetting["大破警告"] = _config.DamagedShipSoundFile;\r
68             _soundSetting["泊地修理20分経過"] = _config.Akashi20MinSoundFile;\r
69             _soundSetting["泊地修理進行"] = _config.AkashiProgressSoundFile;\r
70             _soundSetting["疲労回復"] = _config.ConditionSoundFile;\r
71 \r
72             listBoxSoundFile.SelectedIndex = 0;\r
73         }\r
74 \r
75         private void buttonOk_Click(object sender, EventArgs e)\r
76         {\r
77             _config.TopMost = checkBoxTopMost.Checked;\r
78             _config.HideOnMinimized = checkBoxHideOnMinimized.Checked;\r
79             _config.FlashWindow = checkBoxFlash.Checked;\r
80             _config.ShowBaloonTip = checkBoxBalloon.Checked;\r
81             _config.PlaySound = checkBoxSound.Checked;\r
82             _config.MarginShips = (int)numericUpDownMarginShips.Value;\r
83             _config.MarginEquips = (int)numericUpDownMarginEquips.Value;\r
84 \r
85             _config.NotifyConditions.Clear();\r
86             if (checkBoxCond40.Checked)\r
87                 _config.NotifyConditions.Add(40);\r
88             if (checkBoxCond49.Checked)\r
89                 _config.NotifyConditions.Add(49);\r
90 \r
91             _config.ResetHours.Clear();\r
92             if (checkBoxReset02.Checked)\r
93                 _config.ResetHours.Add(2);\r
94             if (checkBoxReset14.Checked)\r
95                 _config.ResetHours.Add(14);\r
96 \r
97             _config.SoundVolume = (int)numericUpDownSoundVolume.Value;\r
98 \r
99             _config.MissionSoundFile = _soundSetting["遠征終了"];\r
100             _config.NDockSoundFile = _soundSetting["入渠終了"];\r
101             _config.KDockSoundFile = _soundSetting["建造完了"];\r
102             _config.MaxShipsSoundFile = _soundSetting["艦娘数超過"];\r
103             _config.MaxEquipsSoundFile = _soundSetting["装備数超過"];\r
104             _config.DamagedShipSoundFile = _soundSetting["大破警告"];\r
105             _config.Akashi20MinSoundFile = _soundSetting["泊地修理20分経過"];\r
106             _config.AkashiProgressSoundFile = _soundSetting["泊地修理進行"];\r
107             _config.ConditionSoundFile = _soundSetting["疲労回復"];\r
108         }\r
109 \r
110         private void checkBoxSound_CheckedChanged(object sender, EventArgs e)\r
111         {\r
112             groupBoxSound.Enabled = checkBoxSound.Checked;\r
113         }\r
114 \r
115         private void textBoxSoundFile_TextChanged(object sender, EventArgs e)\r
116         {\r
117             _soundSetting[(string)listBoxSoundFile.SelectedItem] = textBoxSoundFile.Text;\r
118         }\r
119 \r
120         private void listBoxSoundFile_SelectedIndexChanged(object sender, EventArgs e)\r
121         {\r
122             textBoxSoundFile.Text = _soundSetting[(string)listBoxSoundFile.SelectedItem];\r
123             textBoxSoundFile.Select(textBoxSoundFile.Text.Length, 0);\r
124         }\r
125 \r
126         private void buttonOpenFile_Click(object sender, EventArgs e)\r
127         {\r
128             openFileDialog.FileName = textBoxSoundFile.Text;\r
129             openFileDialog.InitialDirectory = Path.GetDirectoryName(textBoxSoundFile.Text) ?? "";\r
130             if (openFileDialog.ShowDialog() != DialogResult.OK)\r
131                 return;\r
132             textBoxSoundFile.Text = openFileDialog.FileName;\r
133             textBoxSoundFile.Select(textBoxSoundFile.Text.Length, 0);\r
134         }\r
135 \r
136 \r
137         private void buttonPlay_Click(object sender, EventArgs e)\r
138         {\r
139             _main.PlaySound(_soundSetting[(string)listBoxSoundFile.SelectedItem], (int)numericUpDownSoundVolume.Value);\r
140         }\r
141 \r
142         private void DebugToolStripMenuItem_Click(object sender, EventArgs e)\r
143         {\r
144             if (_debugDialog == null)\r
145                 _debugDialog = new DebugDialog(_config, _main);\r
146             if (_debugDialog.ShowDialog(this) == DialogResult.Abort)\r
147                 DialogResult = DialogResult.Cancel;\r
148         }\r
149 \r
150         private void buttonResetAchievement_Click(object sender, EventArgs e)\r
151         {\r
152             _main.ResetAchievemnt();\r
153         }\r
154 \r
155         private void ProxyToolStripMenuItem_Click(object sender, EventArgs e)\r
156         {\r
157             if (_proxyDialog == null)\r
158                 _proxyDialog = new ProxyDialog(_config.Proxy, _main);\r
159             _proxyDialog.ShowDialog(this);\r
160         }\r
161 \r
162         private void ReportToolStripMenuItem_Click(object sender, EventArgs e)\r
163         {\r
164             if (_logDialog == null)\r
165                 _logDialog = new LogDialog(_config.Log, _main);\r
166             _logDialog.ShowDialog(this);\r
167         }\r
168     }\r
169 }