Exemplo n.º 1
0
        private void CloseUpdateDownloadProgress()
        {
            if (InvokeRequired)
            {
                Invoke(new Action(CloseUpdateDownloadProgress));
            }
            else
            {
                m_updateWebClient.Dispose();
                m_updateDownloadProgress.Hide();
                m_updateDownloadProgress.Close();

                ApplicationUpdater applicationUpdater = new ApplicationUpdater(GetUpdateArchive(), AppDomain.CurrentDomain.BaseDirectory);
                if (!applicationUpdater.Execute())
                {
                    TextBoxForm form = new TextBoxForm(true, MessageBoxButtons.OK)
                    {
                        Text          = "Update Error",
                        HeaderText    = "The application was unable to update.Please download the update manually.",
                        DisplayText   = applicationUpdater.LastError,
                        StartPosition = FormStartPosition.CenterScreen
                    };

                    form.ShowDialog(this);
                }
            }
        }
Exemplo n.º 2
0
        private async void updateMetadataToolStripMenuItem_Click(object sender, EventArgs e)
        {
            IdGamesDataAdapater adapter = new IdGamesDataAdapater(AppConfiguration.IdGamesUrl, AppConfiguration.ApiPage, AppConfiguration.MirrorUrl);

            IGameFile[] localFiles = SelectedItems(GetCurrentViewControl());

            if (localFiles.Length > 0)
            {
                bool showForm = true, showError = true, updateView = false;
                m_cancelMetaUpdate = false;
                DialogResult    result   = DialogResult.Cancel;
                MetaDataForm    form     = CreateMetaForm();
                ProgressBarForm progress = InitMetaProgressBar();

                foreach (IGameFile localFile in localFiles)
                {
                    try
                    {
                        Enabled = false;
                        progress.DisplayText = string.Format("Searching for {0}...", localFile.FileNameNoPath);
                        progress.Show(this);

                        IEnumerable <IGameFile> remoteFiles = await Task.Run(() => GetMetaFiles(adapter, localFile.FileNameNoPath));

                        Enabled = true;
                        progress.Hide();

                        if (remoteFiles == null || m_cancelMetaUpdate)
                        {
                            break;
                        }

                        if (!remoteFiles.Any())
                        {
                            if (showError)
                            {
                                showError = HandleMetaError(localFile);
                            }
                        }
                        else
                        {
                            IGameFile remoteFile = HandleMultipleMetaFilesFound(localFile, remoteFiles);

                            if (remoteFile != null)
                            {
                                form.GameFileEdit.SetDataSource(remoteFile, new ITagData[] { });

                                if (showForm) //OK = Accept current file, Yes = Accept All files
                                {
                                    result = form.ShowDialog(this);
                                }

                                if (result != DialogResult.Cancel)
                                {
                                    List <GameFileFieldType> fields = form.GameFileEdit.UpdateDataSource(localFile);
                                    showForm = (result == DialogResult.OK);

                                    if (fields.Count > 0)
                                    {
                                        updateView = HandleUpdateMetaFields(localFile, fields);
                                    }
                                }
                            }
                        }
                    }
                    catch
                    {
                        Enabled = true;
                        progress.Hide();

                        MessageBox.Show(this, "Failed to fetch metadata from the id games mirror.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        break; //not expected, break from loop
                    }
                }

                if (updateView)
                {
                    HandleSelectionChange(GetCurrentViewControl(), true);
                }
            }
        }