From cdf44e78441a7c9ddb30544502f39aaaf5938bfc Mon Sep 17 00:00:00 2001 From: Michael Mairegger Date: Thu, 9 Nov 2017 15:23:24 +0100 Subject: [PATCH] Code Cleanup --- Mairegger.Printing/Content/BlankLine.cs | 5 +- Mairegger.Printing/Content/PageBreak.cs | 5 +- .../Content/PrintDocumentBackground.cs | 7 +-- .../Internal/InternalPrintProcessor.cs | 4 +- .../Internal/PrintDialogWrapper.cs | 46 ++++++++----------- .../Internal/WindowsProvider.cs | 4 +- .../PrintProcessorCollection.cs | 4 +- 7 files changed, 28 insertions(+), 47 deletions(-) diff --git a/Mairegger.Printing/Content/BlankLine.cs b/Mairegger.Printing/Content/BlankLine.cs index c2a8a6f2..70001fb1 100644 --- a/Mairegger.Printing/Content/BlankLine.cs +++ b/Mairegger.Printing/Content/BlankLine.cs @@ -30,9 +30,6 @@ internal BlankLine(double height) _height = height; } - public UIElement Content - { - get { return new FrameworkElement { Height = _height }; } - } + public UIElement Content => new FrameworkElement { Height = _height }; } } \ No newline at end of file diff --git a/Mairegger.Printing/Content/PageBreak.cs b/Mairegger.Printing/Content/PageBreak.cs index f95413b2..bc5e6238 100644 --- a/Mairegger.Printing/Content/PageBreak.cs +++ b/Mairegger.Printing/Content/PageBreak.cs @@ -27,9 +27,6 @@ private PageBreak() public static IPrintContent Instance => LazyInstance.Value; - UIElement IPrintContent.Content - { - get { throw new InvalidOperationException("There is no available content."); } - } + UIElement IPrintContent.Content => throw new InvalidOperationException("There is no available content."); } } \ No newline at end of file diff --git a/Mairegger.Printing/Content/PrintDocumentBackground.cs b/Mairegger.Printing/Content/PrintDocumentBackground.cs index b9e15d09..d206915e 100644 --- a/Mairegger.Printing/Content/PrintDocumentBackground.cs +++ b/Mairegger.Printing/Content/PrintDocumentBackground.cs @@ -23,13 +23,8 @@ public sealed class PrintDocumentBackground { public PrintDocumentBackground([NotNull] Panel panel, Rect size = new Rect()) { - if (panel == null) - { - throw new ArgumentNullException(nameof(panel)); - } - + Element = panel ?? throw new ArgumentNullException(nameof(panel)); Size = size; - Element = panel; } public Panel Element { get; } diff --git a/Mairegger.Printing/Internal/InternalPrintProcessor.cs b/Mairegger.Printing/Internal/InternalPrintProcessor.cs index ed2c50a3..0d13f961 100644 --- a/Mairegger.Printing/Internal/InternalPrintProcessor.cs +++ b/Mairegger.Printing/Internal/InternalPrintProcessor.cs @@ -393,9 +393,7 @@ private PageHelper CreateNewPageHelper() _printProcessor.CurrentPage++; _printProcessor.OnPageBreak(); - Brush borderBrush; - double gridTableHeight; - var table = _printProcessor.GetTable(out gridTableHeight, out borderBrush); + var table = _printProcessor.GetTable(out var gridTableHeight, out var borderBrush); var itemsControl = new ItemsControl(); diff --git a/Mairegger.Printing/Internal/PrintDialogWrapper.cs b/Mairegger.Printing/Internal/PrintDialogWrapper.cs index fbf8d47a..65435b7c 100644 --- a/Mairegger.Printing/Internal/PrintDialogWrapper.cs +++ b/Mairegger.Printing/Internal/PrintDialogWrapper.cs @@ -26,66 +26,60 @@ internal class PrintDialogWrapper : IPrintDialog public bool CurrentPageEnabled { - get { return _printDialog.CurrentPageEnabled; } - set { _printDialog.CurrentPageEnabled = value; } + get => _printDialog.CurrentPageEnabled; + set => _printDialog.CurrentPageEnabled = value; } public int MaxPage { - get { return (int)_printDialog.MaxPage; } - set { _printDialog.MaxPage = (uint)value; } + get => (int)_printDialog.MaxPage; + set => _printDialog.MaxPage = (uint)value; } public int MinPage { - get { return (int)_printDialog.MinPage; } - set { _printDialog.MinPage = (uint)value; } + get => (int)_printDialog.MinPage; + set => _printDialog.MinPage = (uint)value; } public PageRange PageRange { - get { return _printDialog.PageRange; } - set { _printDialog.PageRange = value; } + get => _printDialog.PageRange; + set => _printDialog.PageRange = value; } public PageRangeSelection PageRangeSelection { - get { return _printDialog.PageRangeSelection; } - set { _printDialog.PageRangeSelection = value; } + get => _printDialog.PageRangeSelection; + set => _printDialog.PageRangeSelection = value; } - public double PrintableAreaHeight - { - get { return _printDialog.PrintableAreaHeight; } - } + public double PrintableAreaHeight => _printDialog.PrintableAreaHeight; - public double PrintableAreaWidth - { - get { return _printDialog.PrintableAreaWidth; } - } + public double PrintableAreaWidth => _printDialog.PrintableAreaWidth; public PrintQueue PrintQueue { - get { return _printDialog.PrintQueue; } - set { _printDialog.PrintQueue = value; } + get => _printDialog.PrintQueue; + set => _printDialog.PrintQueue = value; } public PrintTicket PrintTicket { - get { return _printDialog.PrintTicket; } - set { _printDialog.PrintTicket = value; } + get => _printDialog.PrintTicket; + set => _printDialog.PrintTicket = value; } public bool SelectedPagesEnabled { - get { return _printDialog.SelectedPagesEnabled; } - set { _printDialog.SelectedPagesEnabled = value; } + get => _printDialog.SelectedPagesEnabled; + set => _printDialog.SelectedPagesEnabled = value; } public bool UserPageRangeEnabled { - get { return _printDialog.UserPageRangeEnabled; } - set { _printDialog.UserPageRangeEnabled = value; } + get => _printDialog.UserPageRangeEnabled; + set => _printDialog.UserPageRangeEnabled = value; } public void PrintDocument(DocumentPaginator documentPaginator, string description) diff --git a/Mairegger.Printing/Internal/WindowsProvider.cs b/Mairegger.Printing/Internal/WindowsProvider.cs index 629a70fa..8d81f778 100644 --- a/Mairegger.Printing/Internal/WindowsProvider.cs +++ b/Mairegger.Printing/Internal/WindowsProvider.cs @@ -25,8 +25,8 @@ internal class WindowsProvider : IWindowProvider public event EventHandler Closed { - add { _window.Closed += value; } - remove { _window.Closed -= value; } + add => _window.Closed += value; + remove => _window.Closed -= value; } public void Show(string windowTitle, DocumentViewer documentViewer) diff --git a/Mairegger.Printing/PrintProcessor/PrintProcessorCollection.cs b/Mairegger.Printing/PrintProcessor/PrintProcessorCollection.cs index 392e639b..0af83eef 100644 --- a/Mairegger.Printing/PrintProcessor/PrintProcessorCollection.cs +++ b/Mairegger.Printing/PrintProcessor/PrintProcessorCollection.cs @@ -60,8 +60,8 @@ public PrintProcessorCollection([NotNull] IList coll, string fil public string FileName { - get { return _fileName; } - set { _fileName = PrintProcessor.ReplaceInvalidCharsFromFilename(value); } + get => _fileName; + set => _fileName = PrintProcessor.ReplaceInvalidCharsFromFilename(value); } ///