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;
22 using tlog = Tizen.Log;
25 namespace Tizen.NUI.BaseComponents
28 /// AnimatedImageView is a class for displaying Animated-GIF and Image-Array
30 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
31 [EditorBrowsable(EditorBrowsableState.Never)]
32 public class AnimatedImageView : ImageView
34 #region Constructor, Distructor, Dispose
36 /// Construct AnimatedImageView
38 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
39 [EditorBrowsable(EditorBrowsableState.Never)]
40 public AnimatedImageView() : base()
46 /// You can override it to clean-up your own resources
48 /// <param name="type">DisposeTypes</param>
49 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
50 [EditorBrowsable(EditorBrowsableState.Never)]
51 protected override void Dispose(DisposeTypes type)
58 //Release your own unmanaged resources here.
59 //You should not access any managed member here except static instance.
60 //because the execution order of Finalizes is non-deterministic.
63 #endregion Constructor, Distructor, Dispose
67 /// Image URL for Animated-GIF
69 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
70 [EditorBrowsable(EditorBrowsableState.Never)]
71 public new string ResourceUrl
85 /// Image URL list for Image-Array
87 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
88 [EditorBrowsable(EditorBrowsableState.Never)]
89 public List<string> URLs
98 /// Defines the batch size for pre-loading images in the Image-Array animation.
99 /// number of images to pre-load before starting to play. Default value: 1.
101 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
102 [EditorBrowsable(EditorBrowsableState.Never)]
117 /// Defines the cache size for loading images in the Image-Array animation.
118 /// number of images to keep cached ahead during playback. Default value: 1.
121 /// cacheSize should be >= batchSize. If it isn't, then the cache will automatically be changed to batchSize.
122 /// because of the defaults, it is expected that the application developer tune the batch and cache sizes to their particular use case.
124 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
125 [EditorBrowsable(EditorBrowsableState.Never)]
140 /// The number of milliseconds between each frame in the Image-Array animation.
141 /// The number of milliseconds between each frame.
144 /// This is only used when URLs(multiple string) are provided.
146 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
147 [EditorBrowsable(EditorBrowsableState.Never)]
148 public int FrameDelay
162 /// The number of looping.
164 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
165 [EditorBrowsable(EditorBrowsableState.Never)]
182 /// To make the properies be set. This should be called after the properties are set.
184 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
185 [EditorBrowsable(EditorBrowsableState.Never)]
186 public void SetValues()
188 if (mDirtyFlag == false)
194 PropertyMap tMap = new PropertyMap();
195 PropertyValue animatiedImage = new PropertyValue((int)Visual.Type.AnimatedImage);
196 tMap.Insert(Visual.Property.Type, animatiedImage);
197 if (mResourceURLs?.Count != 0)
199 PropertyArray mArray = new PropertyArray();
200 PropertyArray returnedArr = new PropertyArray();
201 PropertyValue index = new PropertyValue();
202 foreach (var iter in mResourceURLs)
204 index = new PropertyValue(iter);
205 returnedArr = mArray.Add(index);
208 returnedArr.Dispose();
209 PropertyValue array = new PropertyValue(mArray);
210 tMap.Insert(ImageVisualProperty.URL, array);
211 PropertyValue batchSize = new PropertyValue(mBatchSize);
212 tMap.Insert(ImageVisualProperty.BatchSize, batchSize);
213 PropertyValue cacheSize = new PropertyValue(mCacheSize);
214 tMap.Insert(ImageVisualProperty.CacheSize, cacheSize);
215 PropertyValue frameDelay = new PropertyValue(mFrameDelay);
216 tMap.Insert(ImageVisualProperty.FrameDelay, frameDelay);
217 PropertyValue loopCount = new PropertyValue(mLoopCount);
218 tMap.Insert(ImageVisualProperty.LoopCount, loopCount);
221 frameDelay.Dispose();
229 PropertyValue url = new PropertyValue(mUrl);
230 tMap.Insert(ImageVisualProperty.URL, url);
235 PropertyValue map = new PropertyValue(mMap);
236 SetProperty(ImageView.Property.IMAGE, map);
240 animatiedImage.Dispose();
246 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
247 [EditorBrowsable(EditorBrowsableState.Never)]
248 public new void Play()
255 /// Pause animation. Currently pause and stop are same
257 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
258 [EditorBrowsable(EditorBrowsableState.Never)]
259 public new void Pause()
266 /// Stop animation. Currently pause and stop are same
268 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
269 [EditorBrowsable(EditorBrowsableState.Never)]
270 public new void Stop()
278 #region Event, Enum, Struct, ETC
279 #endregion Event, Enum, Struct, ETC
288 List<string> mResourceURLs = new List<string>();
293 bool mDirtyFlag = false;