Aplikasi Bandwith |
Menampilkan suatu nilai ukuran data bandwith yang di lakukan secara Online dalam melakukan aktivitas internet. yaitu menampilkan Speed/Received/Upload/Download.
Hasil Aplikasi Bandwith |
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.Net.NetworkInformation;
namespace pert4_Aplikasi_Bandwidth
{
public partial class Form1 : Form
{
public const double waktu_update = 1000;
private NetworkInterface[] network_interface;
public Timer timer;
public Form1()
{
InitializeComponent();
InitializeNetworkInterface();
Timer_intial();
}
private void Form1_Load(object sender, EventArgs e)
{
timer.Stop();
}
public void InitializeNetworkInterface()
{
network_interface = NetworkInterface.GetAllNetworkInterfaces();
for (int i = 0; i < network_interface.Length; i++)
{
comboBox1.Items.Add(network_interface[i].Name);
}
comboBox1.SelectedIndex = 0;
}
long lngBytesSend;
long lngBytesReceived;
public void proc()
{
NetworkInterface NIC = network_interface[comboBox1.SelectedIndex];
IPv4InterfaceStatistics status = NIC.GetIPv4Statistics();
int sent_Speed = (int)(status.BytesSent - lngBytesSend) / 1024;
int received_speed = (int)(status.BytesReceived - lngBytesReceived) / 1024;
label8.Text = (NIC.Speed / 1000000) + "Mbps";
label10.Text = status.BytesReceived.ToString();
label9.Text = status.BytesSent.ToString();
label12.Text = (sent_Speed).ToString() + "KB/s";
label11.Text = (received_speed).ToString() + "KB/s";
lngBytesSend = status.BytesSent;
lngBytesReceived = status.BytesReceived;
}
public void clear()
{
label8.Text = "0";
label9.Text = "0";
label10.Text = "0";
label11.Text = "0";
label12.Text = "0";
}
public void Timer_intial()
{
timer = new Timer();
timer.Interval = (int)waktu_update;
timer.Tick += new EventHandler(Update_waktu);
}
void Update_waktu(object sender, EventArgs e)
{ proc(); }
private void button1_Click(object sender, EventArgs e)
{
{ timer.Start(); }
}
private void button2_Click(object sender, EventArgs e)
{
{
timer.Stop();
clear();
}
}
}
}
INGAT!!
Jika Anda kurang puas atau ingin menambahkan ide
Anda dapat mengkostumnya di Form/View code nya
Untuk keterangan lebih lanjut lihat slide
Download Slide
Download Program
Selamat mencoba,
Semoga Bermanfaat.
0 komentar:
Posting Komentar