using BPASmartClient.Helper;
using FryPot_DosingSystem.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
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;
namespace FryPot_DosingSystem.View
{
///
/// NewRecipeView.xaml 的交互逻辑
///
public partial class NewRecipeView : Window
{
public NewRecipeView()
{
InitializeComponent();
this.br.MouseLeftButtonDown += (o, e) => { if (e.LeftButton == MouseButtonState.Pressed) this.DragMove(); };
ActionManage.GetInstance.CancelRegister("CloseNewRecipeView");
ActionManage.GetInstance.Register(new Action(() => { this.Close();}), "CloseNewRecipeView");
}
private void Button_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
private void ComboBox_KeyUp(object sender, KeyEventArgs e)
{
var res = sender as ComboBox;
Json.Read();
if (res.Text != null && res.Text != String.Empty)
{
var datas = Json.Data.Names.Where(s => s.Contains(res.Text.Trim()));
// var datas = Json.Data.Names.ToList().FindAll(s => s.Contains(res.Text.Trim()));
if (datas.Count() > 0)
{
res.ItemsSource = datas;
res.IsDropDownOpen = true;
}
else
{
res.IsDropDownOpen = false;
}
}
}
private void ComboBox_LostFocus(object sender, RoutedEventArgs e)
{
var res = sender as ComboBox;
if (res.Text != null && res.Text != String.Empty)
{
if (!MaterialNames.GetInstance.Names.Contains(res.Text.Trim()))//判断是否存在原料
{
MaterialNames.GetInstance.Names.Add(res.Text.Trim());
Json.Data = MaterialNames.GetInstance;
Json.Save();
}
}
}
private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
{
if (sender is TextBox txt)
{
if (new Regex("^[1-8]$").IsMatch(txt.Text))//全匹配
{
}
else
{
txt.Text=string.Empty;
}
}
}
}
}