Task Manager enhs & fiexs <Pablo <pborobia@gmail.com>

- make a last used cpu usage color memory
- fix colors in the cpu history
- high refresh more offten
- fix kernel cpu usage colorbars paint

Bug 1271.
Modified: trunk/reactos/subsys/system/taskmgr/graph.c
Modified: trunk/reactos/subsys/system/taskmgr/graph.h
Modified: trunk/reactos/subsys/system/taskmgr/perfpage.c
Modified: trunk/reactos/subsys/system/taskmgr/taskmgr.c

Modified: trunk/reactos/subsys/system/taskmgr/graph.c
--- trunk/reactos/subsys/system/taskmgr/graph.c	2006-01-12 20:38:54 UTC (rev 20816)
+++ trunk/reactos/subsys/system/taskmgr/graph.c	2006-01-12 20:54:35 UTC (rev 20817)
@@ -22,6 +22,8 @@
 
 #include <precomp.h>
 
+int                nlastBarsUsed = 0;
+
 LONG                OldGraphWndProc;
 
 void                Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd);
@@ -158,11 +160,8 @@
      * Get the CPU usage
      */
     CpuUsage = PerfDataGetProcessorUsage();
-    CpuKernelUsage = PerfDataGetProcessorSystemUsage();
     if (CpuUsage < 0)         CpuUsage = 0;
     if (CpuUsage > 100)       CpuUsage = 100;
-    if (CpuKernelUsage < 0)   CpuKernelUsage = 0;
-    if (CpuKernelUsage > 100) CpuKernelUsage = 100;
 
     /*
      * Check and see how many digits it will take
@@ -197,11 +196,14 @@
     {
         nBarsUsed = 1;
     }
-    nBarsFree = nBars - nBarsUsed;
+    nBarsFree = nBars - (nlastBarsUsed>nBarsUsed ? nlastBarsUsed : nBarsUsed);
+    
     if (TaskManagerSettings.ShowKernelTimes)
     {
-        nBarsUsedKernel = ((nBars * 2) * CpuKernelUsage) / 100;
-        nBarsUsed -= (nBarsUsedKernel / 2);
+	    CpuKernelUsage = PerfDataGetProcessorSystemUsage();
+	    if (CpuKernelUsage < 0)   CpuKernelUsage = 0;
+	    if (CpuKernelUsage > 100) CpuKernelUsage = 100;
+        nBarsUsedKernel = (nBars * CpuKernelUsage) / 100;
     }
     else
     {
@@ -226,7 +228,7 @@
 
     if (nBarsUsedKernel < 0)     nBarsUsedKernel = 0;
     if (nBarsUsedKernel > nBars) nBarsUsedKernel = nBars;
-
+    
     /*
      * Draw the "free" bars
      */
@@ -243,6 +245,25 @@
     }
 
     /*
+     * Draw the last "used" bars
+     */
+	if ((nlastBarsUsed - nBarsUsed) > 0) {
+	    for (i=0; i< (nlastBarsUsed - nBarsUsed); i++)
+	    {
+	        if (nlastBarsUsed > 5000) nlastBarsUsed = 5000;
+	
+	        FillSolidRect(hDC, &rcBarLeft, MEDIUM_GREEN);
+	        FillSolidRect(hDC, &rcBarRight, MEDIUM_GREEN);
+	
+	        rcBarLeft.top += 3;
+	        rcBarLeft.bottom += 3;
+	
+	        rcBarRight.top += 3;
+	        rcBarRight.bottom += 3;
+	    }
+	}
+	nlastBarsUsed = nBarsUsed;
+    /*
      * Draw the "used" bars
      */
     for (i=0; i<nBarsUsed; i++)
@@ -262,48 +283,25 @@
     /*
      * Draw the "used" kernel bars
      */
-    rcBarLeft.bottom--;
-    rcBarRight.bottom--;
-    if (nBarsUsedKernel && nBarsUsedKernel % 2)
-    {
-        rcBarLeft.top -= 2;
-        rcBarLeft.bottom -= 2;
+    
+    rcBarLeft.top -=3;
+    rcBarLeft.bottom -=3;
 
-        rcBarRight.top -= 2;
-        rcBarRight.bottom -= 2;
-
-        FillSolidRect(hDC, &rcBarLeft, RED);
-        FillSolidRect(hDC, &rcBarRight, RED);
-
-        rcBarLeft.top += 2;
-        rcBarLeft.bottom += 2;
-
-        rcBarRight.top += 2;
-        rcBarRight.bottom += 2;
-
-        nBarsUsedKernel--;
-    }
+    rcBarRight.top -=3;
+    rcBarRight.bottom -=3;
+    
     for (i=0; i<nBarsUsedKernel; i++)
     {
-        if (nBarsUsedKernel > 5000) nBarsUsedKernel = 5000;
 
         FillSolidRect(hDC, &rcBarLeft, RED);
         FillSolidRect(hDC, &rcBarRight, RED);
 
-        rcBarLeft.top++;
-        rcBarLeft.bottom++;
+        rcBarLeft.top -=3;
+        rcBarLeft.bottom -=3;
 
-        rcBarRight.top++;
-        rcBarRight.bottom++;
+        rcBarRight.top -=3;
+        rcBarRight.bottom -=3;
 
-        if (i % 2)
-        {
-            rcBarLeft.top++;
-            rcBarLeft.bottom++;
-
-            rcBarRight.top++;
-            rcBarRight.bottom++;
-        }
     }
 }
 
@@ -338,8 +336,10 @@
     CommitChargeTotal = (ULONGLONG)PerfDataGetCommitChargeTotalK();
     CommitChargeLimit = (ULONGLONG)PerfDataGetCommitChargeLimitK();
 
-    _stprintf(Text, _T("%dK"), (int)CommitChargeTotal);
-
+    if (CommitChargeTotal > 1024)
+    	_stprintf(Text, _T("%d MB"), (int)(CommitChargeTotal / 1024));
+	else
+		_stprintf(Text, _T("%d K"), (int)CommitChargeTotal);
     /*
      * Draw the font text onto the graph
      * The bottom 20 pixels are reserved for the text

Modified: trunk/reactos/subsys/system/taskmgr/graph.h
--- trunk/reactos/subsys/system/taskmgr/graph.h	2006-01-12 20:38:54 UTC (rev 20816)
+++ trunk/reactos/subsys/system/taskmgr/graph.h	2006-01-12 20:54:35 UTC (rev 20817)
@@ -29,6 +29,7 @@
 
 
 #define BRIGHT_GREEN	RGB(0, 255, 0)
+#define MEDIUM_GREEN	RGB(0, 190, 0)
 #define DARK_GREEN		RGB(0, 130, 0)
 #define RED				RGB(255, 0, 0)
 

Modified: trunk/reactos/subsys/system/taskmgr/perfpage.c
--- trunk/reactos/subsys/system/taskmgr/perfpage.c	2006-01-12 20:38:54 UTC (rev 20816)
+++ trunk/reactos/subsys/system/taskmgr/perfpage.c	2006-01-12 20:54:35 UTC (rev 20817)
@@ -174,8 +174,10 @@
 /*         PerformancePageCpuUsageHistoryGraph.SetPlotColor(RGB(255, 255, 255)) ; */
         GraphCtrl_SetBackgroundColor(&PerformancePageCpuUsageHistoryGraph, RGB(0, 0, 0)) ;
         GraphCtrl_SetGridColor(&PerformancePageCpuUsageHistoryGraph, RGB(152, 205, 152)) ;
-        GraphCtrl_SetPlotColor(&PerformancePageCpuUsageHistoryGraph, 0, RGB(255, 0, 0)) ;
-        GraphCtrl_SetPlotColor(&PerformancePageCpuUsageHistoryGraph, 1, RGB(0, 255, 0)) ;
+        
+        GraphCtrl_SetPlotColor(&PerformancePageCpuUsageHistoryGraph, 0, RGB(0, 255, 0)) ;
+        GraphCtrl_SetPlotColor(&PerformancePageCpuUsageHistoryGraph, 1, RGB(255, 0, 0)) ;
+        
 
         GetClientRect(hPerformancePageMemUsageHistoryGraph, &rc);
         GraphCtrl_Create(&PerformancePageMemUsageHistoryGraph, hPerformancePageMemUsageHistoryGraph, hDlg, IDC_MEM_USAGE_HISTORY_GRAPH);
@@ -418,12 +420,19 @@
         	 *  Get the CPU usage
         	 */
 	        CpuUsage = PerfDataGetProcessorUsage();
-        	CpuKernelUsage = PerfDataGetProcessorSystemUsage();
         	if (CpuUsage < 0 )        CpuUsage = 0;
         	if (CpuUsage > 100)       CpuUsage = 100;
-        	if (CpuKernelUsage < 0)   CpuKernelUsage = 0;
-        	if (CpuKernelUsage > 100) CpuKernelUsage = 100;
-
+        	
+        	if (TaskManagerSettings.ShowKernelTimes)
+        	{
+        		CpuKernelUsage = PerfDataGetProcessorSystemUsage();
+        		if (CpuKernelUsage < 0)   CpuKernelUsage = 0;
+        		if (CpuKernelUsage > 100) CpuKernelUsage = 100;
+			} 
+			else
+			{
+				CpuKernelUsage = 0;
+			}
             /*
              *  Get the memory usage
              */
@@ -435,6 +444,7 @@
 			PhysicalMemoryAvailable = PerfDataGetPhysicalMemoryAvailableK();
             nBarsUsed2 = PhysicalMemoryTotal ? ((PhysicalMemoryAvailable * 100) / PhysicalMemoryTotal) : 0;
 
+			 
 
             GraphCtrl_AppendPoint(&PerformancePageCpuUsageHistoryGraph, CpuUsage, CpuKernelUsage, 0.0, 0.0);
             GraphCtrl_AppendPoint(&PerformancePageMemUsageHistoryGraph, nBarsUsed1, nBarsUsed2, 0.0, 0.0);

Modified: trunk/reactos/subsys/system/taskmgr/taskmgr.c
--- trunk/reactos/subsys/system/taskmgr/taskmgr.c	2006-01-12 20:38:54 UTC (rev 20816)
+++ trunk/reactos/subsys/system/taskmgr/taskmgr.c	2006-01-12 20:54:35 UTC (rev 20817)
@@ -873,7 +873,7 @@
     CheckMenuRadioItem(hUpdateSpeedMenu, ID_VIEW_UPDATESPEED_HIGH, ID_VIEW_UPDATESPEED_PAUSED, ID_VIEW_UPDATESPEED_HIGH, MF_BYCOMMAND);
 
     KillTimer(hMainWnd, 1);
-    SetTimer(hMainWnd, 1, 1000, NULL);
+    SetTimer(hMainWnd, 1, 500, NULL);
 }
 
 void TaskManager_OnViewUpdateSpeedNormal(void)