From 3d933d3bcad8519d5ca587310f9b04cb2fda460c Mon Sep 17 00:00:00 2001
From: Danial Ahmad <108906119+iamdanialahmad@users.noreply.github.com>
Date: Tue, 18 Nov 2025 14:22:58 +0100
Subject: [PATCH 1/3] GUI: Add Paste button to Java Input pane, #136
---
.../Infrastructure/ITextClipboard.cs | 6 ++++++
.../Infrastructure/TextClipboard.cs | 10 ++++++++++
.../ViewModels/MainWindowViewModel.cs | 20 +++++++++++++++++++
JavaToCSharpGui/Views/MainWindow.axaml | 16 +++++++++++++--
4 files changed, 50 insertions(+), 2 deletions(-)
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..d44f34f4 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..c83d82a1 100644
--- a/JavaToCSharpGui/Views/MainWindow.axaml
+++ b/JavaToCSharpGui/Views/MainWindow.axaml
@@ -57,7 +57,7 @@
-
+
Java Source Code Input:
File:
@@ -74,10 +74,22 @@
+
+
+
Date: Tue, 18 Nov 2025 14:43:36 +0100
Subject: [PATCH 2/3] GUI: Fix Paste button positioning in file controls row,
#136
---
JavaToCSharpGui/Views/MainWindow.axaml | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/JavaToCSharpGui/Views/MainWindow.axaml b/JavaToCSharpGui/Views/MainWindow.axaml
index c83d82a1..167ce988 100644
--- a/JavaToCSharpGui/Views/MainWindow.axaml
+++ b/JavaToCSharpGui/Views/MainWindow.axaml
@@ -57,9 +57,9 @@
-
+
Java Source Code Input:
-
+
File:
-
-
-
-
+
Date: Mon, 8 Dec 2025 20:14:52 -0700
Subject: [PATCH 3/3] Update JavaToCSharpGui/Infrastructure/TextClipboard.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
---
JavaToCSharpGui/Infrastructure/TextClipboard.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/JavaToCSharpGui/Infrastructure/TextClipboard.cs b/JavaToCSharpGui/Infrastructure/TextClipboard.cs
index d44f34f4..4c91edad 100644
--- a/JavaToCSharpGui/Infrastructure/TextClipboard.cs
+++ b/JavaToCSharpGui/Infrastructure/TextClipboard.cs
@@ -12,7 +12,7 @@ internal class TextClipboard : ITextClipboard
///
public async Task GetTextAsync()
{
- if(_clipboard is null)
+ if (_clipboard is null)
{
return null;
}