EndPointDlg.xaml.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. using System.Windows.Data;
  8. using System.Windows.Documents;
  9. using System.Windows.Input;
  10. using System.Windows.Media;
  11. using System.Windows.Media.Imaging;
  12. using System.Windows.Shapes;
  13. using System.Text.RegularExpressions;
  14. using EPDViewerLib;
  15. namespace Aitex.UI.RecipeEditor.View
  16. {
  17. /// <summary>
  18. /// Interaction logic for RecipeNameInputDlg.xaml
  19. /// </summary>
  20. public partial class EndPointDlg : Window
  21. {
  22. public EndPointConfigItem ConfigItem
  23. {
  24. get;
  25. set;
  26. }
  27. public class AlogarithmTypeItem
  28. {
  29. public string AlogarithmName { get; set; }
  30. }
  31. public List<AlogarithmTypeItem> AlgorithmTypes { get; set; }
  32. public string SelectedConfig { get; set; }
  33. public EndPointDlg( )
  34. {
  35. InitializeComponent();
  36. AlgorithmTypes = new List<AlogarithmTypeItem>()
  37. {
  38. new AlogarithmTypeItem() { AlogarithmName = "Unknown"},
  39. new AlogarithmTypeItem() { AlogarithmName = "Above_ABS_Value"},
  40. new AlogarithmTypeItem() { AlogarithmName = "Below_ABS_Value"},
  41. new AlogarithmTypeItem() { AlogarithmName = "Drop_Percent"},
  42. new AlogarithmTypeItem() { AlogarithmName = "Up_Percent"},
  43. new AlogarithmTypeItem() { AlogarithmName = "Range_In"},
  44. new AlogarithmTypeItem() { AlogarithmName = "Gradient"},
  45. new AlogarithmTypeItem() { AlogarithmName = "Peek"},
  46. new AlogarithmTypeItem() { AlogarithmName = "Valley"},
  47. new AlogarithmTypeItem() { AlogarithmName = "Min_Drop_Percent"},
  48. new AlogarithmTypeItem() { AlogarithmName = "Min_Up_Percent"},
  49. new AlogarithmTypeItem() { AlogarithmName = "Max_Drop_Percent"},
  50. new AlogarithmTypeItem() { AlogarithmName = "Max_Up_Percent"},
  51. new AlogarithmTypeItem() { AlogarithmName = "Rise_Fall"},
  52. new AlogarithmTypeItem() { AlogarithmName = "Fall_Rise"},
  53. };
  54. Loaded += new RoutedEventHandler(EndPointDlg_Loaded);
  55. SelectedConfig = "BelowValue3";
  56. }
  57. void EndPointDlg_Loaded(object sender, RoutedEventArgs e)
  58. {
  59. DataContext = ConfigItem;
  60. }
  61. private void buttonCancel_Click(object sender, RoutedEventArgs e)
  62. {
  63. this.DialogResult = false;
  64. }
  65. private void buttonOK_Click(object sender, RoutedEventArgs e)
  66. {
  67. this.DialogResult = true;
  68. }
  69. private void TextBoxEx_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
  70. {
  71. if (sender is TextBox txt)
  72. {
  73. var regionList = new List<string> { "A", "B", "C", "D"};
  74. var input = new ExpressionWindow(txt, regionList);
  75. input.Show();
  76. }
  77. }
  78. private void TextBoxEx_TextChanged(object sender, TextChangedEventArgs e)
  79. {
  80. if (sender is TextBox txt)
  81. {
  82. var regionList = new List<string> { "A", "B", "C", "D" };
  83. var res = ExpressionWindow.TransExpression(txt.Text, regionList);
  84. txt.Foreground = res ? Brushes.Black : Brushes.Red;
  85. }
  86. }
  87. }
  88. }