Exemplo n.º 1
0
        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;
            }
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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;
        }
Exemplo n.º 4
0
        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);
            }
        }
Exemplo n.º 5
0
        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;
        }
Exemplo n.º 6
0
        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;
        }