//注册此事件的监听 回调函数 public void AddListener(MyBtnEvent myBtnEvent, BaseEventHandler call) { Debug.Log("执行事件注册函数"); switch (myBtnEvent) { case MyBtnEvent.Left_DOWN: btnEventHandler_LeftDown += call; Debug.Log("执行完 LeftDown 事件注册"); break; case MyBtnEvent.Left_PRESSED: btnEventHandler_LeftPressed += call; break; case MyBtnEvent.Left_UP: btnEventHandler_LeftUp += call; break; case MyBtnEvent.Right_DOWN: btnEventHandler_RightDown += call; break; case MyBtnEvent.Right_PRESSED: btnEventHandler_RightPressed += call; break; case MyBtnEvent.Right_UP: btnEventHandler_RightUp += call; break; } }
/// <summary> /// 事件订阅 /// </summary> /// <param name="handler">处理回调</param> /// <param name="mode">匹配过滤模式</param> /// <param name="descriptions">匹配事件描述</param> public Guid Subscribe <TEvent>(BaseEventHandler <TEvent> handler, string descriptions, FilterMode mode = FilterMode.StartsWith) where TEvent : IEvent, new() { var task = SubscribeAsync(handler, descriptions, mode); task.Wait(); return(task.Result); }
private void OnLoaded(object sender, System.Windows.RoutedEventArgs e) { WindowsFormsHost FormsHost = new WindowsFormsHost(); Panel = new System.Windows.Forms.Panel(); FormsHost.Child = Panel; AddChild(FormsHost); this.Process = new Process(); this.Process.StartInfo = StartInfo; this.Process.Exited += OnProcessExited; this.Process.Start(); //this.Process.StartInfo.CreateNoWindow = true; this.Process.EnableRaisingEvents = true; this.Process.WaitForInputIdle(); Thread.Sleep(WaitTimeout); NativeMethods.SetParent(Process.MainWindowHandle, Panel.Handle); // remove control box int style = NativeMethods.GetWindowLong(Process.MainWindowHandle, GWL_STYLE); style = style & ~WS_CAPTION & ~WS_THICKFRAME; NativeMethods.SetWindowLong(Process.MainWindowHandle, GWL_STYLE, style); // resize embedded application & refresh ResizeEmbeddedApp(); }
protected override void Awake() { if (GetComponentInChildren <AnimEventHandler>() != null) { base.Awake(); if (m_Animation == null) { m_Animation = this.GetComponentInChildren <AnimHandler>(true); } if (m_AnimationEvents == null) { m_AnimationEvents = this.GetComponentInChildren <AnimEventHandler>(true); } m_old = true; } else { base.Awake(); if (m_animator == null) { m_animator = this.GetComponentInChildren <Animator>(true); } if (m_animatorControl == null) { m_animatorControl = this.GetComponentInChildren <AnimatorControl>(true); } if (m_eventHandler == null) { m_eventHandler = this.GetComponentInChildren <BaseEventHandler>(true); } m_animator.cullingMode = AnimatorCullingMode.AlwaysAnimate; } }
public void AddEventListener <T>(string _evtType, BaseEventHandler <T> _handler) where T : BaseEvent { // TODO: Maybe we need to find a way to deal with the situation that subscriber continuously add listen //even though we already have one dispatching. //if(m_dispatchingEvent == _evtType) //{ // // Add it later // return; //} // Make a temporary copy of the event to avoid possibility of a race condition // if the last subscriber unsubscribes immediately after the null check and // before the event is raised. List <Delegate> thisEventHandlers; // First find or create the handlers corresponded to this event. if (m_allHandlers.ContainsKey(_evtType)) { thisEventHandlers = m_allHandlers[_evtType]; } else { m_allHandlers[_evtType] = thisEventHandlers = new List <Delegate>(); } // Append one if it's not included in the existed handlers. if (thisEventHandlers.IndexOf(_handler as Delegate) == -1) { m_allHandlers[_evtType].Add(_handler); } }
//移除此事件的监听 回调函数 public void RemoveListener(MyBtnEvent myBtnEvent, BaseEventHandler call) { switch (myBtnEvent) { case MyBtnEvent.Left_DOWN: btnEventHandler_LeftDown -= call; break; case MyBtnEvent.Left_PRESSED: btnEventHandler_LeftPressed -= call; break; case MyBtnEvent.Left_UP: btnEventHandler_LeftUp -= call; break; case MyBtnEvent.Right_DOWN: btnEventHandler_RightDown -= call; break; case MyBtnEvent.Right_PRESSED: btnEventHandler_RightPressed -= call; break; case MyBtnEvent.Right_UP: btnEventHandler_RightUp -= call; break; } }
/// <summary> /// 异步事件订阅 /// </summary> /// <param name="handler">处理回调</param> /// <param name="mode">匹配过滤模式</param> /// <param name="descriptions">匹配事件描述</param> /// <returns>异步任务</returns> public Task <Guid> SubscribeAsync <TEvent>(BaseEventHandler <TEvent> handler, string descriptions, FilterMode mode = FilterMode.StartsWith) where TEvent : IEvent, new() { return(Task.Factory.StartNew(() => { if (handler == null) { throw new DomianEventException("事件处理回调不能为空!"); } if (descriptions == null || descriptions.Length == 0) { throw new DomianEventException("订阅事件至少需要一条描述!"); } //if (mode == FilterMode.FullLocalEvent && !(handler is BaseEventHandler<EventJsonWrapper>)) //{ // throw new DomianEventException("订阅本地全部事件时,请实现BaseEventHandler<EventJsonWrapper>!"); //} var id = Guid.NewGuid(); lock (subscribes) { subscribes.Add(new LocalSubscribeItem() { Handler = handler, Descriptions = descriptions, FilterMode = mode, Id = id }); } // if (FilterMode.FullLocalEvent != mode) RemoteServiceAgent?.Subscribe(new SubscribeItem() { Descriptions = descriptions, FilterMode = mode, PublisherId = PublisherId }); return id; })); }
protected override void Awake() { base.Awake(); m_Effects = GetComponent <FXDefinitions>(); if (m_AnimationEventHandler == null) { m_AnimationEventHandler = this.GetComponentInChildren <BaseEventHandler>(true); } }
public void RemoveEventListener <T>(string _evtType, BaseEventHandler <T> _handler) where T : BaseEvent { if (m_dispatchingEvent == _evtType) { // Remove it later return; } m_eventRegister.RemoveEventListener <T>(_evtType, _handler); }
public async Task RunAsync() { var activity = new DiscordActivity("with startup code.", ActivityType.Playing); await Client.ConnectAsync(activity); var channel = await Client.GetChannelAsync(LogChannel); BaseEventHandler.SetUpEvents(Client, channel); await Task.Delay(-1); }
public static void RemoveListener(System.Type eventType, BaseEventHandler handler) { if (_events.ContainsKey(eventType)) { if (_events[eventType].Contains(handler)) { _events[eventType].Remove(handler); } } }
public static void AddListener(System.Type eventType, BaseEventHandler handler) { if (!_events.ContainsKey(eventType)) { _events[eventType] = new List <BaseEventHandler>(); } if (!_events[eventType].Contains(handler)) { _events[eventType].Add(handler); } }
public void RemoveEventListener <T>(string _evtType, BaseEventHandler <T> _handler) where T : BaseEvent { List <Delegate> thisEventHandlers; if (m_allHandlers != null && m_allHandlers.ContainsKey(_evtType)) { thisEventHandlers = m_allHandlers[_evtType]; // Remove only when existed. if (thisEventHandlers.IndexOf(_handler as Delegate) != -1) { thisEventHandlers.Remove(_handler as Delegate); } } }
protected override void Awake() { base.Awake(); if (m_animator == null) { m_animator = this.GetComponent <Animator>(true); } if (m_animatorControl == null) { m_animatorControl = this.GetComponent <AnimatorControl>(true); } if (m_eventHandler == null) { m_eventHandler = this.GetComponentInChildren <BaseEventHandler>(true); } m_animator.cullingMode = AnimatorCullingMode.AlwaysAnimate; m_MainView = this.GetComponent <LevelEntityView>(true); }
public void Configurate(BaseEventHandler p_handler, FXArgs p_args) { if (p_handler == null) { throw new ArgumentNullException("handler"); } if (p_args == null) { throw new ArgumentNullException("args"); } for (Int32 i = 0; i < m_FXQueueMap.Length; i++) { if (!(m_FXQueueMap[i] == null)) { m_FXQueueMap[i] = Helper.Instantiate <FXQueue>(m_FXQueueMap[i]); m_FXQueueMap[i].EffectArguments = p_args; m_FXQueueMap[i].Finished += HandleFinishedFXQueue; p_handler.RegisterAnimationCallback((EAnimEventType)i, new Action(m_FXQueueMap[i].Execute)); } } }
public void RemoveEventListener<T>(string _evtType, BaseEventHandler<T> _handler) where T : BaseEvent { FlowDispatcher.RemoveEventListener<T>(_evtType, _handler); }
public void RemoveEventListener(string _evtType, BaseEventHandler<FlowEvent> _handler) { // Inherit from EventDispatcher. FlowDispatcher.RemoveEventListener<FlowEvent>(_evtType, _handler); }
public void RemoveEventListener(string _evtType, BaseEventHandler <BaseEvent> _handler) { Dispatcher.RemoveEventListener <BaseEvent>(_evtType, _handler); }
public void AddEventListener <T>(string _evtType, BaseEventHandler <T> _handler) where T : BaseEvent { Dispatcher.AddEventListener <T>(_evtType, _handler); }
/// <summary> /// Initializes a new instance of <see cref="BaseEventProxy"/> for specified <see cref="BaseEventHandler"/>. /// </summary> /// <param name="action">Event action</param> public BaseEventProxy(BaseEventHandler action) { EventHandler += action; }