using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Collections;
using System.Net;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if ((e.Control == true) && (e.KeyCode == Keys.A ))
{
MessageBox.Show("ctrl+A");
}
}
private void Form1_Load(object sender, EventArgs e)
{
string[] logicdrives = System.IO.Directory.GetLogicalDrives();
for (int i = 0; i < logicdrives.Length; i++)
{
comboBox1.Items.Add(logicdrives[i]);
}
listView1.Columns.Add("environment", 150, HorizontalAlignment.Left);
listView1.Columns.Add("value", 150, HorizontalAlignment.Left);
listView1.Columns.Add("value2", 150, HorizontalAlignment.Left);
ListViewItem myitem;
foreach (DictionaryEntry dentry in Environment.GetEnvironmentVariables())
{
myitem = new ListViewItem(dentry.Key.ToString(), 0);
myitem.SubItems.Add(dentry.Value.ToString());
myitem.SubItems.Add("aaa");
listView1.Items.Add(myitem);
}
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
System.IO.DriveInfo[] drive = System.IO.DriveInfo.GetDrives();
switch(comboBox1.SelectedItem.ToString())
{
case @"C:\":
label1.Text = drive[0].TotalSize/1024/1024/1024 + "G";
label2.Text = drive[0].TotalFreeSpace / 1024 / 1024 / 1024 + "G";
label3.Text = (drive[0].TotalSize - drive[0].TotalFreeSpace) / 1024 / 1024 / 1024 + "G";
break;
case @"D:\":
label1.Text = drive[1].TotalSize / 1024 / 1024 / 1024 + "G";
label2.Text = drive[1].TotalFreeSpace / 1024 / 1024 / 1024 + "G";
label3.Text = (drive[1].TotalSize - drive[1].TotalFreeSpace) / 1024 / 1024 / 1024 + "G";
break;
default:
break;
}
}
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar != 8 && !char.IsDigit(e.KeyChar))
{
MessageBox.Show("only number");
e.Handled = true;
}
}
}
}
No comments:
Post a Comment