1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 // This File has been auto-generated by SWIG and then modified using DALi Ruby Scripts
17 //------------------------------------------------------------------------------
20 // This file was automatically generated by SWIG (http://www.swig.org).
23 // Do not make changes to this file unless you know what you are doing--modify
24 // the SWIG interface file instead.
25 //------------------------------------------------------------------------------
27 namespace Tizen.NUI.BaseComponents
30 using System.Runtime.InteropServices;
33 /// ImageView is a class for displaying an image resource.<br>
34 /// An instance of ImageView can be created using a URL or an Image instance.<br>
36 public class ImageView : View
38 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
40 internal ImageView(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.ImageView_SWIGUpcast(cPtr), cMemoryOwn)
42 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
43 // By default, we do not want the position to use the anchor point
44 PositionUsesAnchorPoint = false;
47 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ImageView obj)
49 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
54 /// Event arguments of resource ready.
56 public class ResourceReadyEventArgs : EventArgs
61 /// The view whose resource is ready.
76 private EventHandler<ResourceReadyEventArgs> _resourceReadyEventHandler;
77 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
78 private delegate void ResourceReadyEventCallbackType(IntPtr data);
79 private ResourceReadyEventCallbackType _resourceReadyEventCallback;
82 /// Event for ResourceReady signal which can be used to subscribe/unsubscribe the event handler.<br>
83 /// This signal is emitted after all resources required by a control are loaded and ready.<br>
84 /// Most resources are only loaded when the control is placed on stage.<br>
86 public event EventHandler<ResourceReadyEventArgs> ResourceReady
90 if (_resourceReadyEventHandler == null)
92 _resourceReadyEventCallback = OnResourceReady;
93 ResourceReadySignal(this).Connect(_resourceReadyEventCallback);
96 _resourceReadyEventHandler += value;
101 _resourceReadyEventHandler -= value;
103 if (_resourceReadyEventHandler == null && ResourceReadySignal(this).Empty() == false)
105 ResourceReadySignal(this).Disconnect(_resourceReadyEventCallback);
110 // Callback for View ResourceReady signal
111 private void OnResourceReady(IntPtr data)
113 ResourceReadyEventArgs e = new ResourceReadyEventArgs();
116 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
119 if (_resourceReadyEventHandler != null)
121 _resourceReadyEventHandler(this, e);
125 //you can override it to clean-up your own resources.
126 protected override void Dispose(DisposeTypes type)
133 if(type == DisposeTypes.Explicit)
136 //Release your own managed resources here.
137 //You should release all of your own disposable objects here.
140 _nPatchMap?.Dispose();
144 //Release your own unmanaged resources here.
145 //You should not access any managed member here except static instance.
146 //because the execution order of Finalizes is non-deterministic.
148 if (swigCPtr.Handle != global::System.IntPtr.Zero)
153 NDalicPINVOKE.delete_ImageView(swigCPtr);
155 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
161 internal class Property
163 internal static readonly int RESOURCE_URL = NDalicPINVOKE.ImageView_Property_RESOURCE_URL_get();
164 internal static readonly int IMAGE = NDalicPINVOKE.ImageView_Property_IMAGE_get();
165 internal static readonly int PRE_MULTIPLIED_ALPHA = NDalicPINVOKE.ImageView_Property_PRE_MULTIPLIED_ALPHA_get();
166 internal static readonly int PIXEL_AREA = NDalicPINVOKE.ImageView_Property_PIXEL_AREA_get();
170 /// Creates an initialized ImageView.
172 public ImageView() : this(NDalicPINVOKE.ImageView_New__SWIG_0(), true)
174 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
178 /// Creates an initialized ImageView from an URL to an image resource.<br>
179 /// If the string is empty, ImageView will not display anything.<br>
181 /// <param name="url">The url of the image resource to display</param>
182 public ImageView(string url) : this(NDalicPINVOKE.ImageView_New__SWIG_2(url), true)
184 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
187 internal ImageView(string url, Uint16Pair size) : this(NDalicPINVOKE.ImageView_New__SWIG_3(url, Uint16Pair.getCPtr(size)), true)
189 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
194 /// Sets this ImageView from the given URL.<br>
195 /// If the URL is empty, ImageView will not display anything.<br>
197 /// <param name="url">The URL to the image resource to display</param>
198 public void SetImage(string url)
200 NDalicPINVOKE.ImageView_SetImage__SWIG_1(swigCPtr, url);
201 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
203 internal void SetImage(string url, Uint16Pair size)
205 NDalicPINVOKE.ImageView_SetImage__SWIG_2(swigCPtr, url, Uint16Pair.getCPtr(size));
206 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
209 internal ViewResourceReadySignal ResourceReadySignal(View view) {
210 ViewResourceReadySignal ret = new ViewResourceReadySignal(NDalicPINVOKE.ResourceReadySignal(View.getCPtr(view)), false);
211 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
216 /// Query if all resources required by a control are loaded and ready.<br>
217 /// Most resources are only loaded when the control is placed on stage.<br>
218 /// true if the resources are loaded and ready, false otherwise.<br>
220 public bool IsResourceReady()
222 bool ret = NDalicPINVOKE.IsResourceReady(swigCPtr);
223 if (NDalicPINVOKE.SWIGPendingException.Pending)
224 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
229 /// ImageView ResourceUrl, type string
231 public string ResourceUrl
235 GetProperty(ImageView.Property.RESOURCE_URL).Get(out _url);
246 /// ImageView ImageMap, type PropertyMap : string if it is a url, map otherwise
248 public PropertyMap ImageMap
254 PropertyMap temp = new PropertyMap();
255 GetProperty(ImageView.Property.IMAGE).Get(temp);
267 SetProperty(ImageView.Property.IMAGE, new Tizen.NUI.PropertyValue(value));
273 /// ImageView PreMultipliedAlpha, type Boolean.<br>
274 /// Image must be initialized.<br>
276 public bool PreMultipliedAlpha
281 GetProperty(ImageView.Property.PRE_MULTIPLIED_ALPHA).Get(out temp);
286 SetProperty(ImageView.Property.PRE_MULTIPLIED_ALPHA, new Tizen.NUI.PropertyValue(value));
291 /// ImageView PixelArea, type Vector4 (Animatable property).<br>
292 /// Pixel area is a relative value with the whole image area as [0.0, 0.0, 1.0, 1.0].<br>
294 public RelativeVector4 PixelArea
298 Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
299 GetProperty(ImageView.Property.PIXEL_AREA).Get(temp);
304 SetProperty(ImageView.Property.PIXEL_AREA, new Tizen.NUI.PropertyValue(value));
309 /// The border of the image in the order: left, right, bottom, top.<br>
310 /// If set, ImageMap will be ignored.<br>
311 /// For N-Patch images only.<br>
314 public Rectangle Border
328 /// Get or set whether to draws the borders only(If true).<br>
329 /// If not specified, the default is false.<br>
330 /// For N-Patch images only.<br>
333 public bool BorderOnly
337 return _borderOnly ?? false;
346 public bool SynchronosLoading
350 return _synchronousLoading ?? false;
354 _synchronousLoading = value;
359 private void UpdateImage()
364 { // for nine-patch image
365 _nPatchMap = new PropertyMap();
366 _nPatchMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.NPatch));
367 _nPatchMap.Add(NpatchImageVisualProperty.URL, new PropertyValue(_url));
368 _nPatchMap.Add(NpatchImageVisualProperty.Border, new PropertyValue(_border));
369 if (_borderOnly != null) { _nPatchMap.Add(NpatchImageVisualProperty.BorderOnly, new PropertyValue((bool)_borderOnly)); }
370 if (_synchronousLoading != null) _nPatchMap.Add(NpatchImageVisualProperty.SynchronousLoading, new PropertyValue((bool)_synchronousLoading));
371 SetProperty(ImageView.Property.IMAGE, new PropertyValue(_nPatchMap));
373 else if(_synchronousLoading != null)
374 { // for normal image, with synchronous loading property
375 PropertyMap imageMap = new PropertyMap();
376 imageMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
377 imageMap.Add(ImageVisualProperty.URL, new PropertyValue(_url));
378 imageMap.Add(ImageVisualProperty.SynchronousLoading, new PropertyValue((bool)_synchronousLoading));
379 SetProperty(ImageView.Property.IMAGE, new PropertyValue(imageMap));
382 { // just for normal image
383 SetProperty(ImageView.Property.RESOURCE_URL, new PropertyValue(_url));
388 private Rectangle _border = null;
389 private PropertyMap _nPatchMap = null;
390 private bool? _synchronousLoading = null;
391 private bool? _borderOnly = null;
392 private string _url = null;