Skip to content

Commit

Permalink
修复BUG: 图片在部分情况下无法粘贴
Browse files Browse the repository at this point in the history
  • Loading branch information
silentmoooon committed Apr 28, 2020
1 parent 3e41b5b commit b5de050
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 9 additions & 2 deletions service/ClipService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,14 @@ public void SetValueToClipboard(ClipModel result)
}
else
{
string ext = Path.GetExtension(result.DisplayValue).ToLower();
string ext;
if (result.DisplayValue == null || result.DisplayValue == string.Empty)
{
ext = ".jpg";
}
else {
ext = Path.GetExtension(result.DisplayValue).ToLower();
}

string savePath = Path.GetTempPath() + Guid.NewGuid().ToString() + ext;
//savePath= @"C:\users\xiecan\desktop\" + Guid.NewGuid().ToString() + ext;
Expand Down Expand Up @@ -402,7 +409,7 @@ public void HandleImage(ClipModel clip)
base64 = Convert.ToBase64String(ms.GetBuffer());
}
clip.Type = IMAGE_TYPE;

clip.DisplayValue = "image.jpg";
clip.ClipValue = base64;


Expand Down
3 changes: 2 additions & 1 deletion view/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public MainWindow()

private void Window_Loaded(object sender, RoutedEventArgs e)
{

taskbar = (TaskbarIcon)FindResource("Taskbar");


Expand Down Expand Up @@ -152,7 +153,7 @@ private void WebView1_ScriptNotify(object sender, WebViewControlScriptNotifyEven

if (args[0] == "PasteValue")
{

PasteValue(args[1]);


Expand Down

0 comments on commit b5de050

Please sign in to comment.