1 // Copyright (C) 2014 Kazuhiro Fujieda <fujieda@users.sourceforge.jp>
\r
3 // This program is part of KancolleSniffer.
\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
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
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
19 using System.Collections.Generic;
\r
22 using System.Windows.Forms;
\r
24 namespace KancolleSniffer
\r
26 public partial class ConfigDialog : Form
\r
28 private readonly Config _config;
\r
29 private readonly MainForm _main;
\r
30 private DebugDialog _debugDialog;
\r
31 private ProxyDialog _proxyDialog;
\r
32 private readonly Dictionary<string, string> _soundSetting = new Dictionary<string, string>();
\r
34 public ConfigDialog(Config config, MainForm main)
\r
36 InitializeComponent();
\r
39 listBoxSoundFile.Items.AddRange(new object[] {"遠征終了", "入渠終了", "建造完了", "艦娘数超過", "大破警告", "泊地修理20分経過", "泊地修理進行"});
\r
42 private void ConfigDialog_Load(object sender, EventArgs e)
\r
44 checkBoxTopMost.Checked = _config.TopMost;
\r
45 checkBoxHideOnMinimized.Checked = _config.HideOnMinimized;
\r
46 checkBoxFlash.Checked = _config.FlashWindow;
\r
47 checkBoxBalloon.Checked = _config.ShowBaloonTip;
\r
48 groupBoxSound.Enabled = checkBoxSound.Checked = _config.PlaySound;
\r
49 numericUpDownMarginShips.Value = _config.MarginShips;
\r
51 checkBoxReset02.Checked = _config.ResetHours.Any(x => x == 2);
\r
52 checkBoxReset14.Checked = _config.ResetHours.Any(x => x == 14);
\r
54 numericUpDownSoundVolume.Value = _config.SoundVolume;
\r
56 _soundSetting["遠征終了"] = _config.MissionSoundFile;
\r
57 _soundSetting["入渠終了"] = _config.NDockSoundFile;
\r
58 _soundSetting["建造完了"] = _config.KDockSoundFile;
\r
59 _soundSetting["艦娘数超過"] = _config.MaxShipsSoundFile;
\r
60 _soundSetting["大破警告"] = _config.DamagedShipSoundFile;
\r
61 _soundSetting["泊地修理20分経過"] = _config.Akashi20MinSoundFile;
\r
62 _soundSetting["泊地修理進行"] = _config.AkashiProgressSoundFile;
\r
63 listBoxSoundFile.SelectedIndex = 0;
\r
66 private void buttonOk_Click(object sender, EventArgs e)
\r
68 _config.TopMost = checkBoxTopMost.Checked;
\r
69 _config.HideOnMinimized = checkBoxHideOnMinimized.Checked;
\r
70 _config.FlashWindow = checkBoxFlash.Checked;
\r
71 _config.ShowBaloonTip = checkBoxBalloon.Checked;
\r
72 _config.PlaySound = checkBoxSound.Checked;
\r
73 _config.MarginShips = (int)numericUpDownMarginShips.Value;
\r
75 _config.ResetHours.Clear();
\r
76 if (checkBoxReset02.Checked)
\r
77 _config.ResetHours.Add(2);
\r
78 if (checkBoxReset14.Checked)
\r
79 _config.ResetHours.Add(14);
\r
81 _config.SoundVolume = (int)numericUpDownSoundVolume.Value;
\r
83 _config.MissionSoundFile = _soundSetting["遠征終了"];
\r
84 _config.NDockSoundFile = _soundSetting["入渠終了"];
\r
85 _config.KDockSoundFile = _soundSetting["建造完了"];
\r
86 _config.MaxShipsSoundFile = _soundSetting["艦娘数超過"];
\r
87 _config.DamagedShipSoundFile = _soundSetting["大破警告"];
\r
88 _config.Akashi20MinSoundFile = _soundSetting["泊地修理20分経過"];
\r
89 _config.AkashiProgressSoundFile = _soundSetting["泊地修理進行"];
\r
92 private void checkBoxSound_CheckedChanged(object sender, EventArgs e)
\r
94 groupBoxSound.Enabled = checkBoxSound.Checked;
\r
97 private void textBoxSoundFile_TextChanged(object sender, EventArgs e)
\r
99 _soundSetting[(string)listBoxSoundFile.SelectedItem] = textBoxSoundFile.Text;
\r
102 private void listBoxSoundFile_SelectedIndexChanged(object sender, EventArgs e)
\r
104 textBoxSoundFile.Text = _soundSetting[(string)listBoxSoundFile.SelectedItem];
\r
105 textBoxSoundFile.Select(textBoxSoundFile.Text.Length, 0);
\r
108 private void buttonOpenFile_Click(object sender, EventArgs e)
\r
110 openFileDialog.FileName = textBoxSoundFile.Text;
\r
111 openFileDialog.InitialDirectory = Path.GetDirectoryName(textBoxSoundFile.Text) ?? "";
\r
112 if (openFileDialog.ShowDialog() != DialogResult.OK)
\r
114 textBoxSoundFile.Text = openFileDialog.FileName;
\r
115 textBoxSoundFile.Select(textBoxSoundFile.Text.Length, 0);
\r
119 private void buttonPlay_Click(object sender, EventArgs e)
\r
121 _main.PlaySound(_soundSetting[(string)listBoxSoundFile.SelectedItem], (int)numericUpDownSoundVolume.Value);
\r
124 private void DebugToolStripMenuItem_Click(object sender, EventArgs e)
\r
126 if (_debugDialog == null)
\r
127 _debugDialog = new DebugDialog(_config, _main);
\r
128 _debugDialog.ShowDialog(this);
\r
131 private void buttonResetAchievement_Click(object sender, EventArgs e)
\r
133 _main.ResetAchievemnt();
\r
136 private void ProxyToolStripMenuItem_Click(object sender, EventArgs e)
\r
138 if (_proxyDialog == null)
\r
139 _proxyDialog = new ProxyDialog(_config.Proxy, _main);
\r
140 _proxyDialog.ShowDialog(this);
\r