OSDN Git Service

DPIスケーリングに対応する
[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 readonly Dictionary<string, string> _soundSetting = new Dictionary<string, string>();\r
32 \r
33         public ConfigDialog(Config config, MainForm main)\r
34         {\r
35             InitializeComponent();\r
36             _config = config;\r
37             _main = main;\r
38             listBoxSoundFile.Items.AddRange(new object[]\r
39             {\r
40                 "遠征終了", "入渠終了", "建造完了", "艦娘数超過", "装備数超過",\r
41                 "大破警告", "泊地修理20分経過", "泊地修理進行", "疲労回復"\r
42             });\r
43         }\r
44 \r
45         private void ConfigDialog_Load(object sender, EventArgs e)\r
46         {\r
47             checkBoxTopMost.Checked = _config.TopMost;\r
48             checkBoxHideOnMinimized.Checked = _config.HideOnMinimized;\r
49             checkBoxAutoScale.Checked = _config.AutoScale;\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.AutoScale = checkBoxAutoScale.Checked;\r
80             _config.FlashWindow = checkBoxFlash.Checked;\r
81             _config.ShowBaloonTip = checkBoxBalloon.Checked;\r
82             _config.PlaySound = checkBoxSound.Checked;\r
83             _config.MarginShips = (int)numericUpDownMarginShips.Value;\r
84             _config.MarginEquips = (int)numericUpDownMarginEquips.Value;\r
85 \r
86             _config.NotifyConditions.Clear();\r
87             if (checkBoxCond40.Checked)\r
88                 _config.NotifyConditions.Add(40);\r
89             if (checkBoxCond49.Checked)\r
90                 _config.NotifyConditions.Add(49);\r
91 \r
92             _config.ResetHours.Clear();\r
93             if (checkBoxReset02.Checked)\r
94                 _config.ResetHours.Add(2);\r
95             if (checkBoxReset14.Checked)\r
96                 _config.ResetHours.Add(14);\r
97 \r
98             _config.SoundVolume = (int)numericUpDownSoundVolume.Value;\r
99 \r
100             _config.MissionSoundFile = _soundSetting["遠征終了"];\r
101             _config.NDockSoundFile = _soundSetting["入渠終了"];\r
102             _config.KDockSoundFile = _soundSetting["建造完了"];\r
103             _config.MaxShipsSoundFile = _soundSetting["艦娘数超過"];\r
104             _config.MaxEquipsSoundFile = _soundSetting["装備数超過"];\r
105             _config.DamagedShipSoundFile = _soundSetting["大破警告"];\r
106             _config.Akashi20MinSoundFile = _soundSetting["泊地修理20分経過"];\r
107             _config.AkashiProgressSoundFile = _soundSetting["泊地修理進行"];\r
108             _config.ConditionSoundFile = _soundSetting["疲労回復"];\r
109         }\r
110 \r
111         private void checkBoxSound_CheckedChanged(object sender, EventArgs e)\r
112         {\r
113             groupBoxSound.Enabled = checkBoxSound.Checked;\r
114         }\r
115 \r
116         private void textBoxSoundFile_TextChanged(object sender, EventArgs e)\r
117         {\r
118             _soundSetting[(string)listBoxSoundFile.SelectedItem] = textBoxSoundFile.Text;\r
119         }\r
120 \r
121         private void listBoxSoundFile_SelectedIndexChanged(object sender, EventArgs e)\r
122         {\r
123             textBoxSoundFile.Text = _soundSetting[(string)listBoxSoundFile.SelectedItem];\r
124             textBoxSoundFile.Select(textBoxSoundFile.Text.Length, 0);\r
125         }\r
126 \r
127         private void buttonOpenFile_Click(object sender, EventArgs e)\r
128         {\r
129             openFileDialog.FileName = textBoxSoundFile.Text;\r
130             openFileDialog.InitialDirectory = Path.GetDirectoryName(textBoxSoundFile.Text) ?? "";\r
131             if (openFileDialog.ShowDialog() != DialogResult.OK)\r
132                 return;\r
133             textBoxSoundFile.Text = openFileDialog.FileName;\r
134             textBoxSoundFile.Select(textBoxSoundFile.Text.Length, 0);\r
135         }\r
136 \r
137 \r
138         private void buttonPlay_Click(object sender, EventArgs e)\r
139         {\r
140             _main.PlaySound(_soundSetting[(string)listBoxSoundFile.SelectedItem], (int)numericUpDownSoundVolume.Value);\r
141         }\r
142 \r
143         private void DebugToolStripMenuItem_Click(object sender, EventArgs e)\r
144         {\r
145             if (_debugDialog == null)\r
146                 _debugDialog = new DebugDialog(_config, _main);\r
147             _debugDialog.ShowDialog(this);\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 }