Beispiel #1
0
        /// <summary>
        /// Creates a new Desktop object with the same desktop open.
        /// </summary>
        /// <returns>Cloned desktop object.</returns>
        public object Clone()
        {
            // make sure object isnt disposed.
            CheckDisposed();

            Desktop desktop = new Desktop();

            // if a desktop is open, make the clone open it.
            if (IsOpen) desktop.Open(m_desktopName);

            return desktop;
        }
Beispiel #2
0
        /// <summary>
        /// Sets the desktop of the calling thread.
        /// NOTE: Function will fail if thread has hooks or windows in the current desktop.
        /// </summary>
        /// <param name="desktop">Desktop to put the thread in.</param>
        /// <returns>True if the threads desktop was successfully changed.</returns>
        public static bool SetCurrent(Desktop desktop)
        {
            // set threads desktop.
            if (!desktop.IsOpen) return false;

            return SetThreadDesktop(desktop.DesktopHandle);
        }
Beispiel #3
0
        /// <summary>
        /// Switches to the specified desktop.
        /// </summary>
        /// <param name="name">Name of desktop to switch input to.</param>
        /// <returns>True if desktops were successfully switched.</returns>
        public static bool Show(string name)
        {
            // attmempt to open desktop.
            bool result = false;

            using (Desktop d = new Desktop())
            {
                result = d.Open(name);

                // something went wrong.
                if (!result) return false;

                // attempt to switch desktops.
                result = d.Show();
            }

            return result;
        }
Beispiel #4
0
        /// <summary>
        /// Opens the current input desktop.
        /// </summary>
        /// <returns>If successful, a Desktop object, otherwise, null.</returns>
        public static Desktop OpenInputDesktop()
        {
            // open the desktop.
            Desktop desktop = new Desktop();
            bool result = desktop.OpenInput();

            // somethng went wrong.
            if (!result) return null;

            return desktop;
        }
Beispiel #5
0
        /// <summary>
        /// Opens a desktop.
        /// </summary>
        /// <param name="name">The name of the desktop to open.</param>
        /// <returns>If successful, a Desktop object, otherwise, null.</returns>
        public static Desktop OpenDesktop(string name)
        {
            // open the desktop.
            Desktop desktop = new Desktop();
            bool result = desktop.Open(name);

            // somethng went wrong.
            if (!result) return null;

            return desktop;
        }
Beispiel #6
0
        /// <summary>
        /// Gets the name of a given desktop.
        /// </summary>
        /// <param name="desktop">Desktop object whos name is to be found.</param>
        /// <returns>If successful, the desktop name, otherwise, null.</returns>
        public static string GetDesktopName(Desktop desktop)
        {
            // get name.
            if (desktop.IsOpen) return null;

            return GetDesktopName(desktop.DesktopHandle);
        }
Beispiel #7
0
 /// <summary>
 /// Checks if the specified desktop exists (using a case sensitive search).
 /// </summary>
 /// <param name="name">The name of the desktop.</param>
 /// <returns>True if the desktop exists, otherwise false.</returns>
 public static bool Exists(string name)
 {
     return(Desktop.Exists(name, false));
 }
Beispiel #8
0
 /// <summary>
 /// Opens the default desktop.
 /// </summary>
 /// <returns>If successful, a Desktop object, otherwise, null.</returns>
 public static Desktop OpenDefaultDesktop()
 {
     // opens the default desktop.
     return(Desktop.OpenDesktop("Default"));
 }