|
7 | 7 | namespace Openize.Slides |
8 | 8 | { |
9 | 9 | /// <summary> |
10 | | - /// This class represents the rectangle shape within a slide. |
| 10 | + /// Represents a rectangle shape within a slide. |
11 | 11 | /// </summary> |
12 | 12 | public class Rectangle |
13 | 13 | { |
14 | | - private double _x; |
15 | | - private double _y; |
16 | | - private double _Width; |
17 | | - private double _Height; |
18 | | - private RectangleShapeFacade _Facade; |
19 | | - private int _shapeIndex; |
20 | | - private string _BackgroundColor = null; |
21 | | - private AnimationType _Animation = AnimationType.None; |
22 | 14 | /// <summary> |
23 | | - /// Property to get or set X coordinate of the shape. |
| 15 | + /// Gets or sets the X coordinate of the rectangle shape. |
24 | 16 | /// </summary> |
25 | | - public double X { get => _x; set => _x = value; } |
| 17 | + public double X { get; set; } |
26 | 18 |
|
27 | 19 | /// <summary> |
28 | | - /// Property to get or set Y coordinate of the shape. |
| 20 | + /// Gets or sets the Y coordinate of the rectangle shape. |
29 | 21 | /// </summary> |
30 | | - public double Y { get => _y; set => _y = value; } |
| 22 | + public double Y { get; set; } |
31 | 23 |
|
32 | 24 | /// <summary> |
33 | | - /// Property to get or set width of the shape. |
| 25 | + /// Gets or sets the width of the rectangle shape. |
34 | 26 | /// </summary> |
35 | | - public double Width { get => _Width; set => _Width = value; } |
| 27 | + public double Width { get; set; } |
36 | 28 |
|
37 | 29 | /// <summary> |
38 | | - /// Property to get or set height of the shape. |
| 30 | + /// Gets or sets the height of the rectangle shape. |
39 | 31 | /// </summary> |
40 | | - public double Height { get => _Height; set => _Height = value; } |
| 32 | + public double Height { get; set; } |
41 | 33 |
|
42 | 34 | /// <summary> |
43 | | - /// Property to get or set the RectangleShapeFacade. |
| 35 | + /// Gets or sets the facade that handles rectangle shape operations. |
44 | 36 | /// </summary> |
45 | | - public RectangleShapeFacade Facade { get => _Facade; set => _Facade = value; } |
| 37 | + public RectangleShapeFacade Facade { get; set; } |
46 | 38 |
|
47 | 39 | /// <summary> |
48 | | - /// Property to get or set the shape index within a slide. |
| 40 | + /// Gets or sets the index of the shape within a slide. |
49 | 41 | /// </summary> |
50 | | - public int ShapeIndex { get => _shapeIndex; set => _shapeIndex = value; } |
| 42 | + public int ShapeIndex { get; set; } |
51 | 43 |
|
52 | 44 | /// <summary> |
53 | | - /// Property to set or get background color of a rectangle shape. |
| 45 | + /// Gets or sets the background color of the rectangle shape. |
| 46 | + /// Default value is "Transparent". |
54 | 47 | /// </summary> |
55 | | - public string BackgroundColor { get => _BackgroundColor; set => _BackgroundColor = value; } |
| 48 | + public string BackgroundColor { get; set; } = "Transparent"; |
| 49 | + |
56 | 50 | /// <summary> |
57 | | - /// Property to set animation |
| 51 | + /// Gets or sets the animation type applied to the rectangle shape. |
| 52 | + /// Default value is <see cref="AnimationType.None"/>. |
58 | 53 | /// </summary> |
59 | | - public AnimationType Animation { get => _Animation; set => _Animation = value; } |
| 54 | + public AnimationType Animation { get; set; } = AnimationType.None; |
| 55 | + |
60 | 56 | /// <summary> |
61 | | - /// Constructor of the Rectangle class initializes the object of RectangleShapeFacade and populates its fields. |
| 57 | + /// Initializes a new instance of the <see cref="Rectangle"/> class. |
62 | 58 | /// </summary> |
63 | 59 | public Rectangle() |
64 | 60 | { |
65 | | - _Facade = new RectangleShapeFacade(); |
66 | | - _Facade.ShapeIndex = _shapeIndex; |
| 61 | + Facade = new RectangleShapeFacade |
| 62 | + { |
| 63 | + ShapeIndex = ShapeIndex |
| 64 | + }; |
67 | 65 |
|
68 | | - _BackgroundColor = "Transparent"; |
69 | | - _x = Utility.EmuToPixels(1349828); |
70 | | - _y = Utility.EmuToPixels(1999619); |
71 | | - _Width = Utility.EmuToPixels(6000000); |
72 | | - _Height = Utility.EmuToPixels(2000000); |
| 66 | + X = Utility.EmuToPixels(1349828); |
| 67 | + Y = Utility.EmuToPixels(1999619); |
| 68 | + Width = Utility.EmuToPixels(6000000); |
| 69 | + Height = Utility.EmuToPixels(2000000); |
73 | 70 |
|
74 | | - Populate_Facade(); |
| 71 | + PopulateFacade(); |
75 | 72 | } |
76 | 73 |
|
77 | 74 | /// <summary> |
78 | | - /// Method to update rectangle shape. |
| 75 | + /// Updates the rectangle shape by synchronizing its properties with the facade. |
79 | 76 | /// </summary> |
80 | 77 | public void Update() |
81 | 78 | { |
82 | | - Populate_Facade(); |
83 | | - _Facade.UpdateShape(); |
| 79 | + PopulateFacade(); |
| 80 | + Facade.UpdateShape(); |
84 | 81 | } |
85 | 82 |
|
86 | 83 | /// <summary> |
87 | | - /// Method to populate the fields of the respective facade. |
| 84 | + /// Populates the facade with the current rectangle properties. |
| 85 | + /// Converts pixel values to EMUs before setting them in the facade. |
88 | 86 | /// </summary> |
89 | | - private void Populate_Facade() |
| 87 | + private void PopulateFacade() |
90 | 88 | { |
91 | | - _Facade.BackgroundColor = _BackgroundColor; |
92 | | - _Facade.X = Utility.PixelsToEmu(_x); |
93 | | - _Facade.Y = Utility.PixelsToEmu(_y); |
94 | | - _Facade.Width = Utility.PixelsToEmu(_Width); |
95 | | - _Facade.Height = Utility.PixelsToEmu(_Height); |
| 89 | + Facade.BackgroundColor = BackgroundColor; |
| 90 | + Facade.X = Utility.PixelsToEmu(X); |
| 91 | + Facade.Y = Utility.PixelsToEmu(Y); |
| 92 | + Facade.Width = Utility.PixelsToEmu(Width); |
| 93 | + Facade.Height = Utility.PixelsToEmu(Height); |
96 | 94 | } |
97 | 95 |
|
98 | 96 | /// <summary> |
99 | | - /// Method for getting the list of rectangle shapes. |
| 97 | + /// Retrieves a list of rectangle objects from their corresponding facades. |
100 | 98 | /// </summary> |
101 | | - /// <param name="RectangleFacades">A list of RectangleShapeFacade objects.</param> |
102 | | - /// <returns>A list of Rectangle objects.</returns> |
103 | | - public static List<Rectangle> GetRectangles(List<RectangleShapeFacade> RectangleFacades) |
| 99 | + /// <param name="rectangleFacades">A list of <see cref="RectangleShapeFacade"/> objects.</param> |
| 100 | + /// <returns>A list of <see cref="Rectangle"/> objects.</returns> |
| 101 | + public static List<Rectangle> GetRectangles(List<RectangleShapeFacade> rectangleFacades) |
104 | 102 | { |
105 | | - List<Rectangle> Rectangles = new List<Rectangle>(); |
106 | | - try |
| 103 | + var rectangles = new List<Rectangle>(); |
| 104 | + foreach (var facade in rectangleFacades) |
107 | 105 | { |
108 | | - foreach (var facade in RectangleFacades) |
| 106 | + rectangles.Add(new Rectangle |
109 | 107 | { |
110 | | - Rectangle Rectangle = new Rectangle |
111 | | - { |
112 | | - BackgroundColor = facade.BackgroundColor, |
113 | | - X = Utility.EmuToPixels(facade.X), |
114 | | - Y = Utility.EmuToPixels(facade.Y), |
115 | | - Width = Utility.EmuToPixels(facade.Width), |
116 | | - Height = Utility.EmuToPixels(facade.Height), |
117 | | - Facade = facade, |
118 | | - ShapeIndex = facade.ShapeIndex |
119 | | - }; |
120 | | - |
121 | | - Rectangles.Add(Rectangle); |
122 | | - } |
| 108 | + BackgroundColor = facade.BackgroundColor, |
| 109 | + X = Utility.EmuToPixels(facade.X), |
| 110 | + Y = Utility.EmuToPixels(facade.Y), |
| 111 | + Width = Utility.EmuToPixels(facade.Width), |
| 112 | + Height = Utility.EmuToPixels(facade.Height), |
| 113 | + Facade = facade, |
| 114 | + ShapeIndex = facade.ShapeIndex |
| 115 | + }); |
123 | 116 | } |
124 | | - catch (Exception ex) |
125 | | - { |
126 | | - string errorMessage = Common.OpenizeException.ConstructMessage(ex, "Getting Rectangle Shapes"); |
127 | | - throw new Common.OpenizeException(errorMessage, ex); |
128 | | - } |
129 | | - |
130 | | - return Rectangles; |
| 117 | + return rectangles; |
131 | 118 | } |
132 | 119 |
|
133 | 120 | /// <summary> |
134 | | - /// Method to remove the rectangle shape from a slide. |
| 121 | + /// Removes the rectangle shape from the slide. |
135 | 122 | /// </summary> |
136 | 123 | public void Remove() |
137 | 124 | { |
138 | | - _Facade.RemoveShape(this.Facade.RectangleShape); |
| 125 | + Facade.RemoveShape(Facade.RectangleShape); |
139 | 126 | } |
140 | 127 | } |
141 | 128 | } |
0 commit comments