Files
QuestPDF/QuestPDF.Previewer/PreviewerView.axaml.cs
T
Bebo-Maker 346513ee85 Optimize document rendering.
We dont need to render the document two times anymore.
2022-03-17 10:34:00 +01:00

43 lines
1.1 KiB
C#

using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using QuestPDF.Infrastructure;
namespace QuestPDF.Previewer
{
internal class PreviewerView : UserControl
{
private readonly PreviewerControl _previewHost;
public static readonly StyledProperty<IDocument?> DocumentProperty =
AvaloniaProperty.Register<PreviewerControl, IDocument?>(nameof(Document));
public IDocument? Document
{
get => GetValue(DocumentProperty);
set => SetValue(DocumentProperty, value);
}
public PreviewerView()
{
InitializeComponent();
_previewHost = this.FindControl<PreviewerControl>("PreviewerSurface");
DocumentProperty
.Changed
.Subscribe(v => _previewHost.Document = v.NewValue.Value);
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
public void InvalidatePreview()
{
_previewHost.InvalidateDocument();
}
}
}