Пример #1
0
        internal static void Initialize()
        {
            VirtualDesktopManager             = GetVirtualDesktopManager();
            VirtualDesktopManagerInternal     = VirtualDesktopManagerInternal.GetInstance();
            VirtualDesktopNotificationService = GetVirtualDesktopNotificationService();
            VirtualDesktopPinnedApps          = GetVirtualDesktopPinnedApps();
            ApplicationViewCollection         = GetApplicationViewCollection();

            _virtualDesktops.Clear();
            _listener = VirtualDesktop.RegisterListener();
        }
Пример #2
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();
        }
Пример #3
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();
            }
        }