Changes in trunk/MacFaceFloat/MainForm.cs [20:30]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MacFaceFloat/MainForm.cs
r20 r30 21 21 public class MainForm : Misuzilla.Windows.Forms.AlphaForm 22 22 { 23 private System.Windows.Forms.NotifyIcon notifyIcon; 23 24 private System.Windows.Forms.ContextMenu contextMenu; 24 25 private System.Windows.Forms.MenuItem menuItemPatternSelect; … … 30 31 private FaceDef _currentFaceDef; 31 32 private Configuration _config; 32 33 Int32 prevUsage; 34 PerformanceCounter cpuCount; 35 PerformanceCounter pageoutCount; 36 PerformanceCounter pageinCount; 33 private float _patternSize; 34 35 private int prevPattern; 36 private FaceDef.PatternSuite prevSuite; 37 private int prevMarkers; 38 39 private CPUUsageCounter cpuCounter; 40 private MemoryUsageCounter memoryCounter; 37 41 38 42 // RXgN^ … … 43 47 this.MoveAtFormDrag = true; 44 48 45 prevUsage = -10; 46 47 cpuCount = new PerformanceCounter(); 48 cpuCount.CategoryName = "Processor"; 49 cpuCount.CounterName = "% Processor Time"; 50 cpuCount.InstanceName = "_Total"; 51 52 pageoutCount = new PerformanceCounter(); 53 pageoutCount.CategoryName = "Memory"; 54 pageoutCount.CounterName = "Pages Output/sec"; 55 56 pageinCount = new PerformanceCounter(); 57 pageinCount.CategoryName = "Memory"; 58 pageinCount.CounterName = "Pages Input/sec"; 49 prevPattern = -1; 50 prevSuite = FaceDef.PatternSuite.Normal; 51 prevMarkers = -1; 52 53 cpuCounter = new CPUUsageCounter(); 54 memoryCounter = new MemoryUsageCounter(); 59 55 60 56 _updateTimer = new System.Windows.Forms.Timer(); … … 65 61 66 62 void InitializeComponent() { 63 this.notifyIcon = new System.Windows.Forms.NotifyIcon(); 67 64 this.menuItemPatternSelect = new System.Windows.Forms.MenuItem(); 68 65 this.menuItemConfigure = new System.Windows.Forms.MenuItem(); 69 66 this.menuItemExit = new System.Windows.Forms.MenuItem(); 70 67 this.contextMenu = new System.Windows.Forms.ContextMenu(); 68 69 // 70 // notifyIcon 71 // 72 this.notifyIcon.Text = "MacFace"; 73 this.notifyIcon.Icon = this.Icon; 74 this.notifyIcon.Visible = true; 75 this.notifyIcon.ContextMenu = this.contextMenu; 76 71 77 // 72 78 // menuItemPatternSelect … … 189 195 _currentFaceDef = newFaceDef; 190 196 _facePath = _currentFaceDef.Path; 191 prevUsage = -10; 197 notifyIcon.Text = "MacFace - " + _currentFaceDef.Title; 198 prevPattern = -1; 199 prevMarkers = -1; 192 200 193 201 // XVÄJ … … 199 207 public void CountProcessorUsage(object sender, EventArgs e) 200 208 { 201 int usage = (int)cpuCount.NextValue(); 202 int pagein = (int)pageinCount.NextValue(); 203 int pageout = (int)pageoutCount.NextValue(); 204 205 usage /= 10; 206 if (usage > 10) { 207 usage = 10; 208 } else if (usage < 0) { 209 usage = 0; 209 CPUUsage cpuUsage = cpuCounter.CurrentUsage(); 210 MemoryUsage memUsage = memoryCounter.CurrentUsage(); 211 212 int pattern = cpuUsage.Active / 10; 213 214 FaceDef.PatternSuite suite = FaceDef.PatternSuite.Normal; 215 if (memUsage.Available < (10 * 1024 *1024)) 216 { 217 suite = FaceDef.PatternSuite.MemoryInsufficient; 218 } 219 else if (memUsage.Available < (30 * 1024 *1024)) 220 { 221 suite = FaceDef.PatternSuite.MemoryDecline; 210 222 } 211 223 212 224 int markers = FaceDef.MarkerNone; 213 if ( pagein > 0) markers += FaceDef.MarkerPageIn;214 if ( pageout > 0) markers += FaceDef.MarkerPageOut;215 216 if (prev Usage != usage)225 if (memUsage.Pagein > 0) markers += FaceDef.MarkerPageIn; 226 if (memUsage.Pageout > 0) markers += FaceDef.MarkerPageOut; 227 228 if (prevPattern != pattern || prevSuite != suite || prevMarkers != markers) 217 229 { 218 230 Graphics g = this.Graphics; 219 231 g.Clear(Color.FromArgb(0, 0, 0, 0)); 220 _currentFaceDef.DrawPatternImage(g, FaceDef.PatternSuite.Normal, usage, markers);232 _currentFaceDef.DrawPatternImage(g, suite, pattern, markers, _patternSize); 221 233 this.Update(); 222 234 } 223 235 224 prevUsage = usage; 225 } 226 236 prevPattern = pattern; 237 prevSuite = suite; 238 prevMarkers = markers; 239 } 240 241 public float PatternSize 242 { 243 get { return _patternSize; } 244 set { _patternSize = value; } 245 } 227 246 228 247 // … … 260 279 private void MainForm_Closing(object sender, CancelEventArgs e) 261 280 { 281 notifyIcon.Visible = false; 282 262 283 // Û¶ 263 284 _config.Opacity = (int) (this.Opacity * 100); … … 297 318 { 298 319 this.Opacity = (float)_config.Opacity / 100; 320 this.PatternSize = (float)_config.PatternSize / 100; 299 321 this.Location = _config.Location; 300 322 this.TransparentMouseMessage = _config.TransparentMouseMessage;
Note: See TracChangeset
for help on using the changeset viewer.