예제 #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="callback"></param>
        public void Add(EventCallback1 callback)
        {
            if (_bridge == null)
                _bridge = this.owner.GetEventBridge(_type);

            _bridge.Add(callback);
        }
예제 #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="strType"></param>
        /// <param name="callback"></param>
        public void AddEventListener(string strType, EventCallback1 callback)
        {
            if (strType == null)
                throw new Exception("event type cant be null");

            if (_dic == null)
                _dic = new Dictionary<string, EventBridge>();

            EventBridge bridge = null;
            if (!_dic.TryGetValue(strType, out bridge))
            {
                bridge = new EventBridge(this);
                _dic[strType] = bridge;
            }
            bridge.Add(callback);
        }
예제 #3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="callback"></param>
        public void Set(EventCallback1 callback)
        {
            if (_bridge == null)
                _bridge = this.owner.GetEventBridge(_type);

            _bridge.Clear();
            if (callback != null)
                _bridge.Add(callback);
        }
예제 #4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="callback"></param>
        public void RemoveCapture(EventCallback1 callback)
        {
            if (_bridge == null)
                _bridge = this.owner.GetEventBridge(_type);

            _bridge.RemoveCapture(callback);
        }
예제 #5
0
        /// <summary>
        /// 
        /// </summary>
        public void Clear()
        {
            if (_bridge == null)
                _bridge = this.owner.GetEventBridge(_type);

            _bridge.Clear();
        }
예제 #6
0
        internal bool InternalDispatchEvent(string strType, EventBridge bridge, object data, object initiator)
        {
            EventBridge gBridge = null;
            if ((this is DisplayObject) && ((DisplayObject)this).gOwner != null)
                gBridge = ((DisplayObject)this).gOwner.TryGetEventBridge(strType);

            bool b1 = bridge != null && !bridge.isEmpty;
            bool b2 = gBridge != null && !gBridge.isEmpty;
            if (b1 || b2)
            {
                EventContext context = EventContext.Get();
                context.initiator = initiator != null ? initiator : this;
                context._stopsPropagation = false;
                context._defaultPrevented = false;
                context.type = strType;
                context.data = data;

                if (b1)
                {
                    bridge.CallCaptureInternal(context);
                    bridge.CallInternal(context);
                }

                if (b2)
                {
                    gBridge.CallCaptureInternal(context);
                    gBridge.CallInternal(context);
                }

                EventContext.Return(context);
                context.initiator = null;
                context.sender = null;
                context.data = null;

                return context._defaultPrevented;
            }
            else
                return false;
        }
예제 #7
0
        internal EventBridge GetEventBridge(string strType)
        {
            if (_dic == null)
                _dic = new Dictionary<string, EventBridge>();

            EventBridge bridge = null;
            if (!_dic.TryGetValue(strType, out bridge))
            {
                bridge = new EventBridge(this);
                _dic[strType] = bridge;
            }
            return bridge;
        }
예제 #8
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public bool Call(object data)
        {
            if (_bridge == null)
                _bridge = this.owner.GetEventBridge(_type);

            return owner.InternalDispatchEvent(this._type, _bridge, data, null);
        }