示例#1
0
 public void UpdateStatus(string line)
 {
     Dispatcher.Invoke(() =>
     {
         ProgressBox.AppendText(line + "\n");
         ProgressBox.ScrollToEnd();
     });
 }
示例#2
0
 private void UpdateTextBox(string text)
 {
     ProgressBox.AppendText(text + "\r\n");
 }
 public void UpdateProgress(string update)
 {
     ProgressBox.AppendText(update + '\n');
 }
示例#4
0
        private void Converter_Progress(object sender, ProgressEventArgs e)
        {
            Progress?.Invoke(this, e);

            switch (e.Type)
            {
            case ProgressEvent.Converted:
                // Save the conversion if data was changed in the conversion
                if (!e.Item.OldData.Equals(e.Item.NewData))
                {
                    HistoryManager.SaveConversion(e.Item);
                }

                ConvertedFiles++;

                this.InvokeSafe(() => {
                    ProgressBox.AppendText(string.Format("Converted:{3}\t{0}{3}\tFrom:\t{1}{3}\tTo:\t{2}{3}",
                                                         Path.GetDirectoryName(e.Item.OldData.FilePath),
                                                         Path.GetFileName(e.Item.OldData.FilePath),
                                                         Path.GetFileName(e.Item.NewData.FilePath),
                                                         Environment.NewLine));
                    Text = $"Conversion Progress {ConvertedFiles}/{TotalFiles}";
                });
                break;

            case ProgressEvent.FileDoesNotExist:
                ConvertedFiles++;

                this.InvokeSafe(() => {
                    ProgressBox.AppendText(string.Format("FAIL - File does not exist{2}\t{0}{2}\tFile: {1}{2}",
                                                         Path.GetDirectoryName(e.Item.OldData.FilePath),
                                                         Path.GetFileName(e.Item.OldData.FilePath),
                                                         Environment.NewLine));
                    Text = $"Conversion Progress {ConvertedFiles}/{TotalFiles}";
                });
                break;

            case ProgressEvent.FileAlreadyExists:
                ConvertedFiles++;

                this.InvokeSafe(() => {
                    ProgressBox.AppendText(string.Format("FAIL - Cannot override existing file with the same name{3}\t{0}{3}\tOriginal:\t{1}{3}\tExisting:\t{2}{3}",
                                                         Path.GetDirectoryName(e.Item.OldData.FilePath),
                                                         Path.GetFileName(e.Item.OldData.FilePath),
                                                         Path.GetFileName(e.Item.NewData.FilePath),
                                                         Environment.NewLine));
                    Text = $"Conversion Progress {ConvertedFiles}/{TotalFiles}";
                });
                break;

            case ProgressEvent.Reverted:
                // Remove the conversion from history
                HistoryManager.RemoveConversion(e.Item);

                ConvertedFiles++;

                this.InvokeSafe(() => {
                    ProgressBox.AppendText(string.Format("Reverted:{3}\t{0}{3}\tFrom:\t{1}{3}\tTo:\t{2}{3}",
                                                         Path.GetDirectoryName(e.Item.OldData.FilePath),
                                                         Path.GetFileName(e.Item.NewData.FilePath),
                                                         Path.GetFileName(e.Item.OldData.FilePath),
                                                         Environment.NewLine));
                    Text = $"Conversion Progress {ConvertedFiles}/{TotalFiles}";
                });
                break;

            case ProgressEvent.Completed:
                this.InvokeSafe(() => {
                    ProgressBox.AppendText("Conversion completed");
                    CloseBTN.Text = "Done";
                });
                break;

            default:
                throw new Exception("Invalid progress update type");
            }
        }