/// <summary> /// Update GUI components for the network interfaces /// </summary> private void UpdateUi(UDStatistic item, double timeSpan) { //MessageBox.Show(cmbInterface.Items.Count.ToString()); if (cmbInterface.Items.Count >= 1) { // Grab NetworkInterface object that describes the current interface NetworkInterface nic = goodAdapters[cmbInterface.SelectedIndex]; // Grab the stats for that interface //IPv4InterfaceStatistics interfaceStats = nic.GetIPv4Statistics(); // Update the labels lblInterfaceType.Content = nic.NetworkInterfaceType.ToString(); //All Trafic lblBytesSent.Content = Tool.ToString(App._History.Data.Total.Upload); lblBytesReceived.Content = Tool.ToString(App._History.Data.Total.Download); //Now Trafic lblUpload.Content = Tool.GetNetSpeedString(item.upload, timeSpan); lblDownload.Content = Tool.GetNetSpeedString(item.download, timeSpan); //update try Balloon _trayIcon.BalloonTipText("▲ " + lblUpload.Content + "▼ " + lblDownload.Content); if (!isEdgeHide) {//Byte to kB/s Chart1.Downloaded(item.download / 1024); Chart1.Uploaded(item.upload / 1024); } UnicastIPAddressInformationCollection ipInfo = nic.GetIPProperties().UnicastAddresses; foreach (UnicastIPAddressInformation Info in ipInfo) { if (Info.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) { labelIPAddress.Content = Info.Address.ToString(); //uniCastIPInfo = item; break; } } } else { lblInterfaceType.Content = "-"; lblDownload.Content = 0; lblUpload.Content = 0; lblBytesReceived.Content = 0; lblBytesSent.Content = 0; labelIPAddress.Content = "0.0.0.0"; } }
public void NewData(List <UDOneItem> items, double timeSpan) { UDOneItem item = items.Where(x => x.ProcessID == IDProcess).FirstOrDefault(); if (item != null) { down.Text = Tool.GetNetSpeedString(item.Download, timeSpan); up.Text = Tool.GetNetSpeedString(item.Upload, timeSpan); Upload += item.Upload; Download += item.Download; up2.Text = Tool.ToString(Upload); down2.Text = Tool.ToString(Download); Chart1.Uploaded(item.Upload); Chart1.Downloaded(item.Download); if (item.ProcessID == -1) { Names.Text = "bridge"; } else { if (!idMap.TryGetValue(item.ProcessID, out ProcessView view)) { view = new ProcessView(item.ProcessID); idMap[item.ProcessID] = view; } Names.Text = view.Name ?? "Process ID: " + view.ID; if (view.Image != null) { Icons.Source = view.Image; } } } else { up.Text = "0K/s"; down.Text = "0K/s"; Chart1.Uploaded(0); Chart1.Downloaded(0); } }