Esempio n. 1
0
        public async Task Increase(CountState state)
        {
            await Task.Run(() =>
            {
                var count  = state.Count + 1;
                this.State = new CountState(count);
            });

            NotifyStateChanged("Increase");
        }
Esempio n. 2
0
        public async Task Decrease(CountState state)
        {
            await Task.Run(() =>
            {
                var count = state.Count - 1;
                Thread.Sleep(5000);
                this.State = new CountState(count);
            });

            NotifyStateChanged("Increase");
        }
Esempio n. 3
0
        public SelectList states(CountState state)
        {
            var otherStates = unitOfWork.CountstateRepository.Get(c => c.countryID == state.countryID)
                              .OrderBy(o => o.CultureStateName);

            if (ITTConfig.CurrentCultureIsNotEN)
            {
                return(new SelectList(otherStates, "stateID", "stateName", state.stateID));
            }
            else
            {
                return(new SelectList(otherStates, "stateID", "stateNameEN", state.stateID));
            }
        }
        /// <summary>
        /// Process a frame update while in the Ready state. In this
        /// state, the gesture detector is waiting for a finger count
        /// to stabilise before starting gesture detection.
        /// </summary>
        private void ProcessFrameReady(Frame frame)
        {
            #region Hand check
            List<Hand> hands = DetectedHands(frame.Hands);

            if (hands.Count == 0)
            {
                LeaveWorkspace();
                return;
            }

            Hand activeHand = null;
            foreach (Hand hand in hands)
            {
                if (hand.Id == activeHandId)
                {
                    activeHand = hand;
                    break;
                }
            }

            if (activeHand == null)
            {
                // Lost sight of the active hand
                LeaveWorkspace();
                return;
            }

            if (ExtendedFingers(activeHand.Fingers, false).Count == 0)
                PoseEnd();
            #endregion

               /* #region Groups
            // If a group switch has taken place, abort selection
            if (ProcessGroups(activeHand))
                return;
            #endregion */

            discardedFrames++;

            if (discardedFrames == READY_FRAMES)
            {
                Log("Ready to count");

                state = CountState.Counting;
            }
        }
        private void PoseStart()
        {
            state = CountState.Ready;
            selectionState = CountSelectionState.Idle;

            Log("Count: PoseStart");
        }
        private void PoseEnd()
        {
            if (selectionState != CountSelectionState.Idle)
                CountStop();

            //GroupLeave(activeGroup);

            state = CountState.Tracking;
            selectionState = CountSelectionState.Idle;
            //activeGroup = 0;
            discardedFrames = 0;

            Log("Count: PoseEnd");
        }
        private void LeaveWorkspace()
        {
            if (selectionState != CountSelectionState.Idle)
                CountStop();

            //GroupLeave(activeGroup);

            state = CountState.Idle;
            selectionState = CountSelectionState.Idle;
            //activeGroup = 0;
            discardedFrames = 0;
            activeHandId = -1;

            foreach (IParentObserver observer in observers)
            {
                observer.LeaveWorkspace(0);
                Log("Count: LeaveWorkspace");
            }
        }
        private void EnterWorkspace(int handId, int fingers)
        {
            state = CountState.Tracking;
            selectionState = CountSelectionState.Idle;
            //activeGroup = 0;
            activeHandId = handId;

            foreach (IParentObserver observer in observers)
            {
                observer.EnterWorkspace(-1, fingers);
            }

            Log("Count: EnterWorkspace");
        }
        private void CountStart(ROI.ROI roi, int count)
        {
            state = CountState.Counting;
            selectionState = CountSelectionState.InProgress;

            countStart = DateTime.Now;
            countTotal = 0;
            countFrames = 0;

            for (int i = 0; i < observers.Count; i++ )
            {
                //if (observer.Equals(typeof(ICountObserver)))
                Log(String.Format("Observer{0}", observers[i]));
                if (observers[i] is ICountObserver)
                {
                    ICountObserver ic = (ICountObserver)observers[i];
                    ic.CountStart(null, roi, count, this, observers);
                }
            }

            Log(String.Format("Count: CountStart {0}", count));
        }
        // private int activeGroup;
        public CountDetector(LeapInterface leap, GestureSpace space)
        {
            // Initialise state machines
            state = CountState.Idle;
            selectionState = CountSelectionState.Idle;
            activeHandId = -1;
            discardedFrames = 0;
            ignoredFrames = 0;
            this.leap = leap;

               /* // Initialise groups and ROIs
            activeGroup = 0; */

            // Initialise list of observers
            observers = new List<IParentObserver>();

            // Initialise selection metadata
            countStart = DateTime.Now;

            // Register gesture workspace
            this.RegisterWorkspace(space);

            // Register this gesture detector for frame updates and keep reference of the LeapMotion controller
            this.leap.RegisterFrameListener(this);

            GestureDetector.DEBUG = false;
        }
        private void CountStart(ROI.ROI roi, int count)
        {
            state = CountState.Counting;
            selectionState = CountSelectionState.InProgress;

            countStart = DateTime.Now;
            countTotal = 0;
            countFrames = 0;

            foreach (ICountObserver observer in observers)
                observer.CountStart(null, roi, count);

            Log(String.Format("Count: CountStart {0}", count));
        }