diff --git a/JavaToCSharpGui/Infrastructure/ITextClipboard.cs b/JavaToCSharpGui/Infrastructure/ITextClipboard.cs
index 7057f18e..0c71366e 100644
--- a/JavaToCSharpGui/Infrastructure/ITextClipboard.cs
+++ b/JavaToCSharpGui/Infrastructure/ITextClipboard.cs
@@ -5,6 +5,12 @@
///
public interface ITextClipboard
{
+ ///
+ /// Gets the clipboard's text.
+ ///
+ /// A Task representing the async operation that returns the clipboard text.
+ Task GetTextAsync();
+
///
/// Sets the clipboard's text.
///
diff --git a/JavaToCSharpGui/Infrastructure/TextClipboard.cs b/JavaToCSharpGui/Infrastructure/TextClipboard.cs
index 043357ed..4c91edad 100644
--- a/JavaToCSharpGui/Infrastructure/TextClipboard.cs
+++ b/JavaToCSharpGui/Infrastructure/TextClipboard.cs
@@ -9,6 +9,16 @@ internal class TextClipboard : ITextClipboard
public TextClipboard(IClipboard? clipboard) => _clipboard = clipboard;
+ ///
+ public async Task GetTextAsync()
+ {
+ if (_clipboard is null)
+ {
+ return null;
+ }
+ return await _clipboard.GetTextAsync();
+ }
+
///
public async Task SetTextAsync(string? text)
{
diff --git a/JavaToCSharpGui/ViewModels/MainWindowViewModel.cs b/JavaToCSharpGui/ViewModels/MainWindowViewModel.cs
index 33242393..7372a7f9 100644
--- a/JavaToCSharpGui/ViewModels/MainWindowViewModel.cs
+++ b/JavaToCSharpGui/ViewModels/MainWindowViewModel.cs
@@ -313,6 +313,26 @@ private async Task OpenFileDialog()
}
}
+ [RelayCommand]
+ private async Task PasteInput()
+ {
+ if (_clipboard is null)
+ {
+ return;
+ }
+
+ var text = await _clipboard.GetTextAsync();
+ if (!string.IsNullOrEmpty(text))
+ {
+ JavaText.Text = text;
+ ConversionStateLabel = "Pasted Java code from clipboard!";
+
+ await Task.Delay(2000);
+
+ await _dispatcher.InvokeAsync(() => { ConversionStateLabel = ""; }, DispatcherPriority.Background);
+ }
+ }
+
[RelayCommand]
private async Task CopyOutput()
{
diff --git a/JavaToCSharpGui/Views/MainWindow.axaml b/JavaToCSharpGui/Views/MainWindow.axaml
index 2a9ec3f2..167ce988 100644
--- a/JavaToCSharpGui/Views/MainWindow.axaml
+++ b/JavaToCSharpGui/Views/MainWindow.axaml
@@ -59,7 +59,7 @@
Java Source Code Input:
-
+
File:
+