using CommunityToolkit.Mvvm.Input;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
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.Shapes;
using Telerik.Windows.Controls.Data.PropertyGrid;

namespace MegaRobo.C00224159App
{
    /// <summary>
    /// TipBottleTypeWindow.xaml 的交互逻辑
    /// </summary>
    public partial class TipBottleTypeWindow : Window, INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler? PropertyChanged;

        // 核心方法：触发属性变更通知
        protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null!)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }

        // 封装属性赋值逻辑
        protected bool SetProperty<T>(ref T storage, T value, [CallerMemberName] string propertyName = null!)
        {
            if (EqualityComparer<T>.Default.Equals(storage, value))
                return false;

            storage = value;
            OnPropertyChanged(propertyName);
            return true;
        }

        private string tipcontent = "50mL样品瓶";
        public string TipContent
        {
            get => tipcontent;
            set => SetProperty(ref tipcontent, value);
        }

        public ICommand OKCancelCommand { get; set; }


        public TipBottleTypeWindow()
        {
            InitializeComponent();
            DataContext = this;
            OKCancelCommand = new RelayCommand<string>(OKCancelControl);
        }
      
        private void OKCancelControl(string parameter)
        {
            if (parameter.Equals("OK"))
            {
                DialogResult = true; // 对应 OK
            }
            else if (parameter.Equals("Cancel"))
            {
                DialogResult = false; // 对应 Cancel
            }
        }
    }
}
