示例#1
0
        private void loadProfile(string fileName, bool quiet)
        {
            try
            {
                FileInfo fiDest = new FileInfo(fileName);

                FileStream        fsDest            = fiDest.Open(FileMode.Open, FileAccess.Read);
                DeviceItemProfile deviceItemProfile = DeviceItem.Load(fsDest);
                mCurrentDeviceItem = deviceItemProfile.DeviceItem;
                fsDest.Close();
                if (DriverResManager.Check())
                {
                    wizMain.NextTo(wizardPageConfigDevice);
                    return;
                }
                MessageBox.Show(this, "Driver resources were not found.");
            }
            catch (Exception ex)
            {
                if (!quiet)
                {
                    MessageBox.Show(ex.ToString(), "Failed loading profile.");
                }
            }
        }
示例#2
0
        private void wizardPageWelcome_CloseFromNext(object sender, PageEventArgs e)
        {
            rtfWelcomeStatus.LoggingEnabled = false;

            if (mSkipToDriverResourceLocator)
            {
                mSkipToDriverResourceLocator = false;
                return;
            }
            if (DriverResManager.Check())
            {
                SynchronizationContext.Current.Post(moveToWizardPage, wizardPageSelectDevice);
            }
        }
        private void downloadDriverResources()
        {
            bool success = false;

            groupBoxDriverList.Enabled      = false;
            buttonCancelDownload.Enabled    = false;
            groupBoxDownloadStatus.Enabled  = true;
            rtfDownloadSatus.LoggingEnabled = true;
            driverResourceDownloader.Reset();

            try
            {
                DriverResourceDownloads resourceDownloads = new DriverResourceDownloads();
                foreach (DataGridViewRow selectedRow in dataGridViewDriverDownloadList.SelectedRows)
                {
                    resourceDownloads.Add(selectedRow.Tag as DriverResourceDownload);
                }

                int waitRet = -1;
                foreach (DriverResourceDownload resourceDownload in resourceDownloads)
                {
                    if (driverResourceDownloader.IsCancelled)
                    {
                        waitRet = 1;
                        break;
                    }
                    InfWizardStatus.Log(CategoryType.DriverDownloader,
                                        StatusType.Info,
                                        "requesting driver resource {0}..",
                                        resourceDownload.DisplayName);

                    progressBarDownloadDriverResources.Value = 0;
                    driverResourceDownloader.DownloadDataAsync(progressBarDownloadDriverResources, resourceDownload.Url, null);
                    buttonCancelDownload.Enabled = true;

                    WaitHandle[] waitHandles = new WaitHandle[]
                    { driverResourceDownloader.CompleteWaitHandle, driverResourceDownloader.CancelWaitHandle };
                    do
                    {
                        waitRet = WaitHandle.WaitAny(waitHandles, 10);
                        Application.DoEvents();
                        Thread.Sleep(0);
                    } while (waitRet == WaitHandle.WaitTimeout);

                    switch (waitRet)
                    {
                    case 0:
                        InfWizardStatus.Log(CategoryType.DriverDownloader, StatusType.Info, "driver resource downloaded.");
                        break;

                    case 1:
                        InfWizardStatus.Log(CategoryType.DriverDownloader, StatusType.Warning, "failed getting driver resource; operation cancelled.");
                        break;

                    case WaitHandle.WaitTimeout:
                        InfWizardStatus.Log(CategoryType.DriverDownloader, StatusType.Error, "connection timed out.");
                        break;
                    }
                    if (waitRet == 0 && driverResourceDownloader.Result != null)
                    {
                        string downloadFilename = driverResourceDownloader.GetDownloadFilename();

                        // TODO: Add main driver resource path for saving downloaded resources
                        string path = null;
                        if (String.IsNullOrEmpty(path))
                        {
                            path = Environment.CurrentDirectory;
                        }

                        string resourceFilename = Path.Combine(path, downloadFilename);
                        if (File.Exists(resourceFilename))
                        {
                            InfWizardStatus.Log(CategoryType.DriverDownloader, StatusType.Warning, "deleting driver resource file {0}", resourceFilename);
                            File.Delete(resourceFilename);
                        }
                        InfWizardStatus.Log(CategoryType.DriverDownloader, StatusType.Success, "saving driver resource {0}", resourceFilename);
                        FileStream resourceStreamOut = File.Create(resourceFilename);
                        resourceStreamOut.Write(driverResourceDownloader.Result, 0, driverResourceDownloader.Result.Length);
                        resourceStreamOut.Flush();
                        resourceStreamOut.Close();
                    }
                    else
                    {
                        break;
                    }
                }

                if (waitRet == 0)
                {
                    if (DriverResManager.LoadResources())
                    {
                        success = true;
                    }
                    else
                    {
                        InfWizardStatus.Log(CategoryType.DriverDownloader, StatusType.Error, "failed loading driver resources!");
                    }
                }
            }
            catch (Exception ex)
            {
                InfWizardStatus.Log(CategoryType.DriverDownloader, StatusType.Error, ex.ToString());
                buttonDownloadDriverResources.Enabled = false;
                success = false;
            }
            finally
            {
                buttonCancelDownload.Enabled    = false;
                rtfDownloadSatus.LoggingEnabled = false;
                if (success)
                {
                    buttonSelectAllDriverResources_Click(this, new EventArgs());
                    wizMain.NextEnabled = DriverResManager.Check();
                }
                groupBoxDriverList.Enabled = true;
            }
        }
示例#4
0
 private void wizardPageGetDrivers_ShowFromNext(object sender, EventArgs e)
 {
     wizMain.NextEnabled = DriverResManager.Check();
 }
示例#5
0
 private void InfWizardForm_Load(object sender, EventArgs e)
 {
     if (!DriverResManager.LoadResources())
     {
     }
 }