84 lines
2.3 KiB
C#
84 lines
2.3 KiB
C#
using System;
|
|
using System.Collections.ObjectModel;
|
|
using System.ComponentModel;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Windows;
|
|
using System.Windows.Media;
|
|
using BeWo.Annotations;
|
|
|
|
namespace BeWo.View.Detail
|
|
{
|
|
public partial class DebugMessageLogView : INotifyPropertyChanged
|
|
{
|
|
private ObservableCollection<DebugWindowMessage> _DebugMessageList;
|
|
|
|
public ObservableCollection<DebugWindowMessage> DebugMessageList
|
|
{
|
|
get => _DebugMessageList;
|
|
|
|
set
|
|
{
|
|
if(!Equals(_DebugMessageList, value))
|
|
{
|
|
_DebugMessageList = value;
|
|
OnPropertyChanged(nameof(DebugMessageList));
|
|
}
|
|
}
|
|
}
|
|
|
|
public DebugMessageLogView()
|
|
{
|
|
InitializeComponent();
|
|
|
|
DebugMessageList = new ObservableCollection<DebugWindowMessage>();
|
|
|
|
DataContext = this;
|
|
}
|
|
|
|
public void LogMessage(string message)
|
|
{
|
|
DebugMessageList.Add(new DebugWindowMessage(message));
|
|
}
|
|
|
|
public void LogMessage(string message, Color color)
|
|
{
|
|
DebugMessageList.Add(new DebugWindowMessage(message, color));
|
|
}
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
|
|
[NotifyPropertyChangedInvocator]
|
|
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
|
{
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
}
|
|
|
|
private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
|
|
{
|
|
DebugMessageList.Clear();
|
|
}
|
|
}
|
|
|
|
public class DebugWindowMessage
|
|
{
|
|
public string MessageText { get; }
|
|
|
|
public Color CustomColor { get; }
|
|
|
|
public SolidColorBrush TextColor => new SolidColorBrush(CustomColor);
|
|
|
|
public DebugWindowMessage(string messageText)
|
|
{
|
|
MessageText = $"{DateTime.Now:dd.MM.yyyy HH:mm:ss}: {messageText}";
|
|
CustomColor = Colors.Black;
|
|
}
|
|
|
|
public DebugWindowMessage(string messageText, Color customColor)
|
|
{
|
|
MessageText = $"{DateTime.Now:dd.MM.yyyy HH:mm:ss}: {messageText}";
|
|
CustomColor = customColor;
|
|
}
|
|
}
|
|
}
|