Files
29WxOrder/29WxOrderWpf/Windows/OrderWindows/BuyMapSkuSelectWindow.xaml.cs
T
2026-09-06 19:13:34 +08:00

118 lines
2.9 KiB
C#

using _29WxOrderWpf.BaseWindows;
using _29WxOrderWpf.ViewModels;
using AllBase;
using AllBase.Helper;
using AllBase.Model.Config;
using AllBase.Model.DBModel;
using AllBase.Model.Result;
using NaiBa.Util.Extension;
using Newtonsoft.Json.Linq;
using NPOI.POIFS.NIO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Work._29Tools.BLL;
using Work._29Tools.Forms.ToolForms;
namespace _29WxOrderWpf.Windows.OrderWindows
{
/// <summary>
/// SkuSelectWindow.xaml 的交互逻辑
/// </summary>
public partial class BuyMapSkuSelectWindow : BaseWindow
{
public oms_wei_order_item_info OrderItem { get; set; }
public BuyMapSkuViewModel ViewModel { get; set; } = null;
public BuyMapSkuSelectWindow(oms_wei_order_item_info orderItem)
{
InitializeComponent();
if (orderItem != null)
OrderItem = orderItem;
ViewModel = new BuyMapSkuViewModel(orderItem);
this.DataContext = ViewModel;
ViewModel.RequestClose += ViewModel_RequestClose;
}
private void ViewModel_RequestClose()
{
this.Close();
}
private async void SkuSelectWindow_Loaded(object sender, RoutedEventArgs e)
{
btnAdd.IsEnabled = true;
await Task.Run(() =>
{
// 异步加载图片防止卡顿
// 缩略图在有的电脑上无法显示
//BitmapImage bImg = ImageUrlToBitmapImageConverter.LoadImageFromUrl(order_item.thumb_img + "?imageView2/1/w/100/format/webp|imageMogr2/auto-orient=");
BitmapImage bImg = AllBase.ImageBuild.LoadBitmipImageFromUrl(OrderItem.thumb_img);
Thread.Sleep(Randomx.GetId(200));
Dispatcher.Invoke(new Action(() =>
{
imgSku.Source = bImg;
}));
});
}
private void btnAdd_Click(object sender, RoutedEventArgs e)
{
}
private void gridTitle_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
this.DragMove();
}
}
private void RadioButton_Click(object sender, RoutedEventArgs e)
{
if (this.IsLoaded && sender is RadioButton rb)
{
if (rb.DataContext is WXBuyMapSkusInfo skuInfo)
{
this.ViewModel.SetCurrentFrontSkuInfo3(skuInfo);
}
}
}
private void imgSku_MouseDown(object sender, MouseButtonEventArgs e)
{
ShowImgForm imgFrom = new ShowImgForm(this.OrderItem?.thumb_img);
imgFrom.TopMost = true;
imgFrom.Show();
}
private void imgSku_MouseEnter(object sender, MouseEventArgs e)
{
}
private void imgSku_MouseLeave(object sender, MouseEventArgs e)
{
}
}
}