Ejemplo n.º 1
0
        public void AddEvent(EventTriggerType type, PointerEventDelegate action)
        {
            //type = EventTriggerType.BeginDrag;
            //LOG.Write("AddEvent1 " + action.ToString());
            //LOG.Write("AddEvent2 " + action.Method.ReflectedType.Name);
            //LOG.Write("AddEvent3 " + action.Method.Name);
            //LOG.Write("AddEvent4 " + action.Method.ToString());
            //LOG.Write("AddEvent5 " + action.Method.ReflectedType.Namespace);
            //LOG.Write("AddEvent6 " + action.Method.ReturnType.Name);
            //VoidDelegate del = AddEvent;

            string methodName = action.MethodFullName();

            Log.Write("AddEvent " + methodName);
            //LOG.Write("AddEvent action.Method.ToString()=" + action.Method.ToString());
            ActionEventDictionary typeEvents;

            if (!dict.ContainsKey(type))
            {
                typeEvents = new ActionEventDictionary();
                dict.Add(type, typeEvents);
            }
            else if (dict.TryGetValue(type, out typeEvents))
            {
                if (typeEvents != null && typeEvents.ContainsKey(action))
                {
                    if (typeEvents[action] != null)
                    {
                        Log.Write("typeEvents already contain " + methodName + " for " + type);
                        return;
                    }
                    else
                    {
                        typeEvents.Remove(action);
                    }
                }
            }

            ActionEvent actionListener = new ActionEvent((data) => { action((PointerEventData)data); });

            foreach (var item in triggers)
            {
                if (item.eventID == type)
                {
                    item.callback.AddListener(actionListener);
                    typeEvents.Add(action, actionListener);
                    return;
                }
            }
            EventTrigger.Entry entry = new EventTrigger.Entry();
            entry.eventID = type;
            //entry.callback.AddListener((data) => { action((PointerEventData)data); });
            entry.callback.AddListener(actionListener);
            typeEvents.Add(action, actionListener);
            triggers.Add(entry);
        }
Ejemplo n.º 2
0
 public void RemoveEvent(EventTriggerType type, PointerEventDelegate action)
 {
     foreach (var item in triggers)
     {
         if (item.eventID == type)
         {
             ActionEventDictionary typeEvents;
             if (dict.TryGetValue(type, out typeEvents))
             {
                 ActionEvent actionListener;
                 string      methodName = action.MethodFullName();
                 if (typeEvents.TryGetValue(action, out actionListener))
                 {
                     item.callback.RemoveListener(actionListener);
                     typeEvents.Remove(action);
                     Log.Write("successfully removed " + methodName + " from typeEvents");
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
 public void AddPointerDownListener(PointerEventDelegate pointerEventDelegate)
 {
     onPointerDown += pointerEventDelegate;
 }
Ejemplo n.º 4
0
 public void AddPointerUpListener(PointerEventDelegate pointerEventDelegate)
 {
     onPointerUp += pointerEventDelegate;
 }
Ejemplo n.º 5
0
 public void AddPointerDragListener(PointerEventDelegate pointerEventDelegate)
 {
     onPointerDrag += pointerEventDelegate;
 }