コード例 #1
0
 public static bool IsApplicationPinned(IntPtr hWnd)
 { // Returns true if application for window <hWnd> is pinned to all desktops
     if (hWnd == IntPtr.Zero)
     {
         throw new ArgumentNullException();
     }
     return(DesktopManager.VirtualDesktopPinnedApps.IsAppIdPinned(DesktopManager.GetAppId(hWnd)));
 }
コード例 #2
0
        public static void PinApplication(IntPtr hWnd)
        { // pin application for window <hWnd> to all desktops
            if (hWnd == IntPtr.Zero)
            {
                throw new ArgumentNullException();
            }
            string appId = DesktopManager.GetAppId(hWnd);

            if (!DesktopManager.VirtualDesktopPinnedApps.IsAppIdPinned(appId))
            { // pin only if not already pinned
                DesktopManager.VirtualDesktopPinnedApps.PinAppID(appId);
            }
        }
コード例 #3
0
        public static void UnpinApplication(IntPtr hWnd)
        { // unpin application for window <hWnd> from all desktops
            if (hWnd == IntPtr.Zero)
            {
                throw new ArgumentNullException();
            }
            var    view  = hWnd.GetApplicationView();
            string appId = DesktopManager.GetAppId(hWnd);

            if (DesktopManager.VirtualDesktopPinnedApps.IsAppIdPinned(appId))
            { // unpin only if already pinned
                DesktopManager.VirtualDesktopPinnedApps.UnpinAppID(appId);
            }
        }
        public static string DesktopNameFromIndex(int index)
        {         // return name of desktop from index (-> index = 0..Count-1) or "Desktop n" if it has no name
            Guid guid = DesktopManager.GetDesktop(index).GetId();

            // read desktop name in registry
            string desktopName = null;

            try
            {
                desktopName = (string)Microsoft.Win32.Registry.GetValue("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\VirtualDesktops\\Desktops\\{" + guid.ToString() + "}", "Name", null);
            }
            catch { }

            // no name found, generate generic name
            if (string.IsNullOrEmpty(desktopName))
            {             // create name "Desktop n" (n = number starting with 1)
                desktopName = "Desktop " + (index + 1).ToString();
            }
            return(desktopName);
        }
        public static bool HasDesktopNameFromIndex(int index)
        {         // return true is desktop is named or false if it has no name
            Guid guid = DesktopManager.GetDesktop(index).GetId();

            // read desktop name in registry
            string desktopName = null;

            try
            {
                desktopName = (string)Microsoft.Win32.Registry.GetValue("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\VirtualDesktops\\Desktops\\{" + guid.ToString() + "}", "Name", null);
            }
            catch { }

            // name found?
            if (string.IsNullOrEmpty(desktopName))
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
コード例 #6
0
        public void Remove(Desktop fallback = null)
        { // Destroy desktop and switch to <fallback>
            IVirtualDesktop fallbackdesktop;

            if (fallback == null)
            { // if no fallback is given use desktop to the left except for desktop 0.
                Desktop dtToCheck = new Desktop(DesktopManager.GetDesktop(0));
                if (this.Equals(dtToCheck))
                {                                                                                                 // desktop 0: set fallback to second desktop (= "right" desktop)
                    DesktopManager.VirtualDesktopManagerInternal.GetAdjacentDesktop(ivd, 4, out fallbackdesktop); // 4 = RightDirection
                }
                else
                {                                                                                                 // set fallback to "left" desktop
                    DesktopManager.VirtualDesktopManagerInternal.GetAdjacentDesktop(ivd, 3, out fallbackdesktop); // 3 = LeftDirection
                }
            }
            else
            {
                // set fallback desktop
                fallbackdesktop = fallback.ivd;
            }

            DesktopManager.VirtualDesktopManagerInternal.RemoveDesktop(ivd, fallbackdesktop);
        }
コード例 #7
0
 public static int FromDesktop(Desktop desktop)
 { // Returns index of desktop object or -1 if not found
     return(DesktopManager.GetDesktopIndex(desktop.ivd));
 }
コード例 #8
0
 public static Desktop FromIndex(int index)
 { // Create desktop object from index 0..Count-1
     return(new Desktop(DesktopManager.GetDesktop(index)));
 }
 public static Desktop FromIndex(int index)
 {         // return desktop object from index (-> index = 0..Count-1)
     return(new Desktop(DesktopManager.GetDesktop(index)));
 }