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.
17 using System.Collections.Generic;
22 /// A class encapsulating the property map of the animated image (AGIF) visual.
24 /// <since_tizen> 3 </since_tizen>
25 public class AnimatedImageVisual : VisualMap
27 private List<string> _urls = null;
28 private int? _batchSize = null;
29 private int? _cacheSize = null;
30 private float? _frameDelay = null;
31 private float? _loopCount = null;
36 /// <since_tizen> 3 </since_tizen>
37 public AnimatedImageVisual() : base()
42 /// Gets and Sets the url in the AnimatedImageVisual.
44 /// <since_tizen> 3 </since_tizen>
62 _urls = new List<string>();
74 /// Gets and Sets the url list in the AnimatedImageVisual.
76 /// <since_tizen> 4 </since_tizen>
77 public List<string> URLS
91 /// Gets and Sets the batch size for pre-loading images in the AnimatedImageVisual.
93 /// <since_tizen> 4 </since_tizen>
98 return _batchSize ?? 1;
108 /// Gets and Sets the cache size for loading images in the AnimatedImageVisual.
110 /// <since_tizen> 4 </since_tizen>
115 return _cacheSize ?? 1;
125 /// Gets and Sets The number of milliseconds between each frame in the AnimatedImageVisual.
127 /// <since_tizen> 4 </since_tizen>
128 public float FrameDelay
132 return _frameDelay ?? 0.1f;
142 /// Gets and sets the number of times the AnimatedImageVisual will be looped.
143 /// The default is -1. If the number is less than 0 then it loops unlimited,otherwise loop loopCount times.
145 /// <since_tizen> 5 </since_tizen>
146 public float LoopCount
150 return _loopCount ?? -1;
160 /// Compose the out visual map.
162 /// <since_tizen> 3 </since_tizen>
163 protected override void ComposingPropertyMap()
167 _outputVisualMap = new PropertyMap();
168 PropertyValue temp = new PropertyValue((int)Visual.Type.AnimatedImage);
169 _outputVisualMap.Add(Visual.Property.Type, temp);
171 if (_urls.Count == 1)
173 temp = new PropertyValue(_urls[0]);
174 _outputVisualMap.Add(ImageVisualProperty.URL, temp);
179 var urlArray = new PropertyArray();
180 foreach (var url in _urls)
182 urlArray.Add(new PropertyValue(url));
184 temp = new PropertyValue(urlArray);
185 _outputVisualMap.Add(ImageVisualProperty.URL, temp);
189 if (_batchSize != null)
191 temp = new PropertyValue((int)_batchSize);
192 _outputVisualMap.Add(ImageVisualProperty.BatchSize, temp);
195 if (_cacheSize != null)
197 temp = new PropertyValue((int)_cacheSize);
198 _outputVisualMap.Add(ImageVisualProperty.CacheSize, temp);
201 if (_frameDelay != null)
203 temp = new PropertyValue((float)_frameDelay);
204 _outputVisualMap.Add(ImageVisualProperty.FrameDelay, temp);
207 if (_loopCount != null)
209 temp = new PropertyValue((int)_loopCount);
210 _outputVisualMap.Add(ImageVisualProperty.LoopCount, temp);
213 base.ComposingPropertyMap();