Example #1
0
        /// <summary>Gets the current application.</summary>
        /// <param name="preview">Boolean indicating whether the application is selected because it is previewing (true) or because the process is open (false).</param>
        public ILightEvent GetCurrentProfile(out bool preview)
        {
            string      process_name  = Path.GetFileName(processMonitor.ProcessPath).ToLower();
            string      process_title = processMonitor.GetActiveWindowsProcessTitle();
            ILightEvent profile       = null;
            ILightEvent tempProfile   = null;

            preview = false;

            //TODO: GetProfile that checks based on event type
            if ((((tempProfile = GetProfileFromProcessName(process_name)) != null) || ((tempProfile = GetProfileFromProcessTitle(process_title)) != null)) && tempProfile.Config.Type == LightEventType.Normal && tempProfile.IsEnabled)
            {
                profile = tempProfile;
            }
            else if ((tempProfile = GetProfileFromProcessName(previewModeProfileKey)) != null) //Don't check for it being Enabled as a preview should always end-up with the previewed profile regardless of it being disabled
            {
                profile = tempProfile;
                preview = true;
            }
            else if (Global.Configuration.allow_wrappers_in_background && Global.net_listener != null && Global.net_listener.IsWrapperConnected && ((tempProfile = GetProfileFromProcessName(Global.net_listener.WrappedProcess)) != null) && tempProfile.Config.Type == LightEventType.Normal && tempProfile.IsEnabled)
            {
                profile = tempProfile;
            }

            profile = profile ?? DesktopProfile;

            return(profile);
        }