From: Emil Abraham Date: Wed, 2 Nov 2016 13:10:29 +0000 (+0530) Subject: Dali C# binding : Creating Color Constructor to accept enum Colors X-Git-Tag: dali_1.2.15~10^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=9485bf59c285547e4d5ba97b0270f914a2b2cf63 Dali C# binding : Creating Color Constructor to accept enum Colors The Color class takes a string in the constructor, so it cannot check whether the string represents a valid color. Here we define constants for these colors as enum, so that it can do this check during compilation. Now we can use stage.BackgroundColor = new Color(Colors.White); instead of stage.BackgroundColor = new Color("white"); Change-Id: I135e4103d6f9171011ed9d4e60f486a3e237d6cd Signed-off-by: Emil Abraham --- diff --git a/plugins/dali-swig/examples/dali-test.cs b/plugins/dali-swig/examples/dali-test.cs index 27b04bf..d13b4ea 100644 --- a/plugins/dali-swig/examples/dali-test.cs +++ b/plugins/dali-swig/examples/dali-test.cs @@ -62,7 +62,7 @@ namespace MyCSharpExample Console.WriteLine("Actor name: " + actor.Name); Stage stage = Stage.GetCurrent(); - stage.BackgroundColor = new Color("white") ; + stage.BackgroundColor = new Color(Colors.White) ; Size stageSize = stage.Size; Console.WriteLine("Stage size: " + stageSize.x + ", " + stageSize.y); diff --git a/plugins/dali-swig/manual/csharp/Color.cs b/plugins/dali-swig/manual/csharp/Color.cs index 0082950..3115a71 100644 --- a/plugins/dali-swig/manual/csharp/Color.cs +++ b/plugins/dali-swig/manual/csharp/Color.cs @@ -2,6 +2,22 @@ namespace Dali { using System; + +public enum Colors +{ + Red, + White, + Blue, + Green, + Black, + Grey, + Yellow, + Azure, + Rose +} + + + public class Color : Vector4 { /** @@ -77,6 +93,49 @@ public class Color : Vector4 break; } } + + + /** + * @brief constructor + * + * @since 1.0.0 + * @param [in] color as enum Colors. + */ + public Color(Colors color) + : base(0, 0, 0, 0) + { + switch (color) + { + case Colors.Red: + SetColor(255, 0, 0, 255); + break; + case Colors.White: + SetColor(255, 255, 255, 255); + break; + case Colors.Blue: + SetColor(0, 0, 255, 255); + break; + case Colors.Green: + SetColor(0, 255, 0, 255); + break; + case Colors.Black: + SetColor(0, 0, 0, 255); + break; + case Colors.Grey: + SetColor(128, 128, 128, 255); + break; + case Colors.Yellow: + SetColor(255, 255, 0, 255); + break; + case Colors.Azure: + SetColor(0, 255, 255, 255); + break; + case Colors.Rose: + SetColor(255, 0, 255, 255); + break; + } + } + /** * @brief SetColor