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