Пример #1
0
 private static void OnListenerRemoved(MyEventType eventType)
 {
     if (m_EventTable[eventType] == null)
     {
         m_EventTable.Remove(eventType);
     }
 }
Пример #2
0
        //跟新增类型没区别,只是父节点和级数有变化
        private void barButtonItem_CreateSonType_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            g_eventType = new MyEventType();
            TreeListNode node = this.TreeList_Event.FocusedNode;

            this.DBOperType = "I";
            //this.addflage = "0";
            //无数据
            if (node == null)
            {
                MessageBox.Show("请先选择类型");
            }
            //一级节点
            if (node != null && node.ParentNode == null)
            {
                g_eventType.EVENTTYPE_ID       = Guid.NewGuid().ToString();
                g_eventType.EVENTTYPE_PARENTID = node.GetValue("EVENTTYPE_ID").ToString();
                g_eventType.EVENTTYPE_IFDETAIL = "F";
                g_eventType.EVENTTYPE_GRADE    = 2;
            }
            //非一级节点
            if (node != null && node.ParentNode != null)
            {
                g_eventType.EVENTTYPE_ID       = Guid.NewGuid().ToString();
                g_eventType.EVENTTYPE_PARENTID = node.GetValue("EVENTTYPE_ID").ToString();
                g_eventType.EVENTTYPE_IFDETAIL = "F";
                g_eventType.EVENTTYPE_GRADE    = Convert.ToInt32(node.GetValue("EVENTTYPE_GRADE")) + 1;
            }

            //状态修改
            ChangeCardState(true);
        }
Пример #3
0
        public void TriggerEvent(MyEventType eventType, EventInfo info)
        {
            if (eventListeners == null || !eventListeners.ContainsKey(eventType))
            {
                return;
            }

            eventListeners[eventType]?.Invoke(info);
        }
Пример #4
0
        public void StopListening(MyEventType eventType, Action <EventInfo> listener)
        {
            if (eventListeners.ContainsKey(eventType))
            {
                eventListeners[eventType] -= listener;

                if (eventListeners[eventType] == null)
                {
                    eventListeners.Remove(eventType);
                }
            }
        }
Пример #5
0
    private static void OnListenerAdding(MyEventType eventType, Delegate callBack)
    {
        if (!m_EventTable.ContainsKey(eventType))
        {
            m_EventTable.Add(eventType, null);
        }
        Delegate d = m_EventTable[eventType];

        if (d != null && d.GetType() != callBack.GetType())
        {
            throw new Exception(string.Format("尝试为事件{0}添加不同类型的委托,当前事件所对应的委托是{1},要添加的委托类型为{2}", eventType, d.GetType(), callBack.GetType()));
        }
    }
Пример #6
0
        public Sentence(float typ, string nam, Color namcol, string lin, Sprite portrai, Animationname[] aaba, MyEventType actio, bool goo, bool destro, bool questio)
        {
            typingSpeed = typ;
            name        = nam;
            namecolor   = namcol;
            line        = lin;

            portrait = portrai;
            aabs     = aaba;
            action   = actio;
            goon     = goo;
            destroy  = destro;
            question = questio;
        }
Пример #7
0
        public void StartListening(MyEventType eventType, Action <EventInfo> listener)
        {
            if (eventListeners == null)
            {
                eventListeners = new Dictionary <MyEventType, Action <EventInfo> >();
            }

            if (!eventListeners.ContainsKey(eventType))
            {
                eventListeners.Add(eventType, listener);
            }
            else
            {
                eventListeners[eventType] += listener;
            }
        }
Пример #8
0
    //five parameters
    public static void Broadcast <T, X, Y, Z, W>(MyEventType eventType, T arg1, X arg2, Y arg3, Z arg4, W arg5)
    {
        Delegate d;

        if (m_EventTable.TryGetValue(eventType, out d))
        {
            CallBack <T, X, Y, Z, W> callBack = d as CallBack <T, X, Y, Z, W>;
            if (callBack != null)
            {
                callBack(arg1, arg2, arg3, arg4, arg5);
            }
            else
            {
                throw new Exception(string.Format("广播事件错误:事件{0}对应委托具有不同的类型", eventType));
            }
        }
    }
Пример #9
0
    //no parameters
    public static void Broadcast(MyEventType eventType)
    {
        Delegate d;

        if (m_EventTable.TryGetValue(eventType, out d))
        {
            CallBack callBack = d as CallBack;
            if (callBack != null)
            {
                callBack();
            }
            else
            {
                throw new Exception(string.Format("广播事件错误:事件{0}对应委托具有不同的类型", eventType));
            }
        }
    }
Пример #10
0
 private static void OnListenerRemoving(MyEventType eventType, Delegate callBack)
 {
     if (m_EventTable.ContainsKey(eventType))
     {
         Delegate d = m_EventTable[eventType];
         if (d == null)
         {
             throw new Exception(string.Format("移除监听错误:事件{0}没有对应的委托", eventType));
         }
         else if (d.GetType() != callBack.GetType())
         {
             throw new Exception(string.Format("移除监听错误:尝试为事件{0}移除不同类型的委托,当前委托类型为{1},要移除的委托类型为{2}", eventType, d.GetType(), callBack.GetType()));
         }
     }
     else
     {
         throw new Exception(string.Format("移除监听错误:没有事件码{0}", eventType));
     }
 }
Пример #11
0
 /// <summary>
 /// Constructor for Normal Priority messages
 /// </summary>
 /// <param name="typeId">The type id to cast to derived for payload retrieval</param>
 /// <param name="eventId">The event identifier</param>
 public MyBaseMsg(MyMsgType msgType, MyEventType eventId)
     : this(msgType, eventId, SpEventPriority.Normal)
 {
 }
Пример #12
0
        IEnumerator TriggerEventDelay(MyEventType eventType, EventInfo info, float delay)
        {
            yield return(new WaitForSeconds(delay));

            TriggerEvent(eventType, info, delay);
        }
Пример #13
0
 public void TriggerEvent(MyEventType eventType, EventInfo info, float delay)
 {
     StartCoroutine(TriggerEventDelay(eventType, info, delay));
 }
Пример #14
0
 //no parameters
 public static void AddListener(MyEventType eventType, CallBack callBack)
 {
     OnListenerAdding(eventType, callBack);
     m_EventTable[eventType] = (CallBack)m_EventTable[eventType] + callBack;
 }
Пример #15
0
 //five parameters
 public static void AddListener <T, X, Y, Z, W>(MyEventType eventType, CallBack <T, X, Y, Z, W> callBack)
 {
     OnListenerAdding(eventType, callBack);
     m_EventTable[eventType] = (CallBack <T, X, Y, Z, W>)m_EventTable[eventType] + callBack;
 }
Пример #16
0
 //no parameters
 public static void RemoveListener(MyEventType eventType, CallBack callBack)
 {
     OnListenerRemoving(eventType, callBack);
     m_EventTable[eventType] = (CallBack)m_EventTable[eventType] - callBack;
     OnListenerRemoved(eventType);
 }
        private ISpEventMessage GetMsg(MyEventType eventId)
        {
            //Console.WriteLine("-- Sending msg:{0}", eventId.ToString());

            Log.Info("","", String.Format("---------------------- Sending msg:{0}", eventId));
            return new MyBaseMsg(MyMsgType.SimpleMsg, eventId);
        }
Пример #18
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="type">The type id to cast to derived for payload retrieval</param>
 /// <param name="eventId">The event identifier</param>
 /// <param name="priority">The priority of the message</param>
 public MyBaseMsg(MyMsgType msgType, MyEventType eventType, SpEventPriority priority)
     : base(new SpEnumToInt(msgType), new SpEnumToInt(eventType), priority)
 {
 }
Пример #19
0
        /// <summary>
        /// 循环绑定类型树
        /// </summary>
        /// <param name="treeList"></param>
        /// <param name="treeNode"></param>
        /// <param name="eventType"></param>
        /// <param name="eventTypeList"></param>
        private void LoadTypeTreeNode(DevExpress.XtraTreeList.TreeList treeList, TreeListNode treeNode, MyEventType eventType, List <MyEventType> eventTypeList)
        {
            int    grade    = eventType.EVENTTYPE_GRADE;
            string parentid = eventType.EVENTTYPE_ID;

            foreach (MyEventType item in eventTypeList)
            {
                if (item.EVENTTYPE_PARENTID == parentid && item.EVENTTYPE_GRADE - grade == 1)
                {
                    TreeListNode typeNode = treeList.AppendNode(new Object[] { item.EVENTTYPE_ID, item.EVENTTYPE_CODE, item.EVENTTYPE_NAME, item.EVENTTYPE_PARENTID, item.EVENTTYPE_IFDETAIL, item.EVENTTYPE_GRADE, item.EVENTTYPE_IFINVALID, item.EVENTTYPE_NOTE, item.EVENTTYPE_CREATETIME, item.EVENTTYPE_LASTMODIFIEDTIME, item.EVENTTYPE_MODIFICATIONTIMES, "EventType" }, treeNode);
                    typeNode.StateImageIndex = 0;
                    //循环绑定子类型
                    LoadTypeTreeNode(treeList, typeNode, item, eventTypeList);
                    LoadInfoTreeNode(treeList, typeNode, item.EVENTTYPE_EVENTINFO);
                }
            }
        }
Пример #20
0
 public MyEvent(MyEventType type, object myObject)
 {
     this.type     = type;
     this.myObject = myObject;
 }
Пример #21
0
 public MyEvent(MyEventType evtType)
 {
     m_MyEventType = evtType;
 }
 public void AnimationEvent(MyEventType evt)
 {
     EventManager.instance.TriggerEvent(evt, null);
 }
Пример #23
0
 public MyEventArgs(MyEventType type)
 {
     ThisType = type;
 }