BoxStyle.cs
 1  // Copyright (c) Microsoft Corporation
 2  // The Microsoft Corporation licenses this file to you under the MIT license.
 3  // See the LICENSE file in the project root for more information.
 4  
 5  namespace MouseJump.Common.Models.Styles;
 6  
 7  /// <summary>
 8  /// Represents the styles to apply to a simple box-layout based drawing object.
 9  /// </summary>
10  public sealed class BoxStyle
11  {
12      /*
13  
14      see https://www.w3schools.com/css/css_boxmodel.asp
15  
16      +--------------[bounds]---------------+
17      |▒▒▒▒▒▒▒▒▒▒▒▒▒▒[margin]▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒|
18      |▒▒▓▓▓▓▓▓▓▓▓▓▓▓[border]▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒|
19      |▒▒▓▓░░░░░░░░░░[padding]░░░░░░░░░░▓▓▒▒|
20      |▒▒▓▓░░                         ░░▓▓▒▒|
21      |▒▒▓▓░░                         ░░▓▓▒▒|
22      |▒▒▓▓░░        [content]        ░░▓▓▒▒|
23      |▒▒▓▓░░                         ░░▓▓▒▒|
24      |▒▒▓▓░░                         ░░▓▓▒▒|
25      |▒▒▓▓░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▒▒|
26      |▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒|
27      |▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒|
28      +-------------------------------------+
29  
30      */
31  
32      public static readonly BoxStyle Empty = new(MarginStyle.Empty, BorderStyle.Empty, PaddingStyle.Empty, BackgroundStyle.Empty);
33  
34      public BoxStyle(
35          MarginStyle marginStyle,
36          BorderStyle borderStyle,
37          PaddingStyle paddingStyle,
38          BackgroundStyle backgroundStyle)
39      {
40          this.MarginStyle = marginStyle ?? throw new ArgumentNullException(nameof(marginStyle));
41          this.BorderStyle = borderStyle ?? throw new ArgumentNullException(nameof(borderStyle));
42          this.PaddingStyle = paddingStyle ?? throw new ArgumentNullException(nameof(paddingStyle));
43          this.BackgroundStyle = backgroundStyle ?? throw new ArgumentNullException(nameof(backgroundStyle));
44      }
45  
46      /// <summary>
47      /// Gets the margin style for this layout box.
48      /// </summary>
49      public MarginStyle MarginStyle
50      {
51          get;
52      }
53  
54      /// <summary>
55      /// Gets the border style for this layout box.
56      /// </summary>
57      public BorderStyle BorderStyle
58      {
59          get;
60      }
61  
62      /// <summary>
63      /// Gets the padding style for this layout box.
64      /// </summary>
65      public PaddingStyle PaddingStyle
66      {
67          get;
68      }
69  
70      /// <summary>
71      /// Gets the background fill style for the content area of this layout box.
72      /// </summary>
73      public BackgroundStyle BackgroundStyle
74      {
75          get;
76      }
77  }