Skip to content

Commit

Permalink
Fix Occasional error setting clipboard content
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas694 committed Mar 16, 2022
1 parent d762b30 commit 6b722f7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
29 changes: 19 additions & 10 deletions src/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.IO;
using System.Linq;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using System.Web;
using System.Windows;
Expand Down Expand Up @@ -645,17 +646,25 @@ private void Grid1_MouseDown(object sender, MouseButtonEventArgs e)

if (e.ChangedButton == MouseButton.Right)
{
if (e.ClickCount == 2)
var data = (e.ClickCount == 2) ? imagePath : Path.GetDirectoryName(imagePath);
string message;
int i = 0;
do
{
Clipboard.SetText(imagePath);
ShowMessage("Image path copied to clipboard");
}
else
{
var imageDir = Path.GetDirectoryName(imagePath);
Clipboard.SetText(imageDir);
ShowMessage("Directory path copied to clipboard");
}
i++;
message = (e.ClickCount == 2) ? "Image path copied to clipboard" : "Directory path copied to clipboard";
try
{
Clipboard.SetText(data);
i = 9;
}
catch (Exception)
{
message = "Failed to set clipboard content!";
Thread.Sleep(200);
}
} while (i > 0 && i < 2);
ShowMessage(message);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.3.0.0")]
[assembly: AssemblyFileVersion("1.3.0.0")]
[assembly: AssemblyVersion("1.3.1.0")]
[assembly: AssemblyFileVersion("1.3.1.0")]

0 comments on commit 6b722f7

Please sign in to comment.