X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=plugins%2Fdali-swig%2Fexamples%2Fcustom-control.cs;h=2da7ea4089f924c6236c34043a2c2662617fc200;hp=92b06109ead732190bcdcc641f1fe96d236a0ca9;hb=bc7cb028cf42ff75d7644c278201883ea3426199;hpb=8d7a2d639ced5d2eb3ce4321653ad4d8b55b0b95 diff --git a/plugins/dali-swig/examples/custom-control.cs b/plugins/dali-swig/examples/custom-control.cs index 92b0610..2da7ea4 100644 --- a/plugins/dali-swig/examples/custom-control.cs +++ b/plugins/dali-swig/examples/custom-control.cs @@ -31,7 +31,21 @@ namespace MyCSharpExample private int _myRating; private bool _myDragEnabled; - public StarRating() : base(ViewWrapperImpl.CustomViewBehaviour.VIEW_BEHAVIOUR_DEFAULT) + // Called by DALi Builder if it finds a StarRating control in a JSON file + static CustomView CreateInstance() + { + return new StarRating(); + } + + // static constructor registers the control type (only runs once) + static StarRating() + { + // ViewRegistry registers control type with DALi type registery + // also uses introspection to find any properties that need to be registered with type registry + ViewRegistry.Instance.Register(CreateInstance, typeof(StarRating) ); + } + + public StarRating() : base(typeof(StarRating).Name, ViewWrapperImpl.CustomViewBehaviour.VIEW_BEHAVIOUR_DEFAULT) { } @@ -62,7 +76,7 @@ namespace MyCSharpExample UpdateStartImages(_myRating); // Enable pan gesture detection - EnableGestureDetection(Gesture.Type.Pan); + EnableGestureDetection(Gesture.GestureType.Pan); _myDragEnabled = true; // Allow dragging by default (can be disabled) } @@ -72,19 +86,19 @@ namespace MyCSharpExample // Only handle pan gesture if dragging is allowed if(_myDragEnabled) { - switch (gesture.state) + switch (gesture.State) { - case Gesture.State.Started: + case Gesture.StateType.Started: { _gestureDisplacement = new Vector3(0.0f, 0.0f, 0.0f); _currentValue = 0; break; } - case Gesture.State.Continuing: + case Gesture.StateType.Continuing: { // Calculate the rating according to pan desture displacement - _gestureDisplacement.x += gesture.displacement.x; - int delta = (int)Math.Ceiling(_gestureDisplacement.x / 40.0f); + _gestureDisplacement.X += gesture.Displacement.X; + int delta = (int)Math.Ceiling(_gestureDisplacement.X / 40.0f); _currentValue = _myRating + delta; // Clamp the rating @@ -163,7 +177,7 @@ namespace MyCSharpExample _application.Initialized += Initialize; } - public void Initialize(object source, AUIApplicationInitEventArgs e) + public void Initialize(object source, NUIApplicationInitEventArgs e) { Stage stage = Stage.GetCurrent(); stage.BackgroundColor = Color.White; @@ -229,6 +243,8 @@ namespace MyCSharpExample [STAThread] static void Main(string[] args) { + System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor (typeof(MyCSharpExample.StarRating).TypeHandle); + Example example = new Example(Application.NewApplication()); example.MainLoop (); }