public NetworkAdapter(ManagementBaseObject adapter) { Name = (string)adapter["NetConnectionID"]; DeviceName = (string)adapter["Name"]; DeviceId = (string)adapter["DeviceID"]; DeviceName = DeviceName.Replace('(', '[').Replace(')', ']'); // for intel: Intel(R) => Intel[R] in perfcounter DeviceName = DeviceName.Replace('#', '_'); // for cards with same name which are numbered like this: #2 #3 => _2 _3 DeviceName = DeviceName.Replace('/', '_'); // for Intel Pro/1000 _bytespersecout = new PerformanceCounter("Network Interface", "Bytes Sent/sec", DeviceName); _bytespersecin = new PerformanceCounter("Network Interface", "Bytes Received/sec", DeviceName); _bytespersecin.NextValue(); _bytespersecout.NextValue(); }
private void ToolStripButtonSave_Click(object sender, EventArgs e) { if (IsRunning()) { var i = 1; string filename = string.Empty; while (filename == string.Empty || File.Exists(filename)) { filename = string.Format("{0}_{1}_{2}_{3}.jpg", DeviceName.Replace(' ', '_'), Program.SessionId, DateTime.Now.ToString("yyyyMMdd"), i.ToString()); if (Properties.Settings.Default.AutoSave && !string.IsNullOrEmpty(Properties.Settings.Default.DefaultPath) && Directory.Exists(Properties.Settings.Default.DefaultPath)) { if (Properties.Settings.Default.AskAlbumName && string.IsNullOrEmpty(Program.AlbumName)) { Program.ShowInputDialog(ref Program.AlbumName, "Album"); } filename = Path.Combine(Properties.Settings.Default.DefaultPath, Program.AlbumName, filename); } i++; } saveFileDialogMain.FileName = filename; if (Properties.Settings.Default.AutoSave && !string.IsNullOrEmpty(Properties.Settings.Default.DefaultPath) && Directory.Exists(Properties.Settings.Default.DefaultPath)) { SaveFileDialogMain_FileOk(sender, new CancelEventArgs()); } else { saveFileDialogMain.ShowDialog(); } } }