工单 修复 微信复制图片上传不展示的bug
This commit is contained in:
1 parent
9c62e0c03d
commit
1d5b6ba0e4
2 files changed
+69
-10
No files matched your search
@@ -14,16 +14,52 @@ public partial class TicketComposerView : UserControl
|
||||
|
||||
private void ChatTextBox_PreviewKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
var isPaste = (e.Key == Key.V && Keyboard.Modifiers == ModifierKeys.Control) || (e.Key == Key.Insert && Keyboard.Modifiers == ModifierKeys.Shift);
|
||||
if (!isPaste || DataContext is not OrderSupportTicketViewModel viewModel) return;
|
||||
var isPaste = (e.Key == Key.V && Keyboard.Modifiers == ModifierKeys.Control)
|
||||
|| (e.Key == Key.Insert && Keyboard.Modifiers == ModifierKeys.Shift);
|
||||
if (!isPaste || DataContext is not OrderSupportTicketViewModel viewModel)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IDataObject data;
|
||||
try { data = Clipboard.GetDataObject(); } catch (ExternalException) { return; }
|
||||
if (data == null) return;
|
||||
if (data.GetDataPresent(DataFormats.Bitmap) && data.GetData(DataFormats.Bitmap) is BitmapSource bitmap) { viewModel.AddPendingImage(bitmap); e.Handled = true; return; }
|
||||
if (!data.GetDataPresent(DataFormats.FileDrop) || data.GetData(DataFormats.FileDrop) is not string[] files) return;
|
||||
var images = files.Where(path => PendingAttachmentViewModel.TryGetMimeType(System.IO.Path.GetExtension(path), out _)).ToArray();
|
||||
if (images.Length == 0) return;
|
||||
try
|
||||
{
|
||||
data = Clipboard.GetDataObject();
|
||||
}
|
||||
catch (ExternalException)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (data == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.GetDataPresent(DataFormats.Bitmap)
|
||||
&& data.GetData(DataFormats.Bitmap) is BitmapSource bitmap)
|
||||
{
|
||||
viewModel.AddPendingImage(bitmap);
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.GetDataPresent(DataFormats.FileDrop)
|
||||
|| data.GetData(DataFormats.FileDrop) is not string[] files)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var images = files
|
||||
.Where(path => PendingAttachmentViewModel.TryGetMimeType(System.IO.Path.GetExtension(path), out _))
|
||||
.ToArray();
|
||||
|
||||
if (images.Length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
viewModel.AddPendingImages(images);
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user