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.Windows.Forms;\r
21 \r
22 namespace KancolleSniffer\r
23 {\r
24     public partial class ConfigDialog : Form\r
25     {\r
26         public ConfigDialog()\r
27         {\r
28             InitializeComponent();\r
29         }\r
30 \r
31         private void ConfigDialog_Load(object sender, EventArgs e)\r
32         {\r
33             var config = (Config)Tag;\r
34 \r
35             checkBoxTopMost.Checked = config.TopMost;\r
36             checkBoxFlash.Checked = config.FlashWindow;\r
37             checkBoxBalloon.Checked = config.ShowBaloonTip;\r
38             groupBoxSound.Enabled = checkBoxSound.Checked = config.PlaySound;\r
39             numericUpDownMarginShips.Value = config.MarginShips;\r
40 \r
41             numericUpDownSoundVolume.Value = config.SoundVolume;\r
42             textBoxMissionSoundFile.Text = config.MissionSoundFile;\r
43             textBoxNDockSoundFile.Text = config.NDockSoundFile;\r
44             textBoxKDockSoundFile.Text = config.KDockSoundFile;\r
45             textBoxMaxShipsSoundFile.Text = config.MaxShipsSoundFile;\r
46         }\r
47 \r
48         private void buttonOk_Click(object sender, EventArgs e)\r
49         {\r
50             var config = (Config)Tag;\r
51 \r
52             config.TopMost = checkBoxTopMost.Checked;\r
53             config.FlashWindow = checkBoxFlash.Checked;\r
54             config.ShowBaloonTip = checkBoxBalloon.Checked;\r
55             config.PlaySound = checkBoxSound.Checked;\r
56             config.MarginShips = (int)numericUpDownMarginShips.Value;\r
57 \r
58             config.SoundVolume = (int)numericUpDownSoundVolume.Value;\r
59             config.MissionSoundFile = textBoxMissionSoundFile.Text;\r
60             config.NDockSoundFile = textBoxNDockSoundFile.Text;\r
61             config.KDockSoundFile = textBoxKDockSoundFile.Text;\r
62             config.MaxShipsSoundFile = textBoxMaxShipsSoundFile.Text;\r
63         }\r
64 \r
65         private void checkBoxSound_CheckedChanged(object sender, EventArgs e)\r
66         {\r
67             groupBoxSound.Enabled = checkBoxSound.Checked;\r
68         }\r
69 \r
70         private void buttonMissionOpenFile_Click(object sender, EventArgs e)\r
71         {\r
72             ChooseSoundFile(textBoxMissionSoundFile);\r
73         }\r
74 \r
75         private void buttonNDockOpenFile_Click(object sender, EventArgs e)\r
76         {\r
77             ChooseSoundFile(textBoxNDockSoundFile);\r
78         }\r
79 \r
80         private void buttonKDockOpenFile_Click(object sender, EventArgs e)\r
81         {\r
82             ChooseSoundFile(textBoxKDockSoundFile);\r
83         }\r
84 \r
85         private void buttonMaxShipsOpenFile_Click(object sender, EventArgs e)\r
86         {\r
87             ChooseSoundFile(textBoxMaxShipsSoundFile);\r
88         }\r
89 \r
90         private void ChooseSoundFile(TextBox textBox)\r
91         {\r
92             openFileDialog.FileName = textBox.Text;\r
93             openFileDialog.InitialDirectory = Path.GetDirectoryName(textBox.Text) ?? "";\r
94             if (openFileDialog.ShowDialog() == DialogResult.OK)\r
95                 textBox.Text = openFileDialog.FileName;\r
96         }\r
97     }\r
98 }