Skip to content

Commit 3a6fadb

Browse files
Clipboard fixes
1 parent d90a531 commit 3a6fadb

File tree

5 files changed

+31
-7
lines changed

5 files changed

+31
-7
lines changed

MSUScripter/Services/ControlServices/MsuSongInfoPanelService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public void ImportAudioMetadata(string file)
9797
return
9898
"""
9999
# yaml-language-server: $schema=https://raw.githubusercontent.com/MattEqualsCoder/MSUScripter/main/Schemas/MsuSongInfo.json
100-
# Use Visual Studio Code with the YAML plugin from redhat for schema support
100+
# Use Visual Studio Code with the YAML plugin from redhat for schema support (make sure the language is set to YAML)
101101
102102
""" + yamlText;
103103
}

MSUScripter/Services/ControlServices/MsuSongMsuPcmInfoPanelService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public void HideSubTracksSubChannelsWarning()
127127
return
128128
"""
129129
# yaml-language-server: $schema=https://raw.githubusercontent.com/MattEqualsCoder/MSUScripter/main/Schemas/MsuSongMsuPcmInfo.json
130-
# Use Visual Studio Code with the YAML plugin from redhat for schema support
130+
# Use Visual Studio Code with the YAML plugin from redhat for schema support (make sure the language is set to YAML)
131131
132132
""" + yamlText;
133133
}

MSUScripter/Views/MsuSongInfoPanel.axaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,14 @@
5959
Click="MenuButton_OnClick"
6060
>
6161
<Button.ContextMenu>
62-
<ContextMenu>
62+
<ContextMenu Opening="ContextMenu_OnOpening">
6363
<MenuItem Header="Import Audio File Metadta"
6464
Click="ImportSongMetadataButton_OnClick"
6565
></MenuItem>
6666
<MenuItem Header="Copy Song Details to Clipboard"
6767
Click="CopySongToClipboardMenuItem_OnClick"
6868
></MenuItem>
69-
<MenuItem Header="Paste Song Details from Clipboard"
69+
<MenuItem Header="Paste Song Details from Clipboard" x:Name="PasteMenuItem"
7070
Click="PasteSongFromClipboardMenuItem_OnClick"
7171
></MenuItem>
7272
<MenuItem Header="Duplicate Song"

MSUScripter/Views/MsuSongInfoPanel.axaml.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.ComponentModel;
23
using System.Linq;
34
using System.Threading.Tasks;
45
using Avalonia;
@@ -112,7 +113,7 @@ private async void StopMusicButton_OnClick(object? sender, RoutedEventArgs e)
112113
await _service.PauseSong();
113114
}
114115

115-
private void MenuButton_OnClick(object? sender, RoutedEventArgs e)
116+
private async void MenuButton_OnClick(object? sender, RoutedEventArgs e)
116117
{
117118
if (sender is not Button button)
118119
{
@@ -125,6 +126,11 @@ private void MenuButton_OnClick(object? sender, RoutedEventArgs e)
125126
return;
126127
}
127128

129+
if (contextMenu.Items.FirstOrDefault(x => x is MenuItem { Name: "PasteMenuItem" }) is MenuItem pasteMenuItem)
130+
{
131+
pasteMenuItem.IsEnabled = !string.IsNullOrEmpty((await this.GetClipboardAsync())?.Trim());
132+
}
133+
128134
contextMenu.PlacementTarget = button;
129135
contextMenu.Open();
130136
e.Handled = true;
@@ -209,4 +215,17 @@ private void TestAudioLevelButton_OnClick(object? sender, RoutedEventArgs e)
209215
{
210216
_service?.AnalyzeAudio();
211217
}
218+
219+
private async void ContextMenu_OnOpening(object? sender, CancelEventArgs e)
220+
{
221+
if (sender is not ContextMenu contextMenu)
222+
{
223+
return;
224+
}
225+
226+
if (contextMenu.Items.FirstOrDefault(x => x is MenuItem { Name: "PasteMenuItem" }) is MenuItem pasteMenuItem)
227+
{
228+
pasteMenuItem.IsEnabled = !string.IsNullOrEmpty((await this.GetClipboardAsync())?.Trim());
229+
}
230+
}
212231
}

MSUScripter/Views/MsuSongMsuPcmInfoPanel.axaml.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ private async void GetTrimEndButton_OnClick(object? sender, RoutedEventArgs e)
139139
}
140140
}
141141

142-
private void MenuButton_OnClick(object? sender, RoutedEventArgs e)
142+
private async void MenuButton_OnClick(object? sender, RoutedEventArgs e)
143143
{
144144
if (sender is not Button button)
145145
{
@@ -152,6 +152,11 @@ private void MenuButton_OnClick(object? sender, RoutedEventArgs e)
152152
return;
153153
}
154154

155+
if (contextMenu.Items.FirstOrDefault(x => x is MenuItem { Name: "PasteMenuItem" }) is MenuItem pasteMenuItem)
156+
{
157+
pasteMenuItem.IsEnabled = !string.IsNullOrEmpty((await this.GetClipboardAsync())?.Trim());
158+
}
159+
155160
contextMenu.PlacementTarget = button;
156161
contextMenu.Open();
157162
e.Handled = true;
@@ -195,7 +200,7 @@ private async void ContextMenu_OnOpening(object? sender, CancelEventArgs e)
195200

196201
if (contextMenu.Items.FirstOrDefault(x => x is MenuItem { Name: "PasteMenuItem" }) is MenuItem pasteMenuItem)
197202
{
198-
pasteMenuItem.IsEnabled = !string.IsNullOrWhiteSpace(await this.GetClipboardAsync());
203+
pasteMenuItem.IsEnabled = !string.IsNullOrEmpty((await this.GetClipboardAsync())?.Trim());
199204
}
200205
}
201206

0 commit comments

Comments
 (0)