Skip to content

Commit

Permalink
feat: change export audio menu item index
Browse files Browse the repository at this point in the history
  • Loading branch information
LiuYunPlayer committed Jul 23, 2024
1 parent efe74cf commit 292abed
Showing 1 changed file with 33 additions and 33 deletions.
66 changes: 33 additions & 33 deletions TuneLab/UI/MainWindow/Editor/TrackWindow/TrackHeadList/TrackHead.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,39 @@ public TrackHead()
MinWidth = 200;

var menu = new ContextMenu();
{
var menuItem = new MenuItem().SetTrName("Export Audio").SetAction(async () =>
{
if (Track == null)
return;

var topLevel = TopLevel.GetTopLevel(this);
if (topLevel == null)
return;

var file = await topLevel.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
{
Title = "Save File".Tr(TC.Dialog),
DefaultExtension = ".wav",
SuggestedFileName = Track.Name.Value,
ShowOverwritePrompt = true,
FileTypeChoices = [new("WAVE File".Tr(TC.Dialog)) { Patterns = ["*.wav"] }]
});
var result = file?.TryGetLocalPath();
if (result == null)
return;

try
{
AudioEngine.ExportTrack(result, Track, false);
}
catch (Exception ex)
{
await this.ShowMessage("Error".Tr(TC.Dialog), "Export failed: \n".Tr(TC.Dialog) + ex.Message);
}
});
menu.Items.Add(menuItem);
}
{
var menuItem = new MenuItem().SetTrName("Move Up").SetAction(() =>
{
Expand Down Expand Up @@ -196,39 +229,6 @@ public TrackHead()
menuItem.SetName(!Track.AsRefer.GetInfo() ? "Visible as Refer".Tr(TC.Menu) : "Hidden as Refer".Tr(TC.Menu));
};
}
{
var menuItem = new MenuItem().SetTrName("Export Audio").SetAction(async () =>
{
if (Track == null)
return;

var topLevel = TopLevel.GetTopLevel(this);
if (topLevel == null)
return;

var file = await topLevel.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
{
Title = "Save File".Tr(TC.Dialog),
DefaultExtension = ".wav",
SuggestedFileName = Track.Name.Value,
ShowOverwritePrompt = true,
FileTypeChoices = [new("WAVE File".Tr(TC.Dialog)) { Patterns = ["*.wav"] }]
});
var result = file?.TryGetLocalPath();
if (result == null)
return;

try
{
AudioEngine.ExportTrack(result, Track, false);
}
catch (Exception ex)
{
await this.ShowMessage("Error".Tr(TC.Dialog), "Export failed: \n".Tr(TC.Dialog) + ex.Message);
}
});
menu.Items.Add(menuItem);
}
{
var menuItem = new MenuItem().SetTrName("Delete").SetAction(() =>
{
Expand Down

0 comments on commit 292abed

Please sign in to comment.