From 0690a5d703b060076a6964f5793b28ddd4034817 Mon Sep 17 00:00:00 2001 From: Jeremy Kuhne Date: Mon, 5 Feb 2024 10:57:50 -0800 Subject: [PATCH] Fix command line build Also simplify constructors for Window Need to figure out how to make SA1518 an error in VS --- src/samples/ClipboardViewer/Program.cs | 2 +- src/samples/Layout/Program.cs | 2 +- src/samples/Petzold/5th/Beeper/Beeper1.cs | 2 +- src/samples/Petzold/5th/Beeper/Beeper2.cs | 2 +- src/samples/Petzold/5th/Bezier/Program.cs | 2 +- src/samples/Petzold/5th/Blokout2/Program.cs | 2 +- src/samples/Petzold/5th/BtnLook/Program.cs | 2 +- src/samples/Petzold/5th/Checker1/Checker1.cs | 2 +- src/samples/Petzold/5th/Checker1/Checker2.cs | 2 +- src/samples/Petzold/5th/Checker1/Checker3.cs | 2 +- src/samples/Petzold/5th/Clock/Program.cs | 2 +- src/samples/Petzold/5th/Clover/Program.cs | 2 +- src/samples/Petzold/5th/HelloWin/Program.cs | 2 +- src/samples/Petzold/5th/LineDemo/Program.cs | 2 +- src/samples/Windows101/Program.cs | 2 +- src/thirtytwo/MainWindow.cs | 22 ++----------------- src/thirtytwo/Win32/Graphics/GdiPlus/Brush.cs | 2 +- .../Graphics/GdiPlus/GdiPlusException.cs | 2 +- src/thirtytwo/Win32/Graphics/GdiPlus/Pen.cs | 2 +- .../Win32/Graphics/GdiPlus/SolidBrush.cs | 2 +- 20 files changed, 21 insertions(+), 39 deletions(-) diff --git a/src/samples/ClipboardViewer/Program.cs b/src/samples/ClipboardViewer/Program.cs index ef25851..72b535d 100644 --- a/src/samples/ClipboardViewer/Program.cs +++ b/src/samples/ClipboardViewer/Program.cs @@ -16,7 +16,7 @@ private class ClipboardViewer : MainWindow private readonly EditControl _editControl; private readonly TextLabelControl _textLabel; - public ClipboardViewer(string title) : base(text: title) + public ClipboardViewer(string title) : base(title: title) { _editControl = new EditControl( editStyle: EditControl.Styles.Multiline | EditControl.Styles.Left diff --git a/src/samples/Layout/Program.cs b/src/samples/Layout/Program.cs index b233f18..508e46c 100644 --- a/src/samples/Layout/Program.cs +++ b/src/samples/Layout/Program.cs @@ -21,7 +21,7 @@ private class LayoutWindow : MainWindow private readonly StaticControl _staticControl; private readonly TextLabelControl _textLabel; - public LayoutWindow(string title) : base(title) + public LayoutWindow(string title) : base(title: title) { _editControl = new EditControl( text: "Type text here...", diff --git a/src/samples/Petzold/5th/Beeper/Beeper1.cs b/src/samples/Petzold/5th/Beeper/Beeper1.cs index e9e0e72..536c7a5 100644 --- a/src/samples/Petzold/5th/Beeper/Beeper1.cs +++ b/src/samples/Petzold/5th/Beeper/Beeper1.cs @@ -15,7 +15,7 @@ internal class Beeper1 : MainWindow private bool _flipFlop = false; private nuint _timerId; - public Beeper1(string title) : base(title) { } + public Beeper1(string title) : base(title: title) { } protected override LRESULT WindowProcedure(HWND window, MessageType message, WPARAM wParam, LPARAM lParam) { diff --git a/src/samples/Petzold/5th/Beeper/Beeper2.cs b/src/samples/Petzold/5th/Beeper/Beeper2.cs index c379a72..5547c45 100644 --- a/src/samples/Petzold/5th/Beeper/Beeper2.cs +++ b/src/samples/Petzold/5th/Beeper/Beeper2.cs @@ -16,7 +16,7 @@ internal class Beeper2 : MainWindow private nuint _timerId; private TimerProcedure? _timerCallback; - public Beeper2(string title) : base(title) { } + public Beeper2(string title) : base(title: title) { } protected override LRESULT WindowProcedure(HWND window, MessageType message, WPARAM wParam, LPARAM lParam) { diff --git a/src/samples/Petzold/5th/Bezier/Program.cs b/src/samples/Petzold/5th/Bezier/Program.cs index 176f0d0..419d2c9 100644 --- a/src/samples/Petzold/5th/Bezier/Program.cs +++ b/src/samples/Petzold/5th/Bezier/Program.cs @@ -22,7 +22,7 @@ internal class Bezier : MainWindow { private readonly Point[] _apt = new Point[4]; - public Bezier(string title) : base(title) + public Bezier(string title) : base(title: title) { } diff --git a/src/samples/Petzold/5th/Blokout2/Program.cs b/src/samples/Petzold/5th/Blokout2/Program.cs index 6b7bb6e..2e15846 100644 --- a/src/samples/Petzold/5th/Blokout2/Program.cs +++ b/src/samples/Petzold/5th/Blokout2/Program.cs @@ -24,7 +24,7 @@ internal class Blockout2 : MainWindow private bool _fBlocking, _fValidBox; private Point _ptBeg, _ptEnd, _ptBoxBeg, _ptBoxEnd; - public Blockout2(string title) : base(title) + public Blockout2(string title) : base(title: title) { } diff --git a/src/samples/Petzold/5th/BtnLook/Program.cs b/src/samples/Petzold/5th/BtnLook/Program.cs index 05806df..88c9d9a 100644 --- a/src/samples/Petzold/5th/BtnLook/Program.cs +++ b/src/samples/Petzold/5th/BtnLook/Program.cs @@ -27,7 +27,7 @@ private class OwnerDraw : MainWindow private const int ID_SMALLER = 1; private const int ID_LARGER = 2; - public OwnerDraw(string title) : base(title) + public OwnerDraw(string title) : base(title: title) { } diff --git a/src/samples/Petzold/5th/Checker1/Checker1.cs b/src/samples/Petzold/5th/Checker1/Checker1.cs index 2b11e18..583b71f 100644 --- a/src/samples/Petzold/5th/Checker1/Checker1.cs +++ b/src/samples/Petzold/5th/Checker1/Checker1.cs @@ -14,7 +14,7 @@ public class Checker1 : MainWindow private readonly bool[,] _fState = new bool[DIVISIONS, DIVISIONS]; private int _cxBlock, _cyBlock; - public Checker1(string title) : base(title) + public Checker1(string title) : base(title: title) { } diff --git a/src/samples/Petzold/5th/Checker1/Checker2.cs b/src/samples/Petzold/5th/Checker1/Checker2.cs index fdd2627..4f2fe76 100644 --- a/src/samples/Petzold/5th/Checker1/Checker2.cs +++ b/src/samples/Petzold/5th/Checker1/Checker2.cs @@ -16,7 +16,7 @@ internal class Checker2 : MainWindow private readonly bool[,] _state = new bool[DIVISIONS, DIVISIONS]; private int _cxBlock, _cyBlock; - public Checker2(string title) : base(title) + public Checker2(string title) : base(title: title) { } diff --git a/src/samples/Petzold/5th/Checker1/Checker3.cs b/src/samples/Petzold/5th/Checker1/Checker3.cs index dc2d43f..f8c98fc 100644 --- a/src/samples/Petzold/5th/Checker1/Checker3.cs +++ b/src/samples/Petzold/5th/Checker1/Checker3.cs @@ -16,7 +16,7 @@ internal class Checker3 : MainWindow private int _cxBlock, _cyBlock; private readonly Checker3Child _childClass = (Checker3Child)(new Checker3Child().Register()); - public Checker3(string title) : base(title) + public Checker3(string title) : base(title: title) { } diff --git a/src/samples/Petzold/5th/Clock/Program.cs b/src/samples/Petzold/5th/Clock/Program.cs index 7f2b7fe..9e3810d 100644 --- a/src/samples/Petzold/5th/Clock/Program.cs +++ b/src/samples/Petzold/5th/Clock/Program.cs @@ -39,7 +39,7 @@ internal class Clock : MainWindow private readonly GdiPlusBrush _whiteBrush = new SolidBrush(Color.White); #endif - public Clock(string title) : base(title) { } + public Clock(string title) : base(title: title) { } private void SetIsotropic(DeviceContext hdc) { diff --git a/src/samples/Petzold/5th/Clover/Program.cs b/src/samples/Petzold/5th/Clover/Program.cs index b6f46a6..eab8e91 100644 --- a/src/samples/Petzold/5th/Clover/Program.cs +++ b/src/samples/Petzold/5th/Clover/Program.cs @@ -24,7 +24,7 @@ internal class Clover : MainWindow private HRGN _hrgnClip; private const double TWO_PI = Math.PI * 2; - public Clover() : base(text: "Draw a Clover", backgroundBrush: StockBrush.White) { } + public Clover() : base(title: "Draw a Clover", backgroundBrush: StockBrush.White) { } protected override LRESULT WindowProcedure(HWND window, MessageType message, WPARAM wParam, LPARAM lParam) { diff --git a/src/samples/Petzold/5th/HelloWin/Program.cs b/src/samples/Petzold/5th/HelloWin/Program.cs index 0d17b4a..e1b7475 100644 --- a/src/samples/Petzold/5th/HelloWin/Program.cs +++ b/src/samples/Petzold/5th/HelloWin/Program.cs @@ -121,7 +121,7 @@ private static LRESULT WindowProcedure(HWND window, uint message, WPARAM wParam, private class HelloWindow : MainWindow { - public HelloWindow(string text) : base(text, backgroundBrush: StockBrush.White) + public HelloWindow(string title) : base(title: title, backgroundBrush: StockBrush.White) { } diff --git a/src/samples/Petzold/5th/LineDemo/Program.cs b/src/samples/Petzold/5th/LineDemo/Program.cs index 72dff94..8e49269 100644 --- a/src/samples/Petzold/5th/LineDemo/Program.cs +++ b/src/samples/Petzold/5th/LineDemo/Program.cs @@ -21,7 +21,7 @@ private class LineDemo : MainWindow { private static int s_cxClient, s_cyClient; - public LineDemo(string title) : base(title) { } + public LineDemo(string title) : base(title: title) { } protected override LRESULT WindowProcedure(HWND window, MessageType message, WPARAM wParam, LPARAM lParam) { diff --git a/src/samples/Windows101/Program.cs b/src/samples/Windows101/Program.cs index 877ecb6..b7b3dde 100644 --- a/src/samples/Windows101/Program.cs +++ b/src/samples/Windows101/Program.cs @@ -68,7 +68,7 @@ protected override LRESULT WindowProcedure(HWND window, MessageType message, WPA private class HelloWindow : MainWindow { - public HelloWindow() : base("HelloWindow") + public HelloWindow() : base(title: "HelloWindow") { } diff --git a/src/thirtytwo/MainWindow.cs b/src/thirtytwo/MainWindow.cs index 5831319..e6d43ed 100644 --- a/src/thirtytwo/MainWindow.cs +++ b/src/thirtytwo/MainWindow.cs @@ -11,34 +11,16 @@ namespace Windows; public class MainWindow : Window { public MainWindow( + Rectangle bounds = default, string? title = default, WindowStyles style = WindowStyles.OverlappedWindow, ExtendedWindowStyles extendedStyle = ExtendedWindowStyles.Default, WindowClass? windowClass = default, nint parameters = default, HMENU menuHandle = default, - HBRUSH backgroundBrush = default) : this( - DefaultBounds, - title, - style, - extendedStyle, - windowClass, - parameters, - menuHandle, - backgroundBrush) - { } - - public MainWindow( - Rectangle bounds, - string? text = default, - WindowStyles style = WindowStyles.OverlappedWindow, - ExtendedWindowStyles extendedStyle = ExtendedWindowStyles.Default, - WindowClass? windowClass = default, - nint parameters = default, - HMENU menuHandle = default, HBRUSH backgroundBrush = default) : base( bounds, - text, + title, style, extendedStyle, default, diff --git a/src/thirtytwo/Win32/Graphics/GdiPlus/Brush.cs b/src/thirtytwo/Win32/Graphics/GdiPlus/Brush.cs index 6fffa8c..c56fcfd 100644 --- a/src/thirtytwo/Win32/Graphics/GdiPlus/Brush.cs +++ b/src/thirtytwo/Win32/Graphics/GdiPlus/Brush.cs @@ -23,4 +23,4 @@ protected override void Dispose(bool disposing) _pointer = null; } -} +} \ No newline at end of file diff --git a/src/thirtytwo/Win32/Graphics/GdiPlus/GdiPlusException.cs b/src/thirtytwo/Win32/Graphics/GdiPlus/GdiPlusException.cs index 53108b6..f4e5155 100644 --- a/src/thirtytwo/Win32/Graphics/GdiPlus/GdiPlusException.cs +++ b/src/thirtytwo/Win32/Graphics/GdiPlus/GdiPlusException.cs @@ -9,4 +9,4 @@ public class GdiPlusException : ThirtyTwoException { public GdiPlusException(Status status) : base(status.ToString()) => Status = status; public Status Status { get; private set; } -} +} \ No newline at end of file diff --git a/src/thirtytwo/Win32/Graphics/GdiPlus/Pen.cs b/src/thirtytwo/Win32/Graphics/GdiPlus/Pen.cs index 772133c..074d2dd 100644 --- a/src/thirtytwo/Win32/Graphics/GdiPlus/Pen.cs +++ b/src/thirtytwo/Win32/Graphics/GdiPlus/Pen.cs @@ -29,4 +29,4 @@ protected override void Dispose(bool disposing) _pointer = null; } -} +} \ No newline at end of file diff --git a/src/thirtytwo/Win32/Graphics/GdiPlus/SolidBrush.cs b/src/thirtytwo/Win32/Graphics/GdiPlus/SolidBrush.cs index 1597912..d843bed 100644 --- a/src/thirtytwo/Win32/Graphics/GdiPlus/SolidBrush.cs +++ b/src/thirtytwo/Win32/Graphics/GdiPlus/SolidBrush.cs @@ -19,4 +19,4 @@ public SolidBrush(ARGB color) : base(CreateBrush(color)) Interop.GdipCreateSolidFill(color, (GpSolidFill**)&brush).ThrowIfFailed(); return brush; } -} +} \ No newline at end of file