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.Runtime.InteropServices;
19 using System.ComponentModel;
20 using Tizen.NUI.Binding;
22 namespace Tizen.NUI.BaseComponents
26 /// ImageView is a class for displaying an image resource.<br />
27 /// An instance of ImageView can be created using a URL or an image instance.<br />
29 /// <since_tizen> 3 </since_tizen>
30 public class ImageView : View
32 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
33 [EditorBrowsable(EditorBrowsableState.Never)]
34 public static readonly BindableProperty ResourceUrlProperty = BindableProperty.Create(nameof(ImageView.ResourceUrl), typeof(string), typeof(ImageView), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
36 var imageView = (ImageView)bindable;
37 string url = (string)newValue;
38 url = (url == null ? "" : url);
39 if (imageView.IsCreateByXaml && url.Contains("*Resource*"))
41 string resource = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
42 url = url.Replace("*Resource*", resource);
44 imageView._resourceUrl = url;
45 imageView.UpdateImage(ImageVisualProperty.URL, new PropertyValue(url));
47 defaultValueCreator: (bindable) =>
49 var imageView = (ImageView)bindable;
52 PropertyMap imageMap = new PropertyMap();
53 Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
54 imageMap.Find(ImageVisualProperty.URL)?.Get(out ret);
58 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
59 [EditorBrowsable(EditorBrowsableState.Never)]
60 public static readonly BindableProperty ImageProperty = BindableProperty.Create(nameof(ImageView.Image), typeof(PropertyMap), typeof(ImageView), null, propertyChanged: (bindable, oldValue, newValue) =>
62 var imageView = (ImageView)bindable;
65 PropertyMap map = (PropertyMap)newValue;
66 if (imageView.IsCreateByXaml)
68 string url = "", alphaMaskURL = "", auxiliaryImageURL = "";
69 string resource = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
70 PropertyValue urlValue = map.Find(NDalic.IMAGE_VISUAL_URL);
72 if (urlValue != null) ret = urlValue.Get(out url);
73 PropertyMap mmap = new PropertyMap();
74 if (ret && url.Contains("*Resource*"))
76 url = url.Replace("*Resource*", resource);
77 mmap.Insert(NDalic.IMAGE_VISUAL_URL, new PropertyValue(url));
81 PropertyValue alphaMaskUrlValue = map.Find(NDalic.IMAGE_VISUAL_ALPHA_MASK_URL);
82 if (alphaMaskUrlValue != null) ret = alphaMaskUrlValue.Get(out alphaMaskURL);
83 if (ret && alphaMaskURL.Contains("*Resource*"))
85 alphaMaskURL = alphaMaskURL.Replace("*Resource*", resource);
86 mmap.Insert(NDalic.IMAGE_VISUAL_URL, new PropertyValue(alphaMaskURL));
90 PropertyValue auxiliaryImageURLValue = map.Find(NDalic.IMAGE_VISUAL_AUXILIARY_IMAGE_URL);
91 if (auxiliaryImageURLValue != null) ret = auxiliaryImageURLValue.Get(out auxiliaryImageURL);
92 if (ret && auxiliaryImageURL.Contains("*Resource*"))
94 auxiliaryImageURL = auxiliaryImageURL.Replace("*Resource*", resource);
95 mmap.Insert(NDalic.IMAGE_VISUAL_AUXILIARY_IMAGE_URL, new PropertyValue(auxiliaryImageURL));
100 if (imageView._border == null)
102 Tizen.NUI.Object.SetProperty(imageView.swigCPtr, ImageView.Property.IMAGE, new Tizen.NUI.PropertyValue(map));
106 defaultValueCreator: (bindable) =>
108 var imageView = (ImageView)bindable;
109 if (imageView._border == null)
111 PropertyMap temp = new PropertyMap();
112 Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.IMAGE).Get(temp);
121 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
122 [EditorBrowsable(EditorBrowsableState.Never)]
123 public static readonly BindableProperty PreMultipliedAlphaProperty = BindableProperty.Create("PreMultipliedAlpha", typeof(bool), typeof(ImageView), false, propertyChanged: (bindable, oldValue, newValue) =>
125 var imageView = (ImageView)bindable;
126 if (newValue != null)
128 Tizen.NUI.Object.SetProperty(imageView.swigCPtr, ImageView.Property.PRE_MULTIPLIED_ALPHA, new Tizen.NUI.PropertyValue((bool)newValue));
131 defaultValueCreator: (bindable) =>
133 var imageView = (ImageView)bindable;
135 Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.PRE_MULTIPLIED_ALPHA).Get(out temp);
139 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
140 [EditorBrowsable(EditorBrowsableState.Never)]
141 public static readonly BindableProperty PixelAreaProperty = BindableProperty.Create("PixelArea", typeof(RelativeVector4), typeof(ImageView), null, propertyChanged: (bindable, oldValue, newValue) =>
143 var imageView = (ImageView)bindable;
144 if (newValue != null)
146 Tizen.NUI.Object.SetProperty(imageView.swigCPtr, ImageView.Property.PIXEL_AREA, new Tizen.NUI.PropertyValue((RelativeVector4)newValue));
149 defaultValueCreator: (bindable) =>
151 var imageView = (ImageView)bindable;
152 Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
153 Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.PIXEL_AREA).Get(temp);
154 RelativeVector4 relativeTemp = new RelativeVector4(temp.X, temp.Y, temp.Z, temp.W);
158 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
159 [EditorBrowsable(EditorBrowsableState.Never)]
160 public static readonly BindableProperty BorderProperty = BindableProperty.Create("Border", typeof(Rectangle), typeof(ImageView), null, propertyChanged: (bindable, oldValue, newValue) =>
164 var imageView = (ImageView)bindable;
165 imageView._border = (Rectangle)newValue;
166 imageView.UpdateImage(NpatchImageVisualProperty.Border, new PropertyValue(imageView._border));
169 defaultValueCreator: (bindable) =>
171 var imageView = (ImageView)bindable;
172 return imageView._border;
175 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
176 [EditorBrowsable(EditorBrowsableState.Never)]
177 public static readonly BindableProperty BorderOnlyProperty = BindableProperty.Create("BorderOnly", typeof(bool), typeof(ImageView), false, propertyChanged: (bindable, oldValue, newValue) =>
179 var imageView = (ImageView)bindable;
180 if (newValue != null)
182 imageView.UpdateImage(NpatchImageVisualProperty.BorderOnly, new PropertyValue((bool)newValue));
185 defaultValueCreator: (bindable) =>
187 var imageView = (ImageView)bindable;
189 PropertyMap imageMap = new PropertyMap();
190 Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
191 imageMap.Find(ImageVisualProperty.BorderOnly)?.Get(out ret);
195 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
196 [EditorBrowsable(EditorBrowsableState.Never)]
197 public static readonly BindableProperty SynchronosLoadingProperty = BindableProperty.Create("SynchronosLoading", typeof(bool), typeof(ImageView), false, propertyChanged: (bindable, oldValue, newValue) =>
199 var imageView = (ImageView)bindable;
200 if (newValue != null)
202 imageView._synchronosLoading = (bool) newValue;
203 imageView.UpdateImage(NpatchImageVisualProperty.SynchronousLoading, new PropertyValue((bool)newValue));
206 defaultValueCreator: (bindable) =>
208 var imageView = (ImageView)bindable;
209 return imageView._synchronosLoading;
212 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
213 [EditorBrowsable(EditorBrowsableState.Never)]
214 public static readonly BindableProperty OrientationCorrectionProperty = BindableProperty.Create("OrientationCorrection", typeof(bool), typeof(ImageView), false, propertyChanged: (bindable, oldValue, newValue) =>
216 var imageView = (ImageView)bindable;
217 if (newValue != null)
219 imageView.UpdateImage(ImageVisualProperty.OrientationCorrection, new PropertyValue((bool)newValue));
222 defaultValueCreator: (bindable) =>
224 var imageView = (ImageView)bindable;
227 PropertyMap imageMap = new PropertyMap();
228 Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
229 imageMap?.Find(ImageVisualProperty.OrientationCorrection)?.Get(out ret);
234 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
235 private EventHandler<ResourceReadyEventArgs> _resourceReadyEventHandler;
236 private ResourceReadyEventCallbackType _resourceReadyEventCallback;
237 private EventHandler<ResourceLoadedEventArgs> _resourceLoadedEventHandler;
238 private _resourceLoadedCallbackType _resourceLoadedCallback;
240 private Rectangle _border;
241 private string _resourceUrl = "";
242 private bool _synchronosLoading = false;
245 /// Creates an initialized ImageView.
247 /// <since_tizen> 3 </since_tizen>
248 public ImageView() : this(Interop.ImageView.ImageView_New__SWIG_0(), true)
250 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
254 /// Creates an initialized ImageView with setting the status of shown or hidden.
256 /// <param name="shown">false : Not displayed (hidden), true : displayed (shown)</param>
257 /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
258 [EditorBrowsable(EditorBrowsableState.Never)]
259 public ImageView(bool shown) : this(Interop.ImageView.ImageView_New__SWIG_0(), true)
261 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
266 /// Creates an initialized ImageView from a URL to an image resource.<br />
267 /// If the string is empty, ImageView will not display anything.<br />
269 /// <param name="url">The URL of the image resource to display.</param>
270 /// <since_tizen> 3 </since_tizen>
271 public ImageView(string url) : this(Interop.ImageView.ImageView_New__SWIG_2(url), true)
274 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
279 /// Creates an initialized ImageView from a URL to an image resource with setting shown or hidden.
281 /// <param name="url">The URL of the image resource to display.</param>
282 /// <param name="shown">false : Not displayed (hidden), true : displayed (shown)</param>
283 /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
284 [EditorBrowsable(EditorBrowsableState.Never)]
285 public ImageView(string url, bool shown) : this(Interop.ImageView.ImageView_New__SWIG_2(url), true)
288 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
292 internal ImageView(string url, Uint16Pair size, bool shown = true) : this(Interop.ImageView.ImageView_New__SWIG_3(url, Uint16Pair.getCPtr(size)), true)
295 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
303 internal ImageView(global::System.IntPtr cPtr, bool cMemoryOwn, bool shown = true) : base(Interop.ImageView.ImageView_SWIGUpcast(cPtr), cMemoryOwn)
305 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
313 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
314 private delegate void ResourceReadyEventCallbackType(IntPtr data);
315 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
316 private delegate void _resourceLoadedCallbackType(IntPtr view);
319 /// An event for ResourceReady signal which can be used to subscribe or unsubscribe the event handler.<br />
320 /// This signal is emitted after all resources required by a control are loaded and ready.<br />
321 /// Most resources are only loaded when the control is placed on the stage.<br />
323 /// <since_tizen> 3 </since_tizen>
324 public event EventHandler<ResourceReadyEventArgs> ResourceReady
328 if (_resourceReadyEventHandler == null)
330 _resourceReadyEventCallback = OnResourceReady;
331 ResourceReadySignal(this).Connect(_resourceReadyEventCallback);
334 _resourceReadyEventHandler += value;
339 _resourceReadyEventHandler -= value;
341 if (_resourceReadyEventHandler == null && ResourceReadySignal(this).Empty() == false)
343 ResourceReadySignal(this).Disconnect(_resourceReadyEventCallback);
348 internal event EventHandler<ResourceLoadedEventArgs> ResourceLoaded
352 if (_resourceLoadedEventHandler == null)
354 _resourceLoadedCallback = OnResourceLoaded;
355 this.ResourceReadySignal(this).Connect(_resourceLoadedCallback);
358 _resourceLoadedEventHandler += value;
362 _resourceLoadedEventHandler -= value;
364 if (_resourceLoadedEventHandler == null && this.ResourceReadySignal(this).Empty() == false)
366 this.ResourceReadySignal(this).Disconnect(_resourceLoadedCallback);
372 /// Enumeration for LoadingStatus of image.
374 /// <since_tizen> 5 </since_tizen>
375 public enum LoadingStatusType
378 /// Loading preparing status.
380 /// <since_tizen> 5 </since_tizen>
383 /// Loading ready status.
385 /// <since_tizen> 5 </since_tizen>
388 /// Loading failed status.
390 /// <since_tizen> 5 </since_tizen>
395 /// ImageView ResourceUrl, type string.
396 /// This is one of mandatory property. Even if not set or null set, it sets empty string ("") internally.
397 /// When it is set as null, it gives empty string ("") to be read.
399 /// <since_tizen> 3 </since_tizen>
400 public string ResourceUrl
404 return (string)GetValue(ResourceUrlProperty);
408 SetValue(ResourceUrlProperty, value);
409 NotifyPropertyChanged();
414 /// This will be deprecated, please use Image instead. <br />
415 /// ImageView ImageMap, type PropertyMap: string if it is a URL, map otherwise.
417 /// <since_tizen> 3 </since_tizen>
418 [Obsolete("Please do not use! This will be deprecated! Please use Image property instead!")]
419 [EditorBrowsable(EditorBrowsableState.Never)]
420 public PropertyMap ImageMap
426 PropertyMap temp = new PropertyMap();
427 GetProperty(ImageView.Property.IMAGE).Get(temp);
439 SetProperty(ImageView.Property.IMAGE, new Tizen.NUI.PropertyValue(value));
440 NotifyPropertyChanged();
446 /// ImageView Image, type PropertyMap
448 /// <since_tizen> 4 </since_tizen>
449 public PropertyMap Image
455 return (PropertyMap)GetValue(ImageProperty);
466 SetValue(ImageProperty, value);
467 NotifyPropertyChanged();
473 /// ImageView PreMultipliedAlpha, type Boolean.<br />
474 /// Image must be initialized.<br />
476 /// <since_tizen> 3 </since_tizen>
477 public bool PreMultipliedAlpha
481 return (bool)GetValue(PreMultipliedAlphaProperty);
485 SetValue(PreMultipliedAlphaProperty, value);
486 NotifyPropertyChanged();
491 /// ImageView PixelArea, type Vector4 (Animatable property).<br />
492 /// Pixel area is a relative value with the whole image area as [0.0, 0.0, 1.0, 1.0].<br />
494 /// <since_tizen> 3 </since_tizen>
495 public RelativeVector4 PixelArea
499 return (RelativeVector4)GetValue(PixelAreaProperty);
503 SetValue(PixelAreaProperty, value);
504 NotifyPropertyChanged();
509 /// The border of the image in the order: left, right, bottom, top.<br />
510 /// If set, ImageMap will be ignored.<br />
511 /// For N-Patch images only.<br />
514 /// <since_tizen> 3 </since_tizen>
515 public Rectangle Border
519 return (Rectangle)GetValue(BorderProperty);
523 SetValue(BorderProperty, value);
524 NotifyPropertyChanged();
529 /// Gets or sets whether to draw the borders only (if true).<br />
530 /// If not specified, the default is false.<br />
531 /// For N-Patch images only.<br />
534 /// <since_tizen> 3 </since_tizen>
535 public bool BorderOnly
539 return (bool)GetValue(BorderOnlyProperty);
543 SetValue(BorderOnlyProperty, value);
544 NotifyPropertyChanged();
549 /// Gets or sets whether to synchronos loading the resourceurl of image.<br />
551 /// <since_tizen> 3 </since_tizen>
552 public bool SynchronosLoading
556 return (bool)GetValue(SynchronosLoadingProperty);
560 SetValue(SynchronosLoadingProperty, value);
561 NotifyPropertyChanged();
566 /// Gets or sets whether to automatically correct the orientation of an image.<br />
568 /// <since_tizen> 5 </since_tizen>
569 public bool OrientationCorrection
573 return (bool)GetValue(OrientationCorrectionProperty);
577 SetValue(OrientationCorrectionProperty, value);
578 NotifyPropertyChanged();
583 /// Gets the loading state of the visual resource.
585 /// <since_tizen> 5 </since_tizen>
586 public ImageView.LoadingStatusType LoadingStatus
590 return (ImageView.LoadingStatusType)Interop.View.View_GetVisualResourceStatus(swigCPtr, (int)Property.IMAGE);
595 /// Downcasts a handle to imageView handle.
597 /// Please do not use! this will be deprecated!
598 /// Instead please use as keyword.
599 /// <since_tizen> 3 </since_tizen>
600 [Obsolete("Please do not use! This will be deprecated! Please use as keyword instead! " +
602 "BaseHandle handle = new ImageView(imagePath); " +
603 "ImageView image = handle as ImageView")]
604 [EditorBrowsable(EditorBrowsableState.Never)]
605 public static ImageView DownCast(BaseHandle handle)
607 ImageView ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as ImageView;
608 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
613 /// Sets this ImageView from the given URL.<br />
614 /// If the URL is empty, ImageView will not display anything.<br />
616 /// <param name="url">The URL to the image resource to display.</param>
617 /// <since_tizen> 3 </since_tizen>
618 public void SetImage(string url)
620 if(url.Contains(".json"))
622 Tizen.Log.Fatal("NUI", "[ERROR] Please DO NOT set lottie file in ImageView! This is temporary checking, will be removed soon!");
626 Interop.ImageView.ImageView_SetImage__SWIG_1(swigCPtr, url);
627 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
633 /// Queries if all resources required by a control are loaded and ready.<br />
634 /// Most resources are only loaded when the control is placed on the stage.<br />
635 /// True if the resources are loaded and ready, false otherwise.<br />
637 /// <since_tizen> 3 </since_tizen>
638 public new bool IsResourceReady()
640 bool ret = Interop.View.IsResourceReady(swigCPtr);
641 if (NDalicPINVOKE.SWIGPendingException.Pending)
642 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
647 /// Forcefully reloads the image. All the visuals using this image will reload to the latest image.
649 /// <since_tizen> 5 </since_tizen>
652 this.DoAction(ImageView.Property.IMAGE, Property.ACTION_RELOAD, new PropertyValue(0));
656 /// Plays the animated GIF. This is also the default playback mode.
658 /// <since_tizen> 5 </since_tizen>
661 this.DoAction(ImageView.Property.IMAGE, Property.ACTION_PLAY, new PropertyValue(0));
665 /// Pauses the animated GIF.
667 /// <since_tizen> 5 </since_tizen>
670 this.DoAction(ImageView.Property.IMAGE, Property.ACTION_PAUSE, new PropertyValue(0));
674 /// Stops the animated GIF.
676 /// <since_tizen> 5 </since_tizen>
679 this.DoAction(ImageView.Property.IMAGE, Property.ACTION_STOP, new PropertyValue(0));
683 /// Gets or sets the URL of the alpha mask.<br />
686 /// <since_tizen> 6</since_tizen>
687 [EditorBrowsable(EditorBrowsableState.Never)]
688 public string AlphaMaskURL
693 PropertyMap imageMap = new PropertyMap();
694 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
695 imageMap?.Find(ImageVisualProperty.AlphaMaskURL)?.Get(out ret);
706 UpdateImage(ImageVisualProperty.AlphaMaskURL, new PropertyValue(value));
712 /// Whether to crop image to mask or scale mask to fit image.
714 /// <since_tizen> 6 </since_tizen>
715 public bool CropToMask
720 PropertyMap imageMap = new PropertyMap();
721 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
722 imageMap?.Find(ImageVisualProperty.CropToMask)?.Get(out ret);
728 UpdateImage(ImageVisualProperty.CropToMask, new PropertyValue(value));
734 /// Gets or sets fitting options used when resizing images to fit the desired dimensions.<br />
735 /// If not supplied, the default is FittingModeType.ShrinkToFit.<br />
736 /// For normal quad images only.<br />
739 /// <since_tizen> 6 </since_tizen>
740 [EditorBrowsable(EditorBrowsableState.Never)]
741 public FittingModeType FittingMode
745 int ret = (int)FittingModeType.ShrinkToFit;
746 PropertyMap imageMap = new PropertyMap();
747 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
748 imageMap?.Find(ImageVisualProperty.FittingMode)?.Get(out ret);
750 return (FittingModeType)ret;
754 UpdateImage(ImageVisualProperty.CropToMask, new PropertyValue((int)value));
761 /// Gets or sets the desired image width.<br />
762 /// If not specified, the actual image width is used.<br />
763 /// For normal quad images only.<br />
766 /// <since_tizen> 6 </since_tizen>
767 [EditorBrowsable(EditorBrowsableState.Never)]
768 public int DesiredWidth
773 PropertyMap imageMap = new PropertyMap();
774 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
775 imageMap?.Find(ImageVisualProperty.DesiredWidth)?.Get(out ret);
781 UpdateImage(ImageVisualProperty.DesiredWidth, new PropertyValue(value));
786 /// Gets or sets the desired image height.<br />
787 /// If not specified, the actual image height is used.<br />
788 /// For normal quad images only.<br />
791 /// <since_tizen> 6 </since_tizen>
792 [EditorBrowsable(EditorBrowsableState.Never)]
793 public int DesiredHeight
798 PropertyMap imageMap = new PropertyMap();
799 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
800 imageMap?.Find(ImageVisualProperty.DesiredHeight)?.Get(out ret);
806 UpdateImage(ImageVisualProperty.DesiredHeight, new PropertyValue(value));
812 /// Gets or sets the wrap mode for the u coordinate.<br />
813 /// It decides how the texture should be sampled when the u coordinate exceeds the range of 0.0 to 1.0.<br />
814 /// If not specified, the default is WrapModeType.Default(CLAMP).<br />
815 /// For normal quad images only.<br />
818 /// <since_tizen> 6 </since_tizen>
819 [EditorBrowsable(EditorBrowsableState.Never)]
820 public WrapModeType WrapModeU
824 int ret = (int)WrapModeType.Default;
825 PropertyMap imageMap = new PropertyMap();
826 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
827 imageMap?.Find(ImageVisualProperty.WrapModeU)?.Get(out ret);
829 return (WrapModeType)ret;
833 UpdateImage(ImageVisualProperty.WrapModeU, new PropertyValue((int)value));
838 /// Gets or sets the wrap mode for the v coordinate.<br />
839 /// It decides how the texture should be sampled when the v coordinate exceeds the range of 0.0 to 1.0.<br />
840 /// The first two elements indicate the top-left position of the area, and the last two elements are the areas of the width and the height respectively.<br />
841 /// If not specified, the default is WrapModeType.Default(CLAMP).<br />
842 /// For normal quad images only.
845 /// <since_tizen> 6 </since_tizen>
846 [EditorBrowsable(EditorBrowsableState.Never)]
847 public WrapModeType WrapModeV
851 int ret = (int)WrapModeType.Default;
852 PropertyMap imageMap = new PropertyMap();
853 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
854 imageMap?.Find(ImageVisualProperty.WrapModeV)?.Get(out ret);
856 return (WrapModeType)ret;
860 UpdateImage(ImageVisualProperty.WrapModeV, new PropertyValue((int)value));
865 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ImageView obj)
867 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
870 internal void SetImage(string url, Uint16Pair size)
872 if(url.Contains(".json"))
874 Tizen.Log.Fatal("NUI", "[ERROR] Please DO NOT set lottie file in ImageView! This is temporary checking, will be removed soon!");
878 Interop.ImageView.ImageView_SetImage__SWIG_2(swigCPtr, url, Uint16Pair.getCPtr(size));
879 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
884 internal ViewResourceReadySignal ResourceReadySignal(View view)
886 ViewResourceReadySignal ret = new ViewResourceReadySignal(Interop.View.ResourceReadySignal(View.getCPtr(view)), false);
887 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
891 internal ResourceLoadingStatusType GetResourceStatus()
893 return (ResourceLoadingStatusType)Interop.View.View_GetVisualResourceStatus(this.swigCPtr, Property.IMAGE);
897 /// you can override it to clean-up your own resources.
899 /// <param name="type">DisposeTypes</param>
900 /// <since_tizen> 3 </since_tizen>
901 protected override void Dispose(DisposeTypes type)
908 if (type == DisposeTypes.Explicit)
911 //Release your own managed resources here.
912 //You should release all of your own disposable objects here.
917 //Release your own unmanaged resources here.
918 //You should not access any managed member here except static instance.
919 //because the execution order of Finalizes is non-deterministic.
921 if (swigCPtr.Handle != global::System.IntPtr.Zero)
926 Interop.ImageView.delete_ImageView(swigCPtr);
928 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
934 // Callback for View ResourceReady signal
935 private void OnResourceReady(IntPtr data)
937 ResourceReadyEventArgs e = new ResourceReadyEventArgs();
940 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
943 if (_resourceReadyEventHandler != null)
945 _resourceReadyEventHandler(this, e);
949 private void UpdateImageMap(PropertyMap fromMap)
951 PropertyMap imageMap = new PropertyMap();
952 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
953 imageMap.Merge(fromMap);
955 SetProperty(ImageView.Property.IMAGE, new PropertyValue(imageMap));
958 private void UpdateImage(int key, PropertyValue value)
960 PropertyMap temp = new PropertyMap();
962 if (_resourceUrl == "")
964 temp.Insert(ImageVisualProperty.URL, new PropertyValue(_resourceUrl));
965 SetProperty(ImageView.Property.IMAGE, new PropertyValue(temp));
971 temp.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
975 temp.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.NPatch));
976 temp.Insert(NpatchImageVisualProperty.Border, new PropertyValue(_border));
979 temp.Insert(NpatchImageVisualProperty.SynchronousLoading, new PropertyValue(_synchronosLoading));
983 temp.Insert(key, value);
986 UpdateImageMap(temp);
993 private void OnResourceLoaded(IntPtr view)
995 ResourceLoadedEventArgs e = new ResourceLoadedEventArgs();
996 e.Status = (ResourceLoadingStatusType)Interop.View.View_GetVisualResourceStatus(this.swigCPtr, Property.IMAGE);
998 if (_resourceLoadedEventHandler != null)
1000 _resourceLoadedEventHandler(this, e);
1005 /// Event arguments of resource ready.
1007 /// <since_tizen> 3 </since_tizen>
1008 public class ResourceReadyEventArgs : EventArgs
1013 /// The view whose resource is ready.
1015 /// <since_tizen> 3 </since_tizen>
1029 internal class ResourceLoadedEventArgs : EventArgs
1031 private ResourceLoadingStatusType status = ResourceLoadingStatusType.Invalid;
1032 public ResourceLoadingStatusType Status
1045 internal new class Property
1047 internal static readonly int IMAGE = Interop.ImageView.ImageView_Property_IMAGE_get();
1048 internal static readonly int PRE_MULTIPLIED_ALPHA = Interop.ImageView.ImageView_Property_PRE_MULTIPLIED_ALPHA_get();
1049 internal static readonly int PIXEL_AREA = Interop.ImageView.ImageView_Property_PIXEL_AREA_get();
1050 internal static readonly int ACTION_RELOAD = Interop.ImageView.ImageView_IMAGE_VISUAL_ACTION_RELOAD_get();
1051 internal static readonly int ACTION_PLAY = Interop.ImageView.ImageView_IMAGE_VISUAL_ACTION_PLAY_get();
1052 internal static readonly int ACTION_PAUSE = Interop.ImageView.ImageView_IMAGE_VISUAL_ACTION_PAUSE_get();
1053 internal static readonly int ACTION_STOP = Interop.ImageView.ImageView_IMAGE_VISUAL_ACTION_STOP_get();
1056 private enum ImageType
1059 /// For Normal Image.
1064 /// For normal image, with synchronous loading and orientation correction property
1069 /// For nine-patch image