Add project files.
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
<UserControl x:Class="SafeBagDE70.Admin.AdminLoginUC"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:SafeBagDE70.Admin"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="1024" d:DesignWidth="1280">
|
||||
<Grid>
|
||||
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
|
||||
<TextBlock Text="Admin Login" FontSize="20" HorizontalAlignment="Center"/>
|
||||
<TextBox x:Name="UsernameTextBox" Width="200" Margin="10" />
|
||||
<PasswordBox x:Name="PasswordBox" Width="200" Margin="10" />
|
||||
<Button Content="Login" Width="200" Margin="10" Click="LoginButton_Click"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,71 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Serilog;
|
||||
using Serilog.Core;
|
||||
using Serilog.Events;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
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.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace SafeBagDE70.Admin
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for LogViewerUC.xaml
|
||||
/// </summary>
|
||||
public partial class LogViewerUC : UserControl
|
||||
{
|
||||
private ObservableCollection<string> _logItems = new ObservableCollection<string>();
|
||||
|
||||
public LogViewerUC()
|
||||
{
|
||||
InitializeComponent();
|
||||
LogListView.ItemsSource = AppData.logCollection;
|
||||
AppData.logListView = LogListView;
|
||||
}
|
||||
|
||||
private void LogInfoButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Log.Information("This is an informational log message");
|
||||
}
|
||||
}
|
||||
public class RealTimeLogSink : ILogEventSink
|
||||
{
|
||||
private readonly IFormatProvider _formatProvider;
|
||||
|
||||
public RealTimeLogSink( IFormatProvider formatProvider = null)
|
||||
{
|
||||
_formatProvider = formatProvider;
|
||||
}
|
||||
|
||||
public void Emit(LogEvent logEvent)
|
||||
{
|
||||
var message = logEvent.RenderMessage(_formatProvider);
|
||||
var logLevel = logEvent.Level.ToString();
|
||||
var timestampedMessage = $"[{logEvent.Timestamp:HH:mm:ss}] [{logLevel}]{message}";
|
||||
|
||||
// Ensure the message is added on the UI thread
|
||||
App.Current.Dispatcher.Invoke(() => {
|
||||
AppData.logCollection.Add(timestampedMessage);
|
||||
if (AppData.logCollection.Count > AppData.MaxLogCount)
|
||||
{
|
||||
AppData.logCollection.RemoveAt(0); // Remove the oldest event
|
||||
}
|
||||
if (AppData.logListView != null && AppData.logListView.Items.Count > 0)
|
||||
{
|
||||
AppData.logListView.ScrollIntoView(AppData.logListView.Items[AppData.logListView.Items.Count - 1]);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user