frm_Main.cs

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Management;
using System.IO;
/* 
 *源码来自(C#源码世界)  www.HelloCsharp.com
 *如果对该源码有问题可以直接点击下方的提问按钮进行提问哦
 *站长将亲自帮你解决问题
 *C#源码世界-找到你需要的C#源码,交流和学习
 */
// 下载于www.51aspx.com
namespace Case09_7
{
    public partial class frm_Main : Form
    {
        public frm_Main()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            SelectQuery selectQuery = new SelectQuery("select * from win32_logicaldisk");
            ManagementObjectSearcher searcher = new ManagementObjectSearcher(selectQuery);
            foreach (ManagementObject disk in searcher.Get())
            {
                comboBox1.Items.Add(disk["Name"].ToString());
            }
        }
        // 下载于www.51aspx.com
        private void button1_Click(object sender, EventArgs e)
        {
            DriveInfo dinfo = new DriveInfo(comboBox1.Text);
            float tsize = dinfo.TotalSize;
            float fsize = dinfo.TotalFreeSpace;
            Graphics graphics = this.CreateGraphics();
            graphics.Clear(Color.White);
            Pen pen1 = new Pen(Color.Red);
            Brush brush1 = new SolidBrush(Color.WhiteSmoke);
            Brush brush2 = new SolidBrush(Color.Red );
            Brush brush3 = new SolidBrush(Color.SteelBlue );
            Font font1 = new Font("Courier New", 16, FontStyle.Bold);
            Font font2 = new Font("宋体", 9);
            graphics.DrawString("磁盘容量分析", font1, brush2, new Point(60, 50));
            float angle1 = Convert.ToSingle((360 * (Convert.ToSingle(fsize / 100000000000) / Convert.ToSingle(tsize / 100000000000))));
            float angle2 = Convert.ToSingle((360 * (Convert.ToSingle((tsize - fsize) / 100000000000) / Convert.ToSingle(tsize / 100000000000))));
            graphics.FillPie(brush2, 60, 80, 150, 150, 0, angle1);
            graphics.FillPie(brush3, 60, 80, 150, 150, angle1, angle2);
            graphics.DrawRectangle(pen1, 30, 235, 200, 50);
            graphics.FillRectangle(brush2, 35, 245, 20, 10);
            graphics.DrawString("磁盘剩余容量:" + dinfo.TotalFreeSpace / 1024/1024 + "M", font2, brush2, 55, 245);
            graphics.FillRectangle(brush3, 35, 265, 20, 10);
            graphics.DrawString("磁盘已用容量:" + (dinfo.TotalSize - dinfo.TotalFreeSpace) / 1024/1024 + "M", font2, brush3, 55, 265);
        }
后面还有 8 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。