35c39fbfb1c7d407cfd804cf64d8cb44d09463d7
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Samples / Tizen.NUI.Samples / Samples / ContactCard / ContactCard.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Threading.Tasks;
6 using Tizen.NUI.BaseComponents;
7 using Tizen.NUI.UIComponents;
8
9 namespace Tizen.NUI.Samples
10 {
11     public class ContactCard
12     {
13         private TapGestureDetector mTapDetector;
14         private View mContactCard;
15         private View mHeader;
16         private View mClippedImage;
17         private View mMaskedImage;
18         private TextLabel mNameText;
19         private TextLabel mDetailText;
20
21         private Animation mAnimation;
22         private ContactCardLayoutInfo mContactCardLayoutInfo;
23         private Vector2 foldedPosition;
24         private int mClippedImagePropertyIndex;
25         private bool mFolded;
26
27
28         private readonly TimePeriod TIME_PERIOD_UNFOLD_X = new TimePeriod(0, 360); ///< Start at 0ms, duration 360ms
29         private readonly TimePeriod TIME_PERIOD_UNFOLD_Y = new TimePeriod(40, 360); ///< Start at 40ms, duration 360ms
30         private readonly TimePeriod TIME_PERIOD_UNFOLD_WIDTH = new TimePeriod(0, 360); ///< Start at 0ms, duration 360ms
31         private readonly TimePeriod TIME_PERIOD_UNFOLD_HEIGHT = new TimePeriod(40, 360); ///< Start at 40ms, duration 360ms
32         private readonly TimePeriod TIME_PERIOD_UNFOLD_NAME_OPACITY = new TimePeriod(0, 80); ///< Start at 0ms, duration 80ms
33         private readonly TimePeriod TIME_PERIOD_UNFOLD_DETAIL_OPACITY = new TimePeriod( 80, 80 ); ///< Start at 80ms, duration 80ms
34         private readonly TimePeriod TIME_PERIOD_UNFOLD_SIBLING_OPACITY = new TimePeriod( 0, 80 ); ///< Start at 0ms, duration 80ms
35         private readonly TimePeriod TIME_PERIOD_UNFOLD_MESH_MORPH = new TimePeriod( 0, 400 ); ///< Start at 0ms, duration 400ms
36
37         private readonly TimePeriod TIME_PERIOD_FOLD_X = new TimePeriod( 64, 336 ); ///< Start at 64ms, duration 336ms
38         private readonly TimePeriod TIME_PERIOD_FOLD_Y = new TimePeriod( 0, 336 ); ///< Start at 0ms, duration 336ms
39         private readonly TimePeriod TIME_PERIOD_FOLD_WIDTH = new TimePeriod( 64, 336 ); ///< Start at 64ms, duration 336ms
40         private readonly TimePeriod TIME_PERIOD_FOLD_HEIGHT = new TimePeriod( 0, 336 ); ///< Start at 0ms, duration 336ms
41         private readonly TimePeriod TIME_PERIOD_FOLD_NAME_OPACITY = new TimePeriod( 80, 80 ); ///< Start at 80ms, duration 80ms
42         private readonly TimePeriod TIME_PERIOD_FOLD_DETAIL_OPACITY = new TimePeriod( 0, 80 ); ///< Start at 0ms, duration 80ms
43         private readonly TimePeriod TIME_PERIOD_FOLD_SIBLING_OPACITY = new TimePeriod( 320, 80 ); ///< Start at 320ms, duration 80ms
44         private readonly TimePeriod TIME_PERIOD_FOLD_MESH_MORPH = new TimePeriod( 0, 400 ); ///< Start at 0ms, duration 400ms
45
46         private AlphaFunction.BuiltinFunctions ALPHA_FUNCTION_UNFOLD = AlphaFunction.BuiltinFunctions.Default;
47         private AlphaFunction.BuiltinFunctions ALPHA_FUNCTION_FOLD = AlphaFunction.BuiltinFunctions.EaseInOut;
48
49         private readonly Color HEADER_COLOR = new Color( 231.0f / 255.0f, 231.0f / 255.0f, 231.0f / 255.0f, 1.0f );
50
51
52         public ContactCard(ContactCardLayoutInfo contactCardLayoutInfo, string contactName, string contactAddress, string imagePath, Vector2 position, View rootView)
53         {
54             mContactCardLayoutInfo = contactCardLayoutInfo;
55             foldedPosition = new Vector2(position.X, position.Y);
56             mClippedImagePropertyIndex = -1;
57             mFolded = true;
58
59             //NUIApplication.GetDefaultWindow().KeyEvent += OnKeyEvent;
60
61             // Create a View which will be used for the background and to clip the contents
62             mContactCard = new View();
63             mContactCard.BackgroundColor = Color.White;
64             mContactCard.ClippingMode = ClippingModeType.ClipChildren;
65             mContactCard.ParentOrigin = ParentOrigin.TopLeft;
66             mContactCard.PivotPoint = PivotPoint.TopLeft;
67             mContactCard.PositionUsesPivotPoint = true;
68             mContactCard.Position2D = new Position2D((int)foldedPosition.X, (int)foldedPosition.Y);
69             mContactCard.Size2D = new Size2D((int)mContactCardLayoutInfo.foldedSize.Width, (int)mContactCardLayoutInfo.foldedSize.Height);
70             mContactCard.KeyEvent += OnKeyEvent;
71
72             NUIApplication.GetDefaultWindow().GetDefaultLayer().Add(mContactCard);
73             rootView.Add(mContactCard);
74
75             // Create the header which will be shown only when the contact is unfolded
76             mHeader = new View();
77             mHeader.Size2D = new Size2D((int)mContactCardLayoutInfo.headerSize.Width, (int)mContactCardLayoutInfo.headerSize.Height);
78             mHeader.BackgroundColor = HEADER_COLOR;
79             mHeader.ParentOrigin = ParentOrigin.TopLeft;
80             mHeader.PivotPoint = PivotPoint.TopLeft;
81             mHeader.PositionUsesPivotPoint = true;
82             mHeader.Position2D = new Position2D((int)mContactCardLayoutInfo.headerFoldedPosition.X, (int)mContactCardLayoutInfo.headerFoldedPosition.Y);
83
84             // Create a clipped image (whose clipping can be animated)
85             mClippedImage = ClippedImage.Create(imagePath);
86             mClippedImage.Size2D = new Size2D((int)mContactCardLayoutInfo.imageSize.Width, (int)mContactCardLayoutInfo.imageSize.Height);
87             mClippedImage.ParentOrigin = ParentOrigin.TopLeft;
88             mClippedImage.PivotPoint = PivotPoint.TopLeft;
89             mClippedImage.PositionUsesPivotPoint = true;
90             mClippedImage.Position2D = new Position2D((int)mContactCardLayoutInfo.imageFoldedPosition.X, (int)mContactCardLayoutInfo.imageFoldedPosition.Y);
91             mClippedImage.Hide();
92             mContactCard.Add(mClippedImage);
93
94             // Create an image with a mask which is to be used when the contact is folded
95             mMaskedImage = MaskedImage.Create(imagePath);
96             mMaskedImage.Size2D = new Size2D((int)mContactCardLayoutInfo.imageSize.Width, (int)mContactCardLayoutInfo.imageSize.Height);
97             mMaskedImage.ParentOrigin = ParentOrigin.TopLeft;
98             mMaskedImage.PivotPoint = PivotPoint.TopLeft;
99             mMaskedImage.PositionUsesPivotPoint = true;
100             mMaskedImage.Position2D = new Position2D((int)mContactCardLayoutInfo.imageFoldedPosition.X, (int)mContactCardLayoutInfo.imageFoldedPosition.Y);
101             mContactCard.Add(mMaskedImage);
102
103             // Add the text label for just the name
104             mNameText = new TextLabel(contactName);
105             //mNameText.StyleName = "ContactNameTextLabel";
106             mNameText.TextColor = new Color(0, 0, 0, 1);
107             mNameText.HorizontalAlignment = HorizontalAlignment.Center;
108             mNameText.PointSize = 14;
109             mNameText.ParentOrigin = ParentOrigin.TopLeft;
110             mNameText.PivotPoint = PivotPoint.TopLeft;
111             mNameText.PositionUsesPivotPoint = true;
112             mNameText.WidthResizePolicy = ResizePolicyType.FillToParent;
113             mNameText.Position2D = new Position2D((int)mContactCardLayoutInfo.textFoldedPosition.X, (int)mContactCardLayoutInfo.textFoldedPosition.Y);
114             mContactCard.Add(mNameText);
115
116             // Create the detail text-label
117             string detailString = contactName;
118             detailString += "\n\n";
119             detailString += contactAddress;
120
121             mDetailText = new TextLabel(detailString);
122             //mDetailText.StyleName = "ContactDetailTextLabel";
123             mDetailText.TextColor = new Color(0, 0, 0, 1);
124             mDetailText.MultiLine = true;
125             mDetailText.PointSize = 20;
126             mDetailText.ParentOrigin = ParentOrigin.TopLeft;
127             mDetailText.PivotPoint = PivotPoint.TopLeft;
128             mDetailText.PositionUsesPivotPoint = true;
129             mDetailText.Position2D = new Position2D((int)mContactCardLayoutInfo.textFoldedPosition.X, (int)mContactCardLayoutInfo.textFoldedPosition.Y);
130             mDetailText.Size2D = new Size2D((int)(mContactCardLayoutInfo.unfoldedSize.Width - mContactCardLayoutInfo.textFoldedPosition.X * 2.0f), 0);
131             mDetailText.Opacity = 0.0f;
132
133             // Attach tap detection to the overall clip control
134             mTapDetector = new TapGestureDetector();
135             mTapDetector.Attach(mContactCard);
136             mTapDetector.Detected += OnTap;
137         }
138
139         private void Animate()
140         {
141             FocusManager focusManager = FocusManager.Instance;
142             mAnimation = new Animation(0);
143
144             if(mFolded)
145             {
146                 mContactCard.Focusable = true;
147                 focusManager.SetCurrentFocusView(mContactCard);
148
149                 mContactCard.Add(mHeader);
150                 mContactCard.Add(mDetailText);
151
152                 // Show clipped-image to animate geometry and hide the masked-image
153                 mClippedImage.Show();
154                 mMaskedImage.Hide();
155
156                 // Animate the size of the control (and clipping area)
157                 mAnimation.AnimateTo(mContactCard, "PositionX", mContactCardLayoutInfo.unfoldedPosition.X, TIME_PERIOD_UNFOLD_X.start, TIME_PERIOD_UNFOLD_X.start + TIME_PERIOD_UNFOLD_X.duration, new AlphaFunction(ALPHA_FUNCTION_UNFOLD));
158                 mAnimation.AnimateTo(mContactCard, "PositionY", mContactCardLayoutInfo.unfoldedPosition.Y, TIME_PERIOD_UNFOLD_Y.start, TIME_PERIOD_UNFOLD_Y.start + TIME_PERIOD_UNFOLD_Y.duration, new AlphaFunction(ALPHA_FUNCTION_UNFOLD));
159                 mAnimation.AnimateTo(mContactCard, "SizeWidth", mContactCardLayoutInfo.unfoldedSize.Width, TIME_PERIOD_UNFOLD_WIDTH.start, TIME_PERIOD_UNFOLD_WIDTH.start + TIME_PERIOD_UNFOLD_WIDTH.duration, new AlphaFunction(ALPHA_FUNCTION_UNFOLD));
160                 mAnimation.AnimateTo(mContactCard, "SizeHeight", mContactCardLayoutInfo.unfoldedSize.Height, TIME_PERIOD_UNFOLD_HEIGHT.start, TIME_PERIOD_UNFOLD_HEIGHT.start + TIME_PERIOD_UNFOLD_HEIGHT.duration, new AlphaFunction(ALPHA_FUNCTION_UNFOLD));
161
162                 // Animate the header area into position
163                 mAnimation.AnimateTo(mHeader, "PositionX", mContactCardLayoutInfo.headerUnfoldedPosition.X, TIME_PERIOD_UNFOLD_X.start, TIME_PERIOD_UNFOLD_X.start + TIME_PERIOD_UNFOLD_X.duration, new AlphaFunction(ALPHA_FUNCTION_UNFOLD));
164                 mAnimation.AnimateTo(mHeader, "PositionY", mContactCardLayoutInfo.headerUnfoldedPosition.Y, TIME_PERIOD_UNFOLD_Y.start, TIME_PERIOD_UNFOLD_Y.start + TIME_PERIOD_UNFOLD_Y.duration, new AlphaFunction(ALPHA_FUNCTION_UNFOLD));
165
166                 // Animate the clipped image into the unfolded position and into a quad
167                 mAnimation.AnimateTo(mClippedImage, "PositionX", mContactCardLayoutInfo.imageUnfoldedPosition.X, TIME_PERIOD_UNFOLD_X.start, TIME_PERIOD_UNFOLD_X.start + TIME_PERIOD_UNFOLD_X.duration, new AlphaFunction(ALPHA_FUNCTION_UNFOLD));
168                 mAnimation.AnimateTo(mClippedImage, "PositionY", mContactCardLayoutInfo.imageUnfoldedPosition.Y, TIME_PERIOD_UNFOLD_Y.start, TIME_PERIOD_UNFOLD_Y.start + TIME_PERIOD_UNFOLD_Y.duration, new AlphaFunction(ALPHA_FUNCTION_UNFOLD));
169                 mAnimation.AnimateTo(mClippedImage, "uDelta", ClippedImage.QUAD_GEOMETRY, TIME_PERIOD_UNFOLD_MESH_MORPH.start , TIME_PERIOD_UNFOLD_MESH_MORPH.start + TIME_PERIOD_UNFOLD_MESH_MORPH.duration, new AlphaFunction(ALPHA_FUNCTION_UNFOLD));
170
171                 // Fade out the opacity of the name, and animate into the unfolded position
172                 mAnimation.AnimateTo(mNameText, "ColorAlpha", 0.0f, TIME_PERIOD_UNFOLD_NAME_OPACITY.start, TIME_PERIOD_UNFOLD_NAME_OPACITY.start + TIME_PERIOD_UNFOLD_NAME_OPACITY.duration, new AlphaFunction(ALPHA_FUNCTION_UNFOLD));
173                 mAnimation.AnimateTo(mNameText, "PositionX", mContactCardLayoutInfo.textUnfoldedPosition.X, TIME_PERIOD_UNFOLD_X.start, TIME_PERIOD_UNFOLD_X.start + TIME_PERIOD_UNFOLD_X.duration, new AlphaFunction(ALPHA_FUNCTION_UNFOLD));
174                 mAnimation.AnimateTo(mNameText, "PositionY", mContactCardLayoutInfo.textUnfoldedPosition.Y, TIME_PERIOD_UNFOLD_Y.start, TIME_PERIOD_UNFOLD_Y.start + TIME_PERIOD_UNFOLD_Y.duration, new AlphaFunction(ALPHA_FUNCTION_UNFOLD));
175
176                 // Fade in the opacity of the detail, and animate into the unfolded position
177                 mAnimation.AnimateTo(mDetailText, "ColorAlpha", 1.0f, TIME_PERIOD_UNFOLD_NAME_OPACITY.start, TIME_PERIOD_UNFOLD_NAME_OPACITY.start + TIME_PERIOD_UNFOLD_NAME_OPACITY.duration, new AlphaFunction(ALPHA_FUNCTION_UNFOLD));
178                 mAnimation.AnimateTo(mDetailText, "PositionX", mContactCardLayoutInfo.textUnfoldedPosition.X, TIME_PERIOD_UNFOLD_X.start, TIME_PERIOD_UNFOLD_X.start + TIME_PERIOD_UNFOLD_X.duration, new AlphaFunction(ALPHA_FUNCTION_UNFOLD));
179                 mAnimation.AnimateTo(mDetailText, "PositionY", mContactCardLayoutInfo.textUnfoldedPosition.Y, TIME_PERIOD_UNFOLD_Y.start, TIME_PERIOD_UNFOLD_Y.start + TIME_PERIOD_UNFOLD_Y.duration, new AlphaFunction(ALPHA_FUNCTION_UNFOLD));
180
181                 // Fade out all the siblings
182                 View parent = mContactCard.GetParent() as View;
183                 for (uint i = 0; i < parent.GetChildCount(); ++i)
184                 {
185                     View sibling = parent.GetChildAt(i);
186                     if (sibling != mContactCard)
187                     {
188                         mAnimation.AnimateTo(sibling, "ColorAlpha", 0.0f, TIME_PERIOD_UNFOLD_SIBLING_OPACITY.start, TIME_PERIOD_UNFOLD_SIBLING_OPACITY.start + TIME_PERIOD_UNFOLD_SIBLING_OPACITY.duration, new AlphaFunction(ALPHA_FUNCTION_UNFOLD));
189                         sibling.Sensitive = false;
190                     }
191                 }
192
193                 mAnimation.Finished += OnAnimationFinished;
194                 mAnimation.Play();
195             }
196             else
197             {
198                 // Remove key-input-focus from our contact-card when we are folded
199                 FocusManager.Instance.ClearFocus();
200
201                 mContactCard.Add(mNameText);
202
203                 // Animate the size of the control (and clipping area)
204                 mAnimation.AnimateTo(mContactCard, "PositionX", foldedPosition.X, TIME_PERIOD_FOLD_X.start, TIME_PERIOD_FOLD_X.start + TIME_PERIOD_FOLD_X.duration, new AlphaFunction(ALPHA_FUNCTION_FOLD));
205                 mAnimation.AnimateTo(mContactCard, "PositionY", foldedPosition.Y, TIME_PERIOD_FOLD_Y.start, TIME_PERIOD_FOLD_Y.start + TIME_PERIOD_FOLD_Y.duration, new AlphaFunction(ALPHA_FUNCTION_FOLD));
206                 mAnimation.AnimateTo(mContactCard, "SizeWidth", mContactCardLayoutInfo.foldedSize.Width, TIME_PERIOD_FOLD_WIDTH.start, TIME_PERIOD_FOLD_WIDTH.start + TIME_PERIOD_FOLD_WIDTH.duration, new AlphaFunction(ALPHA_FUNCTION_FOLD));
207                 mAnimation.AnimateTo(mContactCard, "SizeHeight", mContactCardLayoutInfo.foldedSize.Height, TIME_PERIOD_FOLD_HEIGHT.start, TIME_PERIOD_FOLD_HEIGHT.start + TIME_PERIOD_FOLD_HEIGHT.duration, new AlphaFunction(ALPHA_FUNCTION_FOLD));
208
209                 // Animate the header area out of position
210                 mAnimation.AnimateTo(mHeader, "PositionX", mContactCardLayoutInfo.headerFoldedPosition.X, TIME_PERIOD_FOLD_X.start, TIME_PERIOD_FOLD_X.start + TIME_PERIOD_FOLD_X.duration, new AlphaFunction(ALPHA_FUNCTION_FOLD));
211                 mAnimation.AnimateTo(mHeader, "PositionY", mContactCardLayoutInfo.headerFoldedPosition.Y, TIME_PERIOD_FOLD_Y.start, TIME_PERIOD_FOLD_Y.start + TIME_PERIOD_FOLD_Y.duration, new AlphaFunction(ALPHA_FUNCTION_FOLD));
212
213                 // Animate the clipped image into the folded position and into a circle
214                 mAnimation.AnimateTo(mClippedImage, "PositionX", mContactCardLayoutInfo.imageFoldedPosition.X, TIME_PERIOD_FOLD_X.start, TIME_PERIOD_FOLD_X.start + TIME_PERIOD_FOLD_X.duration, new AlphaFunction(ALPHA_FUNCTION_FOLD));
215                 mAnimation.AnimateTo(mClippedImage, "PositionY", mContactCardLayoutInfo.imageFoldedPosition.Y, TIME_PERIOD_FOLD_Y.start, TIME_PERIOD_FOLD_Y.start + TIME_PERIOD_FOLD_Y.duration, new AlphaFunction(ALPHA_FUNCTION_FOLD));
216                 mAnimation.AnimateTo(mClippedImage, "uDelta", 0.0f, TIME_PERIOD_FOLD_MESH_MORPH.start, TIME_PERIOD_FOLD_MESH_MORPH.start + TIME_PERIOD_FOLD_MESH_MORPH.duration, new AlphaFunction(ALPHA_FUNCTION_FOLD));
217
218                 // Fade in the opacity of the name, and animate into the folded position
219                 mAnimation.AnimateTo(mNameText, "ColorAlpha", 1.0f, TIME_PERIOD_FOLD_NAME_OPACITY.start, TIME_PERIOD_FOLD_NAME_OPACITY.start + TIME_PERIOD_FOLD_NAME_OPACITY.duration, new AlphaFunction(ALPHA_FUNCTION_FOLD));
220                 mAnimation.AnimateTo(mNameText, "PositionX", mContactCardLayoutInfo.textFoldedPosition.X, TIME_PERIOD_FOLD_X.start, TIME_PERIOD_FOLD_X.start + TIME_PERIOD_FOLD_X.duration, new AlphaFunction(ALPHA_FUNCTION_FOLD));
221                 mAnimation.AnimateTo(mNameText, "PositionY", mContactCardLayoutInfo.textFoldedPosition.Y, TIME_PERIOD_FOLD_Y.start, TIME_PERIOD_FOLD_Y.start + TIME_PERIOD_FOLD_Y.duration, new AlphaFunction(ALPHA_FUNCTION_FOLD));
222
223                 // Fade out the opacity of the detail, and animate into the folded position
224                 mAnimation.AnimateTo(mDetailText, "ColorAlpha", 0.0f, TIME_PERIOD_FOLD_DETAIL_OPACITY.start, TIME_PERIOD_FOLD_DETAIL_OPACITY.start + TIME_PERIOD_FOLD_DETAIL_OPACITY.duration, new AlphaFunction(ALPHA_FUNCTION_FOLD));
225                 mAnimation.AnimateTo(mDetailText, "PositionX", mContactCardLayoutInfo.textFoldedPosition.X, TIME_PERIOD_FOLD_X.start, TIME_PERIOD_FOLD_X.start + TIME_PERIOD_FOLD_X.duration, new AlphaFunction(ALPHA_FUNCTION_FOLD));
226                 mAnimation.AnimateTo(mDetailText, "PositionY", mContactCardLayoutInfo.textFoldedPosition.Y, TIME_PERIOD_FOLD_Y.start, TIME_PERIOD_FOLD_Y.start + TIME_PERIOD_FOLD_Y.duration, new AlphaFunction(ALPHA_FUNCTION_FOLD));
227
228                 // Slowly fade in all the siblings
229                 View parent = mContactCard.GetParent() as View;
230                 for (uint i = 0; i < parent.GetChildCount(); ++i)
231                 {
232                     View sibling = parent.GetChildAt(i);
233                     if (sibling != mContactCard)
234                     {
235                         mAnimation.AnimateTo(sibling, "ColorAlpha", 1.0f, TIME_PERIOD_FOLD_SIBLING_OPACITY.start, TIME_PERIOD_FOLD_SIBLING_OPACITY.start + TIME_PERIOD_FOLD_SIBLING_OPACITY.duration, new AlphaFunction(ALPHA_FUNCTION_FOLD));
236                         sibling.Sensitive = true;
237                     }
238                 }
239
240                 mAnimation.Finished += OnAnimationFinished;
241                 mAnimation.Play();
242             }
243
244             mFolded = !mFolded;
245         }
246
247         private void OnAnimationFinished(object sender, EventArgs e)
248         {
249             Animation animation = sender as Animation;
250
251             // Ensure the finishing animation is the latest as we do not want to change state if a previous animation has finished
252             if (mAnimation == animation)
253             {
254                 if(mFolded)
255                 {
256                     mHeader.Unparent();
257                     mDetailText.Unparent();
258
259                     // Hide the clipped-image as we have finished animating the geometry and show the masked-image again
260                     mClippedImage.Hide();
261                     mMaskedImage.Show();
262                 }
263             }
264         }
265
266         private bool OnKeyEvent(object sender, View.KeyEventArgs e)
267         {
268             if((!mFolded) && (e.Key.State == Key.StateType.Down))
269             {
270                 if(e.Key.KeyPressedName == "Escape" || e.Key.KeyPressedName == "BackSpace")
271                 {
272                     FocusManager focusManager = FocusManager.Instance;
273                     if(focusManager.GetCurrentFocusView() == mContactCard)
274                     {
275                         // Our contact - card is set to receive focus and we're unfolded so animate back to the folded state
276                         Animate();
277                     }
278                 }
279             }
280
281             return true;
282         }
283
284         private void OnTap(object sender, TapGestureDetector.DetectedEventArgs e)
285         {
286             View view = sender as View;
287             if(view = mContactCard)
288             {
289                 Animate();
290             }
291         }
292
293         public class TimePeriod
294         {
295             public int start;
296             public int duration;
297
298             public TimePeriod(int _start, int _duration)
299             {
300                 start = _start;
301                 duration = _duration;
302             }
303         }
304     }
305 }