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.Windows.Forms;
\r
21 namespace KancolleSniffer
\r
23 public partial class LogDialog : Form
\r
25 private readonly LogConfig _config;
\r
26 private readonly MainForm _main;
\r
28 public LogDialog(LogConfig config, MainForm main)
\r
30 InitializeComponent();
\r
31 numericUpDownMaterialLogInterval.Maximum = 1440;
\r
36 private void LogDialog_Load(object sender, EventArgs e)
\r
38 checkBoxOutput.Checked = _config.On;
\r
39 textBoxOutput.Text = _config.OutputDir;
\r
40 textBoxOutput.Select(textBoxOutput.Text.Length, 0);
\r
41 folderBrowserDialogOutputDir.SelectedPath = _config.OutputDir;
\r
42 numericUpDownMaterialLogInterval.Value = _config.MaterialLogInterval;
\r
43 (_config.ServerOn ? radioButtonServerOn : radioButtonServerOff).PerformClick();
\r
44 textBoxListen.Text = _config.Listen.ToString("D");
\r
47 private void radioButtonServerOn_CheckedChanged(object sender, EventArgs e)
\r
49 var on = ((RadioButton)sender).Checked;
\r
50 textBoxListen.Enabled = on;
\r
51 labelListen.Enabled = on;
\r
54 private void buttonOk_Click(object sender, EventArgs e)
\r
57 if (radioButtonServerOn.Checked && !ValidatePortNumber(textBoxListen, out listen))
\r
59 _config.ServerOn = radioButtonServerOn.Checked;
\r
60 if (_config.ServerOn)
\r
61 _config.Listen = listen;
\r
62 _config.MaterialLogInterval = (int)numericUpDownMaterialLogInterval.Value;
\r
63 _config.OutputDir = textBoxOutput.Text;
\r
64 _main.ApplyLogSetting();
\r
65 DialogResult = DialogResult.OK;
\r
68 private bool ValidatePortNumber(TextBox textBox, out int result)
\r
70 var s = textBox.Text;
\r
71 if (!int.TryParse(s, out result))
\r
73 ShowToolTip("数字を入力してください。", textBox);
\r
78 ShowToolTip("0より大きい数字を入力してください。", textBox);
\r
84 private void ShowToolTip(string message, Control control)
\r
86 toolTipError.Show(message, control, 0, control.Height, 3000);
\r
89 private void buttonOutputDir_Click(object sender, EventArgs e)
\r
91 if (folderBrowserDialogOutputDir.ShowDialog(this) == DialogResult.OK)
\r
92 textBoxOutput.Text = folderBrowserDialogOutputDir.SelectedPath;
\r
93 textBoxOutput.Select(textBoxOutput.Text.Length, 0);
\r