Esempio n. 1
0
        public CCTouchHandler findHandler(ICCTouchDelegate pDelegate)
        {
            CCTouchHandler cCTouchHandler;

            foreach (CCTouchHandler mPTargetedHandler in this.m_pTargetedHandlers)
            {
                if (mPTargetedHandler.Delegate != pDelegate)
                {
                    continue;
                }
                cCTouchHandler = mPTargetedHandler;
                return(cCTouchHandler);
            }
            List <CCTouchHandler> .Enumerator enumerator = this.m_pStandardHandlers.GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    CCTouchHandler current = enumerator.Current;
                    if (current.Delegate != pDelegate)
                    {
                        continue;
                    }
                    cCTouchHandler = current;
                    return(cCTouchHandler);
                }
                return(null);
            }
            finally
            {
                ((IDisposable)enumerator).Dispose();
            }
            return(cCTouchHandler);
        }
        /// <summary>
        /// Changes the priority of a previously added delegate.
        /// The lower the number, the higher the priority
        /// </summary>
        public void setPriority(int nPriority, ICCTouchDelegate pDelegate)
        {
            CCTouchHandler handler = null;

            handler          = this.findHandler(pDelegate);
            handler.Priority = nPriority;

            this.rearrangeHandlers(m_pTargetedHandlers);
            this.rearrangeHandlers(m_pStandardHandlers);
        }
Esempio n. 3
0
        public static CCTouchHandler handlerWithDelegate(ICCTouchDelegate pDelegate, int nPriority)
        {
            CCTouchHandler handler = new CCTouchHandler();

            if (handler.initWithDelegate(pDelegate, nPriority))
            {
                return(null);
            }
            return(null);
        }
Esempio n. 4
0
        public void addTargetedDelegate(ICCTargetedTouchDelegate pDelegate, int nPriority, bool bSwallowsTouches)
        {
            CCTouchHandler cCTouchHandler = CCTargetedTouchHandler.handlerWithDelegate(pDelegate, nPriority, bSwallowsTouches);

            if (!this.m_bLocked)
            {
                this.forceAddHandler(cCTouchHandler, this.m_pTargetedHandlers);
                return;
            }
            this.m_pHandlersToAdd.Add(cCTouchHandler);
            this.m_bToAdd = true;
        }
Esempio n. 5
0
        public void addStandardDelegate(ICCStandardTouchDelegate pDelegate, int nPriority)
        {
            CCTouchHandler cCTouchHandler = CCStandardTouchHandler.handlerWithDelegate(pDelegate, nPriority);

            if (!this.m_bLocked)
            {
                this.forceAddHandler(cCTouchHandler, this.m_pStandardHandlers);
                return;
            }
            this.m_pHandlersToAdd.Add(cCTouchHandler);
            this.m_bToAdd = true;
        }
        /// <summary>
        /// Adds a targeted touch delegate to the dispatcher's list.
        /// See TargetedTouchDelegate description.
        /// IMPORTANT: The delegate will be retained.
        /// </summary>
        public void addTargetedDelegate(ICCTargetedTouchDelegate pDelegate, int nPriority, bool bSwallowsTouches)
        {
            CCTouchHandler pHandler = CCTargetedTouchHandler.handlerWithDelegate(pDelegate, nPriority, bSwallowsTouches);

            if (!m_bLocked)
            {
                forceAddHandler(pHandler, m_pTargetedHandlers);
            }
            else
            {
                m_pHandlersToAdd.Add(pHandler);
                m_bToAdd = true;
            }
        }
        /// <summary>
        /// Adds a standard touch delegate to the dispatcher's list.
        /// See StandardTouchDelegate description.
        /// IMPORTANT: The delegate will be retained.
        /// </summary>
        public void addStandardDelegate(ICCStandardTouchDelegate pDelegate, int nPriority)
        {
            CCTouchHandler pHandler = CCStandardTouchHandler.handlerWithDelegate(pDelegate, nPriority);

            if (!m_bLocked)
            {
                forceAddHandler(pHandler, m_pStandardHandlers);
            }
            else
            {
                m_pHandlersToAdd.Add(pHandler);
                m_bToAdd = true;
            }
        }
Esempio n. 8
0
        /// <summary>
        /// allocates a TouchHandler with a delegate and a priority 
        /// </summary>
        public static CCTouchHandler handlerWithDelegate(ICCTouchDelegate pDelegate, int nPriority)
        {
            CCTouchHandler pHandler = new CCTouchHandler();

            if (pHandler.initWithDelegate(pDelegate, nPriority))
            {
                pHandler = null;
            }
            else
            {
                pHandler = null;
            }

            return pHandler;
        }
Esempio n. 9
0
        /// <summary>
        /// allocates a TouchHandler with a delegate and a priority
        /// </summary>
        public static CCTouchHandler handlerWithDelegate(ICCTouchDelegate pDelegate, int nPriority)
        {
            CCTouchHandler pHandler = new CCTouchHandler();

            if (pHandler.initWithDelegate(pDelegate, nPriority))
            {
                pHandler = null;
            }
            else
            {
                pHandler = null;
            }

            return(pHandler);
        }
Esempio n. 10
0
        protected void forceAddHandler(CCTouchHandler pHandler, List <CCTouchHandler> pArray)
        {
            int num = 0;

            for (int i = 0; i < pArray.Count; i++)
            {
                CCTouchHandler item = pArray[i];
                if (item != null)
                {
                    if (item.Priority < pHandler.Priority)
                    {
                        num++;
                    }
                    if (item.Delegate == pHandler.Delegate)
                    {
                        return;
                    }
                }
            }
            pArray.Insert(num, pHandler);
        }
        protected void forceAddHandler(CCTouchHandler pHandler, List <CCTouchHandler> pArray)
        {
            int u = 0;

            for (int i = 0; i < pArray.Count; i++)
            {
                CCTouchHandler h = pArray[i];

                if (h != null)
                {
                    if (h.Priority < pHandler.Priority)
                    {
                        ++u;
                    }

                    if (h.Delegate == pHandler.Delegate)
                    {
                        return;
                    }
                }
            }

            pArray.Insert(u, pHandler);
        }
 /// <summary>
 /// Used for sort
 /// </summary>
 int less(CCTouchHandler p1, CCTouchHandler p2)
 {
     return p1.Priority - p2.Priority;
 }
        protected void forceAddHandler(CCTouchHandler pHandler, List<CCTouchHandler> pArray)
        {
            int u = 0;
            for (int i = 0; i < pArray.Count; i++)
            {
                CCTouchHandler h = pArray[i];

                if (h != null)
                {
                    if (h.Priority < pHandler.Priority)
                    {
                        ++u;
                    }

                    if (h.Delegate == pHandler.Delegate)
                    {
                        return;
                    }
                }
            }

            pArray.Insert(u, pHandler);
        }
 /// <summary>
 /// Used for sort
 /// </summary>
 int less(CCTouchHandler p1, CCTouchHandler p2)
 {
     return(p1.Priority - p2.Priority);
 }
Esempio n. 15
0
 /// <summary>
 /// Used for sort
 /// </summary>
 private int Less(CCTouchHandler p1, CCTouchHandler p2)
 {
     return p1.Priority - p2.Priority;
 }