+
+ private void bClearLog_Click(object sender, EventArgs e)
+ {
+ tbLog.Text = string.Empty;
+ }
+
+ private void bSaveLog_Click(object sender, EventArgs e)
+ {
+ SaveFileDialog dialog = new SaveFileDialog()
+ {
+ Title = "Where do you want to store the log file?",
+ InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
+ FileName = "cec-log.txt",
+ Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*",
+ FilterIndex = 1
+ };
+
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ FileStream fs = (FileStream)dialog.OpenFile();
+ if (fs == null)
+ {
+ MessageBox.Show("Cannot open '" + dialog.FileName + "' for writing", "Pulse-Eight USB-CEC Adapter", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ else
+ {
+ StreamWriter writer = new StreamWriter(fs);
+ writer.Write(tbLog.Text);
+ writer.Close();
+ fs.Close();
+ fs.Dispose();
+ MessageBox.Show("The log file was stored as '" + dialog.FileName + "'.", "Pulse-Eight USB-CEC Adapter", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ }
+ }