2 * Copyright(c) 2019 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.Collections.Generic;
19 using System.ComponentModel;
21 namespace Tizen.NUI.Components
24 /// The Loading class of nui component. It's used to indicate informs users of the ongoing operation.
26 /// <since_tizen> 6 </since_tizen>
27 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
28 [EditorBrowsable(EditorBrowsableState.Never)]
29 public class Loading : Control
31 private LoadingAttributes loadingAttrs = null; // Loading Attributes
32 private AnimatedImageVisual imageVisual = null;
35 /// The constructor of Loading
37 /// <since_tizen> 6 </since_tizen>
38 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
39 [EditorBrowsable(EditorBrowsableState.Never)]
40 public Loading() : base()
46 /// Constructor of the Loading class with special style.
48 /// <param name="style">The string to initialize the Loading.</param>
49 /// <since_tizen> 6 </since_tizen>
50 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
51 [EditorBrowsable(EditorBrowsableState.Never)]
52 public Loading(string style) : base(style)
58 /// The constructor of the Loading class with specific Attributes.
60 /// <param name="attributes">The Attributes object to initialize the Loading.</param>
61 /// <since_tizen> 6 </since_tizen>
62 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
63 [EditorBrowsable(EditorBrowsableState.Never)]
64 public Loading(LoadingAttributes attributes) : base(attributes)
70 /// Gets or sets loading image resource array.
72 /// <since_tizen> 6 </since_tizen>
73 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
74 [EditorBrowsable(EditorBrowsableState.Never)]
75 public string[] ImageArray
79 return loadingAttrs.ImageArray;
85 loadingAttrs.ImageArray = value;
86 imageVisual.URLS = new List<string>(value);
92 /// Gets or sets loading size.
94 /// <since_tizen> 6 </since_tizen>
95 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
96 [EditorBrowsable(EditorBrowsableState.Never)]
97 public Size2D LoadingSize
101 return loadingAttrs.LoadingSize ?? new Size2D(100, 100);
105 loadingAttrs.LoadingSize = value;
106 imageVisual.Size = value;
111 /// Gets or sets FPS of loading.
113 /// <since_tizen> 6 </since_tizen>
114 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
115 [EditorBrowsable(EditorBrowsableState.Never)]
120 return loadingAttrs?.FPS?.All ?? (int)(1000.0f / 16.6f);
124 if (value != 0) //It will crash if 0
126 if (null == loadingAttrs.FPS)
128 loadingAttrs.FPS = new IntSelector();
130 loadingAttrs.FPS.All = value;
131 imageVisual.FrameDelay = 1000.0f / value;
137 /// Get Loading attribues.
139 /// <since_tizen> 6 </since_tizen>
140 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
141 [EditorBrowsable(EditorBrowsableState.Never)]
142 protected override Attributes GetAttributes()
144 return new LoadingAttributes();
150 /// <param name="type">Dispose type.</param>
151 /// <since_tizen> 6 </since_tizen>
152 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
153 [EditorBrowsable(EditorBrowsableState.Never)]
154 protected override void Dispose(DisposeTypes type)
161 if (type == DisposeTypes.Explicit)
164 //Release your own managed resources here.
165 //You should release all of your own disposable objects here.
166 RemoveVisual("loadingImageVisual");
169 //Release your own unmanaged resources here.
170 //You should not access any managed member here except static instance.
171 //because the execution order of Finalizes is non-deterministic.
172 //Unreference this from if a static instance refer to this.
174 //You must call base.Dispose(type) just before exit.
179 /// Update Loading by attributes.
181 /// <since_tizen> 6 </since_tizen>
182 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
183 [EditorBrowsable(EditorBrowsableState.Never)]
184 protected override void OnUpdate()
188 private void Initialize()
190 loadingAttrs = attributes as LoadingAttributes;
191 if (null == loadingAttrs)
193 throw new Exception("Loading attribute parse error.");
195 ApplyAttributes(this, loadingAttrs);
197 imageVisual = new AnimatedImageVisual()
199 URLS = new List<string>(),
202 Size = new Size2D(100, 100),
203 Position = new Vector2(0, 0),
204 Origin = Visual.AlignType.Center,
205 AnchorPoint = Visual.AlignType.Center
210 this.AddVisual("loadingImageVisual", imageVisual);
213 private void UpdateVisual()
215 if (null != loadingAttrs.ImageArray)
217 imageVisual.URLS = new List<string>(loadingAttrs.ImageArray);
219 if (null != loadingAttrs.FPS)
221 imageVisual.FrameDelay = 1000.0f / (float)loadingAttrs.FPS.All;
223 if (null != loadingAttrs.LoadingSize)
225 imageVisual.Size = loadingAttrs.LoadingSize;