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