using MegaRobo.C00225155.Entities.Entity_DB;
using MegaRobo.C00225155App.MenuViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Telerik.Windows.Controls;

namespace MegaRobo.C00225155App.MenuViews
{
    /// <summary>
    /// AdditivePipetteConfigView.xaml 的交互逻辑
    /// </summary>
    public partial class AdditivePipetteConfigView : UserControl
    {
        //private Dictionary<object, string> _originalSuckCmdCodes = new Dictionary<object, string>();

        public AdditivePipetteConfigView()
        {
            InitializeComponent();
        }

        //private void TaskGridView_BeginningEdit(object sender, Telerik.Windows.Controls.GridViewBeginningEditRoutedEventArgs e)
        //{
        //    var bindingPath = (e.Cell.Column as GridViewDataColumn)?.DataMemberBinding?.Path.Path;
        //    if (e.Cell.Column.Header.ToString() == "吸液模式" || bindingPath == "SuckCmdCode")
        //    {
        //        // 获取当前行数据（Liquid5mlProduct 实例）
        //        var editedProduct = e.Cell.DataContext as Liquid5mlProduct;
        //        if (editedProduct != null)
        //        {
        //            _originalSuckCmdCodes.Add(editedProduct, editedProduct.SuckCmdCode);
        //        }
        //    }
        //}

        //private void TaskGridView_CellEditEnded(object sender, Telerik.Windows.Controls.GridViewCellEditEndedEventArgs e)
        //{
        //    var bindingPath = (e.Cell.Column as GridViewDataColumn)?.DataMemberBinding?.Path.Path;
        //    if (e.Cell.Column.Header.ToString() == "吸液模式" || bindingPath == "SuckCmdCode")
        //    {
        //        // 2. 获取当前编辑的行数据（即 Liquid5mlProduct 实例）
        //        var editedProduct = e.Cell.DataContext as Liquid5mlProduct;
        //        if (editedProduct != null)
        //        {
        //            if (_originalSuckCmdCodes.TryGetValue(editedProduct, out string originalValue))
        //            {
        //                // 4. 对比新旧值：只有不同时才执行清空操作
        //                if (editedProduct.SuckCmdCode != originalValue)
        //                {
        //                    editedProduct.SuckParamJson = ""; // 清空参数

        //                    // （可选）同步到 ViewModel 的 SelectedProduct
        //                    var viewModel = this.DataContext as AdditivePipetteConfigViewModel;
        //                    if (viewModel?.SelectedProduct == editedProduct)
        //                    {
        //                        viewModel.SelectedProduct = editedProduct; // 触发属性通知
        //                    }
        //                }

        //                // 移除已处理的原始值（避免内存占用）
        //                _originalSuckCmdCodes.Remove(editedProduct);
        //            }
        //        }
        //    }
        //}
       
    }
}
