Index: /trunk/MacFaceFloat/MainForm.cs
===================================================================
--- /trunk/MacFaceFloat/MainForm.cs	(revision 24)
+++ /trunk/MacFaceFloat/MainForm.cs	(revision 25)
@@ -31,10 +31,10 @@
 		private FaceDef _currentFaceDef;
 		private Configuration _config;
-		
-		int prevUsage;
-		int prevMarkers;
-		PerformanceCounter cpuCount;
-		PerformanceCounter pageoutCount;
-		PerformanceCounter pageinCount;
+
+		private int prevPattern;
+		private int prevMarkers;
+
+		private CPUUsageCounter cpuCounter;
+		private MemoryUsageCounter memoryCounter;
 
 		// RXgN^
@@ -45,19 +45,9 @@
 			this.MoveAtFormDrag = true;
 
-			prevUsage = -1;
+			prevPattern = -1;
 			prevMarkers = -1;
 
-			cpuCount = new PerformanceCounter();
-			cpuCount.CategoryName = "Processor";
-			cpuCount.CounterName  = "% Processor Time";
-			cpuCount.InstanceName = "_Total";
-
-			pageoutCount = new PerformanceCounter();
-			pageoutCount.CategoryName = "Memory";
-			pageoutCount.CounterName  = "Pages Output/sec";
-
-			pageinCount = new PerformanceCounter();
-			pageinCount.CategoryName = "Memory";
-			pageinCount.CounterName  = "Pages Input/sec";
+			cpuCounter = new CPUUsageCounter();
+			memoryCounter = new MemoryUsageCounter();
 
 			_updateTimer = new System.Windows.Forms.Timer();
@@ -203,5 +193,5 @@
 			_facePath = _currentFaceDef.Path;
 			notifyIcon.Text = "MacFace - " + _currentFaceDef.Title;
-			prevUsage = -1;
+			prevPattern = -1;
 			prevMarkers = -1;
 
@@ -214,28 +204,32 @@
 		public void CountProcessorUsage(object sender, EventArgs e)
 		{
-			int usage = (int)cpuCount.NextValue();
-			int pagein = (int)pageinCount.NextValue();
-			int pageout = (int)pageoutCount.NextValue();
-
-			usage /= 10;
-			if (usage > 10) {
-				usage = 10;
-			} else if (usage < 0) {
-				usage = 0;
+			CPUUsage cpuUsage = cpuCounter.CurrentUsage();
+			MemoryUsage memUsage = memoryCounter.CurrentUsage();
+
+			int pattern = cpuUsage.Active / 10;
+			if (pattern > 10)
+			{
+				pattern = 10;
+			}
+			else if (pattern < 0)
+			{
+				pattern = 0;
 			}
 
 			int markers = FaceDef.MarkerNone;
+			int pagein = memUsage.Pagein;
+			int pageout = memUsage.Pageout;
 			if (pagein > 0) markers += FaceDef.MarkerPageIn;
 			if (pageout > 0) markers += FaceDef.MarkerPageOut;
 
-			if (prevUsage != usage || prevMarkers != markers) 
+			if (prevPattern != pattern || prevMarkers != markers) 
 			{
 				Graphics g = this.Graphics;
 				g.Clear(Color.FromArgb(0, 0, 0, 0));
-				_currentFaceDef.DrawPatternImage(g, FaceDef.PatternSuite.Normal, usage, markers);
+				_currentFaceDef.DrawPatternImage(g, FaceDef.PatternSuite.Normal, pattern, markers);
 				this.Update();
 			}
 				
-			prevUsage = usage;
+			prevPattern = pattern;
 			prevMarkers = markers;
 		}
Index: /trunk/MacFaceLibrary/CPUUsage.cs
===================================================================
--- /trunk/MacFaceLibrary/CPUUsage.cs	(revision 24)
+++ /trunk/MacFaceLibrary/CPUUsage.cs	(revision 25)
@@ -11,9 +11,33 @@
 	public class CPUUsage
 	{
-		public CPUUsage()
+		private int user;
+		private int system;
+		private int idle;
+
+		public CPUUsage(int user, int system, int idle)
 		{
-			// 
-			// TODO: RXgN^ WbNð±±ÉÇÁµÄ­¾³¢B
-			//
+			this.user = user;
+			this.system = system;
+			this.idle = idle;
+		}
+
+		public int User
+		{
+			get { return user; }
+		}
+
+		public int System
+		{
+			get { return user; }
+		}
+
+		public int Active
+		{
+			get { return user + system; }
+		}
+
+		public int Idle
+		{
+			get { return idle; }
 		}
 	}
Index: /trunk/MacFaceLibrary/CPUUsageCounter.cs
===================================================================
--- /trunk/MacFaceLibrary/CPUUsageCounter.cs	(revision 24)
+++ /trunk/MacFaceLibrary/CPUUsageCounter.cs	(revision 25)
@@ -3,4 +3,5 @@
  */
 using System;
+using System.Diagnostics;
 
 namespace MacFace
@@ -9,247 +10,37 @@
 	/// HostStatistics ÌTvÌà¾Å·B
 	/// </summary>
-	public class HostStatistics
+	public class CPUUsageCounter
 	{
-		public HostStatistics()
+		private PerformanceCounter userCounter;
+		private PerformanceCounter systemCounter;
+		private PerformanceCounter idleCounter;
+
+		public CPUUsageCounter()
 		{
-			// 
-			// TODO: RXgN^ WbNð±±ÉÇÁµÄ­¾³¢B
-			//
+			userCounter = new PerformanceCounter();
+			userCounter.CategoryName = "Processor";
+			userCounter.CounterName = "% User Time";
+			userCounter.InstanceName = "_Total";
+
+			systemCounter = new PerformanceCounter();
+			systemCounter.CategoryName = "Processor";
+			systemCounter.CounterName = "% Privileged Time";
+			systemCounter.InstanceName = "_Total";
+
+			idleCounter = new PerformanceCounter();
+			idleCounter.CategoryName = "Processor";
+			idleCounter.CounterName = "% Idle Time";
+			idleCounter.InstanceName = "_Total";
 		}
+
+		public CPUUsage CurrentUsage()
+		{
+			int user   = (int)userCounter.NextValue();
+			int system = (int)systemCounter.NextValue();
+			int idle   = (int)idleCounter.NextValue();
+
+			return new CPUUsage(user, system, idle);
+		}
+
 	}
 }
-
-/*
-
-typedef struct {
-    int freePages;
-    int activePages;
-    int inactivePages;
-    int wirePages;
-    int faults;
-    int pageins;
-    int pageouts;
-    unsigned long userTicks;
-    unsigned long systemTicks;
-    unsigned long idleTicks;
-    unsigned long niceTicks;
-} HostStatData;
-
-typedef struct {
-    int incount;
-    int outcount;
-} Pageio;
-
-typedef struct {
-    float user;
-    float system;
-    float idle;
-    float nice;
-} CPUUsage;
-
-typedef struct {
-    HostStatData stat;
-    Pageio pageio;
-    CPUUsage usage;
-} StatisticsRecord;
-
-@interface HostStatistics : NSObject
-{
-    StatisticsRecord *ringBuffer;
-    int bufMaxLen;
-    int bufHead;
-    int bufTail;
-    int bufLen;
-    int totalPages;
-    int minUsedPages;
-    int maxUsedPages;
-}
-
-+ (unsigned int)vmPageSize;
-+ (NSString*)kernelVersion;
-+ (void)getStatistics:(HostStatData*)data;
-
-- (id)initWithCapacity:(unsigned)capacity;
-- (void)update;
-- (int)totalPages;
-- (int)minUsedPages;
-- (int)maxUsedPages;
-- (int)length;
-- (const StatisticsRecord*)indexAt:(unsigned)index;
-- (const StatisticsRecord*)head;
-- (const StatisticsRecord*)tail;
-@end
-
-#import <mach/mach.h>
-#import <mach/mach_types.h>
-#import "HostStatistics.h"
-
-//
-//
-static void hostStatistics(HostStatData *data)
-{
-    vm_statistics_data_t vm_stat;
-    mach_msg_type_number_t vm_count = HOST_VM_INFO_COUNT;
-    host_cpu_load_info_data_t load_info;
-    mach_msg_type_number_t load_info_count = HOST_CPU_LOAD_INFO_COUNT;
-    host_t host = mach_host_self();
-
-    host_statistics(host,HOST_VM_INFO,(host_info_t)&vm_stat, &vm_count);
-    host_statistics(host,HOST_CPU_LOAD_INFO,(host_info_t)&load_info, &load_info_count);
-
-    data->freePages = vm_stat.free_count;
-    data->activePages = vm_stat.active_count;
-    data->inactivePages = vm_stat.inactive_count;
-    data->wirePages = vm_stat.wire_count;
-    data->faults = vm_stat.faults;
-    data->pageins = vm_stat.pageins;
-    data->pageouts = vm_stat.pageouts;
-
-    data->userTicks = load_info.cpu_ticks[CPU_STATE_USER];
-    data->systemTicks = load_info.cpu_ticks[CPU_STATE_SYSTEM];
-    data->idleTicks = load_info.cpu_ticks[CPU_STATE_IDLE];
-    data->niceTicks = load_info.cpu_ticks[CPU_STATE_NICE];
-}
-
-@implementation HostStatistics
-
-//
-// ¼zL¯Ìy[WTCYðÔ·
-//
-+ (unsigned int)vmPageSize
-{
-    vm_size_t page_size;
-    host_page_size(mach_host_self(),&page_size);
-    return page_size;
-}
-
-//
-// J[lÌo[W¶ñðÔ·
-//
-+ (NSString*)kernelVersion
-{
-    kernel_version_t kver;
-    host_kernel_version(mach_host_self(),kver);
-    return [NSString stringWithUTF8String:kver];
-}
-
-//
-// »ÝÌvîñðÝè·é
-//
-+ (void)getStatistics:(HostStatData*)data
-{
-    hostStatistics(data);
-}
-
-//
-// ú»
-//   capacity: Oobt@ÌeÊ
-//
-- (id)initWithCapacity:(unsigned)capacity
-{
-    StatisticsRecord *rec;
-
-    ringBuffer = calloc(sizeof(StatisticsRecord),capacity);
-    rec = &ringBuffer[0];
-    hostStatistics(&rec->stat);
-    rec->usage.user = 0;
-    rec->usage.system = 0;
-    rec->usage.idle = 100.0;
-    rec->usage.nice = 0;
-
-    bufMaxLen = capacity;
-    bufHead = 0;
-    bufTail = 0;
-    bufLen = 1;
-
-    totalPages = rec->stat.wirePages + rec->stat.activePages + rec->stat.inactivePages + rec->stat.freePages;
-    minUsedPages = rec->stat.wirePages + rec->stat.activePages;
-    maxUsedPages = minUsedPages;
-
-    return self;
-}
-
-//
-// ãn
-//
-- (void)dealloc
-{
-    free(ringBuffer);
-    [super dealloc];
-}
-
-//
-// ðÌXV
-//
-- (void)update
-{
-    StatisticsRecord *rec, *lastRec;
-    int user,sys,idle,nice,total;
-    int usedPages;
-
-    lastRec = &ringBuffer[bufHead];
-    if (bufLen < bufMaxLen) bufLen++;
-    if (++bufHead >= bufLen) bufHead = 0;
-    if (bufHead == bufTail)
-        if (++bufTail >= bufLen) bufTail = 0;
-    rec = &ringBuffer[bufHead];
-    hostStatistics(&rec->stat);
-
-    rec->pageio.incount = rec->stat.pageins - lastRec->stat.pageins;
-    rec->pageio.outcount = rec->stat.pageouts - lastRec->stat.pageouts;
-
-    user = rec->stat.userTicks - lastRec->stat.userTicks;
-    sys = rec->stat.systemTicks - lastRec->stat.systemTicks;
-    idle = rec->stat.idleTicks - lastRec->stat.idleTicks;
-    nice = rec->stat.niceTicks - lastRec->stat.niceTicks;
-    total = user + sys + idle + nice;
-
-    if (total > 0) {
-        rec->usage.user = user * 100.0 / total;
-        rec->usage.system = sys * 100.0 / total;
-        rec->usage.idle = idle * 100.0 / total;
-        rec->usage.nice = nice * 100.0 / total;
-    } else {
-        rec->usage = lastRec->usage;
-    }
-
-    usedPages = rec->stat.wirePages + rec->stat.activePages;
-    if( minUsedPages < usedPages) minUsedPages = usedPages;
-    if( maxUsedPages > usedPages) maxUsedPages = usedPages;
-}
-
-- (int)totalPages { return totalPages; }
-- (int)minUsedPages { return minUsedPages; }
-- (int)maxUsedPages { return maxUsedPages; }
-- (int)length { return bufLen; }
-
-//
-// wèµ½ÊuÌvîñð¾é
-//   index: Êu(ÅVª0)
-//
-- (const StatisticsRecord*)indexAt:(unsigned)index;
-{
-    if (index >= bufLen) return nil;
-    index = (index <= bufHead) ? bufHead - index : bufLen + bufHead - index;
-    return &ringBuffer[index];
-}
-
-//
-// àÁÆàVµ¢vîñðÔ·
-//
-- (const StatisticsRecord*)head
-{
-    return &ringBuffer[bufHead];
-}
-
-//
-// àÁÆàÃ¢vîñðÔ·
-//
-- (const StatisticsRecord*)tail;
-{
-    return &ringBuffer[bufTail];
-}
-
-@end
-
-*/
Index: /trunk/MacFaceLibrary/MemoryUsage.cs
===================================================================
--- /trunk/MacFaceLibrary/MemoryUsage.cs	(revision 24)
+++ /trunk/MacFaceLibrary/MemoryUsage.cs	(revision 25)
@@ -11,9 +11,35 @@
 	public class MemoryUsage
 	{
-		public MemoryUsage()
+		private int available;
+		private int committed;
+		private int pagein;
+		private int pageout;
+
+		public MemoryUsage(int available, int committed, int pagein, int pageout)
 		{
-			// 
-			// TODO: RXgN^ WbNð±±ÉÇÁµÄ­¾³¢B
-			//
+			this.available = available;
+			this.committed = committed;
+			this.pagein = pagein;
+			this.pageout = pageout;
+		}
+
+		public int Available
+		{
+			get { return available; }
+		}
+
+		public int Committed
+		{
+			get { return committed; }
+		}
+
+		public int Pagein
+		{
+			get { return pagein; }
+		}
+
+		public int Pageout
+		{
+			get { return pageout; }
 		}
 	}
Index: /trunk/MacFaceLibrary/MemoryUsageCounter.cs
===================================================================
--- /trunk/MacFaceLibrary/MemoryUsageCounter.cs	(revision 24)
+++ /trunk/MacFaceLibrary/MemoryUsageCounter.cs	(revision 25)
@@ -3,4 +3,5 @@
  */
 using System;
+using System.Diagnostics;
 
 namespace MacFace
@@ -11,9 +12,36 @@
 	public class MemoryUsageCounter
 	{
+		private PerformanceCounter availableCounter;
+		private PerformanceCounter committedCounter;
+		private PerformanceCounter pageoutCounter;
+		private PerformanceCounter pageinCounter;
+
 		public MemoryUsageCounter()
 		{
-			// 
-			// TODO: RXgN^ WbNð±±ÉÇÁµÄ­¾³¢B
-			//
+			availableCounter = new PerformanceCounter();
+			availableCounter.CategoryName = "Memory";
+			availableCounter.CounterName = "Available Bytes";
+
+			committedCounter = new PerformanceCounter();
+			committedCounter.CategoryName = "Memory";
+			committedCounter.CounterName = "Committed Bytes";
+
+			pageoutCounter = new PerformanceCounter();
+			pageoutCounter.CategoryName = "Memory";
+			pageoutCounter.CounterName = "Pages Output/sec";
+
+			pageinCounter = new PerformanceCounter();
+			pageinCounter.CategoryName = "Memory";
+			pageinCounter.CounterName = "Pages Input/sec";
+		}
+
+		public MemoryUsage CurrentUsage()
+		{
+			int available = (int)availableCounter.NextValue();
+			int committed = (int)committedCounter.NextValue();
+			int pagein	= (int)pageinCounter.NextValue();
+			int pageout   = (int)pageoutCounter.NextValue();
+
+			return new MemoryUsage(available, committed, pagein, pageout);
 		}
 	}
