工单 增加图片复制
This commit is contained in:
1 parent
f89670877d
commit
d70b74ee4a
2 files changed
+24
No files matched your search
@@ -164,6 +164,11 @@
|
||||
CornerRadius="5"
|
||||
Cursor="Hand"
|
||||
ToolTip="{Binding ToolTipText}">
|
||||
<Border.ContextMenu>
|
||||
<ContextMenu DataContext="{Binding PlacementTarget.DataContext, RelativeSource={RelativeSource Self}}">
|
||||
<MenuItem Header="复制图片" Click="CopyImage_Click" />
|
||||
</ContextMenu>
|
||||
</Border.ContextMenu>
|
||||
<Border.InputBindings>
|
||||
<MouseBinding
|
||||
Command="{Binding Source={StaticResource ShowImageCommand}}"
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using _29WxOrderWpf.ToolCtrls;
|
||||
using OrderSupportTicket.ViewModels;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Work._29Tools.Forms.ToolForms;
|
||||
|
||||
namespace OrderSupportTicket.Views;
|
||||
@@ -9,6 +11,23 @@ namespace OrderSupportTicket.Views;
|
||||
public partial class TicketConversationView : UserControl
|
||||
{
|
||||
public TicketConversationView() => InitializeComponent();
|
||||
|
||||
private void CopyImage_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
e.Handled = true;
|
||||
var window = Window.GetWindow(this);
|
||||
if (window == null) return;
|
||||
if (sender is not MenuItem { DataContext: ChatAttachmentViewModel attachment }) return;
|
||||
if (attachment.Image is not BitmapSource bitmap)
|
||||
{
|
||||
ToastHelper.Show(window, "图片尚未加载成功,无法复制");
|
||||
return;
|
||||
}
|
||||
|
||||
var data = new DataObject(DataFormats.Bitmap, bitmap);
|
||||
ToastHelper.Show(window, ClipboardHelper.TrySetData(data) ? "图片已复制" : "图片复制失败,请重试");
|
||||
}
|
||||
|
||||
private void CopyOrderId_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (sender is not FrameworkElement element || element.Tag is not string orderId || string.IsNullOrWhiteSpace(orderId)) return;
|
||||
|
||||
Reference in new issue
Block a user