diff --git a/Main.Test/App.xaml b/Main.Test/App.xaml index e9613f0..da88b92 100644 --- a/Main.Test/App.xaml +++ b/Main.Test/App.xaml @@ -11,7 +11,7 @@ - + diff --git a/Main.Test/DemoData.cs b/Main.Test/DemoData.cs new file mode 100644 index 0000000..6749173 --- /dev/null +++ b/Main.Test/DemoData.cs @@ -0,0 +1,78 @@ +using System.Globalization; +using System.Windows; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using Prism.Mvvm; + +namespace Main.Test; + +public class ItemInfo : BindableBase +{ + public int Code { get; init; } + public string Name { get; init; } = ""; + public string Value => Price.ToString("N2", CultureInfo.CurrentCulture); + public decimal Price { get; init; } + public int Qty { get; init; } + public string Sku { get; init; } = ""; + public string Shop { get; init; } = ""; + public string Buyer { get; init; } = ""; + public string Address { get; init; } = ""; + public string Remark { get; init; } = ""; + public DateTime CreatedAt { get; init; } + public ImageSource Thumbnail { get; init; } = null!; + public string? ThumbnailUrl { get; init; } + private string status = "待处理"; + public string Status { get => status; set => SetProperty(ref status, value); } +} + +internal static class DemoData +{ + // 冻结并共享小尺寸位图,滚动不触发网络请求或重复解码。 + private static readonly ImageSource[] Thumbnails = CreateThumbnails(); + + public static List Create(int count, int networkImageSize = 0) + { + string[] names = ["轻量通勤双肩包", "纯棉宽松短袖", "旅行收纳组合", "便携保温水杯", "无线办公鼠标", "桌面收纳置物盒", "运动休闲鞋", "折叠防晒遮阳伞"]; + string[] shops = ["城市生活旗舰店", "优选数码专营店", "日常好物集合店", "远行户外用品店"]; + var random = new Random(20261022); + var session = Guid.NewGuid().ToString("N"); + var result = new List(count); + for (var i = 0; i < count; i++) + result.Add(new ItemInfo + { + Code = 100000 + i, Name = names[i % names.Length] + " · 秋季新品 / 品质款", + Price = random.Next(1900, 69900) / 100m, Qty = random.Next(1, 100), + Sku = $"SKU-{i:000000} / {(i % 2 == 0 ? "雾蓝" : "米白")} / 标准款", + Shop = shops[i % shops.Length], Buyer = $"买家{i:00000}", + Address = $"浙江省杭州市西湖区 文一路 {i % 300 + 1} 号 · 联系尾号 {i % 10000:0000}", + Remark = i % 3 == 0 ? "请核对规格,周末可收货;外包装请加固。" : "常规发货 / 已核对收货信息", + CreatedAt = new DateTime(2026, 10, 22, 12, 0, 0).AddMinutes(-i), + Status = new[] { "待处理", "已确认", "待发货", "已完成" }[i % 4], + Thumbnail = Thumbnails[i % Thumbnails.Length], + ThumbnailUrl = networkImageSize == 0 ? null : $"https://picsum.photos/seed/{session}-{i}/{networkImageSize}/{networkImageSize}" + }); + return result; + } + + private static ImageSource[] CreateThumbnails() + { + var images = new ImageSource[16]; + for (var i = 0; i < images.Length; i++) + { + var visual = new DrawingVisual(); + using (var dc = visual.RenderOpen()) + { + var color = Color.FromRgb((byte)(55 + i * 11), (byte)(100 + i * 6), (byte)(165 - i * 4)); + dc.DrawRoundedRectangle(new SolidColorBrush(Color.FromRgb(241, 245, 249)), null, new Rect(0, 0, 72, 72), 8, 8); + var brush = new SolidColorBrush(color); + var pen = new Pen(brush, 4); + dc.DrawRoundedRectangle(null, pen, new Rect(25, 12, 22, 24), 10, 10); + dc.DrawRoundedRectangle(brush, null, new Rect(14, 26, 44, 36), 6, 6); + dc.DrawLine(new Pen(Brushes.White, 2), new Point(24, 44), new Point(48, 44)); + } + var bitmap = new RenderTargetBitmap(72, 72, 96, 96, PixelFormats.Pbgra32); + bitmap.Render(visual); bitmap.Freeze(); images[i] = bitmap; + } + return images; + } +} diff --git a/Main.Test/MainWindow.xaml b/Main.Test/MainWindow.xaml index 95d6a83..b17e2c0 100644 --- a/Main.Test/MainWindow.xaml +++ b/Main.Test/MainWindow.xaml @@ -3,59 +3,273 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:hc="https://handyorg.github.io/handycontrol" xmlns:local="clr-namespace:Main.Test" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:tf="Trade.Framework" - xmlns:views="clr-namespace:Main.Test.Views" xmlns:vm="clr-namespace:Main.Test.ViewModels" - Title="MainWindow" - Width="800" - Height="450" + Title="复杂表格 · 运行测试" + Width="1380" + Height="820" + MinWidth="900" + MinHeight="500" DataContext="{tf:DISource Type=vm:MainViewModel}" - ResizeMode="CanResizeWithGrip" WindowStartupLocation="CenterScreen" mc:Ignorable="d"> - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + +