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 />
495 /// The property cascade chaining set is possible. For example, this (imageView.PixelArea.X = 0.1f;) is possible.
497 /// <since_tizen> 3 </since_tizen>
498 public RelativeVector4 PixelArea
502 RelativeVector4 temp = (RelativeVector4)GetValue(PixelAreaProperty);
503 return new RelativeVector4(OnPixelAreaChanged, temp.X, temp.Y, temp.Z, temp.W);
507 SetValue(PixelAreaProperty, value);
508 NotifyPropertyChanged();
513 /// The border of the image in the order: left, right, bottom, top.<br />
514 /// If set, ImageMap will be ignored.<br />
515 /// For N-Patch images only.<br />
519 /// The property cascade chaining set is possible. For example, this (imageView.Border.X = 1;) is possible.
521 /// <since_tizen> 3 </since_tizen>
522 public Rectangle Border
526 Rectangle temp = (Rectangle)GetValue(BorderProperty);
527 return new Rectangle(OnBorderChanged, temp.X, temp.Y, temp.Width, temp.Height);
531 SetValue(BorderProperty, value);
532 NotifyPropertyChanged();
537 /// Gets or sets whether to draw the borders only (if true).<br />
538 /// If not specified, the default is false.<br />
539 /// For N-Patch images only.<br />
542 /// <since_tizen> 3 </since_tizen>
543 public bool BorderOnly
547 return (bool)GetValue(BorderOnlyProperty);
551 SetValue(BorderOnlyProperty, value);
552 NotifyPropertyChanged();
557 /// Gets or sets whether to synchronos loading the resourceurl of image.<br />
559 /// <since_tizen> 3 </since_tizen>
560 public bool SynchronosLoading
564 return (bool)GetValue(SynchronosLoadingProperty);
568 SetValue(SynchronosLoadingProperty, value);
569 NotifyPropertyChanged();
574 /// Gets or sets whether to automatically correct the orientation of an image.<br />
576 /// <since_tizen> 5 </since_tizen>
577 public bool OrientationCorrection
581 return (bool)GetValue(OrientationCorrectionProperty);
585 SetValue(OrientationCorrectionProperty, value);
586 NotifyPropertyChanged();
591 /// Gets the loading state of the visual resource.
593 /// <since_tizen> 5 </since_tizen>
594 public ImageView.LoadingStatusType LoadingStatus
598 return (ImageView.LoadingStatusType)Interop.View.View_GetVisualResourceStatus(swigCPtr, (int)Property.IMAGE);
603 /// Downcasts a handle to imageView handle.
605 /// Please do not use! this will be deprecated!
606 /// Instead please use as keyword.
607 /// <since_tizen> 3 </since_tizen>
608 [Obsolete("Please do not use! This will be deprecated! Please use as keyword instead! " +
610 "BaseHandle handle = new ImageView(imagePath); " +
611 "ImageView image = handle as ImageView")]
612 [EditorBrowsable(EditorBrowsableState.Never)]
613 public static ImageView DownCast(BaseHandle handle)
615 ImageView ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as ImageView;
616 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
621 /// Sets this ImageView from the given URL.<br />
622 /// If the URL is empty, ImageView will not display anything.<br />
624 /// <param name="url">The URL to the image resource to display.</param>
625 /// <since_tizen> 3 </since_tizen>
626 public void SetImage(string url)
628 if(url.Contains(".json"))
630 Tizen.Log.Fatal("NUI", "[ERROR] Please DO NOT set lottie file in ImageView! This is temporary checking, will be removed soon!");
634 Interop.ImageView.ImageView_SetImage__SWIG_1(swigCPtr, url);
635 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
641 /// Queries if all resources required by a control are loaded and ready.<br />
642 /// Most resources are only loaded when the control is placed on the stage.<br />
643 /// True if the resources are loaded and ready, false otherwise.<br />
645 /// <since_tizen> 3 </since_tizen>
646 public new bool IsResourceReady()
648 bool ret = Interop.View.IsResourceReady(swigCPtr);
649 if (NDalicPINVOKE.SWIGPendingException.Pending)
650 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
655 /// Forcefully reloads the image. All the visuals using this image will reload to the latest image.
657 /// <since_tizen> 5 </since_tizen>
660 this.DoAction(ImageView.Property.IMAGE, Property.ACTION_RELOAD, new PropertyValue(0));
664 /// Plays the animated GIF. This is also the default playback mode.
666 /// <since_tizen> 5 </since_tizen>
669 this.DoAction(ImageView.Property.IMAGE, Property.ACTION_PLAY, new PropertyValue(0));
673 /// Pauses the animated GIF.
675 /// <since_tizen> 5 </since_tizen>
678 this.DoAction(ImageView.Property.IMAGE, Property.ACTION_PAUSE, new PropertyValue(0));
682 /// Stops the animated GIF.
684 /// <since_tizen> 5 </since_tizen>
687 this.DoAction(ImageView.Property.IMAGE, Property.ACTION_STOP, new PropertyValue(0));
691 /// Gets or sets the URL of the alpha mask.<br />
694 /// <since_tizen> 6</since_tizen>
695 [EditorBrowsable(EditorBrowsableState.Never)]
696 public string AlphaMaskURL
701 PropertyMap imageMap = new PropertyMap();
702 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
703 imageMap?.Find(ImageVisualProperty.AlphaMaskURL)?.Get(out ret);
714 UpdateImage(ImageVisualProperty.AlphaMaskURL, new PropertyValue(value));
720 /// Whether to crop image to mask or scale mask to fit image.
722 /// <since_tizen> 6 </since_tizen>
723 public bool CropToMask
728 PropertyMap imageMap = new PropertyMap();
729 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
730 imageMap?.Find(ImageVisualProperty.CropToMask)?.Get(out ret);
736 UpdateImage(ImageVisualProperty.CropToMask, new PropertyValue(value));
742 /// Gets or sets fitting options used when resizing images to fit the desired dimensions.<br />
743 /// If not supplied, the default is FittingModeType.ShrinkToFit.<br />
744 /// For normal quad images only.<br />
747 /// <since_tizen> 6 </since_tizen>
748 [EditorBrowsable(EditorBrowsableState.Never)]
749 public FittingModeType FittingMode
753 int ret = (int)FittingModeType.ShrinkToFit;
754 PropertyMap imageMap = new PropertyMap();
755 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
756 imageMap?.Find(ImageVisualProperty.FittingMode)?.Get(out ret);
758 return (FittingModeType)ret;
762 UpdateImage(ImageVisualProperty.CropToMask, new PropertyValue((int)value));
769 /// Gets or sets the desired image width.<br />
770 /// If not specified, the actual image width is used.<br />
771 /// For normal quad images only.<br />
774 /// <since_tizen> 6 </since_tizen>
775 [EditorBrowsable(EditorBrowsableState.Never)]
776 public int DesiredWidth
781 PropertyMap imageMap = new PropertyMap();
782 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
783 imageMap?.Find(ImageVisualProperty.DesiredWidth)?.Get(out ret);
789 UpdateImage(ImageVisualProperty.DesiredWidth, new PropertyValue(value));
794 /// Gets or sets the desired image height.<br />
795 /// If not specified, the actual image height is used.<br />
796 /// For normal quad images only.<br />
799 /// <since_tizen> 6 </since_tizen>
800 [EditorBrowsable(EditorBrowsableState.Never)]
801 public int DesiredHeight
806 PropertyMap imageMap = new PropertyMap();
807 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
808 imageMap?.Find(ImageVisualProperty.DesiredHeight)?.Get(out ret);
814 UpdateImage(ImageVisualProperty.DesiredHeight, new PropertyValue(value));
820 /// Gets or sets the wrap mode for the u coordinate.<br />
821 /// It decides how the texture should be sampled when the u coordinate exceeds the range of 0.0 to 1.0.<br />
822 /// If not specified, the default is WrapModeType.Default(CLAMP).<br />
823 /// For normal quad images only.<br />
826 /// <since_tizen> 6 </since_tizen>
827 [EditorBrowsable(EditorBrowsableState.Never)]
828 public WrapModeType WrapModeU
832 int ret = (int)WrapModeType.Default;
833 PropertyMap imageMap = new PropertyMap();
834 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
835 imageMap?.Find(ImageVisualProperty.WrapModeU)?.Get(out ret);
837 return (WrapModeType)ret;
841 UpdateImage(ImageVisualProperty.WrapModeU, new PropertyValue((int)value));
846 /// Gets or sets the wrap mode for the v coordinate.<br />
847 /// It decides how the texture should be sampled when the v coordinate exceeds the range of 0.0 to 1.0.<br />
848 /// 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 />
849 /// If not specified, the default is WrapModeType.Default(CLAMP).<br />
850 /// For normal quad images only.
853 /// <since_tizen> 6 </since_tizen>
854 [EditorBrowsable(EditorBrowsableState.Never)]
855 public WrapModeType WrapModeV
859 int ret = (int)WrapModeType.Default;
860 PropertyMap imageMap = new PropertyMap();
861 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
862 imageMap?.Find(ImageVisualProperty.WrapModeV)?.Get(out ret);
864 return (WrapModeType)ret;
868 UpdateImage(ImageVisualProperty.WrapModeV, new PropertyValue((int)value));
873 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ImageView obj)
875 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
878 internal void SetImage(string url, Uint16Pair size)
880 if(url.Contains(".json"))
882 Tizen.Log.Fatal("NUI", "[ERROR] Please DO NOT set lottie file in ImageView! This is temporary checking, will be removed soon!");
886 Interop.ImageView.ImageView_SetImage__SWIG_2(swigCPtr, url, Uint16Pair.getCPtr(size));
887 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
892 internal ViewResourceReadySignal ResourceReadySignal(View view)
894 ViewResourceReadySignal ret = new ViewResourceReadySignal(Interop.View.ResourceReadySignal(View.getCPtr(view)), false);
895 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
899 internal ResourceLoadingStatusType GetResourceStatus()
901 return (ResourceLoadingStatusType)Interop.View.View_GetVisualResourceStatus(this.swigCPtr, Property.IMAGE);
905 /// you can override it to clean-up your own resources.
907 /// <param name="type">DisposeTypes</param>
908 /// <since_tizen> 3 </since_tizen>
909 protected override void Dispose(DisposeTypes type)
916 if (type == DisposeTypes.Explicit)
919 //Release your own managed resources here.
920 //You should release all of your own disposable objects here.
925 //Release your own unmanaged resources here.
926 //You should not access any managed member here except static instance.
927 //because the execution order of Finalizes is non-deterministic.
929 if (swigCPtr.Handle != global::System.IntPtr.Zero)
934 Interop.ImageView.delete_ImageView(swigCPtr);
936 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
942 // Callback for View ResourceReady signal
943 private void OnResourceReady(IntPtr data)
945 ResourceReadyEventArgs e = new ResourceReadyEventArgs();
948 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
951 if (_resourceReadyEventHandler != null)
953 _resourceReadyEventHandler(this, e);
957 private void UpdateImageMap(PropertyMap fromMap)
959 PropertyMap imageMap = new PropertyMap();
960 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
961 imageMap.Merge(fromMap);
963 SetProperty(ImageView.Property.IMAGE, new PropertyValue(imageMap));
966 private void UpdateImage(int key, PropertyValue value)
968 PropertyMap temp = new PropertyMap();
970 if (_resourceUrl == "")
972 temp.Insert(ImageVisualProperty.URL, new PropertyValue(_resourceUrl));
973 SetProperty(ImageView.Property.IMAGE, new PropertyValue(temp));
979 temp.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
983 temp.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.NPatch));
984 temp.Insert(NpatchImageVisualProperty.Border, new PropertyValue(_border));
987 temp.Insert(NpatchImageVisualProperty.SynchronousLoading, new PropertyValue(_synchronosLoading));
991 temp.Insert(key, value);
994 UpdateImageMap(temp);
1001 private void OnResourceLoaded(IntPtr view)
1003 ResourceLoadedEventArgs e = new ResourceLoadedEventArgs();
1004 e.Status = (ResourceLoadingStatusType)Interop.View.View_GetVisualResourceStatus(this.swigCPtr, Property.IMAGE);
1006 if (_resourceLoadedEventHandler != null)
1008 _resourceLoadedEventHandler(this, e);
1013 /// Event arguments of resource ready.
1015 /// <since_tizen> 3 </since_tizen>
1016 public class ResourceReadyEventArgs : EventArgs
1021 /// The view whose resource is ready.
1023 /// <since_tizen> 3 </since_tizen>
1037 internal class ResourceLoadedEventArgs : EventArgs
1039 private ResourceLoadingStatusType status = ResourceLoadingStatusType.Invalid;
1040 public ResourceLoadingStatusType Status
1053 internal new class Property
1055 internal static readonly int IMAGE = Interop.ImageView.ImageView_Property_IMAGE_get();
1056 internal static readonly int PRE_MULTIPLIED_ALPHA = Interop.ImageView.ImageView_Property_PRE_MULTIPLIED_ALPHA_get();
1057 internal static readonly int PIXEL_AREA = Interop.ImageView.ImageView_Property_PIXEL_AREA_get();
1058 internal static readonly int ACTION_RELOAD = Interop.ImageView.ImageView_IMAGE_VISUAL_ACTION_RELOAD_get();
1059 internal static readonly int ACTION_PLAY = Interop.ImageView.ImageView_IMAGE_VISUAL_ACTION_PLAY_get();
1060 internal static readonly int ACTION_PAUSE = Interop.ImageView.ImageView_IMAGE_VISUAL_ACTION_PAUSE_get();
1061 internal static readonly int ACTION_STOP = Interop.ImageView.ImageView_IMAGE_VISUAL_ACTION_STOP_get();
1064 private enum ImageType
1067 /// For Normal Image.
1072 /// For normal image, with synchronous loading and orientation correction property
1077 /// For nine-patch image
1082 private void OnBorderChanged(int x, int y, int width, int height)
1084 Border = new Rectangle(x, y, width, height);
1086 private void OnPixelAreaChanged(float x, float y, float z, float w)
1088 PixelArea = new RelativeVector4(x, y, z, w);