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
80 /// Image URL list for Image-Array
82 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
83 [EditorBrowsable(EditorBrowsableState.Never)]
84 public List<string> URLs
93 /// Defines the batch size for pre-loading images in the Image-Array animation.
94 /// number of images to pre-load before starting to play. Default value: 1.
96 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
97 [EditorBrowsable(EditorBrowsableState.Never)]
112 /// Defines the cache size for loading images in the Image-Array animation.
113 /// number of images to keep cached ahead during playback. Default value: 1.
116 /// cacheSize should be >= batchSize. If it isn't, then the cache will automatically be changed to batchSize.
117 /// because of the defaults, it is expected that the application developer tune the batch and cache sizes to their particular use case.
119 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
120 [EditorBrowsable(EditorBrowsableState.Never)]
135 /// The number of milliseconds between each frame in the Image-Array animation.
136 /// The number of milliseconds between each frame.
139 /// This is only used when URLs(multiple string) are provided.
141 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
142 [EditorBrowsable(EditorBrowsableState.Never)]
143 public int FrameDelay
157 /// The number of looping.
159 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
160 [EditorBrowsable(EditorBrowsableState.Never)]
177 /// To make the properies be set. This should be called after the properties are set.
179 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
180 [EditorBrowsable(EditorBrowsableState.Never)]
181 public void SetValues()
183 if (mDirtyFlag == false)
189 PropertyMap tMap = new PropertyMap();
190 PropertyValue animatiedImage = new PropertyValue((int)Visual.Type.AnimatedImage);
191 tMap.Insert(Visual.Property.Type, animatiedImage);
192 if (mResourceURLs?.Count != 0)
194 PropertyArray mArray = new PropertyArray();
195 PropertyArray returnedArr = new PropertyArray();
196 PropertyValue index = new PropertyValue();
197 foreach (var iter in mResourceURLs)
199 index = new PropertyValue(iter);
200 returnedArr = mArray.Add(index);
203 returnedArr.Dispose();
204 PropertyValue array = new PropertyValue(mArray);
205 tMap.Insert(ImageVisualProperty.URL, array);
206 PropertyValue batchSize = new PropertyValue(mBatchSize);
207 tMap.Insert(ImageVisualProperty.BatchSize, batchSize);
208 PropertyValue cacheSize = new PropertyValue(mCacheSize);
209 tMap.Insert(ImageVisualProperty.CacheSize, cacheSize);
210 PropertyValue frameDelay = new PropertyValue(mFrameDelay);
211 tMap.Insert(ImageVisualProperty.FrameDelay, frameDelay);
212 PropertyValue loopCount = new PropertyValue(mLoopCount);
213 tMap.Insert(ImageVisualProperty.LoopCount, loopCount);
216 frameDelay.Dispose();
224 PropertyValue url = new PropertyValue(mUrl);
225 tMap.Insert(ImageVisualProperty.URL, url);
230 PropertyValue map = new PropertyValue(mMap);
231 SetProperty(ImageView.Property.IMAGE, map);
235 animatiedImage.Dispose();
241 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
242 [EditorBrowsable(EditorBrowsableState.Never)]
243 public new void Play()
250 /// Pause animation. Currently pause and stop are same
252 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
253 [EditorBrowsable(EditorBrowsableState.Never)]
254 public new void Pause()
261 /// Stop animation. Currently pause and stop are same
263 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
264 [EditorBrowsable(EditorBrowsableState.Never)]
265 public new void Stop()
273 #region Event, Enum, Struct, ETC
274 #endregion Event, Enum, Struct, ETC
283 List<string> mResourceURLs = new List<string>();
288 bool mDirtyFlag = false;