Ejemplo n.º 1
0
        private void CleanInputLocks()
        {
            //remove "dead" locks
            int lowestLockState = int.MaxValue;

            for (int i = InputLocks.Count - 1; i >= 0; i--)
            {
                InputLock iLock = InputLocks[i];
                if (IsOwnerAlive(iLock.Owner))
                {
                    //try lowest lock
                    if ((int)iLock.Type < lowestLockState)
                    {
                        lowestLockState = (int)iLock.Type;
                    }
                }
                else
                {
                    //remove it
                    InputLocks.RemoveAt(i);
                }
            }

            //drop to new lowest lock state
            if (lowestLockState < int.MaxValue)
            {
                ApplyInputLock((InputLockType)lowestLockState);
            }
            else
            {
                DoUnlock();
            }
        }
Ejemplo n.º 2
0
        public static InputLock LockControls(InputLockType type, object token)
        {
            var iLock = new InputLock(type, token);

            Instance.AddInputLock(iLock);
            return(iLock);
        }
Ejemplo n.º 3
0
        private void AddInputLock(InputLock iLock)
        {
            if (InputLockState == null || iLock.Type < InputLockState.Value)
            {
                ApplyInputLock(iLock.Type);
            }

            InputLocks.Add(iLock);
        }
Ejemplo n.º 4
0
        private void RemoveInputLock(InputLock iLock)
        {
            InputLocks.Remove(iLock);

            if (InputLocks.Count > 0)
            {
                CleanInputLocks();
            }
            else
            {
                DoUnlock();
            }
        }