/*
- * Copyright(c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright(c) 2018 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.
using System;
using System.Runtime.InteropServices;
using System.ComponentModel;
+using Tizen.NUI.Binding;
namespace Tizen.NUI.BaseComponents
{
/// An instance of ImageView can be created using a URL or an image instance.<br />
/// </summary>
/// <since_tizen> 3 </since_tizen>
+ [ContentProperty("ResourceUrl")]
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("ResourceUrl", typeof(string), typeof(ImageView), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var imageView = (ImageView)bindable;
+ if (newValue != null)
+ {
+ imageView._url = (newValue == null? "" : (string)newValue);
+ imageView.UpdateImage();
+ }
+ Console.WriteLine("ImageView ResourceUrlProperty changed: oldValue: " + oldValue + ", newValue: " + newValue);
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var imageView = (ImageView)bindable;
+ Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.IMAGE).Get(out imageView._url);
+ return imageView._url;
+ });
+ /// 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("Image", typeof(PropertyMap), typeof(ImageView), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var imageView = (ImageView)bindable;
+ if (newValue != null)
+ {
+ if (imageView._border == null)
+ {
+ Tizen.NUI.Object.SetProperty(imageView.swigCPtr, ImageView.Property.IMAGE, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ }
+ Console.WriteLine("ImageView ImageProperty changed: oldValue: " + oldValue + ", newValue: " + newValue);
+ },
+ 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));
+ }
+ Console.WriteLine("ImageView PreMultipliedAlphaProperty changed: oldValue: " + oldValue + ", newValue: " + 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), new RelativeVector4(0,0,0,0), 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));
+ }
+ Console.WriteLine("ImageView PixelAreaProperty changed: oldValue: " + oldValue + ", newValue: " + 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), new Rectangle(0,0,0,0), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var imageView = (ImageView)bindable;
+ if (newValue != null)
+ {
+ imageView._border = (Rectangle)newValue;
+ imageView.UpdateImage();
+ }
+ Console.WriteLine("ImageView BorderProperty changed: oldValue: " + oldValue + ", newValue: " + newValue);
+ },
+ 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._borderOnly = (bool)newValue;
+ imageView.UpdateImage();
+ }
+ Console.WriteLine("ImageView BorderOnlyProperty changed: oldValue: " + oldValue + ", newValue: " + newValue);
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var imageView = (ImageView)bindable;
+ return imageView._borderOnly ?? false;
+ });
+ /// 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._synchronousLoading = (bool)newValue;
+ imageView.UpdateImage();
+ }
+ Console.WriteLine("ImageView SynchronosLoadingProperty changed: oldValue: " + oldValue + ", newValue: " + newValue);
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var imageView = (ImageView)bindable;
+ return imageView._synchronousLoading ?? false;
+ });
+ /// 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._orientationCorrection = (bool)newValue;
+ imageView.UpdateImage();
+ }
+ Console.WriteLine("ImageView OrientationCorrectionProperty changed: oldValue: " + oldValue + ", newValue: " + newValue);
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var imageView = (ImageView)bindable;
+ return imageView._orientationCorrection ?? false;
+ });
+
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
internal ImageView(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.ImageView_SWIGUpcast(cPtr), cMemoryOwn)
internal static readonly int IMAGE = NDalicPINVOKE.ImageView_Property_IMAGE_get();
internal static readonly int PRE_MULTIPLIED_ALPHA = NDalicPINVOKE.ImageView_Property_PRE_MULTIPLIED_ALPHA_get();
internal static readonly int PIXEL_AREA = NDalicPINVOKE.ImageView_Property_PIXEL_AREA_get();
+ internal static readonly int ACTION_RELOAD = NDalicManualPINVOKE.ImageView_IMAGE_VISUAL_ACTION_RELOAD_get();
+ internal static readonly int ACTION_PLAY = NDalicManualPINVOKE.ImageView_IMAGE_VISUAL_ACTION_PLAY_get();
+ internal static readonly int ACTION_PAUSE = NDalicManualPINVOKE.ImageView_IMAGE_VISUAL_ACTION_PAUSE_get();
+ internal static readonly int ACTION_STOP = NDalicManualPINVOKE.ImageView_IMAGE_VISUAL_ACTION_STOP_get();
}
/// <summary>
/// <since_tizen> 3 </since_tizen>
public ImageView() : this(NDalicPINVOKE.ImageView_New__SWIG_0(), true)
{
+ base.InitXamlResource();
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-
}
+
/// <summary>
/// Creates an initialized ImageView from a URL to an image resource.<br />
/// If the string is empty, ImageView will not display anything.<br />
}
/// <summary>
+ /// Downcasts a handle to imageView handle.
+ /// </summary>
+ /// Please do not use! this will be deprecated!
+ /// Instead please use as keyword.
+ /// <since_tizen> 3 </since_tizen>
+ [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;
+ }
+
+ /// <summary>
/// Sets this ImageView from the given URL.<br />
/// If the URL is empty, ImageView will not display anything.<br />
/// </summary>
}
/// <summary>
+ /// Force reloading of the image, all visuals using this image will get the latest one.
+ /// </summary>
+ /// <since_tizen> 5 </since_tizen>
+ public void Reload()
+ {
+ this.DoAction(ImageView.Property.IMAGE, Property.ACTION_RELOAD, new PropertyValue(0));
+ }
+
+ /// <summary>
+ /// Play the animated GIF. This is also Default playback mode.
+ /// </summary>
+ /// <since_tizen> 5 </since_tizen>
+ public void Play()
+ {
+ this.DoAction(ImageView.Property.IMAGE, Property.ACTION_PLAY, new PropertyValue(0));
+ }
+
+ /// <summary>
+ /// Pause the animated GIF.
+ /// </summary>
+ /// <since_tizen> 5 </since_tizen>
+ public void Pause()
+ {
+ this.DoAction(ImageView.Property.IMAGE, Property.ACTION_PAUSE, new PropertyValue(0));
+ }
+
+ /// <summary>
+ /// Stop the animated GIF.
+ /// </summary>
+ /// <since_tizen> 5 </since_tizen>
+ public void Stop()
+ {
+ this.DoAction(ImageView.Property.IMAGE, Property.ACTION_STOP, new PropertyValue(0));
+ }
+
+ /// <summary>
/// ImageView ResourceUrl, type string.
/// </summary>
/// <since_tizen> 3 </since_tizen>
{
get
{
- GetProperty(ImageView.Property.IMAGE).Get(out _url);
- return _url;
+ return (string)GetValue(ResourceUrlProperty);
}
set
{
- _url = (value == null? "" : value);
- UpdateImage();
+ SetValue(ResourceUrlProperty, value);
+ NotifyPropertyChanged();
}
}
{
if (_url != null) { value.Add("url", new PropertyValue(_url)); }
SetProperty(ImageView.Property.IMAGE, new Tizen.NUI.PropertyValue(value));
+ NotifyPropertyChanged();
}
}
}
{
if (_border == null)
{
- PropertyMap temp = new PropertyMap();
- GetProperty(ImageView.Property.IMAGE).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(ImageProperty);
}
else
{
{
if (_border == null)
{
- if(_url != null) { value.Add("url", new PropertyValue(_url)); }
- SetProperty(ImageView.Property.IMAGE, new Tizen.NUI.PropertyValue(value));
+ SetValue(ImageProperty, value);
+ NotifyPropertyChanged();
}
}
}
{
get
{
- bool temp = false;
- GetProperty(ImageView.Property.PRE_MULTIPLIED_ALPHA).Get(out temp);
- return temp;
+ return (bool)GetValue(PreMultipliedAlphaProperty);
}
set
{
- SetProperty(ImageView.Property.PRE_MULTIPLIED_ALPHA, new Tizen.NUI.PropertyValue(value));
+ SetValue(PreMultipliedAlphaProperty, value);
+ NotifyPropertyChanged();
}
}
{
get
{
- Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
- GetProperty(ImageView.Property.PIXEL_AREA).Get(temp);
- return temp;
+ return (RelativeVector4)GetValue(PixelAreaProperty);
}
set
{
- SetProperty(ImageView.Property.PIXEL_AREA, new Tizen.NUI.PropertyValue(value));
+ SetValue(PixelAreaProperty, value);
+ NotifyPropertyChanged();
}
}
{
get
{
- return _border;
+ return (Rectangle)GetValue(BorderProperty);
}
set
{
- _border = value;
- UpdateImage();
+ SetValue(BorderProperty, value);
+ NotifyPropertyChanged();
}
}
{
get
{
- return _borderOnly ?? false;
+ return (bool)GetValue(BorderOnlyProperty);
}
set
{
- _borderOnly = value;
- UpdateImage();
+ SetValue(BorderOnlyProperty, value);
+ NotifyPropertyChanged();
}
}
{
get
{
- return _synchronousLoading ?? false;
+ return (bool)GetValue(SynchronosLoadingProperty);
}
set
{
- _synchronousLoading = value;
- UpdateImage();
+ SetValue(SynchronosLoadingProperty, value);
+ NotifyPropertyChanged();
}
}
{
get
{
- return _orientationCorrection ?? false;
+ return (bool)GetValue(OrientationCorrectionProperty);
}
set
{
- _orientationCorrection = value;
- UpdateImage();
+ SetValue(OrientationCorrectionProperty, value);
+ NotifyPropertyChanged();
}
}