private async void grdBioses_CellContentClick(object sender, DataGridViewCellEventArgs e) { var grid = (DataGridView)sender; if (grid.Columns[e.ColumnIndex] is DataGridViewLinkColumn && e.RowIndex >= 0) { GenericBindingList <BiosRowData> list = (GenericBindingList <BiosRowData>)bsBioses.DataSource; BiosRowData bios = list[e.RowIndex]; Cursor.Current = Cursors.WaitCursor; if (!await _biosManager.DownloadBiosIfMissingAsync(bios)) { Cursor = Cursors.Default; return; } ProcessStartInfo psi = new ProcessStartInfo(bios.FileName) { UseShellExecute = true }; Process.Start(psi); Cursor = Cursors.Default; } }
public async Task <bool> DownloadBiosIfMissingAsync(BiosRowData bios) { if (File.Exists(bios.FileName)) { return(true); } FileInfo fi = new FileInfo(bios.FileName); if (!fi.Directory.Exists) { fi.Directory.Create(); } try { HttpClient client = new HttpClient(); using Stream stream = await client.GetStreamAsync(bios.DownloadUrl); using FileStream file = File.OpenWrite(bios.FileName); stream.CopyTo(file); } catch (Exception ex) { MessageBox.Show(_unableToDownloadBiosFileString + " " + ex.ToString(), _errorString, MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } return(true); }
private void btnFlash_Click(object sender, EventArgs e) { BiosRowData bios = ddlBioses.SelectedItem as BiosRowData; if (bios == null) { return; } Cursor = Cursors.WaitCursor; _toolManager.Flash(_motherboard, bios, _tool, cbExecuteScript.Checked); Cursor = Cursors.Default; }
private void grdBioses_CellContentClick(object sender, DataGridViewCellEventArgs e) { var grid = (DataGridView)sender; if (grid.Columns[e.ColumnIndex] is DataGridViewLinkColumn && e.RowIndex >= 0) { GenericBindingList <BiosRowData> list = (GenericBindingList <BiosRowData>)bsBioses.DataSource; BiosRowData bios = list[e.RowIndex]; ProcessStartInfo psi = new ProcessStartInfo(bios.FileName) { UseShellExecute = true }; Process.Start(psi); } }
private async void grd_PathCellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0 || e.ColumnIndex < 0) { return; } DataGridView grid = (DataGridView)sender; if (!(grid.Columns[e.ColumnIndex] is DataGridViewLinkColumn)) { return; } GenericBindingList <BiosRowData> list = (GenericBindingList <BiosRowData>)grdBioses.DataSource; BiosRowData bios = list[e.RowIndex]; Cursor.Current = Cursors.WaitCursor; if (!await _biosManager.DownloadBiosIfMissingAsync(bios)) { Cursor = Cursors.Default; return; } string path = grid.Rows[e.RowIndex].Cells[e.ColumnIndex].Value?.ToString(); if (string.IsNullOrEmpty(path)) { Cursor = Cursors.Default; return; } FileInfo fi = new FileInfo(path); ProcessStartInfo startInfo = new ProcessStartInfo(fi.FullName) { UseShellExecute = true }; Process.Start(startInfo); Cursor = Cursors.Default; }
private async void btnFlash_Click(object sender, EventArgs e) { BiosRowData bios = ddlBioses.SelectedItem as BiosRowData; if (bios == null) { return; } Cursor = Cursors.WaitCursor; if (!await _biosManager.DownloadBiosIfMissingAsync(bios)) { Cursor = Cursors.Default; return; } _toolManager.Flash(_motherboard, bios, _tool, cbExecuteScript.Checked); Cursor = Cursors.Default; }