Example #1
0
 public static void RegisterRunOnceTask(UITimerTask.TimerTick action)
 {
     UI.UITimerTask uiTimerTask = new UI.UITimerTask(action);
     uiTimerTask.Enabled = true;
     uiTimerTask.RunOnce = true;
     UIMsgQueueSystem.InternalMsgPumpRegister(uiTimerTask);
 }
        public GraphicsTimerTaskManager(RootGraphic rootgfx)
        {
            _rootgfx = rootgfx;

            //register timer task
            _uiTimerTask          = new UITimerTask(graphicTimer1_Tick);
            _uiTimerTask.Interval = _fastPlanInterval; //fast task plan
            UIPlatform.RegisterTimerTask(_uiTimerTask);
            _uiTimerTask.Enabled = true;
        }
Example #3
0
 internal static int MinUICountDownInMillisec = 10; //default
 internal static void InternalMsgPumpRegister(UITimerTask timerTask)
 {
     if (timerTask.IsRegistered || timerTask.IntervalInMillisec <= 0)
     {
         return;
     }
     //
     s_uiTimerTasks.Enqueue(timerTask);
     timerTask.IsRegistered = true;
 }
        public GraphicsTimerTaskManager(RootGraphic rootgfx)
        {
            this.rootgfx = rootgfx;

            //register timer task
            uiTimerTask = new UITimerTask(graphicTimer1_Tick);
            uiTimerTask.IntervalInMillisec = fastPlanInterval; //fast task plan
            UIPlatform.RegisterTimerTask(uiTimerTask);
            uiTimerTask.Enabled = true;
        }
Example #5
0
 internal static bool CountDown(UITimerTask timer_task, int decrement)
 {
     timer_task._remaining -= decrement;
     if (timer_task._remaining <= 0)
     {
         timer_task._remaining = timer_task._intervalInMillisec;//reset
         //invoke action
         timer_task.InvokeAction();
         if (timer_task.RunOnce)
         {
             timer_task.RemoveFromQueue = true;
         }
         return(true);
     }
     return(false);
 }
Example #6
0
 internal static void InternalMsgPumpOneStep()
 {
     //platform must invoke this in UI/msg queue thread ***
     for (int i = s_uiTimerTasks.Count - 1; i >= 0; --i)
     {
         //just snap
         UITimerTask timer_task = s_uiTimerTasks.Dequeue();
         if (timer_task.Enabled)
         {
             UITimerTask.CountDown(timer_task, MinUICountDownInMillisec);
         }
         if (timer_task.RemoveFromQueue)
         {
             timer_task.IsRegistered = false;
             //don't enqueue back
         }
         else
         {   //add back to the queue
             s_uiTimerTasks.Enqueue(timer_task);
         }
     }
 }
            public MousePressMonitorHelper(int intervalMs)
            {
                _intervalMs           = intervalMs;
                _mousePressCount      = 0;
                _currentMonitoredElem = null;
                _mousePressEventArgs  = new UIMousePressEventArgs();

                _mousePressMonitor = new UITimerTask(t =>
                {
                    if (_currentMonitoredElem != null)
                    {
                        //invoke mouse press event
                        if (_mousePressCount > 0)
                        {
                            _currentMonitoredElem.ListenMousePress(_mousePressEventArgs);
                        }
                        _mousePressCount++;
                    }
                });
                _mousePressMonitor.Enabled  = true;
                _mousePressMonitor.Interval = intervalMs; //interval for mouse press monitor
                UIPlatform.RegisterTimerTask(_mousePressMonitor);
            }
        void graphicTimer1_Tick(UITimerTask timerTask)
        {
            //-------------------------------------------------
            tickAccum += fastPlanInterval;
            //Console.WriteLine("tickaccum:" + tickAccum.ToString());
            //-------------------------------------------------
            bool doCaretPlan = false;

            if (tickAccum > caretBlinkInterval)
            {
                // Console.WriteLine("*********");
                tickAccum   = 0;//reset
                doCaretPlan = true;
            }
            //-------------------------------------------------
            int needUpdate = 0;

            if (enableCaretBlink && doCaretPlan)
            {
                //-------------------------------------------------
                //1. fast and animation plan
                //-------------------------------------------------
                MyIntervalTaskEventArgs args = GetTaskEventArgs();
                int j = this.fastIntervalTaskList.Count;
                if (j > 0)
                {
                    for (int i = 0; i < j; ++i)
                    {
                        fastIntervalTaskList[i].InvokeHandler(args);
                        needUpdate |= args.NeedUpdate;
                    }
                }
                //-------------------------------------------------
                //2. caret plan
                //-------------------------------------------------
                j = this.caretIntervalTaskList.Count;
                for (int i = 0; i < j; ++i)
                {
                    caretIntervalTaskList[i].InvokeHandler(args);
                    needUpdate |= args.NeedUpdate;
                }
                FreeTaskEventArgs(args);
            }
            else
            {
                int j = this.fastIntervalTaskList.Count;
                MyIntervalTaskEventArgs args = GetTaskEventArgs();
                if (j > 0)
                {
                    for (int i = 0; i < j; ++i)
                    {
                        fastIntervalTaskList[i].InvokeHandler(args);
                        needUpdate |= args.NeedUpdate;
                    }
                }
                FreeTaskEventArgs(args);
            }


            if (needUpdate > 0)
            {
                this.rootgfx.PrepareRender();
                this.rootgfx.FlushAccumGraphics();
            }
        }