2025年9月

    void SortRecipeFolder<T>(IEnumerable<T> source, string sortName, ListSortDirection direction)
    {
        var collectionView = CollectionViewSource.GetDefaultView(source);
        if (source is List<RemoteRecipeFolder> wafer)
        {
            collectionView.Filter = (x) =>
            {
                var casted = x as RemoteRecipeFolder;
                return casted != null && casted.WaferId.Contains(SearchText, StringComparison.OrdinalIgnoreCase);
            };
        }
        // 清除旧的排序
        collectionView.SortDescriptions.Clear();
        // 按 Age 升序排序
        collectionView.SortDescriptions.Add(new SortDescription(sortName, direction));
        // 如果需要,强制刷新
        collectionView.Refresh();
    }

using System.Drawing;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;

using (var bitmap = new Bitmap(4, 2, PixelFormat.Format8bppIndexed))
{

//bitmap.Palette.Entries[0] = Color.Red;
//bitmap.Palette.Entries[1] = Color.Black;
var data = bitmap.LockBits(new Rectangle(0, 0, 4, 2), ImageLockMode.WriteOnly, PixelFormat.Format8bppIndexed);
var bytes = new byte[] { 1, 1, 1, 1, 2, 3, 2, 4 };
// 复制数据到位图
Marshal.Copy(bytes, 0, data.Scan0, bytes.Length);
// 解锁位图
bitmap.UnlockBits(data);
bitmap.Save("D:/output.bmp", ImageFormat.Bmp);

}