private DataGridViewComboBoxColumn GetDNSComboBox(int conn_id) { DataGridViewComboBoxColumn cmb = new DataGridViewComboBoxColumn() { //CellTemplate = cell, Name = "DNSServer", HeaderText = "DNS-серверы", DataPropertyName = "DNSServer", // Tell the column which property it should use DisplayMember = "DNSServer", ValueMember = "DNSServer", //Width = 120, AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells, }; WMIMethods methods = new WMIMethods(); List <DNS> dnslist = methods.GetDNSArray(conn_id); if (dnslist.Count > 0) { var bindsList = new BindingList <DNS>(dnslist); var source = new BindingSource(bindsList, null); cmb.DataSource = source; } return(cmb); }
private void ChangeCellToComboBox(int iRowIndex) { if (bIsComboBox == false) { WMIMethods methods = new WMIMethods(); List <DNS> dt = methods.GetDNSArray(0); DataGridViewComboBoxCell dgComboCell = new DataGridViewComboBoxCell(); dgComboCell.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing; if (dt.Count > 0) { var bindsList = new BindingList <DNS>(dt); var source = new BindingSource(bindsList, null); dgComboCell.DataSource = source; } //dgComboCell.DataSource = dt; dgComboCell.ValueMember = "DNSServer"; dgComboCell.DisplayMember = "DNSServer"; ConnectionsdataGridView.Rows[iRowIndex].Cells[ConnectionsdataGridView.CurrentCell.ColumnIndex] = dgComboCell; bIsComboBox = true; } }
private DataGridViewComboBoxColumn GetGatewayComboBox(int conn_id) { DataGridViewComboBoxColumn cmb = new DataGridViewComboBoxColumn() { //CellTemplate = cell, Name = "IPGateway", HeaderText = "Шлюзы", DataPropertyName = "IPGateway", // Tell the column which property it should use DisplayMember = "IPGateway", ValueMember = "IPGateway", //Width = 120, AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill, }; WMIMethods methods = new WMIMethods(); List <Gateway> gtwlist = methods.GetGatewayArray(conn_id); if (gtwlist.Count > 0) { var bindsList = new BindingList <Gateway>(gtwlist); var source = new BindingSource(bindsList, null); cmb.DataSource = source; } return(cmb); }
public static List <DiskData> GetAPMRotaryDrives() { List <DiskData> disksNames = WMIMethods.GetPhysicalDiskNames(); List <DiskData> result = new List <DiskData>(); foreach (DiskData dd in disksNames) { IDENTIFY_DEVICE_DATA?idd = IdentifyDefice(dd.DeviceName); if (idd == null) { continue; } bool?b = IsRotativeDevice(idd.Value); if (b.HasValue && b.Value == true && APMSupported(idd.Value)) { DiskData ndd = new DiskData( DeviceName: dd.DeviceName, Model: ATACharsToString(idd.Value.model).Trim(), SerialNo: ATACharsToString(idd.Value.serial_no).Trim(), APMenabled: APMEnabled(idd.Value), APMvalue: idd.Value.CurrentAPMvalue, Status: dd.Status, Size: dd.Size ); result.Add(ndd); } } return(result); }
private void BindConnectionGrid(ref DataGridView dgv) { WMIMethods methods = new WMIMethods(); List <Connection> connlist = methods.GetNetworkDevices(); AddColumn(ref dgv); //dgv.Columns.Add( GetDNSComboBox(connlist[0].Id) ); //dgv.Columns.Add( GetGatewayComboBox(connlist[0].Id) ); //SetDNSComboBox(ref ConnectionsdataGridView); if (connlist.Count > 0) { var bindsList = new BindingList <Connection>(connlist); //Bind BindingList directly to the DataGrid var source = new BindingSource(bindsList, null); dgv.DataSource = source; } }
private void SetTextBox(ref DataGridView dgv) { WMIMethods methods = new WMIMethods(); List <Connection> connlist = methods.GetNetworkDevices(); //Добавление данных DataGridViewRow row = new DataGridViewRow(); DataGridViewTextBoxCell cell_txt = new DataGridViewTextBoxCell(); //Вписываем текст в заголовок строки row.HeaderCell.Value = "1"; row.CreateCells(dgv); //Создаем массив который будет помещен в ячейку cell_txt.Value = row.Cells[1] = cell_txt; //выбираем строчку по умолчанию - здесь выбрана под номером 2. row.Cells[1].Value = (row.Cells[1] as DataGridViewComboBoxCell).Items[2]; //Вносим в dataGridView dgv.Rows.Add(row); }
protected override void OnFormClosing(FormClosingEventArgs e) { base.OnFormClosing(e); DbMethods DB = new DbMethods(); WMIMethods methods = new WMIMethods(); List <Connection> Connection_list = methods.GetNetworkDevices(); List <DNS> DNS_list = methods.GetDNSArray(Connection_list[0].Id); List <Gateway> Gateway_list = methods.GetGatewayArray(Connection_list[0].Id); if (Connection_list.Count > 0) { DB.SaveConnectionTable(Connection_list, DNS_list, Gateway_list); } //DB.ReadConnectionHistory(ref Connection_list); if (e.CloseReason == CloseReason.WindowsShutDown) { return; } }
public void WmiSetBrightness(UInt32 Timeout, byte Brightness) { WMIMethods.ExecuteMethod(this, Timeout, Brightness); }
public void RenamePrinter(string newName) { WMIMethods.ExecuteMethod(this, newName); }