using BBWY.Client.Models;
using BBWY.Controls;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
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;

namespace BBWY.Client.Views.SealBox
{
    /// <summary>
    /// SplitOtherWareWindow.xaml 的交互逻辑
    /// </summary>
    public partial class SplitOtherWareWindow : BWindow
    {
        public SplitOtherWareWindow(int waitCount, WareType wareType, Action<int, WareType> SplitWare)
        {
           this. SplitWare = SplitWare;
            WaitCount = waitCount;
            WareTypeList.Remove(wareType);//移除当前落仓
            InitializeComponent();
            this.DataContext = this;
        }
       private Action<int, WareType> SplitWare { get;set;}
        private int waitCount;
        public int WaitCount { get => waitCount; set { Set(ref waitCount, value); } }

        private int count;
        public int Count { get => count; set { Set(ref count, value); } }

        private WareType selectWareType;
        public WareType SelectWareType { get => selectWareType; set { Set(ref selectWareType, value); } }
        

        private ObservableCollection<WareType> wareTypeList=new ObservableCollection<WareType> { 
         WareType.京仓, WareType.云仓, WareType.商家仓, WareType.聚水潭
        };
        public ObservableCollection<WareType> WareTypeList { get => wareTypeList; set { Set(ref wareTypeList, value); } }

        private void BButton_Click(object sender, RoutedEventArgs e)
        {
            if (WaitCount< Count)
            {
                MessageBox.Show("可分配量不足!");
                return;
            }
            if (SplitWare != null) SplitWare(Count, SelectWareType);

            this.Close();
        }

        private void BButton_Click_1(object sender, RoutedEventArgs e)
        {
            Count = WaitCount;
        }
    }
}