using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Perforce.View {
///
/// Interaction logic for LogWindow.xaml
///
public partial class LogWindow : Window {
public LogWindow() {
InitializeComponent();
}
private void ClearButton_Click(object sender, RoutedEventArgs e) {
Log.Appender.Notification = string.Empty;
}
private void SaveButton_Click(object sender, RoutedEventArgs e) {
Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
dlg.FileName = "logfile"; // Default file name
dlg.DefaultExt = ".txt"; // Default file extension
dlg.Filter = "Text documents (.txt)|*.txt"; // Filter files by extension
// Show save file dialog box
Nullable result = dlg.ShowDialog();
// Process save file dialog box results
if (result == true) {
// Save document
string path = dlg.FileName;
if (!File.Exists(path)) {
File.WriteAllText(path, Log.Appender.Notification);
} else {
File.AppendAllText(path, Log.Appender.Notification);
}
}
}
public bool IsOpen { get; set; }
private void Window_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) {
IsOpen = (bool) e.NewValue;
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) {
IsOpen = false;
}
}
}