Code cleanup

This commit is contained in:
MarcinZiabek
2022-03-24 23:09:09 +01:00
parent d2601e9e5a
commit 297ca48c70
5 changed files with 10 additions and 29 deletions
-19
View File
@@ -26,20 +26,6 @@ namespace QuestPDF.Previewer
}
}
private bool _isRendering;
public bool IsRendering
{
get => _isRendering;
private set
{
if (_isRendering != value)
{
_isRendering = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsRendering)));
}
}
}
public void UpdateDocument(IDocument? document)
{
Document = document;
@@ -49,7 +35,6 @@ namespace QuestPDF.Previewer
try
{
IsRendering = true;
RenderDocument(document);
}
catch (Exception exception)
@@ -57,10 +42,6 @@ namespace QuestPDF.Previewer
var exceptionDocument = new ExceptionDocument(exception);
RenderDocument(exceptionDocument);
}
finally
{
IsRendering = false;
}
}
private void RenderDocument(IDocument document)
+1 -1
View File
@@ -131,7 +131,7 @@ class InteractiveCanvas : ICustomDrawOperation
canvas.Scale(Scale);
canvas.Translate(TranslateX, -TranslateY + SafeZone / Scale);
foreach (var page in Pages)
{
canvas.Translate(-page.Size.Width / 2f, 0);
+4 -4
View File
@@ -39,15 +39,15 @@ namespace QuestPDF.Previewer
public PreviewerControl()
{
PagesProperty.Changed.Subscribe(p =>
PagesProperty.Changed.Subscribe(x =>
{
InteractiveCanvas.Pages = Pages;
InteractiveCanvas.Pages = x.NewValue.Value;
InvalidateVisual();
});
CurrentScrollProperty.Changed.Subscribe(p =>
CurrentScrollProperty.Changed.Subscribe(x =>
{
InteractiveCanvas.ScrollPercentY = CurrentScroll;
InteractiveCanvas.ScrollPercentY = x.NewValue.Value;
InvalidateVisual();
});
@@ -72,15 +72,15 @@ namespace QuestPDF.Previewer
private void ShowPdf()
{
var path = Path.Combine(Path.GetTempPath(), ".pdf");
var filePath = Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid():N}.pdf");
try
{
Document?.GeneratePdf(path);
Document?.GeneratePdf(filePath);
}
catch (Exception exception)
{
new ExceptionDocument(exception).GeneratePdf(path);
new ExceptionDocument(exception).GeneratePdf(filePath);
}
var openBrowserProcess = new Process
@@ -88,7 +88,7 @@ namespace QuestPDF.Previewer
StartInfo = new()
{
UseShellExecute = true,
FileName = path
FileName = filePath
}
};
+1 -1
View File
@@ -17,7 +17,7 @@ namespace QuestPDF.Drawing
}
public virtual void BeginPage(Size size)
public void BeginPage(Size size)
{
}