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);
                }
            }
        }
Exemple #2
0
        private static void DisplayException(Form form, Exception ex)
        {
            if (form != null && form.InvokeRequired)
            {
                form.Invoke(new Action <Form, Exception>(DisplayException), new object[] { form, ex });
            }
            else
            {
                TextBoxForm txt = new TextBoxForm();
                txt.Text        = "Unexpected Error";
                txt.HeaderText  = "An unexpected error occurred. Please submit the error report by clicking the link below. The report has been copied to your clipboard." + Environment.NewLine;
                txt.DisplayText = ex.ToString();
                txt.SetLink("Click here to submit", GitHubRepository);
                Clipboard.SetText(txt.DisplayText);

                if (form == null)
                {
                    txt.ShowDialog();
                }
                else
                {
                    txt.StartPosition = FormStartPosition.CenterParent;
                    txt.ShowDialog(form);
                }
            }
        }
Exemple #3
0
        private void newProfileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TextBoxForm form    = CreateProfileTextBoxForm("New Profile", true);
            bool        success = false;

            while (!success && form.ShowDialog(this) == DialogResult.OK)
            {
                success = IsValidProfileName(-1, form.DisplayText.Trim(), out string error);

                if (success)
                {
                    GameProfile gameProfile = new GameProfile(GameFile.GameFileID.Value, form.DisplayText);

                    GameProfile.ApplyDefaultsToProfile(gameProfile, m_appConfig);
                    if (form.CheckBoxChecked)
                    {
                        UpdateGameProfile(gameProfile);
                    }

                    m_adapter.InsertGameProfile(gameProfile);

                    cmbProfiles.SelectedIndexChanged -= CmbProfiles_SelectedIndexChanged;
                    var profiles = LoadProfiles();
                    cmbProfiles.SelectedIndexChanged += CmbProfiles_SelectedIndexChanged;
                    cmbProfiles.SelectedValue         = profiles.Max(x => x.GameProfileID);
                }
                else
                {
                    MessageBox.Show(this, error, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        private void lnkMapsEdit_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            TextBoxForm textBoxForm = new TextBoxForm(true, MessageBoxButtons.OKCancel)
            {
                Text          = "Maps",
                HeaderText    = "Enter map names, separated by commas.",
                DisplayText   = m_maps,
                StartPosition = FormStartPosition.CenterScreen
            };

            if (textBoxForm.ShowDialog(this) == DialogResult.OK)
            {
                m_maps = textBoxForm.DisplayText;
            }
        }
Exemple #5
0
        private static TextBoxForm CreateProfileTextBoxForm(string displayText, bool showCheckBox)
        {
            TextBoxForm form = new TextBoxForm(false, MessageBoxButtons.OKCancel);

            form.SetMaxLength(48);
            form.DisplayText   = displayText;
            form.StartPosition = FormStartPosition.CenterParent;
            form.Text          = "Enter Profile Name";
            form.SelectDisplayText(0, form.DisplayText.Length);
            if (showCheckBox)
            {
                form.SetCheckBox("Copy current profile");
            }
            return(form);
        }
Exemple #6
0
        private void TxtParameters_Click(object sender, EventArgs e)
        {
            TextBoxForm form = new TextBoxForm(true, MessageBoxButtons.OKCancel)
            {
                Text          = "Extra Parameters",
                DisplayText   = txtParameters.Text,
                StartPosition = FormStartPosition.CenterParent,
                AcceptButton  = null
            };

            form.SelectDisplayText(0, 0);
            if (form.ShowDialog(this) == DialogResult.OK)
            {
                txtParameters.Text = form.DisplayText;
            }
        }
Exemple #7
0
        private void ShowLaunchParameters(GameFilePlayAdapter playAdapter, IGameFile gameFile, ISourcePortData sourcePort)
        {
            TextBoxForm form = new TextBoxForm
            {
                Text          = "Launch Parameters",
                StartPosition = FormStartPosition.CenterParent
            };

            string launchParameters = playAdapter.GetLaunchParameters(AppConfiguration.GameFileDirectory,
                                                                      AppConfiguration.TempDirectory, gameFile, sourcePort, IsGameFileIwad(gameFile));

            if (launchParameters != null)
            {
                launchParameters = launchParameters.Replace(@" -", string.Concat(Environment.NewLine, " -"));
                launchParameters = launchParameters.Replace("\" \"", string.Concat("\"", Environment.NewLine, " \""));
                if (launchParameters.StartsWith(Environment.NewLine))
                {
                    launchParameters = launchParameters.Substring(Environment.NewLine.Length);
                }
                string individualFiles = string.Empty;

                if (m_currentPlayForm.SpecificFiles != null && m_currentPlayForm.SpecificFiles.Length > 0)
                {
                    individualFiles = Environment.NewLine + string.Format("Selected Files: {0}", string.Join(", ", m_currentPlayForm.SpecificFiles));
                }

                string sourcePortParams = string.Empty;
                if (!string.IsNullOrEmpty(sourcePort.ExtraParameters))
                {
                    sourcePortParams = string.Concat(Environment.NewLine, Environment.NewLine, "Paramters from source port: ", sourcePort.ExtraParameters);
                }

                form.DisplayText = string.Concat(launchParameters, Environment.NewLine, Environment.NewLine,
                                                 string.Format("Supported Extensions: {0}", sourcePort.SupportedExtensions),
                                                 individualFiles,
                                                 sourcePortParams,
                                                 Environment.NewLine, Environment.NewLine,
                                                 "*** If files appear to be missing check the 'Select Individual Files' option and supported extensions options in the Source Port form of the selected source port.");
            }
            else
            {
                form.DisplayText = "Failed to generate launch parameters";
            }

            form.SelectDisplayText(0, 0);
            form.ShowDialog(this);
        }
Exemple #8
0
        private void editProfileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (SelectedGameProfile is GameFile)
            {
                MessageBox.Show(this, "The default profile cannot be renamed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            TextBoxForm form          = CreateProfileTextBoxForm(SelectedGameProfile.Name, false);
            int         gameProfileID = SelectedGameProfile.GameProfileID;
            bool        success       = false;

            while (!success && form.ShowDialog(this) == DialogResult.OK)
            {
                success = RenameGameProfile(gameProfileID, form.DisplayText.Trim());
            }
        }
Exemple #9
0
        private void HandleDemoChange()
        {
            if (chkDemo.Checked && cmbDemo.SelectedItem != null)
            {
                var file   = cmbDemo.SelectedItem as IFileData;
                var parser = DemoUtil.GetDemoParser(Path.Combine(m_appConfig.DemoDirectory.GetFullPath(), file.FileName));

                if (parser != null)
                {
                    m_handler.Reset();
                    SetAdditionalFiles(true);

                    string[]         requiredFiles = parser.GetRequiredFiles();
                    List <string>    unavailable   = new List <string>();
                    List <IGameFile> iwads         = new List <IGameFile>();
                    List <IGameFile> gameFiles     = GetGameFiles(requiredFiles, unavailable, iwads);
                    ctrlFiles.SetDataSource(gameFiles);
                    if (iwads.Count > 0)
                    {
                        SelectedIWad = iwads.First();
                    }

                    if (unavailable.Count > 0)
                    {
                        TextBoxForm form = new TextBoxForm(true, MessageBoxButtons.OK)
                        {
                            StartPosition = FormStartPosition.CenterParent,
                            Text          = "Not Found",
                            HeaderText    = "The following required files were not found:",
                            DisplayText   = string.Join(Environment.NewLine, unavailable.ToArray())
                        };
                        form.ShowDialog(this);
                    }

                    m_demoChangedAdditionalFiles = true;
                    ResetSpecificFilesSelections(ctrlFiles.GetFiles().Cast <IGameFile>().ToArray()); //don't use the handler in this case, we are overriding it
                }
            }
            else
            {
                m_demoChangedAdditionalFiles = false;
            }
        }
Exemple #10
0
        private void HandleStatReaderErrors(IStatisticsReader m_statsReader)
        {
            TextBoxForm form = new TextBoxForm();

            form.StartPosition = FormStartPosition.CenterParent;
            form.Text          = "Statistic Reader Errors";
            form.HeaderText    = string.Concat("The following errors were reported by the statistics reader.",
                                               Environment.NewLine, "The statistics may be incomplete or missing.");

            StringBuilder sb = new StringBuilder();

            foreach (string error in m_statsReader.Errors)
            {
                sb.Append(error);
                sb.Append(Environment.NewLine);
            }

            form.DisplayText = sb.ToString();
            form.ShowDialog(this);
        }
        private void DisplayFilesNotFound(IEnumerable <string> files, List <IGameFile> gameFiles)
        {
            IEnumerable <string> filesNotFound = files.Except(gameFiles.Select(x => x.FileName));

            if (filesNotFound.Any())
            {
                StringBuilder sb = new StringBuilder();
                foreach (string file in filesNotFound)
                {
                    sb.Append(file);
                    sb.Append(Environment.NewLine);
                }

                TextBoxForm form = new TextBoxForm(true, MessageBoxButtons.OK);
                form.Text        = "Files Not Found";
                form.HeaderText  = "The following files were not found in the idgames database:";
                form.DisplayText = sb.ToString();
                form.ShowDialog(this);
            }
        }