32 lines
822 B
C#
32 lines
822 B
C#
|
using Avalonia.Controls;
|
|||
|
using Avalonia.Interactivity;
|
|||
|
using Avalonia.Markup.Xaml;
|
|||
|
using DispenserCommon.Utils;
|
|||
|
using DispenserUI.ViewModels.Components;
|
|||
|
|
|||
|
namespace DispenserUI.Views.Controls;
|
|||
|
|
|||
|
public partial class ConsoleLog : UserControl
|
|||
|
{
|
|||
|
public ConsoleLog()
|
|||
|
{
|
|||
|
DataContext = ViewModel;
|
|||
|
InitializeComponent();
|
|||
|
ConsoleViewer = this.FindControl<ScrollViewer>("ConsoleViewer");
|
|||
|
|
|||
|
ViewModel.Logs.CollectionChanged += (sender, args) => { ConsoleViewer!.ScrollToEnd(); };
|
|||
|
}
|
|||
|
|
|||
|
public ConsoleLogVM ViewModel { get; } = ServiceLocator.GetService<ConsoleLogVM>();
|
|||
|
|
|||
|
private void InitializeComponent()
|
|||
|
{
|
|||
|
AvaloniaXamlLoader.Load(this);
|
|||
|
}
|
|||
|
|
|||
|
protected override void OnLoaded(RoutedEventArgs e)
|
|||
|
{
|
|||
|
base.OnLoaded(e);
|
|||
|
ViewModel.RenderLog();
|
|||
|
}
|
|||
|
}
|