From 292abed8d942be17f34502859b1130858cb50b03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=87=91=E5=88=9A?= <1219318552@qq.com> Date: Tue, 23 Jul 2024 23:27:47 +0800 Subject: [PATCH] feat: change export audio menu item index --- .../TrackWindow/TrackHeadList/TrackHead.cs | 66 +++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/TuneLab/UI/MainWindow/Editor/TrackWindow/TrackHeadList/TrackHead.cs b/TuneLab/UI/MainWindow/Editor/TrackWindow/TrackHeadList/TrackHead.cs index e245e1c..6013aac 100644 --- a/TuneLab/UI/MainWindow/Editor/TrackWindow/TrackHeadList/TrackHead.cs +++ b/TuneLab/UI/MainWindow/Editor/TrackWindow/TrackHeadList/TrackHead.cs @@ -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(() => { @@ -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(() => {