Browse Source

Code cleanup

MarcinZiabek 3 years ago
parent
commit
297ca48c70

+ 0 - 19
QuestPDF.Previewer/DocumentRenderer.cs

@@ -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)
         public void UpdateDocument(IDocument? document)
         {
         {
             Document = document;
             Document = document;
@@ -49,7 +35,6 @@ namespace QuestPDF.Previewer
             
             
             try
             try
             {
             {
-                IsRendering = true;
                 RenderDocument(document);
                 RenderDocument(document);
             }
             }
             catch (Exception exception)
             catch (Exception exception)
@@ -57,10 +42,6 @@ namespace QuestPDF.Previewer
                 var exceptionDocument = new ExceptionDocument(exception);
                 var exceptionDocument = new ExceptionDocument(exception);
                 RenderDocument(exceptionDocument);
                 RenderDocument(exceptionDocument);
             }
             }
-            finally
-            {
-                IsRendering = false;
-            }
         }
         }
 
 
         private void RenderDocument(IDocument document)
         private void RenderDocument(IDocument document)

+ 1 - 1
QuestPDF.Previewer/InteractiveCanvas.cs

@@ -131,7 +131,7 @@ class InteractiveCanvas : ICustomDrawOperation
         
         
         canvas.Scale(Scale);
         canvas.Scale(Scale);
         canvas.Translate(TranslateX, -TranslateY + SafeZone / Scale);
         canvas.Translate(TranslateX, -TranslateY + SafeZone / Scale);
-
+        
         foreach (var page in Pages)
         foreach (var page in Pages)
         {
         {
             canvas.Translate(-page.Size.Width / 2f, 0);
             canvas.Translate(-page.Size.Width / 2f, 0);

+ 4 - 4
QuestPDF.Previewer/PreviewerControl.cs

@@ -39,15 +39,15 @@ namespace QuestPDF.Previewer
         
         
         public PreviewerControl()
         public PreviewerControl()
         {
         {
-            PagesProperty.Changed.Subscribe(p =>
+            PagesProperty.Changed.Subscribe(x =>
             {
             {
-                InteractiveCanvas.Pages = Pages;
+                InteractiveCanvas.Pages = x.NewValue.Value;
                 InvalidateVisual();
                 InvalidateVisual();
             });
             });
 
 
-            CurrentScrollProperty.Changed.Subscribe(p =>
+            CurrentScrollProperty.Changed.Subscribe(x =>
             {
             {
-                InteractiveCanvas.ScrollPercentY = CurrentScroll;
+                InteractiveCanvas.ScrollPercentY = x.NewValue.Value;
                 InvalidateVisual();
                 InvalidateVisual();
             });
             });
 
 

+ 4 - 4
QuestPDF.Previewer/PreviewerWindowViewModel.cs

@@ -72,15 +72,15 @@ namespace QuestPDF.Previewer
 
 
         private void ShowPdf()
         private void ShowPdf()
         {
         {
-            var path = Path.Combine(Path.GetTempPath(), ".pdf");
+            var filePath = Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid():N}.pdf");
 
 
             try
             try
             {
             {
-                Document?.GeneratePdf(path);
+                Document?.GeneratePdf(filePath);
             }
             }
             catch (Exception exception)
             catch (Exception exception)
             {
             {
-                new ExceptionDocument(exception).GeneratePdf(path);
+                new ExceptionDocument(exception).GeneratePdf(filePath);
             }
             }
 
 
             var openBrowserProcess = new Process
             var openBrowserProcess = new Process
@@ -88,7 +88,7 @@ namespace QuestPDF.Previewer
                 StartInfo = new()
                 StartInfo = new()
                 {
                 {
                     UseShellExecute = true,
                     UseShellExecute = true,
-                    FileName = path
+                    FileName = filePath
                 }
                 }
             };
             };
 
 

+ 1 - 1
QuestPDF/Drawing/FreeCanvas.cs

@@ -17,7 +17,7 @@ namespace QuestPDF.Drawing
             
             
         }
         }
 
 
-        public virtual void BeginPage(Size size)
+        public void BeginPage(Size size)
         {
         {
             
             
         }
         }