Ejemplo n.º 1
0
        public bool RegisterEvent(ILightEvent @event)
        {
            string key = @event.Config.ID;

            if (string.IsNullOrWhiteSpace(key) || Events.ContainsKey(key))
            {
                return(false);
            }

            Events.Add(key, @event);

            if (@event.Config.ProcessNames != null)
            {
                foreach (string exe in @event.Config.ProcessNames)
                {
                    if (!exe.Equals(key))
                    {
                        EventProcesses.Add(exe.ToLower(), key);
                    }
                }
            }

            if (@event.Config.ProcessTitles != null)
            {
                foreach (string titleRx in @event.Config.ProcessTitles)
                {
                    EventTitles.Add(titleRx, key);
                }
            }

            if (!String.IsNullOrWhiteSpace(@event.Config.AppID))
            {
                EventAppIDs.Add(@event.Config.AppID, key);
            }

            if (@event is Application)
            {
                if (!Global.Configuration.ProfileOrder.Contains(key))
                {
                    Global.Configuration.ProfileOrder.Add(key);
                }
            }

            this.InsertLightEvent(@event);

            if (Initialized)
            {
                @event.Initialize();
            }

            return(true);
        }
Ejemplo n.º 2
0
        public ILightEvent GetProfileFromAppID(string appid)
        {
            if (EventAppIDs.ContainsKey(appid))
            {
                if (!Events.ContainsKey(EventAppIDs[appid]))
                {
                    Global.logger.LogLine($"GetProfileFromAppID: The appid '{appid}' exists in EventAppIDs but subsequently '{EventAppIDs[appid]}' does not in Events!", Logging_Level.Warning);
                }
                return(Events[EventAppIDs[appid]]);
            }
            else if (Events.ContainsKey(appid))
            {
                return(Events[appid]);
            }

            return(null);
        }