/*
* Copyright(c) 2019 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
using System;
using System.Runtime.InteropServices;
using System.ComponentModel;
using Tizen.NUI.Binding;
namespace Tizen.NUI.BaseComponents
{
///
/// ImageView is a class for displaying an image resource.
/// An instance of ImageView can be created using a URL or an image instance.
///
/// 3
public class ImageView : View
{
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty ResourceUrlProperty = BindableProperty.Create(nameof(ImageView.ResourceUrl), typeof(string), typeof(ImageView), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
{
var imageView = (ImageView)bindable;
string url = (string)newValue;
url = (url == null ? "" : url);
if (imageView.IsCreateByXaml && url.Contains("*Resource*"))
{
string resource = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
url = url.Replace("*Resource*", resource);
}
imageView._resourceUrl = url;
imageView.UpdateImage(ImageVisualProperty.URL, new PropertyValue(url));
},
defaultValueCreator: (bindable) =>
{
var imageView = (ImageView)bindable;
string ret = "";
PropertyMap imageMap = new PropertyMap();
Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
imageMap.Find(ImageVisualProperty.URL)?.Get(out ret);
return ret;
});
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty ImageProperty = BindableProperty.Create(nameof(ImageView.Image), typeof(PropertyMap), typeof(ImageView), null, propertyChanged: (bindable, oldValue, newValue) =>
{
var imageView = (ImageView)bindable;
if (newValue != null)
{
PropertyMap map = (PropertyMap)newValue;
if (imageView.IsCreateByXaml)
{
string url = "", alphaMaskURL = "", auxiliaryImageURL = "";
string resource = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
PropertyValue urlValue = map.Find(NDalic.IMAGE_VISUAL_URL);
bool ret = false;
if (urlValue != null) ret = urlValue.Get(out url);
PropertyMap mmap = new PropertyMap();
if (ret && url.Contains("*Resource*"))
{
url = url.Replace("*Resource*", resource);
mmap.Insert(NDalic.IMAGE_VISUAL_URL, new PropertyValue(url));
}
ret = false;
PropertyValue alphaMaskUrlValue = map.Find(NDalic.IMAGE_VISUAL_ALPHA_MASK_URL);
if (alphaMaskUrlValue != null) ret = alphaMaskUrlValue.Get(out alphaMaskURL);
if (ret && alphaMaskURL.Contains("*Resource*"))
{
alphaMaskURL = alphaMaskURL.Replace("*Resource*", resource);
mmap.Insert(NDalic.IMAGE_VISUAL_URL, new PropertyValue(alphaMaskURL));
}
ret = false;
PropertyValue auxiliaryImageURLValue = map.Find(NDalic.IMAGE_VISUAL_AUXILIARY_IMAGE_URL);
if (auxiliaryImageURLValue != null) ret = auxiliaryImageURLValue.Get(out auxiliaryImageURL);
if (ret && auxiliaryImageURL.Contains("*Resource*"))
{
auxiliaryImageURL = auxiliaryImageURL.Replace("*Resource*", resource);
mmap.Insert(NDalic.IMAGE_VISUAL_AUXILIARY_IMAGE_URL, new PropertyValue(auxiliaryImageURL));
}
map.Merge(mmap);
}
if (imageView._border == null)
{
Tizen.NUI.Object.SetProperty(imageView.swigCPtr, ImageView.Property.IMAGE, new Tizen.NUI.PropertyValue(map));
}
}
},
defaultValueCreator: (bindable) =>
{
var imageView = (ImageView)bindable;
if (imageView._border == null)
{
PropertyMap temp = new PropertyMap();
Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.IMAGE).Get(temp);
return temp;
}
else
{
return null;
}
});
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty PreMultipliedAlphaProperty = BindableProperty.Create("PreMultipliedAlpha", typeof(bool), typeof(ImageView), false, propertyChanged: (bindable, oldValue, newValue) =>
{
var imageView = (ImageView)bindable;
if (newValue != null)
{
Tizen.NUI.Object.SetProperty(imageView.swigCPtr, ImageView.Property.PRE_MULTIPLIED_ALPHA, new Tizen.NUI.PropertyValue((bool)newValue));
}
},
defaultValueCreator: (bindable) =>
{
var imageView = (ImageView)bindable;
bool temp = false;
Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.PRE_MULTIPLIED_ALPHA).Get(out temp);
return temp;
});
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty PixelAreaProperty = BindableProperty.Create("PixelArea", typeof(RelativeVector4), typeof(ImageView), null, propertyChanged: (bindable, oldValue, newValue) =>
{
var imageView = (ImageView)bindable;
if (newValue != null)
{
Tizen.NUI.Object.SetProperty(imageView.swigCPtr, ImageView.Property.PIXEL_AREA, new Tizen.NUI.PropertyValue((RelativeVector4)newValue));
}
},
defaultValueCreator: (bindable) =>
{
var imageView = (ImageView)bindable;
Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.PIXEL_AREA).Get(temp);
RelativeVector4 relativeTemp = new RelativeVector4(temp.X, temp.Y, temp.Z, temp.W);
return relativeTemp;
});
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty BorderProperty = BindableProperty.Create("Border", typeof(Rectangle), typeof(ImageView), null, propertyChanged: (bindable, oldValue, newValue) =>
{
if(newValue != null)
{
var imageView = (ImageView)bindable;
imageView._border = (Rectangle)newValue;
imageView.UpdateImage(NpatchImageVisualProperty.Border, new PropertyValue(imageView._border));
}
},
defaultValueCreator: (bindable) =>
{
var imageView = (ImageView)bindable;
return imageView._border;
});
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty BorderOnlyProperty = BindableProperty.Create("BorderOnly", typeof(bool), typeof(ImageView), false, propertyChanged: (bindable, oldValue, newValue) =>
{
var imageView = (ImageView)bindable;
if (newValue != null)
{
imageView.UpdateImage(NpatchImageVisualProperty.BorderOnly, new PropertyValue((bool)newValue));
}
},
defaultValueCreator: (bindable) =>
{
var imageView = (ImageView)bindable;
bool ret = false;
PropertyMap imageMap = new PropertyMap();
Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
imageMap.Find(ImageVisualProperty.BorderOnly)?.Get(out ret);
return ret;
});
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty SynchronosLoadingProperty = BindableProperty.Create("SynchronosLoading", typeof(bool), typeof(ImageView), false, propertyChanged: (bindable, oldValue, newValue) =>
{
var imageView = (ImageView)bindable;
if (newValue != null)
{
imageView._synchronosLoading = (bool) newValue;
imageView.UpdateImage(NpatchImageVisualProperty.SynchronousLoading, new PropertyValue((bool)newValue));
}
},
defaultValueCreator: (bindable) =>
{
var imageView = (ImageView)bindable;
return imageView._synchronosLoading;
});
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty OrientationCorrectionProperty = BindableProperty.Create("OrientationCorrection", typeof(bool), typeof(ImageView), false, propertyChanged: (bindable, oldValue, newValue) =>
{
var imageView = (ImageView)bindable;
if (newValue != null)
{
imageView.UpdateImage(ImageVisualProperty.OrientationCorrection, new PropertyValue((bool)newValue));
}
},
defaultValueCreator: (bindable) =>
{
var imageView = (ImageView)bindable;
bool ret = false;
PropertyMap imageMap = new PropertyMap();
Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
imageMap?.Find(ImageVisualProperty.OrientationCorrection)?.Get(out ret);
return ret;
});
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
private EventHandler _resourceReadyEventHandler;
private ResourceReadyEventCallbackType _resourceReadyEventCallback;
private EventHandler _resourceLoadedEventHandler;
private _resourceLoadedCallbackType _resourceLoadedCallback;
private Rectangle _border;
private string _resourceUrl = "";
private bool _synchronosLoading = false;
///
/// Creates an initialized ImageView.
///
/// 3
public ImageView() : this(Interop.ImageView.ImageView_New__SWIG_0(), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Creates an initialized ImageView with setting the status of shown or hidden.
///
/// false : Not displayed (hidden), true : displayed (shown)
/// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
[EditorBrowsable(EditorBrowsableState.Never)]
public ImageView(bool shown) : this(Interop.ImageView.ImageView_New__SWIG_0(), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
SetVisible(shown);
}
///
/// Creates an initialized ImageView from a URL to an image resource.
/// If the string is empty, ImageView will not display anything.
///
/// The URL of the image resource to display.
/// 3
public ImageView(string url) : this(Interop.ImageView.ImageView_New__SWIG_2(url), true)
{
ResourceUrl = url;
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Creates an initialized ImageView from a URL to an image resource with setting shown or hidden.
///
/// The URL of the image resource to display.
/// false : Not displayed (hidden), true : displayed (shown)
/// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
[EditorBrowsable(EditorBrowsableState.Never)]
public ImageView(string url, bool shown) : this(Interop.ImageView.ImageView_New__SWIG_2(url), true)
{
ResourceUrl = url;
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
SetVisible(shown);
}
internal ImageView(string url, Uint16Pair size, bool shown = true) : this(Interop.ImageView.ImageView_New__SWIG_3(url, Uint16Pair.getCPtr(size)), true)
{
ResourceUrl = url;
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
if (!shown)
{
SetVisible(false);
}
}
internal ImageView(global::System.IntPtr cPtr, bool cMemoryOwn, bool shown = true) : base(Interop.ImageView.ImageView_SWIGUpcast(cPtr), cMemoryOwn)
{
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
if (!shown)
{
SetVisible(false);
}
}
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
private delegate void ResourceReadyEventCallbackType(IntPtr data);
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
private delegate void _resourceLoadedCallbackType(IntPtr view);
///
/// An event for ResourceReady signal which can be used to subscribe or unsubscribe the event handler.
/// This signal is emitted after all resources required by a control are loaded and ready.
/// Most resources are only loaded when the control is placed on the stage.
///
/// 3
public event EventHandler ResourceReady
{
add
{
if (_resourceReadyEventHandler == null)
{
_resourceReadyEventCallback = OnResourceReady;
ResourceReadySignal(this).Connect(_resourceReadyEventCallback);
}
_resourceReadyEventHandler += value;
}
remove
{
_resourceReadyEventHandler -= value;
if (_resourceReadyEventHandler == null && ResourceReadySignal(this).Empty() == false)
{
ResourceReadySignal(this).Disconnect(_resourceReadyEventCallback);
}
}
}
internal event EventHandler ResourceLoaded
{
add
{
if (_resourceLoadedEventHandler == null)
{
_resourceLoadedCallback = OnResourceLoaded;
this.ResourceReadySignal(this).Connect(_resourceLoadedCallback);
}
_resourceLoadedEventHandler += value;
}
remove
{
_resourceLoadedEventHandler -= value;
if (_resourceLoadedEventHandler == null && this.ResourceReadySignal(this).Empty() == false)
{
this.ResourceReadySignal(this).Disconnect(_resourceLoadedCallback);
}
}
}
///
/// Enumeration for LoadingStatus of image.
///
/// 5
public enum LoadingStatusType
{
///
/// Loading preparing status.
///
/// 5
Preparing,
///
/// Loading ready status.
///
/// 5
Ready,
///
/// Loading failed status.
///
/// 5
Failed
}
///
/// ImageView ResourceUrl, type string.
/// This is one of mandatory property. Even if not set or null set, it sets empty string ("") internally.
/// When it is set as null, it gives empty string ("") to be read.
///
/// 3
public string ResourceUrl
{
get
{
return (string)GetValue(ResourceUrlProperty);
}
set
{
SetValue(ResourceUrlProperty, value);
NotifyPropertyChanged();
}
}
///
/// This will be deprecated, please use Image instead.
/// ImageView ImageMap, type PropertyMap: string if it is a URL, map otherwise.
///
/// 3
[Obsolete("Please do not use! This will be deprecated! Please use Image property instead!")]
[EditorBrowsable(EditorBrowsableState.Never)]
public PropertyMap ImageMap
{
get
{
if (_border == null)
{
PropertyMap temp = new PropertyMap();
GetProperty(ImageView.Property.IMAGE).Get(temp);
return temp;
}
else
{
return null;
}
}
set
{
if (_border == null)
{
SetProperty(ImageView.Property.IMAGE, new Tizen.NUI.PropertyValue(value));
NotifyPropertyChanged();
}
}
}
///
/// ImageView Image, type PropertyMap
///
/// 4
public PropertyMap Image
{
get
{
if (_border == null)
{
return (PropertyMap)GetValue(ImageProperty);
}
else
{
return null;
}
}
set
{
if (_border == null)
{
SetValue(ImageProperty, value);
NotifyPropertyChanged();
}
}
}
///
/// ImageView PreMultipliedAlpha, type Boolean.
/// Image must be initialized.
///
/// 3
public bool PreMultipliedAlpha
{
get
{
return (bool)GetValue(PreMultipliedAlphaProperty);
}
set
{
SetValue(PreMultipliedAlphaProperty, value);
NotifyPropertyChanged();
}
}
///
/// ImageView PixelArea, type Vector4 (Animatable property).
/// Pixel area is a relative value with the whole image area as [0.0, 0.0, 1.0, 1.0].
///
/// 3
public RelativeVector4 PixelArea
{
get
{
return (RelativeVector4)GetValue(PixelAreaProperty);
}
set
{
SetValue(PixelAreaProperty, value);
NotifyPropertyChanged();
}
}
///
/// The border of the image in the order: left, right, bottom, top.
/// If set, ImageMap will be ignored.
/// For N-Patch images only.
/// Optional.
///
/// 3
public Rectangle Border
{
get
{
return (Rectangle)GetValue(BorderProperty);
}
set
{
SetValue(BorderProperty, value);
NotifyPropertyChanged();
}
}
///
/// Gets or sets whether to draw the borders only (if true).
/// If not specified, the default is false.
/// For N-Patch images only.
/// Optional.
///
/// 3
public bool BorderOnly
{
get
{
return (bool)GetValue(BorderOnlyProperty);
}
set
{
SetValue(BorderOnlyProperty, value);
NotifyPropertyChanged();
}
}
///
/// Gets or sets whether to synchronos loading the resourceurl of image.
///
/// 3
public bool SynchronosLoading
{
get
{
return (bool)GetValue(SynchronosLoadingProperty);
}
set
{
SetValue(SynchronosLoadingProperty, value);
NotifyPropertyChanged();
}
}
///
/// Gets or sets whether to automatically correct the orientation of an image.
///
/// 5
public bool OrientationCorrection
{
get
{
return (bool)GetValue(OrientationCorrectionProperty);
}
set
{
SetValue(OrientationCorrectionProperty, value);
NotifyPropertyChanged();
}
}
///
/// Gets the loading state of the visual resource.
///
/// 5
public ImageView.LoadingStatusType LoadingStatus
{
get
{
return (ImageView.LoadingStatusType)Interop.View.View_GetVisualResourceStatus(swigCPtr, (int)Property.IMAGE);
}
}
///
/// Downcasts a handle to imageView handle.
///
/// Please do not use! this will be deprecated!
/// Instead please use as keyword.
/// 3
[Obsolete("Please do not use! This will be deprecated! Please use as keyword instead! " +
"Like: " +
"BaseHandle handle = new ImageView(imagePath); " +
"ImageView image = handle as ImageView")]
[EditorBrowsable(EditorBrowsableState.Never)]
public static ImageView DownCast(BaseHandle handle)
{
ImageView ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as ImageView;
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Sets this ImageView from the given URL.
/// If the URL is empty, ImageView will not display anything.
///
/// The URL to the image resource to display.
/// 3
public void SetImage(string url)
{
if(url.Contains(".json"))
{
Tizen.Log.Fatal("NUI", "[ERROR] Please DO NOT set lottie file in ImageView! This is temporary checking, will be removed soon!");
return;
}
Interop.ImageView.ImageView_SetImage__SWIG_1(swigCPtr, url);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
ResourceUrl = url;
}
///
/// Queries if all resources required by a control are loaded and ready.
/// Most resources are only loaded when the control is placed on the stage.
/// True if the resources are loaded and ready, false otherwise.
///
/// 3
public new bool IsResourceReady()
{
bool ret = Interop.View.IsResourceReady(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending)
throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Forcefully reloads the image. All the visuals using this image will reload to the latest image.
///
/// 5
public void Reload()
{
this.DoAction(ImageView.Property.IMAGE, Property.ACTION_RELOAD, new PropertyValue(0));
}
///
/// Plays the animated GIF. This is also the default playback mode.
///
/// 5
public void Play()
{
this.DoAction(ImageView.Property.IMAGE, Property.ACTION_PLAY, new PropertyValue(0));
}
///
/// Pauses the animated GIF.
///
/// 5
public void Pause()
{
this.DoAction(ImageView.Property.IMAGE, Property.ACTION_PAUSE, new PropertyValue(0));
}
///
/// Stops the animated GIF.
///
/// 5
public void Stop()
{
this.DoAction(ImageView.Property.IMAGE, Property.ACTION_STOP, new PropertyValue(0));
}
///
/// Gets or sets the URL of the alpha mask.
/// Optional.
///
/// 6
[EditorBrowsable(EditorBrowsableState.Never)]
public string AlphaMaskURL
{
get
{
string ret = "";
PropertyMap imageMap = new PropertyMap();
Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
imageMap?.Find(ImageVisualProperty.AlphaMaskURL)?.Get(out ret);
return ret;
}
set
{
if (value == null)
{
value = "";
}
UpdateImage(ImageVisualProperty.AlphaMaskURL, new PropertyValue(value));
}
}
///
/// Whether to crop image to mask or scale mask to fit image.
///
/// 6
public bool CropToMask
{
get
{
bool ret = false;
PropertyMap imageMap = new PropertyMap();
Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
imageMap?.Find(ImageVisualProperty.CropToMask)?.Get(out ret);
return ret;
}
set
{
UpdateImage(ImageVisualProperty.CropToMask, new PropertyValue(value));
}
}
///
/// Gets or sets fitting options used when resizing images to fit the desired dimensions.
/// If not supplied, the default is FittingModeType.ShrinkToFit.
/// For normal quad images only.
/// Optional.
///
/// 6
[EditorBrowsable(EditorBrowsableState.Never)]
public FittingModeType FittingMode
{
get
{
int ret = (int)FittingModeType.ShrinkToFit;
PropertyMap imageMap = new PropertyMap();
Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
imageMap?.Find(ImageVisualProperty.FittingMode)?.Get(out ret);
return (FittingModeType)ret;
}
set
{
UpdateImage(ImageVisualProperty.CropToMask, new PropertyValue((int)value));
}
}
///
/// Gets or sets the desired image width.
/// If not specified, the actual image width is used.
/// For normal quad images only.
/// Optional.
///
/// 6
[EditorBrowsable(EditorBrowsableState.Never)]
public int DesiredWidth
{
get
{
int ret = -1;
PropertyMap imageMap = new PropertyMap();
Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
imageMap?.Find(ImageVisualProperty.DesiredWidth)?.Get(out ret);
return ret;
}
set
{
UpdateImage(ImageVisualProperty.DesiredWidth, new PropertyValue(value));
}
}
///
/// Gets or sets the desired image height.
/// If not specified, the actual image height is used.
/// For normal quad images only.
/// Optional.
///
/// 6
[EditorBrowsable(EditorBrowsableState.Never)]
public int DesiredHeight
{
get
{
int ret = -1;
PropertyMap imageMap = new PropertyMap();
Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
imageMap?.Find(ImageVisualProperty.DesiredHeight)?.Get(out ret);
return ret;
}
set
{
UpdateImage(ImageVisualProperty.DesiredHeight, new PropertyValue(value));
}
}
///
/// Gets or sets the wrap mode for the u coordinate.
/// It decides how the texture should be sampled when the u coordinate exceeds the range of 0.0 to 1.0.
/// If not specified, the default is WrapModeType.Default(CLAMP).
/// For normal quad images only.
/// Optional.
///
/// 6
[EditorBrowsable(EditorBrowsableState.Never)]
public WrapModeType WrapModeU
{
get
{
int ret = (int)WrapModeType.Default;
PropertyMap imageMap = new PropertyMap();
Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
imageMap?.Find(ImageVisualProperty.WrapModeU)?.Get(out ret);
return (WrapModeType)ret;
}
set
{
UpdateImage(ImageVisualProperty.WrapModeU, new PropertyValue((int)value));
}
}
///
/// Gets or sets the wrap mode for the v coordinate.
/// It decides how the texture should be sampled when the v coordinate exceeds the range of 0.0 to 1.0.
/// 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.
/// If not specified, the default is WrapModeType.Default(CLAMP).
/// For normal quad images only.
/// Optional.
///
/// 6
[EditorBrowsable(EditorBrowsableState.Never)]
public WrapModeType WrapModeV
{
get
{
int ret = (int)WrapModeType.Default;
PropertyMap imageMap = new PropertyMap();
Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
imageMap?.Find(ImageVisualProperty.WrapModeV)?.Get(out ret);
return (WrapModeType)ret;
}
set
{
UpdateImage(ImageVisualProperty.WrapModeV, new PropertyValue((int)value));
}
}
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ImageView obj)
{
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
}
internal void SetImage(string url, Uint16Pair size)
{
if(url.Contains(".json"))
{
Tizen.Log.Fatal("NUI", "[ERROR] Please DO NOT set lottie file in ImageView! This is temporary checking, will be removed soon!");
return;
}
Interop.ImageView.ImageView_SetImage__SWIG_2(swigCPtr, url, Uint16Pair.getCPtr(size));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
ResourceUrl = url;
}
internal ViewResourceReadySignal ResourceReadySignal(View view)
{
ViewResourceReadySignal ret = new ViewResourceReadySignal(Interop.View.ResourceReadySignal(View.getCPtr(view)), false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal ResourceLoadingStatusType GetResourceStatus()
{
return (ResourceLoadingStatusType)Interop.View.View_GetVisualResourceStatus(this.swigCPtr, Property.IMAGE);
}
///
/// you can override it to clean-up your own resources.
///
/// DisposeTypes
/// 3
protected override void Dispose(DisposeTypes type)
{
if (disposed)
{
return;
}
if (type == DisposeTypes.Explicit)
{
//Called by User
//Release your own managed resources here.
//You should release all of your own disposable objects here.
_border?.Dispose();
_border = null;
}
//Release your own unmanaged resources here.
//You should not access any managed member here except static instance.
//because the execution order of Finalizes is non-deterministic.
if (swigCPtr.Handle != global::System.IntPtr.Zero)
{
if (swigCMemOwn)
{
swigCMemOwn = false;
Interop.ImageView.delete_ImageView(swigCPtr);
}
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
}
base.Dispose(type);
}
// Callback for View ResourceReady signal
private void OnResourceReady(IntPtr data)
{
ResourceReadyEventArgs e = new ResourceReadyEventArgs();
if (data != null)
{
e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
}
if (_resourceReadyEventHandler != null)
{
_resourceReadyEventHandler(this, e);
}
}
private void UpdateImageMap(PropertyMap fromMap)
{
PropertyMap imageMap = new PropertyMap();
Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
imageMap.Merge(fromMap);
SetProperty(ImageView.Property.IMAGE, new PropertyValue(imageMap));
}
private void UpdateImage(int key, PropertyValue value)
{
PropertyMap temp = new PropertyMap();
if (_resourceUrl == "")
{
temp.Insert(ImageVisualProperty.URL, new PropertyValue(_resourceUrl));
SetProperty(ImageView.Property.IMAGE, new PropertyValue(temp));
return;
}
if (_border == null)
{
temp.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
}
else
{
temp.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.NPatch));
temp.Insert(NpatchImageVisualProperty.Border, new PropertyValue(_border));
}
temp.Insert(NpatchImageVisualProperty.SynchronousLoading, new PropertyValue(_synchronosLoading));
if (value != null)
{
temp.Insert(key, value);
}
UpdateImageMap(temp);
temp.Dispose();
temp = null;
}
private void OnResourceLoaded(IntPtr view)
{
ResourceLoadedEventArgs e = new ResourceLoadedEventArgs();
e.Status = (ResourceLoadingStatusType)Interop.View.View_GetVisualResourceStatus(this.swigCPtr, Property.IMAGE);
if (_resourceLoadedEventHandler != null)
{
_resourceLoadedEventHandler(this, e);
}
}
///
/// Event arguments of resource ready.
///
/// 3
public class ResourceReadyEventArgs : EventArgs
{
private View _view;
///
/// The view whose resource is ready.
///
/// 3
public View View
{
get
{
return _view;
}
set
{
_view = value;
}
}
}
internal class ResourceLoadedEventArgs : EventArgs
{
private ResourceLoadingStatusType status = ResourceLoadingStatusType.Invalid;
public ResourceLoadingStatusType Status
{
get
{
return status;
}
set
{
status = value;
}
}
}
internal new class Property
{
internal static readonly int IMAGE = Interop.ImageView.ImageView_Property_IMAGE_get();
internal static readonly int PRE_MULTIPLIED_ALPHA = Interop.ImageView.ImageView_Property_PRE_MULTIPLIED_ALPHA_get();
internal static readonly int PIXEL_AREA = Interop.ImageView.ImageView_Property_PIXEL_AREA_get();
internal static readonly int ACTION_RELOAD = Interop.ImageView.ImageView_IMAGE_VISUAL_ACTION_RELOAD_get();
internal static readonly int ACTION_PLAY = Interop.ImageView.ImageView_IMAGE_VISUAL_ACTION_PLAY_get();
internal static readonly int ACTION_PAUSE = Interop.ImageView.ImageView_IMAGE_VISUAL_ACTION_PAUSE_get();
internal static readonly int ACTION_STOP = Interop.ImageView.ImageView_IMAGE_VISUAL_ACTION_STOP_get();
}
private enum ImageType
{
///
/// For Normal Image.
///
Normal = 0,
///
/// For normal image, with synchronous loading and orientation correction property
///
Specific = 1,
///
/// For nine-patch image
///
Npatch = 2,
}
}
}