/// <summary> /// 添加事件回调函数 /// </summary> /// <param name="handler">回调处理函数</param> /// <param name="events">事件类型</param> public void AddHandler(GlobalEventHandler handler, params GlobalEventType[] events) { foreach (GlobalEventType type in events) { _globalHandler[(int)type].Add(handler); } }
public ControlPanel(GlobalEventHandler globalEventHandler) : base(globalEventHandler) { InitializeComponent(); DataContext = this; Loaded += onLoaded; PreviewKeyUp += onPreviewKeyUp; }
public static void RemoveListener(EEvent type, GlobalEventHandler listener) { bool isTriggingEvent = EventHelper.IsTriggingEvent; if (isTriggingEvent) { EventHelper.allPendingListeners.Enqueue(new EventHelper.ListenerInfo(false, type, listener)); } else { List <GlobalEventHandler> list; bool flag = EventHelper.allListeners.TryGetValue((int)type, out list); if (flag) { bool flag2 = list.Remove(listener); if (flag2) { bool flag3 = list.Count == 0; if (flag3) { EventHelper.allListeners.Remove((int)type); } } } } }
public GenericAuditHandler(IBus bus, GlobalEventHandler broadcaster, IDocumentStore store, EventLogMappings mappings) { this.bus = bus; this.broadcaster = broadcaster; this.store = store; this.mappings = mappings; }
public static GlobalEventHandler GetInstance() { if( instance == null ) instance = new GlobalEventHandler(); return instance; }
public static void RemoveListener(EEvent type, GlobalEventHandler listener) { if (IsTriggingEvent) { allPendingListeners.Enqueue(new ListenerInfo(false, type, listener)); return; } var itype = (int)type; if (allListeners.TryGetValue(itype, out var tmplst)) { if (tmplst.Remove(listener)) { if (tmplst.Count == 0) { allListeners.Remove(itype); } return; } } //Debug.LogError("Try remove a not exist listner " + type); }
private void OnEnable() { cache = new Dictionary <int, object>(); GlobalEventHandler.SubscribeEvent <int, object>(Events.ConsoleEvents.CacheEvent, CacheId); GlobalEventHandler.SubscribeEvent <int>(Events.ConsoleEvents.RemoveEvent, RemoveId); GlobalEventHandler.SubscribeEvent <int>(Events.ConsoleEvents.ShowIdEvent, DisplayCacheIds); }
private void OnDisable() { cache.Clear(); GlobalEventHandler.UnsubscribeEvent <int, object>(Events.ConsoleEvents.CacheEvent, CacheId); GlobalEventHandler.UnsubscribeEvent <int>(Events.ConsoleEvents.CacheEvent, RemoveId); GlobalEventHandler.UnsubscribeEvent <int>(Events.ConsoleEvents.ShowIdEvent, DisplayCacheIds); }
public static GlobalEventHandler GetEventHandler(MyDefinitionId eventDefinitionId) { GlobalEventHandler handler = null; m_typesToHandlers.TryGetValue(eventDefinitionId, out handler); return(handler); }
/// <summary> /// Executes a registered method within the event tables. If only one argument is parsed /// then the Global Event Table is executed. /// </summary> /// <param name="input">The user's input</param> public void TryExecuteCommand(string input) { // Trim the input of trailing white spaces and split the string into an array of strings. var args = input.Trim().Split(delimiter); if (args.Length > 1) { var parameters = argParser.ParseParameters(CopyArgs(args, 2)); int intValue = argParser.TryParseInt(args[1]); if (cache.IsIdCached(intValue)) { InvokeRelativeEvent(args[0], intValue, parameters); var objectArg = cache[intValue]; GlobalEventHandler.InvokeEvent(args[0], System.Convert.ChangeType(objectArg, objectArg.GetType())); } else { GlobalEventHandler.InvokeEvent(args[0], intValue); } } else { InvokeGlobalEvent(args[0]); } }
public void AddListener(GlobalEventHandler eventHandler) { if (listeners.Contains(eventHandler)) { return; } listeners.Add(eventHandler); }
public void Register(string EventName, GlobalEventHandler Handler) { if (!HandlerChain.Contains(EventName)) { HandlerChain.Add(EventName, new List <GlobalEventHandler>()); } ((List <GlobalEventHandler>)HandlerChain[EventName]).Add(Handler); }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.A) && !isCrushing) { isCrushing = true; // Nervous changes foreach (Collider2D coll in Physics2D.OverlapCircleAll(gameObject.transform.position, 3)) { if (coll.tag == "Victim") { coll.gameObject.GetComponent <VictimControls>().SetNervous(); } } // Spook changes foreach (Collider2D coll in Physics2D.OverlapCircleAll(gameObject.transform.position, 1)) { if (coll.tag == "Victim") { coll.gameObject.GetComponent <VictimControls>().SetSpook(); } } } if (isCrushing) { crushDuration += Time.deltaTime; renderer.sprite = crushDuration > 0 && crushDuration <= 0.0625 ? Frame2 : crushDuration > 0.0625 && crushDuration <= 0.125 ? Frame3 : crushDuration > 0.125 && crushDuration <= 0.1875 ? Frame4 : crushDuration > 0.1875 && crushDuration <= 0.250 ? Frame5 : crushDuration > 0.250 && crushDuration <= 0.3125 ? Frame6 : crushDuration > 0.3125 && crushDuration <= 0.3750 ? Frame7 : crushDuration > 0.3750 && crushDuration <= 0.4375 ? Frame8 : Frame1; if (crushDuration > 0.0625 && crushDuration < 0.125) { foreach (Collider2D coll in Physics2D.OverlapCircleAll(gameObject.transform.position, 1f)) { if (coll.tag == "Victim") { foreach (AudioSource sound in GetComponents <AudioSource>()) { sound.Play(); } bloodGush.Stop(); bloodGush.Play(); Object.Destroy(coll.gameObject); GlobalEventHandler.SendEvent(new GameEvents.VictimDied { }); } } } if (crushDuration > 0.4375) { isCrushing = false; crushDuration = 0; } } }
public UnCloseableWindow(GlobalEventHandler globalEventHandler) : base() { IgnoreWindowPlacement = true; var minMouseMovePoints = 99; _GlobalEventHandler = globalEventHandler; PreviewMouseMove += async(s, e) => minMouseMovePoints = await ExitStrategy.CloseIfBigMoveBoforeGracePeriod(minMouseMovePoints, this, GetType().Name); //Closing += UnCloseableWindow_Closing; Closed += UnCloseableWindow_Closed; PreviewKeyUp += async(s, e) => { e.Handled = await ExitStrategy.CloseBasedOnPCName(e.Key, this); if (e.Handled) { //todo: is it redundant Application.Current.Shutdown(77); Trace.WriteLine($"{DateTime.Now:yy.MM.dd HH:mm:ss.f} +{(DateTime.Now - App.StartedAt):mm\\:ss\\.ff} App.Shutdown(77) in PreviewKeyUp(). "); } else { switch (e.Key) { case Key.F1: _GlobalEventHandler.TglContainerVis("ContainerA"); break; case Key.F2: _GlobalEventHandler.TglContainerVis("ContainerB"); break; case Key.F3: _GlobalEventHandler.TglContainerVis("ContainerC"); break; case Key.F4: _GlobalEventHandler.TglContainerVis("ContainerD"); break; case Key.F5: _GlobalEventHandler.TglContainerVis("ContainerE"); break; case Key.F6: _GlobalEventHandler.TglContainerVis("ContainerF"); break; case Key.F7: _GlobalEventHandler.TglContainerVis("ContainerG"); break; case Key.F8: _GlobalEventHandler.TglContainerVis("ContainerH"); break; case Key.F9: _GlobalEventHandler.TglContainerVis("ContainerI"); break; case Key.F10: _GlobalEventHandler.TglContainerVis("ContainerJ"); break; case Key.F11: _GlobalEventHandler.TglContainerVis("ContainerK"); break; case Key.F12: _GlobalEventHandler.TglContainerVis("ContainerL"); break; default: App.StopSpeakingAsync(); App.SpeakFaF($"{e.Key} not handled!"); return; } } }; }
public static void UnregisterHandler(string evt, GlobalEventHandler handler) { if (string.IsNullOrEmpty(evt) || handler == null) { return; } if (immediateHandlersTable.ContainsKey(evt)) { immediateHandlersTable[evt] -= handler; } }
public GlobalEventArgs(bool isDelay, float delayTime, GlobalEventHandler initEventFunction, bool isTimeLimitation, float limitTime, GlobalEventHandler finishEventFunction, EventTransferArgs args) { IsDelay = isDelay; DelayTime = delayTime; InitEventFunction = initEventFunction; IsTimeLimitation = isTimeLimitation; LimitTime = limitTime; FinishEventFunction = finishEventFunction; Args = args; }
protected override void OnStartup(StartupEventArgs e) { System.AppContext.SetSwitch("Switch.System.Windows.Input.Stylus.EnablePointerSupport", true); CultureInfo culture = new CultureInfo("en"); Thread.CurrentThread.CurrentCulture = culture; Thread.CurrentThread.CurrentUICulture = culture; CultureInfo.DefaultThreadCurrentCulture = culture; CultureInfo.DefaultThreadCurrentUICulture = culture; string baseDir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); CrashHandler.Init(baseDir); // Check command line arguments var cmdLine = new CommandLine(e.Args); // Show Welcome Dialog while initializing bool bSkipWelcome = cmdLine.NoWelcomeDialog || cmdLine.HasPathToOpen || cmdLine.HasScriptToRun; if (!bSkipWelcome) { WelcomeDialog.ShowAsync(); } // Set AppUserModelID for Shell-Features like JumpList, Taskbar-Grouping Win32Api.SetCurrentProcessExplicitAppUserModelID("Macad.1"); CreateInstanceMutexes(); // Init OCCT #if DEBUG Environment.SetEnvironmentVariable(@"CSF_DEBUG", "1"); #endif // Init statics GlobalEventHandler.Init(); WindowsClipboard.Init(); // Init context AppContext.Initialize(cmdLine); // Start main window MainWindow = new MainWindow(new MainWindowModel()); WelcomeDialog.Current?.SetMainWindow(MainWindow); MainWindow.Show(); ShutdownMode = ShutdownMode.OnMainWindowClose; base.OnStartup(e); }
public void AddListener(GlobalEventHandler eventHandler) { if (IsEmpty) { return; } if (!Value) { Debug.LogError($"Cannot add listener to event: {GetPath()}"); return; } Value.AddListener(eventHandler); }
public bool RemoveListener(GlobalEventHandler eventHandler) { if (IsEmpty) { return(false); } if (!Value) { Debug.LogError($"Cannot remove listener to event: {GetPath()}"); return(false); } return(Value.RemoveListener(eventHandler)); }
public static void AddListener(EEvent type, GlobalEventHandler listener) { if (IsTriggingEvent) { allPendingListeners.Enqueue(new ListenerInfo(true, type, listener)); return; } var itype = (int)type; if (allListeners.TryGetValue(itype, out var tmplst)) { tmplst.Add(listener); } else { var lst = new List <GlobalEventHandler>(); lst.Add(listener); allListeners.Add(itype, lst); } }
public static void AddListener(EEvent type, GlobalEventHandler listener) { #if _DEBUG_EVENT_TRIGGER if (IsTriggingEvent) { Debug.LogError("Error!!! can not modify allListeners when was Trigger Event"); } #endif var itype = (int)type; if (allListeners.TryGetValue(itype, out var tmplst)) { tmplst.Add(listener); } else { var lst = new List <GlobalEventHandler>(); lst.Add(listener); allListeners.Add(itype, lst); } }
public static void RemoveListener(EEvent type, GlobalEventHandler listener) { #if _DEBUG_EVENT_TRIGGER if (IsTriggingEvent) { Debug.LogError("Error!!! can not modify allListeners when was Trigger Event"); } #endif var itype = (int)type; if (allListeners.TryGetValue(itype, out var tmplst)) { if (tmplst.Remove(listener)) { if (tmplst.Count == 0) { allListeners.Remove(itype); } return; } } Debug.LogError("Try remove a not exist listner " + type); }
public static void AddListener(EEvent type, GlobalEventHandler listener) { bool isTriggingEvent = EventHelper.IsTriggingEvent; if (isTriggingEvent) { EventHelper.allPendingListeners.Enqueue(new EventHelper.ListenerInfo(true, type, listener)); } else { List <GlobalEventHandler> list; bool flag = EventHelper.allListeners.TryGetValue((int)type, out list); if (flag) { list.Add(listener); } else { List <GlobalEventHandler> list2 = new List <GlobalEventHandler>(); list2.Add(listener); EventHelper.allListeners.Add((int)type, list2); } } }
// Use this for initialization void Start() { this.rounds = 0; this.eventHandler = GameObject.FindGameObjectWithTag("EventHandler").GetComponent<GlobalEventHandler> (); }
public EventMonitor(NSEventMask[] mask, GlobalEventHandler handler) { this.mask = mask; this.handler = handler; }
public AuditEventLogWriter(GlobalEventHandler broadcaster, IDocumentStore store, EventLogMappings mappings) { this.broadcaster = broadcaster; this.store = store; this.mappings = mappings; }
void Awake() { GlobalEventHandler.Register <NPCLeft>(OnNPCLeft); }
void Awake() { instance = this; }
public void Awake() { handler = this; }
private void OnDisable() { GlobalEventHandler.UnsubscribeEvent <object>("ToggleAI", SwapAgentState); }
public bool RemoveListener(GlobalEventHandler eventHandler) { return(listeners.Remove(eventHandler)); }
private static void RegisterHandler(MyDefinitionId eventDefinitionId, GlobalEventHandler handler) { Debug.Assert(!m_typesToHandlers.ContainsKey(eventDefinitionId), "One event definition id can only have one event handler!"); m_typesToHandlers[eventDefinitionId] = handler; }