using S7Explorer.Models; using S7Explorer.Services; using S7Explorer.ViewModels; using System; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Media; namespace S7Explorer { public enum LogLevel { Debug, Info, Warning, Error } public class LogEntry { public DateTime Timestamp { get; set; } public LogLevel Level { get; set; } public string Message { get; set; } = string.Empty; public override string ToString() { return $"[{Timestamp:yyyy-MM-dd HH:mm:ss}] [{Level}] {Message}"; } } public partial class MainWindow : Window { private MainViewModel ViewModel; public MainWindow() { InitializeComponent(); ViewModel = new MainViewModel(); DataContext = ViewModel; } private void TreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs e) { if (e.NewValue is ProjectItem item) { ViewModel.SelectedItem = item; } } } public class IconConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value is string iconName) { // In a real application, return an actual image based on the icon name // Here we're just returning a placeholder return null; } return null; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } } public class LogLevelConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value is LogLevel level) { return level switch { LogLevel.Debug => Brushes.Gray, LogLevel.Info => Brushes.Black, LogLevel.Warning => Brushes.Orange, LogLevel.Error => Brushes.Red, _ => Brushes.Black }; } return Brushes.Black; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } } }