终端一体化运控平台
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 

90 строки
2.8 KiB

  1. using BPASmartClient.Helper;
  2. using FryPot_DosingSystem.Model;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Text.RegularExpressions;
  8. using System.Threading.Tasks;
  9. using System.Windows;
  10. using System.Windows.Controls;
  11. using System.Windows.Data;
  12. using System.Windows.Documents;
  13. using System.Windows.Input;
  14. using System.Windows.Media;
  15. using System.Windows.Media.Imaging;
  16. using System.Windows.Shapes;
  17. namespace FryPot_DosingSystem.View
  18. {
  19. /// <summary>
  20. /// NewRecipeView.xaml 的交互逻辑
  21. /// </summary>
  22. public partial class NewRecipeView : Window
  23. {
  24. public NewRecipeView()
  25. {
  26. InitializeComponent();
  27. this.br.MouseLeftButtonDown += (o, e) => { if (e.LeftButton == MouseButtonState.Pressed) this.DragMove(); };
  28. ActionManage.GetInstance.CancelRegister("CloseNewRecipeView");
  29. ActionManage.GetInstance.Register(new Action(() => { this.Close();}), "CloseNewRecipeView");
  30. }
  31. private void Button_Click(object sender, RoutedEventArgs e)
  32. {
  33. this.Close();
  34. }
  35. private void ComboBox_KeyUp(object sender, KeyEventArgs e)
  36. {
  37. var res = sender as ComboBox;
  38. Json<MaterialNames>.Read();
  39. if (res.Text != null && res.Text != String.Empty)
  40. {
  41. var datas = Json<MaterialNames>.Data.Names.Where(s => s.Contains(res.Text.Trim()));
  42. // var datas = Json<MaterialNames>.Data.Names.ToList().FindAll(s => s.Contains(res.Text.Trim()));
  43. if (datas.Count() > 0)
  44. {
  45. res.ItemsSource = datas;
  46. res.IsDropDownOpen = true;
  47. }
  48. else
  49. {
  50. res.IsDropDownOpen = false;
  51. }
  52. }
  53. }
  54. private void ComboBox_LostFocus(object sender, RoutedEventArgs e)
  55. {
  56. var res = sender as ComboBox;
  57. if (res.Text != null && res.Text != String.Empty)
  58. {
  59. if (!MaterialNames.GetInstance.Names.Contains(res.Text.Trim()))//判断是否存在原料
  60. {
  61. MaterialNames.GetInstance.Names.Add(res.Text.Trim());
  62. Json<MaterialNames>.Data = MaterialNames.GetInstance;
  63. Json<MaterialNames>.Save();
  64. }
  65. }
  66. }
  67. private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
  68. {
  69. if (sender is TextBox txt)
  70. {
  71. if (new Regex("^[1-8]$").IsMatch(txt.Text))//全匹配
  72. {
  73. }
  74. else
  75. {
  76. txt.Text=string.Empty;
  77. }
  78. }
  79. }
  80. }
  81. }