using System; using System.Diagnostics; using System.IO; using System.Windows; using System.Windows.Input; namespace LDUninstaller.UI.Dialogs { public partial class LogViewerWindow : Window { public LogViewerWindow() { InitializeComponent(); Loaded += (s, e) => LoadLog(); } private void TitleBar_MouseDown(object sender, MouseButtonEventArgs e) { if (e.ChangedButton == MouseButton.Left) DragMove(); } private void BtnClose_Click(object sender, RoutedEventArgs e) { Close(); } private void LoadLog() { try { if (File.Exists(App.LogFilePath)) { using var fs = new FileStream(App.LogFilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); using var reader = new StreamReader(fs); txtLog.Text = reader.ReadToEnd(); txtLog.ScrollToEnd(); } else { txtLog.Text = "Henüz bir log kaydı oluşturulmadı."; } } catch (Exception ex) { txtLog.Text = $"Log dosyası okunamadı: {ex.Message}"; } } private void BtnRefresh_Click(object sender, RoutedEventArgs e) => LoadLog(); private void BtnCopy_Click(object sender, RoutedEventArgs e) { if (!string.IsNullOrEmpty(txtLog.Text)) { Clipboard.SetText(txtLog.Text); MessageBox.Show("Log metni panoya kopyalandı.", "Kopyalandı", MessageBoxButton.OK, MessageBoxImage.Information); } } private void BtnOpenExternal_Click(object sender, RoutedEventArgs e) { try { if (File.Exists(App.LogFilePath)) Process.Start(new ProcessStartInfo("notepad.exe", App.LogFilePath) { UseShellExecute = true }); } catch { } } private void BtnClear_Click(object sender, RoutedEventArgs e) { try { if (File.Exists(App.LogFilePath)) File.WriteAllText(App.LogFilePath, string.Empty); LoadLog(); } catch { } } } }