using System;
using Tizen.NUI.Binding;
using System.ComponentModel;
+using System.Globalization;
namespace Tizen.NUI
{
/// Gets the Papaya_whip colored Color class.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public static readonly Color PapayaWhip = NDalic.PAPAYA_WHIP ;
+ public static readonly Color PapayaWhip = NDalic.PAPAYA_WHIP;
/// <summary>
/// Gets the Peach_puff colored Color class.
textColor = textColor.ToUpperInvariant();
textColor = textColor.Replace(" ", "");
- if ( textColor.Length > 0 && textColor[0] == '#')
+ if (textColor.Length > 0 && textColor[0] == '#')
{
textColor = textColor.Replace("#", "");
int textColorLength = textColor.Length;
bool isRGBA = textColor.StartsWith("RGBA(");
bool isRGB = textColor.StartsWith("RGB(");
- if(!isRGBA && !isRGB)
+ if (!isRGBA && !isRGB)
{
throw new global::System.ArgumentException("Please check your color text code");
}
- if(isRGBA)
+ if (isRGBA)
textColor = textColor.Substring(4);
- if(isRGB)
+ if (isRGB)
textColor = textColor.Substring(3);
- textColor = textColor.Replace(")","");
- textColor = textColor.Replace("(","");
+ textColor = textColor.Replace(")", "");
+ textColor = textColor.Replace("(", "");
string[] components = textColor.Split(',');
- if(components.Length == 3 && isRGB)
+ if (components.Length == 3 && isRGB)
{
R = Math.Min(1.0f, ((float)Convert.ToInt32(components[0], 10)) / 255.0f);
G = Math.Min(1.0f, ((float)Convert.ToInt32(components[1], 10)) / 255.0f);
B = Math.Min(1.0f, ((float)Convert.ToInt32(components[2], 10)) / 255.0f);
A = 1.0f;
}
- else if(components.Length == 4 && isRGBA)
+ else if (components.Length == 4 && isRGBA)
{
R = Math.Min(1.0f, ((float)Convert.ToInt32(components[0], 10)) / 255.0f);
G = Math.Min(1.0f, ((float)Convert.ToInt32(components[1], 10)) / 255.0f);
B = Math.Min(1.0f, ((float)Convert.ToInt32(components[2], 10)) / 255.0f);
- A = Math.Min(1.0f, float.Parse(components[3]));
+ A = Math.Min(1.0f, float.Parse(components[3], CultureInfo.InvariantCulture));
}
}
}
/// The copy constructor.
/// </summary>
/// <param name="other">The copy target.</param>
+ /// <exception cref="ArgumentNullException"> Thrown when other is null. </exception>
[EditorBrowsable(EditorBrowsableState.Never)]
- public Color(Color other) : this((float)other?.R, (float)other.G, (float)other.B, (float)other.A)
+ public Color(Color other) : this(other == null ? throw new ArgumentNullException(nameof(other)) : other.R, other.G, other.B, other.A)
{
}
/// The red component.
/// </summary>
/// <remarks>
- /// The setter is deprecated in API8 and will be removed in API10. Please use new Color(...) constructor.
+ /// The setter is deprecated in API8 and will be removed in API10. Use the new Color(...) constructor.
/// </remarks>
/// <code>
- /// // DO NOT use like the followings!
+ /// // DO NOT use as follows:
/// Color color = new Color();
/// color.R = 0.1f;
- /// // Please USE like this
+ /// // USE like this
/// float r = 0.1f, g = 0.5f, b = 0.9f, a = 1.0f;
/// Color color = new Color(r, g, b, a);
/// </code>
/// <since_tizen> 3 </since_tizen>
public float R
{
+ [Obsolete("Do not use this setter, that is deprecated in API8 and will be removed in API10. Use the new Color(...) constructor")]
set
{
- Tizen.Log.Fatal("NUI", "Please do not use this setter, Deprecated in API8, will be removed in API10. please use new Color(...) constructor");
Interop.Vector4.RSet(SwigCPtr, ValueCheck(value));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
/// The green component.
/// </summary>
/// <remarks>
- /// The setter is deprecated in API8 and will be removed in API10. Please use new Color(...) constructor.
+ /// The setter is deprecated in API8 and will be removed in API10. Use the new Color(...) constructor.
/// </remarks>
/// <code>
- /// // DO NOT use like the followings!
+ /// // DO NOT use as follows:
/// Color color = new Color();
/// color.G = 0.5f;
- /// // Please USE like this
+ /// // USE like this
/// float r = 0.1f, g = 0.5f, b = 0.9f, a = 1.0f;
/// Color color = new Color(r, g, b, a);
/// </code>
/// <since_tizen> 3 </since_tizen>
public float G
{
+ [Obsolete("Do not use this setter, that is deprecated in API8 and will be removed in API10. Use the new Color(...) constructor")]
set
{
- Tizen.Log.Fatal("NUI", "Please do not use this setter, Deprecated in API8, will be removed in API10. please use new Color(...) constructor");
Interop.Vector4.GSet(SwigCPtr, ValueCheck(value));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
/// The blue component.
/// </summary>
/// <remarks>
- /// The setter is deprecated in API8 and will be removed in API10. Please use new Color(...) constructor.
+ /// The setter is deprecated in API8 and will be removed in API10. Use the new Color(...) constructor.
/// </remarks>
/// <code>
- /// // DO NOT use like the followings!
+ /// // DO NOT use as follows:
/// Color color = new Color();
/// color.B = 0.9f;
- /// // Please USE like this
+ /// // USE like this
/// float r = 0.1f, g = 0.5f, b = 0.9f, a = 1.0f;
/// Color color = new Color(r, g, b, a);
/// </code>
/// <since_tizen> 3 </since_tizen>
public float B
{
+ [Obsolete("Do not use this setter, that is deprecated in API8 and will be removed in API10. Use the new Color(...) constructor")]
set
{
- Tizen.Log.Fatal("NUI", "Please do not use this setter, Deprecated in API8, will be removed in API10. please use new Color(...) constructor");
Interop.Vector4.BSet(SwigCPtr, ValueCheck(value));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
/// The alpha component.
/// </summary>
/// <remarks>
- /// The setter is deprecated in API8 and will be removed in API10. Please use new Color(...) constructor.
+ /// The setter is deprecated in API8 and will be removed in API10. Use the new Color(...) constructor.
/// </remarks>
/// <code>
- /// // DO NOT use like the followings!
+ /// // DO NOT use as follows:
/// Color color = new Color();
/// color.A = 1.0f;
- /// // Please USE like this
+ /// // USE like this
/// float r = 0.1f, g = 0.5f, b = 0.9f, a = 1.0f;
/// Color color = new Color(r, g, b, a);
/// </code>
/// <since_tizen> 3 </since_tizen>
public float A
{
+ [Obsolete("Do not use this setter, that is deprecated in API8 and will be removed in API10. Use the new Color(...) constructor")]
set
{
- Tizen.Log.Fatal("NUI", "Please do not use this setter, Deprecated in API8, will be removed in API10. please use new Color(...) constructor");
Interop.Vector4.ASet(SwigCPtr, ValueCheck(value));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
/// <since_tizen> 3 </since_tizen>
public static implicit operator Vector4(Color color)
{
- return new Vector4((float)color?.R, (float)color.G, (float)color.B, (float)color.A);
+ if (color == null)
+ {
+ return null;
+ }
+ return new Vector4(color.R, color.G, color.B, color.A);
}
/// <summary>
/// <since_tizen> 3 </since_tizen>
public static implicit operator Color(Vector4 vec)
{
- return new Color((float)vec?.R, (float)vec.G, (float)vec.B, (float)vec.A);
+ if (vec == null)
+ {
+ return null;
+ }
+ return new Color(vec.R, vec.G, vec.B, vec.A);
}
/// <summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public object Clone() => new Color(this);
- internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Color obj)
- {
- return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
- }
-
internal static Color GetColorFromPtr(global::System.IntPtr cPtr)
{
Color ret = new Color(cPtr, false);