コード例 #1
0
ファイル: WorkspacesWidget.cs プロジェクト: nikku/dawsome
 private void SetWorkspaceLabelColor(Workspace workspace)
 {
     var workspaceLabel = workspaceLabels[workspace.id - 1];
     if (workspace.IsCurrentWorkspace)
     {
         workspaceLabel.BackColor = highlightedBackgroundColor;
         workspaceLabel.ForeColor = highlightedForegroundColor;
     }
     else if (workspace.IsWorkspaceVisible)
     {
         workspaceLabel.BackColor = highlightedInactiveBackgroundColor;
         workspaceLabel.ForeColor = highlightedInactiveForegroundColor;
     }
     else
     {
         var count = workspace.GetWindowsCount();
         if (count > 9)
         {
             count = 9;
         }
         workspaceLabel.BackColor = normalBackgroundColor[count];
         workspaceLabel.ForeColor = normalForegroundColor[count];
     }
 }
コード例 #2
0
ファイル: Dawsome.cs プロジェクト: nikku/dawsome
        private void ShowHideWindows(Workspace oldWorkspace, Workspace newWorkspace, bool setForeground)
        {
            var winPosInfo = NativeMethods.BeginDeferWindowPos(newWorkspace.GetWindowsCount() + oldWorkspace.GetWindowsCount());

            var showWindows = newWorkspace.GetWindows();
            foreach (var window in showWindows.Where(Utilities.WindowIsNotHung))
            {
                winPosInfo = window.GetOwnedWindows().Aggregate(winPosInfo, (current, hWnd) =>
                    NativeMethods.DeferWindowPos(current, hWnd, IntPtr.Zero, 0, 0, 0, 0,
                        NativeMethods.SWP.SWP_NOACTIVATE | NativeMethods.SWP.SWP_NOMOVE |
                        NativeMethods.SWP.SWP_NOSIZE | NativeMethods.SWP.SWP_NOZORDER |
                        NativeMethods.SWP.SWP_NOOWNERZORDER | NativeMethods.SWP.SWP_SHOWWINDOW));
                if (window.redrawOnShow)
                {
                    window.Redraw();
                }
            }

            var hideWindows = oldWorkspace.sharedWindowsCount > 0 && newWorkspace.sharedWindowsCount > 0 ?
                oldWorkspace.GetWindows().Except(showWindows) : oldWorkspace.GetWindows();
            // if the window is not visible we shouldn't add it to hiddenApplications as EVENT_OBJECT_HIDE won't be sent
            foreach (var window in hideWindows.Where(Utilities.IsVisibleAndNotHung))
            {
                hiddenApplications.Add(window.hWnd);
                winPosInfo = window.GetOwnedWindows().Aggregate(winPosInfo, (current, hWnd) =>
                    NativeMethods.DeferWindowPos(current, hWnd, IntPtr.Zero, 0, 0, 0, 0,
                        NativeMethods.SWP.SWP_NOACTIVATE | NativeMethods.SWP.SWP_NOMOVE |
                        NativeMethods.SWP.SWP_NOSIZE | NativeMethods.SWP.SWP_NOZORDER |
                        NativeMethods.SWP.SWP_NOOWNERZORDER | NativeMethods.SWP.SWP_HIDEWINDOW));
            }

            NativeMethods.EndDeferWindowPos(winPosInfo);

            // activates the topmost non-minimized window
            if (setForeground)
            {
                DoForTopmostWindowForWorkspace(newWorkspace, ForceForegroundWindow);
            }
        }