Changeset 69
- Timestamp:
- Sep 20, 2005, 11:26:29 PM (19 years ago)
- Location:
- trunk/MacFaceFloat
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MacFaceFloat/StatusWindow.cs
-
Property
svn:keywords
set to
id
r62 r69 1 /* 2 * $Id$ 3 */ 1 4 using System; 2 5 using System.Drawing; … … 13 16 public class StatusWindow : System.Windows.Forms.Form 14 17 { 15 internal System.Windows.Forms.PictureBox memoryGraphPicBox;16 internal System.Windows.Forms.PictureBox cpuGraphPicBox;17 18 /// <summary> 18 19 /// KvÈfUCiÏÅ·B … … 20 21 private System.ComponentModel.Container components = null; 21 22 23 internal System.Windows.Forms.PictureBox memoryGraphPicBox; 24 internal System.Windows.Forms.PictureBox cpuGraphPicBox; 25 22 26 private CPUStatistics cpuStats; 23 27 private MemoryStatistics memStats; … … 36 40 this.memStats = memStats; 37 41 38 cpuGraph = new Bitmap( 5*60, 100);39 memoryGraph = new Bitmap( 5*60, 100);42 cpuGraph = new Bitmap(cpuGraphPicBox.Width, cpuGraphPicBox.Height); 43 memoryGraph = new Bitmap(memoryGraphPicBox.Width, memoryGraphPicBox.Height); 40 44 cpuGraphPicBox.Image = cpuGraph; 41 45 memoryGraphPicBox.Image = memoryGraph; … … 70 74 { 71 75 Graphics g = Graphics.FromImage(cpuGraph); 72 73 76 g.SmoothingMode = SmoothingMode.AntiAlias; 74 77 75 g.FillRectangle(new SolidBrush(Color.White), 0, 0, 300, 100); 78 int fw = cpuGraph.Width; 79 int fh = cpuGraph.Height; 80 int m = fh / 10; 81 82 g.FillRectangle(new SolidBrush(Color.White), 0, 0, fw, fh); 76 83 Pen pen = new Pen(Color.FromArgb(220, 220, 220), 1F); 77 for (int y = 0; y < 100; y += 10)78 { 79 g.DrawLine(pen, 0, y, 300, y);80 } 81 g.DrawLine(Pens.Gray, 0, 50, 300, 50);84 for (int y = 0; y < fh; y += m) 85 { 86 g.DrawLine(pen, 0, y, fw, y); 87 } 88 g.DrawLine(Pens.Gray, 0, fh/2, fw, fh/2); 82 89 83 90 int count = cpuStats.Count; … … 85 92 if (count >= 2) 86 93 { 94 int bw = fw / 60; 87 95 Point[] userGraph = new Point[count+2]; 88 96 Point[] sysGraph = new Point[count+2]; 89 97 90 userGraph[count+0].X = 300 - (count-1) * 5;91 userGraph[count+0].Y = 100- 0;92 userGraph[count+1].X = 300 - 0 * 5;93 userGraph[count+1].Y = 100- 0;94 95 sysGraph[count+0].X = 300 - (count-1) * 5;96 sysGraph[count+0].Y = 100- 0;97 sysGraph[count+1].X = 300 - 0 * 5;98 sysGraph[count+1].Y = 100- 0;98 userGraph[count+0].X = fw - (count-1) * bw; 99 userGraph[count+0].Y = fh - 0; 100 userGraph[count+1].X = fw - 0 * bw; 101 userGraph[count+1].Y = fh - 0; 102 103 sysGraph[count+0].X = fw - (count-1) * bw; 104 sysGraph[count+0].Y = fh - 0; 105 sysGraph[count+1].X = fw - 0 * bw; 106 sysGraph[count+1].Y = fh - 0; 99 107 100 108 for (int i = 0; i < count; i++) 101 109 { 102 110 CPUUsage usage = cpuStats[i]; 103 userGraph[i].X = sysGraph[i].X = 300 - i * 5;104 userGraph[i].Y = 100- usage.Active;105 sysGraph[i].Y = 100- usage.System;111 userGraph[i].X = sysGraph[i].X = fw - i * bw; 112 userGraph[i].Y = fh - usage.Active; 113 sysGraph[i].Y = fh - usage.System; 106 114 } 107 115 … … 118 126 Graphics g = Graphics.FromImage(memoryGraph); 119 127 128 int fw = memoryGraph.Width; 129 int fh = memoryGraph.Height; 130 120 131 int totalMemory = (int)memStats.TotalVisibleMemorySize * 1024; 121 double rate = 100.0/ memStats.CommitLimit;132 double rate = (double)fh / memStats.CommitLimit; 122 133 int border = (int)(totalMemory * rate); 123 134 124 g.FillRectangle(new SolidBrush(Color.White), 0, 0, 300, 100);135 g.FillRectangle(new SolidBrush(Color.White), 0, 0, fw, fh); 125 136 Pen pen = new Pen(Color.FromArgb(220, 220, 220), 1F); 126 for (int y = 100; y > 0; y -= (int)(128*1024*1024 * rate))127 { 128 g.DrawLine(pen, 0, y, 300, y);137 for (int y = fh; y > 0; y -= (int)(128*1024*1024 * rate)) 138 { 139 g.DrawLine(pen, 0, y, fw, y); 129 140 } 130 141 … … 138 149 139 150 int count = memStats.Count; 151 int bw = fw / 60; 140 152 141 153 for (int i = 0; i < count; i++) … … 143 155 MemoryUsage usage = memStats[i]; 144 156 145 int x = 300 - i * 5 - 5;146 int y = 100;147 int w = 5;157 int x = fw - i * bw - bw; 158 int y = fh; 159 int w = bw; 148 160 int h = 0; 149 161 … … 170 182 171 183 172 x = 300 - i * 5 - 5;173 w = 2;184 x = fw - i * bw - bw; 185 w = bw/2; 174 186 h = (int)(usage.Pagein); 175 y = 100- h;187 y = fh - h; 176 188 g.FillRectangle(Brushes.LightGray, x, y, w, h); 177 189 178 x = 303 - i * 5 - 5;179 w = 2;190 x = fw + bw/2 - i * bw - bw; 191 w = bw/2; 180 192 h = (int)(usage.Pageout); 181 y = 100- h;193 y = fh - h; 182 194 g.FillRectangle(Brushes.Black, x, y, w, h); 183 195 } 184 196 Pen borderPen = new Pen(Color.Blue); 185 197 borderPen.DashStyle = DashStyle.Dash; 186 g.DrawLine(borderPen, 0, 100-border, 300, 100-border);198 g.DrawLine(borderPen, 0, fh-border, fw, fh-border); 187 199 188 200 g.Dispose(); … … 203 215 // memoryGraphPicBox 204 216 // 217 this.memoryGraphPicBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 218 | System.Windows.Forms.AnchorStyles.Left) 219 | System.Windows.Forms.AnchorStyles.Right))); 205 220 this.memoryGraphPicBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; 206 this.memoryGraphPicBox.Location = new System.Drawing.Point( 6, 8);221 this.memoryGraphPicBox.Location = new System.Drawing.Point(8, 8); 207 222 this.memoryGraphPicBox.Name = "memoryGraphPicBox"; 208 this.memoryGraphPicBox.Size = new System.Drawing.Size( 302, 102);223 this.memoryGraphPicBox.Size = new System.Drawing.Size(296, 104); 209 224 this.memoryGraphPicBox.TabIndex = 0; 210 225 this.memoryGraphPicBox.TabStop = false; … … 212 227 // cpuGraphPicBox 213 228 // 229 this.cpuGraphPicBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 230 | System.Windows.Forms.AnchorStyles.Right))); 214 231 this.cpuGraphPicBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; 215 this.cpuGraphPicBox.Location = new System.Drawing.Point( 6, 120);232 this.cpuGraphPicBox.Location = new System.Drawing.Point(8, 120); 216 233 this.cpuGraphPicBox.Name = "cpuGraphPicBox"; 217 this.cpuGraphPicBox.Size = new System.Drawing.Size( 302, 102);234 this.cpuGraphPicBox.Size = new System.Drawing.Size(296, 104); 218 235 this.cpuGraphPicBox.TabIndex = 1; 219 236 this.cpuGraphPicBox.TabStop = false; … … 225 242 this.Controls.Add(this.cpuGraphPicBox); 226 243 this.Controls.Add(this.memoryGraphPicBox); 227 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;228 244 this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 229 245 this.MaximizeBox = false; 230 246 this.MinimizeBox = false; 247 this.MinimumSize = new System.Drawing.Size(322, 261); 231 248 this.Name = "StatusWindow"; 232 249 this.Text = "Xe[^X"; 250 this.SizeChanged += new System.EventHandler(this.StatusWindow_SizeChanged); 233 251 this.ResumeLayout(false); 234 252 235 253 } 236 254 #endregion 255 256 private void StatusWindow_SizeChanged(object sender, System.EventArgs e) 257 { 258 cpuGraph.Dispose(); 259 memoryGraph.Dispose(); 260 cpuGraph = new Bitmap(cpuGraphPicBox.Width, cpuGraphPicBox.Height); 261 memoryGraph = new Bitmap(memoryGraphPicBox.Width, memoryGraphPicBox.Height); 262 cpuGraphPicBox.Image = cpuGraph; 263 memoryGraphPicBox.Image = memoryGraph; 264 } 237 265 } 238 266 } -
Property
svn:keywords
set to
-
trunk/MacFaceFloat/StatusWindow.resx
r62 r69 110 110 <value>False</value> 111 111 </data> 112 <data name="cpuGraphPicBox.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 113 <value>Assembly</value> 114 </data> 112 115 <data name="cpuGraphPicBox.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 113 116 <value>Private</value> 114 117 </data> 115 <data name="cpuGraphPicBox.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">116 <value>Assembly</value>117 </data>118 118 <data name="$this.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 119 119 <value>False</value> … … 125 125 <value>False</value> 126 126 </data> 127 <data name="$this.Localizable" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 128 <value>False</value> 129 </data> 130 <data name="$this.GridSize" type="System.Drawing.Size, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> 131 <value>8, 8</value> 132 </data> 127 133 <data name="$this.Name"> 128 134 <value>StatusWindow</value> 129 </data>130 <data name="$this.Localizable" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">131 <value>False</value>132 </data>133 <data name="$this.GridSize" type="System.Drawing.Size, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">134 <value>8, 8</value>135 135 </data> 136 136 <data name="$this.DrawGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
Note: See TracChangeset
for help on using the changeset viewer.