コード例 #1
0
 static ModernUI()
 {
     try {
         // Only try to instanciate when Windows 8 or later.
         if (Environment.OSVersion.Version.Major >= 6 && Environment.OSVersion.Version.Minor >= 2)
         {
             appVisibility = COMWrapper.CreateInstance <IAppVisibility>();
         }
     } catch {
     }
 }
コード例 #2
0
        public TaskbarManager(ConfigurationManager configurationManager)
        {
            dispatcherTimer          = new DispatcherTimer();
            dispatcherTimer.Tick    += DispatcherTimer_Tick;
            dispatcherTimer.Interval = TimeSpan.FromMilliseconds(20);

            appVisibility = (IAppVisibility)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("7E5FE3D9-985F-4908-91F9-EE19F9FD1514")));

            var handle = PInvoke.FindWindow(PrimaryTaskbarClassName, string.Empty);

            primaryTaskbar = new Taskbar(handle.Value);

            configurationManager.Changed += ConfigurationManager_Changed;
            ConfigurationManager_Changed(configurationManager.ConfigFile);
        }
コード例 #3
0
        // Note: when using events, this object must be held in memory by the consumer
        public AppVisibilityHelper(bool useEvents)
        {
            if (!EnvironmentHelper.IsWindows8OrBetter)
            {
                ShellLogger.Debug("AppVisibilityHelper: Requires Windows 8 or higher");
                return;
            }

            // get IAppVisibility instance
            _appVis    = (IAppVisibility) new AppVisibility();
            _useEvents = useEvents;

            if (_appVis == null)
            {
                ShellLogger.Debug("AppVisibilityHelper: Unable create IAppVisibility");
                return;
            }

            if (!_useEvents)
            {
                return;
            }

            if (!EnvironmentHelper.IsWindows10OrBetter)
            {
                ShellLogger.Debug("AppVisibilityHelper: Events require Windows 10 or higher");
                return;
            }

            // register for events
            // only works properly on Windows 10 or later
            AppVisibilityEvents events = new AppVisibilityEvents();

            events.AppVisibilityChanged      += Events_AppVisibilityChanged;
            events.LauncherVisibilityChanged += Events_LauncherVisibilityChanged;

            if (_appVis.Advise(events, out _eventCookie) == 0)
            {
                // subscribed to events successfully
                ShellLogger.Debug("AppVisibilityHelper: Subscribed to change events");
            }
            else
            {
                ShellLogger.Debug("AppVisibilityHelper: Unable to subscribe to change events");
            }
        }