/*
* 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.ComponentModel;
namespace Tizen.NUI
{
///
/// A value-type representing a property value.
///
/// 3
public class PropertyValue : Disposable
{
///
/// Creates a Size2D property value.
///
/// Size2D values.
/// 3
public PropertyValue(Size2D vectorValue) : this(Interop.PropertyValue.NewPropertyValueVector2(Size2D.getCPtr(vectorValue)), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Creates a Position2D property value.
///
/// Position2D values.
/// 3
public PropertyValue(Position2D vectorValue) : this(Interop.PropertyValue.NewPropertyValueVector2(Position2D.getCPtr(vectorValue)), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Creates a Position property value.
///
/// Position values.
/// 3
public PropertyValue(Position vectorValue) : this(Interop.PropertyValue.NewPropertyValueVector3(Position.getCPtr(vectorValue)), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Creates a Color property value.
///
/// Color values.
/// 3
public PropertyValue(Color vectorValue) : this(Interop.PropertyValue.NewPropertyValueVector4(Color.getCPtr(vectorValue)), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// The default constructor.
///
/// 3
public PropertyValue() : this(Interop.PropertyValue.NewPropertyValue(), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Creates a boolean property value.
///
/// A boolean value.
/// 3
public PropertyValue(bool boolValue) : this(Interop.PropertyValue.NewPropertyValue(boolValue), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Creates an integer property value.
///
/// An integer value.
/// 3
public PropertyValue(int integerValue) : this(Interop.PropertyValue.NewPropertyValue(integerValue), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Creates a float property value.
///
/// A floating-point value.
/// 3
public PropertyValue(float floatValue) : this(Interop.PropertyValue.NewPropertyValue(floatValue), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Creates a Vector2 property value.
///
/// A vector of 2 floating-point values.
/// 3
public PropertyValue(Vector2 vectorValue) : this(Interop.PropertyValue.NewPropertyValueVector2(Vector2.getCPtr(vectorValue)), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Creates a Vector3 property value.
///
/// A vector of 3 floating-point values.
/// 3
public PropertyValue(Vector3 vectorValue) : this(Interop.PropertyValue.NewPropertyValueVector3(Vector3.getCPtr(vectorValue)), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Creates a Vector4 property value.
///
/// A vector of 4 floating-point values.
/// 3
public PropertyValue(Vector4 vectorValue) : this(Interop.PropertyValue.NewPropertyValueVector4(Vector4.getCPtr(vectorValue)), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Creates a Rectangle property value.
///
/// Rectangle values.
/// 3
public PropertyValue(Rectangle vectorValue) : this(Interop.PropertyValue.NewPropertyValueRect(Rectangle.getCPtr(vectorValue)), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Creates a Rotation property value.
///
/// Rotation values.
/// 3
public PropertyValue(Rotation quaternion) : this(Interop.PropertyValue.NewPropertyValueQuaternion(Rotation.getCPtr(quaternion)), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Creates a string property value.
///
/// A string.
/// 3
public PropertyValue(string stringValue) : this(Interop.PropertyValue.NewPropertyValueString(stringValue), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Creates an array property value.
///
/// An array.
/// 3
public PropertyValue(PropertyArray arrayValue) : this(Interop.PropertyValue.NewPropertyValueArray(PropertyArray.getCPtr(arrayValue)), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Creates a map property value.
///
/// An array.
/// 3
public PropertyValue(PropertyMap mapValue) : this(Interop.PropertyValue.NewPropertyValueMap(PropertyMap.getCPtr(mapValue)), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Creates a Extents value.
///
/// A Extents value.
/// 4
public PropertyValue(Extents extentsValue) : this(Interop.PropertyValue.NewPropertyValueExtents(Extents.getCPtr(extentsValue)), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Creates a PropertyType value.
///
/// A PropertyType value.
/// 3
public PropertyValue(PropertyType type) : this(Interop.PropertyValue.NewPropertyValueType((int)type), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Creates a PropertyValue value.
///
/// A PropertyValue value.
/// 3
public PropertyValue(PropertyValue value) : this(Interop.PropertyValue.NewPropertyValueValue(PropertyValue.getCPtr(value)), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Creates a Size property value.
///
/// Size values.
internal PropertyValue(Size vectorValue) : this(Interop.PropertyValue.NewPropertyValueVector3(Size.getCPtr(vectorValue)), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
internal PropertyValue(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
{
}
internal PropertyValue(Matrix3 matrixValue) : this(Interop.PropertyValue.NewPropertyValueMatrix3(Matrix3.getCPtr(matrixValue)), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
internal PropertyValue(Matrix matrixValue) : this(Interop.PropertyValue.NewPropertyValueMatrix(Matrix.getCPtr(matrixValue)), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
internal PropertyValue(AngleAxis angleAxis) : this(Interop.PropertyValue.NewPropertyValueAngleAxis(AngleAxis.getCPtr(angleAxis)), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// An extension to the property value class that allows us to create a
/// Property value from a C# object, for example, integer, float, or string.
///
/// An object to create.
/// The created value.
/// Thrown when obj is null.
/// 3
static public PropertyValue CreateFromObject(System.Object obj)
{
if (null == obj)
{
throw new global::System.ArgumentNullException(nameof(obj));
}
System.Type type = obj.GetType();
PropertyValue value;
if (type.IsEnum)
{
value = new PropertyValue((int)obj);//Enum.Parse(type, str);
}
else if (type.Equals(typeof(int)))
{
value = new PropertyValue((int)obj);
}
else if (type.Equals(typeof(System.Int32)))
{
value = new PropertyValue((int)obj);
}
else if (type.Equals(typeof(bool)))
{
value = new PropertyValue((bool)obj);
}
else if (type.Equals(typeof(float)))
{
value = new PropertyValue((float)obj);
}
else if (type.Equals(typeof(string)))
{
value = new PropertyValue((string)obj);
}
else if (type.Equals(typeof(Vector2)))
{
value = new PropertyValue((Vector2)obj);
}
else if (type.Equals(typeof(Vector3)))
{
value = new PropertyValue((Vector3)obj);
}
else if (type.Equals(typeof(Vector4)))
{
value = new PropertyValue((Vector4)obj);
}
else if (type.Equals(typeof(Position)))
{
value = new PropertyValue((Position)obj);
}
else if (type.Equals(typeof(Position2D)))
{
value = new PropertyValue((Position2D)obj);
}
else if (type.Equals(typeof(Size)))
{
value = new PropertyValue((Size)obj);
}
else if (type.Equals(typeof(Size2D)))
{
value = new PropertyValue((Size2D)obj);
}
else if (type.Equals(typeof(Color)))
{
value = new PropertyValue((Color)obj);
}
else if (type.Equals(typeof(Rotation)))
{
value = new PropertyValue((Rotation)obj);
}
else if (type.Equals(typeof(RelativeVector2)))
{
value = new PropertyValue((RelativeVector2)obj);
}
else if (type.Equals(typeof(RelativeVector3)))
{
value = new PropertyValue((RelativeVector3)obj);
}
else if (type.Equals(typeof(RelativeVector4)))
{
value = new PropertyValue((RelativeVector4)obj);
}
else if (type.Equals(typeof(Extents)))
{
value = new PropertyValue((Extents)obj);
}
else if (type.Equals(typeof(Rectangle)))
{
value = new PropertyValue((Rectangle)obj);
}
else
{
throw new global::System.InvalidOperationException("Unimplemented type for Property Value :" + type.Name);
}
return value;
}
///
/// Retrieves a Size2D value.
///
/// On return, a Size2D value.
/// 3
public bool Get(Size2D vectorValue)
{
bool ret = Interop.PropertyValue.GetVector2(swigCPtr, Size2D.getCPtr(vectorValue));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Retrieves a Position2D value.
///
/// On return, a Position2D value.
/// 3
public bool Get(Position2D vectorValue)
{
bool ret = Interop.PropertyValue.GetVector2(swigCPtr, Position2D.getCPtr(vectorValue));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Retrieves a Size value.
///
/// On return, a size value.
/// 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 bool Get(Size vectorValue)
{
bool ret = Interop.PropertyValue.GetVector3(swigCPtr, Size.getCPtr(vectorValue));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Retrieves a Position value.
///
/// On return, a position value.
/// 3
public bool Get(Position vectorValue)
{
bool ret = Interop.PropertyValue.GetVector3(swigCPtr, Position.getCPtr(vectorValue));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Retrieves a Color value.
///
/// On return, a color value.
/// 3
public bool Get(Color vectorValue)
{
bool ret = Interop.PropertyValue.GetVector4(swigCPtr, Color.getCPtr(vectorValue));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Queries the type of this property value.
///
/// The type ID
/// 3
public new PropertyType GetType()
{
PropertyType ret = (PropertyType)Interop.PropertyValue.PropertyValueGetType(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Retrieves a boolean value.
///
/// On return, a boolean value.
/// Returns true if the value is successfully retrieved, false if the type is not convertible.
/// 3
public bool Get(out bool boolValue)
{
bool ret = Interop.PropertyValue.PropertyValueGet(swigCPtr, out boolValue);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Retrieves a floating-point value.
///
/// On return, a floating-point value.
/// Returns true if the value is successfully retrieved, false if the type is not convertible.
/// 3
public bool Get(out float floatValue)
{
bool ret = Interop.PropertyValue.PropertyValueGet(swigCPtr, out floatValue);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Retrieves an integer value.
///
/// On return, an integer value.
/// Returns true if the value is successfully retrieved, false if the type is not convertible.
/// 3
public bool Get(out int integerValue)
{
bool ret = Interop.PropertyValue.PropertyValueGet(swigCPtr, out integerValue);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Retrieves an integer rectangle.
///
/// On return, an integer rectangle.
/// Returns true if the value is successfully retrieved, false if the type is not convertible.
/// 3
public bool Get(Rectangle rect)
{
bool ret = Interop.PropertyValue.GetRect(swigCPtr, Rectangle.getCPtr(rect));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Retrieves a vector value.
///
/// On return, a vector value.
/// Returns true if the value is successfully retrieved, false if the type is not convertible.
/// 3
public bool Get(Vector2 vectorValue)
{
bool ret = Interop.PropertyValue.GetVector2(swigCPtr, Vector2.getCPtr(vectorValue));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Retrieves a vector value.
///
/// On return, a vector value.
/// Returns true if the value is successfully retrieved, false if the type is not convertible.
/// 3
public bool Get(Vector3 vectorValue)
{
bool ret = Interop.PropertyValue.GetVector3(swigCPtr, Vector3.getCPtr(vectorValue));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Retrieves a vector value.
///
/// On return, a vector value.
/// Returns true if the value is successfully retrieved, false if the type is not convertible.
/// 3
public bool Get(Vector4 vectorValue)
{
bool ret = Interop.PropertyValue.GetVector4(swigCPtr, Vector4.getCPtr(vectorValue));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Retrieves a vector value.
///
/// On return, a vector value.
/// Returns true if the value is successfully retrieved, false if the type is not convertible.
/// 5
/// 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 bool Get(RelativeVector2 vectorValue)
{
bool ret = Interop.PropertyValue.GetVector2(swigCPtr, RelativeVector2.getCPtr(vectorValue));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Retrieves a vector value.
///
/// On return, a vector value.
/// Returns true if the value is successfully retrieved, false if the type is not convertible.
/// 5
/// 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 bool Get(RelativeVector3 vectorValue)
{
bool ret = Interop.PropertyValue.GetVector3(swigCPtr, RelativeVector3.getCPtr(vectorValue));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Retrieves a vector value.
///
/// On return, a vector value.
/// Returns true if the value is successfully retrieved, false if the type is not convertible.
/// 5
/// 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 bool Get(RelativeVector4 vectorValue)
{
bool ret = Interop.PropertyValue.GetVector4(swigCPtr, RelativeVector4.getCPtr(vectorValue));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Retrieves a rotation value.
///
/// On return, a rotation value.
/// Returns true if the value is successfully retrieved, false if the type is not convertible.
/// 3
public bool Get(Rotation quaternionValue)
{
bool ret = Interop.PropertyValue.GetQuaternion(swigCPtr, Rotation.getCPtr(quaternionValue));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Retrieves a string property value.
///
/// On return, a string.
/// Returns true if the value is successfully retrieved, false if the type is not convertible.
/// 3
public bool Get(out string stringValue)
{
bool ret = Interop.PropertyValue.GetString(swigCPtr, out stringValue);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Retrieves an array property value.
///
/// On return, the array as a vector property values.
/// Returns true if the value is successfully retrieved, false if the type is not convertible.
/// 3
public bool Get(PropertyArray arrayValue)
{
bool ret = Interop.PropertyValue.GetArray(swigCPtr, PropertyArray.getCPtr(arrayValue));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Retrieves a map property value.
///
/// On return, the map as vector of string and property value pairs.
/// Returns true if the value is successfully retrieved, false if the type is not convertible.
/// 3
public bool Get(PropertyMap mapValue)
{
bool ret = Interop.PropertyValue.GetMap(swigCPtr, PropertyMap.getCPtr(mapValue));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Retrieves a Extents value.
///
/// On return, a extents.
/// Returns true if the value is successfully retrieved, false if the type is not convertible.
/// 4
public bool Get(Extents extentsValue)
{
bool ret = Interop.PropertyValue.GetExtents(swigCPtr, Extents.getCPtr(extentsValue));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PropertyValue obj)
{
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
}
internal bool Get(Matrix3 matrixValue)
{
bool ret = Interop.PropertyValue.GetMatrix3(swigCPtr, Matrix3.getCPtr(matrixValue));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal bool Get(Matrix matrixValue)
{
bool ret = Interop.PropertyValue.GetMatrix(swigCPtr, Matrix.getCPtr(matrixValue));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal bool Get(AngleAxis angleAxisValue)
{
bool ret = Interop.PropertyValue.GetAngleAxis(swigCPtr, AngleAxis.getCPtr(angleAxisValue));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
/// This will not be public opened.
[EditorBrowsable(EditorBrowsableState.Never)]
protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
{
Interop.PropertyValue.DeletePropertyValue(swigCPtr);
}
internal static PropertyValue CreateWithGuard(string value)
{
return value == null ? new PropertyValue() : new PropertyValue(value);
}
internal static PropertyValue CreateWithGuard(Vector2 value)
{
return value == null ? new PropertyValue() : new PropertyValue(value);
}
internal static PropertyValue CreateWithGuard(Rectangle value)
{
return value == null ? new PropertyValue() : new PropertyValue(value);
}
internal static PropertyValue CreateWithGuard(Color value)
{
return value == null ? new PropertyValue() : new PropertyValue(value);
}
}
}