示例#1
0
        /// <summary>
        /// Resets the form to the initial state.
        /// </summary>
        private void ResetForm()
        {
            patchQueue             = null;
            labelSelectedFile.Text = defaultSelectedFileText;
            buttonPatch.Enabled    = false;

            labelCurrentLangVersion.Text = languageCatalog.Version?.ToString() ?? Properties.Resources.UnkownVersion;
        }
示例#2
0
        /// <summary>
        /// Builds the queue from the specified input files
        /// </summary>
        /// <param name="files"></param>
        private void ChooseInputFiles(string[] files)
        {
            patchQueue = new PatchQueue();

            var errors  = new List <string>();
            var builder = new StringBuilder();

            foreach (var file in files)
            {
                var onlyFileName = Path.GetFileName(file);
                using var fileStream = File.OpenRead(file);
                var fileContainer = containers.FirstOrDefault(container => container.CanPatch(fileStream));

                if (fileContainer == null)
                {
                    errors.Add($"Unknown file format: {onlyFileName}");
                    continue;
                }

                if (builder.Length > 0)
                {
                    builder.Append(", ");
                }

                builder.Append(onlyFileName);
                patchQueue.Items.Add(new PatchQueueItem(file, fileContainer));
            }

            if (errors.Count > 0)
            {
                if (builder.Length > 0)
                {
                    ErrorMessage(Properties.Resources.ErrorModalSelectionPartialFail, string.Join("\r\n", errors));
                }
                else
                {
                    ErrorMessage(Properties.Resources.ErrorModalSelectionFullFail, string.Join("\r\n", errors));
                }
            }

            if (builder.Length > 0)
            {
                labelSelectedFile.Text = builder.ToString();
                buttonPatch.Enabled    = true;

                if (progressBar.Visible)
                {
                    progressBar.Visible        = false;
                    labelCurrentStatus.Visible = false;
                }
            }
            else
            {
                labelSelectedFile.Text = defaultSelectedFileText;
                buttonPatch.Enabled    = false;
                patchQueue             = null;
            }
        }
示例#3
0
        /// <summary>
        /// Called when the user clicks the patch button, starts the patch thread.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ButtonPatch_Click(object sender, EventArgs e)
        {
            EnableForm(false);

            progressBar.Maximum        = 1;
            progressBar.Value          = 0;
            progressBar.Visible        = true;
            labelCurrentStatus.Text    = Properties.Resources.StatusPatchStarting;
            labelCurrentStatus.Visible = true;

            patchWorker.StartPatching(patchQueue, this);
            patchQueue = null;
        }