Exemplo n.º 1
0
 internal static void Initialize()
 {
     VirtualDesktopManager         = Utils.CreateInstance <IVirtualDesktopManager>(CLSID.VirtualDesktopManager);
     VirtualDesktopManagerInternal = VirtualDesktopManagerInternal.GetInstance();
     VirtualDesktopPinnedApps      = Utils.FromShell <IVirtualDesktopPinnedApps>(CLSID.VirtualDesktopPinnedApps);
     ApplicationViewCollection     = Utils.FromShell <IApplicationViewCollection>();
 }
Exemplo n.º 2
0
        static DesktopManager()
        {
            var shell = (IServiceProvider10)Activator.CreateInstance(Type.GetTypeFromCLSID(Guids.CLSID_ImmersiveShell));

            VirtualDesktopManagerInternal = (IVirtualDesktopManagerInternal)shell.QueryService(Guids.CLSID_VirtualDesktopManagerInternal, typeof(IVirtualDesktopManagerInternal).GUID);
            VirtualDesktopManager         = (IVirtualDesktopManager)Activator.CreateInstance(Type.GetTypeFromCLSID(Guids.CLSID_VirtualDesktopManager));
            ApplicationViewCollection     = (IApplicationViewCollection)shell.QueryService(typeof(IApplicationViewCollection).GUID, typeof(IApplicationViewCollection).GUID);
            VirtualDesktopPinnedApps      = (IVirtualDesktopPinnedApps)shell.QueryService(Guids.CLSID_VirtualDesktopPinnedApps, typeof(IVirtualDesktopPinnedApps).GUID);
        }
Exemplo n.º 3
0
        internal static void Initialize()
        {
            VirtualDesktopManager             = GetVirtualDesktopManager();
            VirtualDesktopManagerInternal     = VirtualDesktopManagerInternal.GetInstance();
            VirtualDesktopNotificationService = GetVirtualDesktopNotificationService();
            VirtualDesktopPinnedApps          = GetVirtualDesktopPinnedApps();
            ApplicationViewCollection         = GetApplicationViewCollection();

            _virtualDesktops.Clear();
            _listener = VirtualDesktop.RegisterListener();
        }
Exemplo n.º 4
0
        internal static void Initialize()
        {
            if (_listenerWindow == null)
            {
                _listenerWindow = new ExplorerRestartListenerWindow(() => Initialize());
                _listenerWindow.Show();
            }

            VirtualDesktopManager             = GetVirtualDesktopManager();
            VirtualDesktopManagerInternal     = VirtualDesktopManagerInternal.GetInstance();
            VirtualDesktopNotificationService = GetVirtualDesktopNotificationService();
            VirtualDesktopPinnedApps          = GetVirtualDesktopPinnedApps();
            ApplicationViewCollection         = GetApplicationViewCollection();

            _virtualDesktops.Clear();
            _listener = VirtualDesktop.RegisterListener();
        }
Exemplo n.º 5
0
        internal static void Initialize()
        {
            _listener?.Dispose();
            if (_listenerWindow == null)
            {
                _listenerWindow = new ExplorerRestartListenerWindow(() => {
                    // this is required so that user does not try to call APIs via broken references
                    bool waitForAdvanced              = VirtualDesktopManagerInternal != null;
                    VirtualDesktopManagerInternal     = null;
                    VirtualDesktopNotificationService = null;
                    VirtualDesktopPinnedApps          = null;
                    ApplicationViewCollection         = null;
                    try {
                        Initialize();
                    } catch (NotSupportedException) { }

                    while (waitForAdvanced && VirtualDesktopManagerInternal == null)
                    {
                        Dispatcher.CurrentDispatcher.Invoke(DispatcherPriority.Background, new Action(() => { }));
                        try {
                            Initialize();
                        } catch (NotSupportedException) { }
                    }

                    RegisterListener();
                });
                _listenerWindow.Show();
            }

            VirtualDesktopManager = MissingCOMInterfaceException.Ensure(GetVirtualDesktopManager());
            try
            {
                VirtualDesktopManagerInternal     = VirtualDesktopManagerInternal.GetInstance();
                VirtualDesktopNotificationService = MissingCOMInterfaceException.Ensure(GetVirtualDesktopNotificationService());
                VirtualDesktopPinnedApps          = MissingCOMInterfaceException.Ensure(GetVirtualDesktopPinnedApps());
                ApplicationViewCollection         = MissingCOMInterfaceException.Ensure(Interop.ApplicationViewCollection.Get());
            }
            finally {
                _virtualDesktops.Clear();
            }
        }