Esempio n. 1
0
 /// <summary>
 ///   Create a virtual desktop from a previously stored session.
 /// </summary>
 /// <param name = "session">The previously stored session.</param>
 /// <param name = "persistenceProvider">Provider which allows to persist application state.</param>
 internal VirtualDesktop(StoredSession session, AbstractPersistenceProvider persistenceProvider)
     : this( persistenceProvider )
 {
     _persistedApplications = session.PersistedApplications.ToList();
     IsSuspended            = _persistedApplications.Count > 0;
     _windows.AddRange(session.OpenWindows.Where(w => !w.Info.IsDestroyed()));
 }
Esempio n. 2
0
        /// <summary>
        ///   Initializes a new desktop manager and creates one startup desktop containing all currently open windows.
        ///   This desktop is accessible through the <see cref="AbstractWorkspaceManager{TWorkspace,TSession}.CurrentWorkspace" /> property.
        /// </summary>
        /// <param name = "settings">
        ///   Contains settings for how the desktop manager should behave. E.g. which windows to ignore.
        /// </param>
        /// <param name = "persistenceProvider">Allows state of applications to be persisted and restored.</param>
        /// <exception cref = "BadImageFormatException">Thrown when other than x64 virtual desktop manager is run to operate on x64 platform.</exception>
        /// <exception cref = "NotSupportedException">Thrown when virtual desktop manager is started without necessary privileges.</exception>
        public VirtualDesktopManager(ISettings settings, AbstractPersistenceProvider persistenceProvider)
        {
            Contract.Requires(settings != null);

            _persistenceProvider = persistenceProvider;

            if (!settings.IgnoreRequireElevatedPrivileges)
            {
                // ReSharper disable once AssignNullToNotNullAttribute, WindowsIdentity.GetCurrent() will never return null (http://stackoverflow.com/a/15998940/590790)
                var myPrincipal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
                if (!myPrincipal.IsInRole(WindowsBuiltInRole.Administrator) && WindowsIdentityHelper.IsUserInAdminGroup())
                {
                    throw new NotSupportedException(
                              "The virtual desktop manager should be started with elevated privileges, otherwise it can't manage windows of processes with elevated privileges. " +
                              "Alternatively, set 'IgnoreRequireElevantedPrivileges' to true in the settings passed to the VDM initialization, in which case these windows will be ignored entirely. " +
                              "While debugging, we recommend running Visual Studio with elevated privileges as well.");
                }
            }
            if (Environment.Is64BitOperatingSystem && !Environment.Is64BitProcess)
            {
                throw new BadImageFormatException("A 64 bit version is needed for the Virtual Desktop Manager in order to run on a 64 bit platform.");
            }

            // Determine which windows shouldn't be managed by the desktop manager.
            _windowFilter = settings.CreateWindowFilter();
            _hideBehavior = settings.CreateHideBehavior();

            // Initialize visible startup desktop.
            var startupDesktop = new VirtualDesktop(_persistenceProvider)
            {
                IsStartupDesktop = true
            };

            SetStartupWorkspace(startupDesktop);
            startupDesktop.UnresponsiveWindowDetected += OnUnresponsiveWindowDetected;
            startupDesktop.AddWindows(GetNewWindows());

            _monitorServer = new MonitorVdmPipeServer(this);

            UpdateWindowAssociations();
        }
Esempio n. 3
0
 /// <summary>
 ///   Create an empty virtual desktop.
 /// </summary>
 internal VirtualDesktop(AbstractPersistenceProvider persistenceProvider)
 {
     _persistenceProvider = persistenceProvider;
 }