private void TouchEffect_TouchAction(object sender, TouchActionEventArgs e)
        {
            // We don't care if Middle or Right Mouse button is used.
            if ((e.MouseButton == TouchMouseButton.Middle) ||
                (e.MouseButton == TouchMouseButton.Right))
            {
                return;
            }

            Boolean cancelLongPress = false;
            Boolean startLongPress  = false;

            switch (e.Type)
            {
            case TouchActionType.Cancelled:
            case TouchActionType.Entered:
            case TouchActionType.Exited:
            case TouchActionType.Released:
                if (longPressStarted)
                {
                    cancelLongPress = true;
                }
                break;

            case TouchActionType.Moved:
                if (longPressStarted)
                {
                    cancelLongPress = (Math.Abs(e.Location.X - longPressInitialLocation.X) > 15) ||
                                      (Math.Abs(e.Location.Y - longPressInitialLocation.Y) > 15);
                }
                break;

            case TouchActionType.Pressed:
                cancelLongPress = true;
                startLongPress  = true;
                break;
            }

            if (cancelLongPress)
            {
                longPressStarted = false;
                if (cancelableDelayForLongPress != null)
                {
                    cancelableDelayForLongPress.Cancel();
                    cancelableDelayForLongPress = null;
                }
            }

            if (startLongPress)
            {
                longPressStarted            = true;
                longPressInitialLocation    = e.Location; // Here e.Location get the press Location relatively to the MessageContext UI Component
                cancelableDelayForLongPress = CancelableDelay.StartAfter(Helper.DELAY_FOR_LONG_PRESS, () => NeedToDisplayActionMenu(sender, longPressInitialLocation));
            }
        }
Esempio n. 2
0
        private void CheckCacheWithJid()
        {
            var contact = Helper.SdkWrapper.GetContactFromContactJid(peer.Jid);

            if (contact != null)
            {
                peer.Id = contact.Id;
                UpdateDisplay();
                return;
            }

            if (TaskCheckCacheWithJid == null)
            {
                TaskCheckCacheWithJid = CancelableDelay.StartAfter(300, () => CheckCacheWithJid());
            }
            else
            {
                TaskCheckCacheWithJid.PostPone();
            }
        }
Esempio n. 3
0
        private void CheckIfUpdateModelForDateTimePurpose(DateTime dt)
        {
            int delay;

            // do we have a DateTime more recent ?
            if (dt.ToUniversalTime() > mostRecentDateTimeMessage.ToUniversalTime())
            {
                delay = Helper.GetRefreshDelay(dt);
                mostRecentDateTimeMessage = dt;

                // If there is not already a delay in progress, we ask a new one
                if (delayUpdateForDateTimePurpose == null)
                {
                    log.LogDebug("[CheckIfUpdateModelForDateTimePurpose] - Start Delay:[{0}] - DateTime:[{1}] - CASE MORE RECENT", delay, dt.ToString("o"));
                    delayUpdateForDateTimePurpose = CancelableDelay.StartAfter(delay * 1000, () => UpdateModelForDateTimePurpose());
                }
                // There is already a delay running. So we need to cancel it and update display now
                else
                {
                    log.LogDebug("[CheckIfUpdateModelForDateTimePurpose] - Stop current delay and ask update now - DateTime:[{0}]", dt.ToString("o"));

                    // We stop the current "update delay"
                    delayUpdateForDateTimePurpose.Cancel();

                    // We ask the update now
                    //TO DO - must be a UI THREAD TO YPDATE THE MODEL !!!
                    UpdateModelForDateTimePurpose();
                }
            }
            // We have not a more recent DateTime
            else
            {
                delay = Helper.GetRefreshDelay(mostRecentDateTimeMessage);
                // If there is not already a delay in progress, we ask a new one
                if ((delayUpdateForDateTimePurpose == null) || (!delayUpdateForDateTimePurpose.IsRunning()))
                {
                    log.LogDebug("[CheckIfUpdateModelForDateTimePurpose] - Start Delay:[{0}] - DateTime:[{1}] - CASE OLDER", delay, dt.ToString("o"));
                    delayUpdateForDateTimePurpose = CancelableDelay.StartAfter(delay * 1000, () => UpdateModelForDateTimePurpose());
                }
            }
        }
Esempio n. 4
0
        private void OnAsyncExecute(Guid workflowInstanceGuid, string activityInstanceId, int period, bool cancelable)
        {
            if (cancelable)
            {
                var delay = new CancelableDelay(period);

                RegisterCancelable(workflowInstanceGuid, activityInstanceId, delay);
                delay.Execute();
                UnregisterCancelable(workflowInstanceGuid, activityInstanceId, delay);
            }
            else
            {
                // This would idle
                //Thread.Sleep(period);

                // This doesn't idle
                var start = DateTime.Now;
                while ((DateTime.Now - start).TotalMilliseconds < period)
                {
                }
            }
        }
Esempio n. 5
0
        private void OnAsyncExecute(Guid workflowInstanceGuid, string activityInstanceId, int period, bool cancelable)
        {
            if (cancelable)
            {
                var delay = new CancelableDelay(period);

                RegisterCancelable(workflowInstanceGuid, activityInstanceId, delay);
                delay.Execute();
                UnregisterCancelable(workflowInstanceGuid, activityInstanceId, delay);
            }
            else
            {
                // This would idle
                //Thread.Sleep(period);

                // This doesn't idle
                var start = DateTime.Now;
                while ((DateTime.Now - start).TotalMilliseconds < period)
                {
                }
            }
        }
        private void CheckCacheWithJid()
        {
            if (peer.Type == Rainbow.Model.Conversation.ConversationType.User)
            {
                var contact = Helper.SdkWrapper.GetContactFromContactJid(peer.Jid);
                if (contact != null)
                {
                    peer.Id = contact.Id;
                    UpdateAvatarImageDisplay();
                    return;
                }
            }
            else if (peer.Type == Rainbow.Model.Conversation.ConversationType.Room)
            {
                var bubble = Helper.SdkWrapper.GetBubbleByJidFromCache(peer.Jid);
                if (bubble != null)
                {
                    peer.Id = bubble.Id;
                    UpdateAvatarImageDisplay();
                    return;
                }
            }
            else
            {
                return;
            }

            if (TaskCheckCacheWithJid == null)
            {
                TaskCheckCacheWithJid = CancelableDelay.StartAfter(300, () => CheckCacheWithJid());
            }
            else
            {
                TaskCheckCacheWithJid.PostPone();
            }
        }