using Ping9719.WpfEx;
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.Shapes;
using System.Text.RegularExpressions;
using 智慧物流软件系统.ViewModel;

namespace 智慧物流软件系统
{
    public partial class StockTakingView : UserControlBase
    {
        public static StocktakingViewModel viewModel = new StocktakingViewModel();
        public StockTakingView()
        {
            InitializeComponent();
            this.DataContext = viewModel;
        }

        private void DataGrid_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
        {
            try
            {
                var viewModel = this.DataContext as InInventoryViewModel;
                DataGrid datagrid = sender as DataGrid;
                var index = datagrid.SelectedIndex;
                if (index >= 0)
                {

                }
                datagrid.UnselectAllCells();
            }
            catch
            {

            }
        }

        private void ListView_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
        {
            if (!e.Handled)
            {
                // ListView拦截鼠标滚轮事件
                e.Handled = true;

                // 激发一个鼠标滚轮事件，冒泡给外层ListView接收到
                var eventArg = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta);
                eventArg.RoutedEvent = UIElement.MouseWheelEvent;
                eventArg.Source = sender;
                var parent = ((Control)sender).Parent as UIElement;
                parent.RaiseEvent(eventArg);
            }
        }

        private void TextBlock_MouseDown(object sender, MouseButtonEventArgs e)
        {
            viewModel.RefreshStockTakingOrderList(viewModel.SelectedOutOrderNumber);
        }

        private void UserControlBase_LoadedVisible(object sender, EventArgs e)
        {
            viewModel.RefreshStockTakingOrderList();
        }
    }
}
