Skip to content

Commit

Permalink
Remove unused UI elements and redundant code
Browse files Browse the repository at this point in the history
Removed the comboBoxExtension, groupBox1, and progressBar1 along with related code in Main.Designer.cs and Main.cs files. This cleanup simplifies the user interface and codebase by excluding functionality that is not currently utilized. The adjustments improve maintainability and readability of the code.
  • Loading branch information
ivandrofly committed Nov 24, 2024
1 parent 590d96d commit d9034f1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 65 deletions.
55 changes: 3 additions & 52 deletions source/SaveAllFormat/Main.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 6 additions & 13 deletions source/SaveAllFormat/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public partial class Main : Form
private readonly Subtitle _subtitle;
private readonly string _file;
private string _exportLocation;
private volatile string _selExtension;

// todo: add support to portable version
// todo: add support to export specific format e.g: xml, txt...
Expand All @@ -34,7 +33,6 @@ public Main(Form parentForm, Subtitle subtitle)
throw new ArgumentNullException(nameof(parentForm));
}

progressBar1.Visible = false;
_parentForm = parentForm;
_subtitle = subtitle;

Expand All @@ -51,16 +49,6 @@ public Main(Form parentForm, Subtitle subtitle)

Process.Start($"{textBoxLocation.Text}");
};

comboBoxExtension.BeginUpdate();
comboBoxExtension.Items.Add("all");
foreach (var extension in SubtitleFormat.AllSubtitleFormats.Select(f => f.Extension))
{
comboBoxExtension.Items.Add(extension);
}

comboBoxExtension.SelectedIndex = 0;
comboBoxExtension.EndUpdate();
}

private void buttonBrowse_Click(object sender, EventArgs e)
Expand All @@ -86,9 +74,9 @@ private async void buttonExport_Click(object sender, EventArgs e)
return;
}

_selExtension = comboBoxExtension.SelectedItem.ToString();
await Task.Run(() =>
{
// TODO: Use Parallel.ForeachAsync in .NET >= 6
ParallelLoopResult parallelLoopResult = Parallel.ForEach(SubtitleFormat.AllSubtitleFormats, exportFormat =>
{
try
Expand All @@ -111,6 +99,11 @@ await Task.Run(() =>

private static string GetExportFileName(string file, string formatName, string extension)
{
if (string.IsNullOrWhiteSpace(file))
{
return Path.GetRandomFileName() + extension;
}

string fileName = Path.GetFileNameWithoutExtension(file);
string newName = $"{fileName}_{formatName}{extension}";
foreach (var ch in Path.GetInvalidFileNameChars().Concat(Path.GetInvalidPathChars()))
Expand Down

0 comments on commit d9034f1

Please sign in to comment.