From: dongsug.song Date: Mon, 20 Feb 2017 15:44:36 +0000 (+0900) Subject: add Timer Tick event X-Git-Tag: submit/tizen/20170228.014422~1^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dcae0e8d228ee43617f1de209bfc0159f3ffb0f7;p=platform%2Fcore%2Fcsapi%2Fnui.git add Timer Tick event Change-Id: I5a5ad9e93a4b616b4177c43480c626c9ffb38947 Signed-off-by: dongsug.song --- diff --git a/NUISamples/NUISamples.TizenTV/NUISamples.TizenTV.cs b/NUISamples/NUISamples.TizenTV/NUISamples.TizenTV.cs index f7e8e27..2bb8b86 100755 --- a/NUISamples/NUISamples.TizenTV/NUISamples.TizenTV.cs +++ b/NUISamples/NUISamples.TizenTV/NUISamples.TizenTV.cs @@ -42,6 +42,7 @@ namespace MyCSharpExample private TableView _contentContainer; private Stage _stage; private Popup _popup; + private Timer _timer; // List of items private Item[] mViewList = { @@ -107,6 +108,11 @@ namespace MyCSharpExample FocusManager.Instance.PreFocusChange += OnPreFocusChange; + _timer = new Timer(500); + _timer.Tick += OnTimerTick; + _timer.Start(); + + View _testView = new View(); Tizen.Log.Debug("NUI", "1) test view sizewidth = " + _testView.SizeWidth + " sizeHeight= " + _testView.SizeHeight); _testView.Size = new Size(1.0f, 2.0f, 0.0f); @@ -126,6 +132,12 @@ namespace MyCSharpExample #endif } + private bool OnTimerTick(object sender, EventArgs e) + { + Tizen.Log.Debug("NUI", "OnTimerTick() is called!"); + return true; + } + // Callback for KeyboardFocusManager private View OnPreFocusChange(object source, FocusManager.PreFocusChangeEventArgs e) { diff --git a/Tizen.NUI/src/internal/TimerSignalType.cs b/Tizen.NUI/src/internal/TimerSignalType.cs index 427ebf3..a9820fe 100755 --- a/Tizen.NUI/src/internal/TimerSignalType.cs +++ b/Tizen.NUI/src/internal/TimerSignalType.cs @@ -8,75 +8,111 @@ // the SWIG interface file instead. //------------------------------------------------------------------------------ -namespace Tizen.NUI { - -public class TimerSignalType : global::System.IDisposable { - private global::System.Runtime.InteropServices.HandleRef swigCPtr; - protected bool swigCMemOwn; - - internal TimerSignalType(global::System.IntPtr cPtr, bool cMemoryOwn) { - swigCMemOwn = cMemoryOwn; - swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); - } - - internal static global::System.Runtime.InteropServices.HandleRef getCPtr(TimerSignalType obj) { - return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; - } - - ~TimerSignalType() { - Dispose(); - } - - public virtual void Dispose() { - lock(this) { - if (swigCPtr.Handle != global::System.IntPtr.Zero) { - if (swigCMemOwn) { - swigCMemOwn = false; - NDalicPINVOKE.delete_TimerSignalType(swigCPtr); - } - swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); - } - global::System.GC.SuppressFinalize(this); +namespace Tizen.NUI +{ + + public class TimerSignalType : global::System.IDisposable + { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + protected bool swigCMemOwn; + + internal TimerSignalType(global::System.IntPtr cPtr, bool cMemoryOwn) + { + swigCMemOwn = cMemoryOwn; + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(TimerSignalType obj) + { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } + + ~TimerSignalType() + { + Dispose(); + } + + public virtual void Dispose() + { + lock (this) + { + if (swigCPtr.Handle != global::System.IntPtr.Zero) + { + if (swigCMemOwn) + { + swigCMemOwn = false; + NDalicPINVOKE.delete_TimerSignalType(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } + + public TimerSignalType() : this(NDalicPINVOKE.new_TimerSignalType(), true) + { + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + public bool Empty() + { + bool ret = NDalicPINVOKE.TimerSignalType_Empty(swigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public uint GetConnectionCount() + { + uint ret = NDalicPINVOKE.TimerSignalType_GetConnectionCount(swigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public void Connect(SWIGTYPE_p_f___bool func) + { + NDalicPINVOKE.TimerSignalType_Connect__SWIG_0(swigCPtr, SWIGTYPE_p_f___bool.getCPtr(func)); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + public void Disconnect(SWIGTYPE_p_f___bool func) + { + NDalicPINVOKE.TimerSignalType_Disconnect(swigCPtr, SWIGTYPE_p_f___bool.getCPtr(func)); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + public void Connect(ConnectionTrackerInterface connectionTracker, SWIGTYPE_p_Dali__FunctorDelegate arg1) + { + NDalicPINVOKE.TimerSignalType_Connect__SWIG_4(swigCPtr, ConnectionTrackerInterface.getCPtr(connectionTracker), SWIGTYPE_p_Dali__FunctorDelegate.getCPtr(arg1)); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + public bool Emit() + { + bool ret = NDalicPINVOKE.TimerSignalType_Emit(swigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + + public void Connect(System.Delegate func) + { + System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(func); + { + NDalicPINVOKE.TimerSignalType_Connect__SWIG_0(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip)); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + } + + public void Disconnect(System.Delegate func) + { + System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(func); + { + NDalicPINVOKE.TimerSignalType_Disconnect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip)); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + } + + } - } - - public TimerSignalType() : this(NDalicPINVOKE.new_TimerSignalType(), true) { - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - } - - public bool Empty() { - bool ret = NDalicPINVOKE.TimerSignalType_Empty(swigCPtr); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; - } - - public uint GetConnectionCount() { - uint ret = NDalicPINVOKE.TimerSignalType_GetConnectionCount(swigCPtr); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; - } - - public void Connect(SWIGTYPE_p_f___bool func) { - NDalicPINVOKE.TimerSignalType_Connect__SWIG_0(swigCPtr, SWIGTYPE_p_f___bool.getCPtr(func)); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - } - - public void Disconnect(SWIGTYPE_p_f___bool func) { - NDalicPINVOKE.TimerSignalType_Disconnect(swigCPtr, SWIGTYPE_p_f___bool.getCPtr(func)); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - } - - public void Connect(ConnectionTrackerInterface connectionTracker, SWIGTYPE_p_Dali__FunctorDelegate arg1) { - NDalicPINVOKE.TimerSignalType_Connect__SWIG_4(swigCPtr, ConnectionTrackerInterface.getCPtr(connectionTracker), SWIGTYPE_p_Dali__FunctorDelegate.getCPtr(arg1)); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - } - - public bool Emit() { - bool ret = NDalicPINVOKE.TimerSignalType_Emit(swigCPtr); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; - } - -} } diff --git a/Tizen.NUI/src/public/Timer.cs b/Tizen.NUI/src/public/Timer.cs index 9caf62e..98ea103 100755 --- a/Tizen.NUI/src/public/Timer.cs +++ b/Tizen.NUI/src/public/Timer.cs @@ -26,6 +26,9 @@ namespace Tizen.NUI { + using System; + using System.Runtime.InteropServices; + public class Timer : BaseHandle { @@ -147,13 +150,52 @@ namespace Tizen.NUI return ret; } - internal BoolSignal TickSignal() + + + + public TimerSignalType TickSignal() { - BoolSignal ret = new BoolSignal(NDalicPINVOKE.Timer_TickSignal(swigCPtr), false); + TimerSignalType ret = new TimerSignalType(NDalicPINVOKE.Timer_TickSignal(swigCPtr), false); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } + private DaliEventHandlerWithReturnType _tickEventHandler; + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate bool TickCallbackType(); + private TickCallbackType _tickCallBack; + + public event DaliEventHandlerWithReturnType Tick + { + add + { + if (_tickCallBack == null) + { + _tickCallBack = OnTick; + this.TickSignal().Connect(_tickCallBack); + } + _tickEventHandler += value; + } + remove + { + if (_tickCallBack != null) + { + this.TickSignal().Disconnect(_tickCallBack); + _tickCallBack = null; + } + _tickEventHandler -= value; + } + } + private bool OnTick() + { + if (_tickEventHandler != null) + { + return _tickEventHandler(this, null); + } + return false; + } + + } }