工单 优化 ,增加图片
This commit is contained in:
1 parent
bf5a70597c
commit
cf2efbcb16
27 files changed
+3555
-1538
No files matched your search
@@ -0,0 +1,29 @@
|
||||
using OrderSupportTicket.ViewModels;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace OrderSupportTicket.Views;
|
||||
|
||||
public partial class TicketComposerView : UserControl
|
||||
{
|
||||
public TicketComposerView() => InitializeComponent();
|
||||
|
||||
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;
|
||||
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;
|
||||
viewModel.AddPendingImages(images);
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user