Bài viết này hướng dẫn bạn cách tạo ra một ứng dụng biểu đồ dùng để hiện thị dung lượng của các ổ cứng như thế nào. Các namespace được sử dụng như sau: using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System...
Bài viết này hướng dẫn bạn cách tạo ra một ứng dụng biểu đồ dùng để hiện thị dung lượng của các ổ cứng như thế nào.
Các namespace được sử dụng như sau:
- using System;
- using System.Drawing;
- using System.Collections;
- using System.ComponentModel;
- using System.IO;
- using System.Windows.Forms;
- using System.Data;
Các cấu trúc sử dụng:
- struct MyDirTotalSize
- {
- public string dirPath;
- public long totalSize;
- public int parent;
- }
- struct MyAngleStruct
- {
- public string folderpath;
- public float myAngle;
- public long mySize;
- }
Hàm dưới đây đảm nhiệm việc tạo ra các góc cho mỗi đường dẫn thư mục:
- private void GeneratePieChartAngle(string path)
- {
- MyAngleStruct angStructObj;
- angStructObj.myAngle = 0;
- MyDirTotalSize eff;
- long opteller = 0, compsize = 0;
- int startingPoint = -1, startingPoint2;
- for (startingPoint2 = 0; startingPoint2 <>
- {
- eff = (MyDirTotalSize) (SizeDir[startingPoint2]);
- if (path != eff.dirPath) continue;
- compsize += eff.totalSize;
- angStructObj.folderpath = eff.dirPath;
- angStructObj.mySize = eff.totalSize;
- AngleS.Add(angStructObj);
- startingPoint = eff.parent;
- }
- foreach (MyDirTotalSize ef in SizeDir)
- {
- if (ef.dirPath.CompareTo(path) == 0 || startingPoint <>continue;
- if (!ef.dirPath.StartsWith(path)) continue;
- compsize += ef.totalSize;
- startingPoint2 = ef.parent;
- opteller += ef.totalSize;
- if (startingPoint2 > (startingPoint + 1)) continue;
- angStructObj.folderpath = ef.dirPath;
- angStructObj.mySize = opteller;
- AngleS.Add(angStructObj);
- opteller = 0; //ef.size;
- }
- startingPoint = AngleS.Count;
- for (startingPoint2 = 0; startingPoint2 <>
- {
- angStructObj = (MyAngleStruct) (AngleS[startingPoint2]);
- AngleS.RemoveAt(startingPoint2);
- angStructObj.myAngle = (angStructObj.mySize/(float) compsize)*360;
- AngleS.Insert(startingPoint2, angStructObj);
- }
- }
Lưu ý các bài viết của bạn cần nêu rõ nguồn lấy từ đâu!!!
Trả lờiXóahttp://hp-aptech.edu.vn/hpa/programming/archive/2009/01/22/t-o-bi-u-xem-dung-l-ng-c-ng.aspx
Trả lờiXóa