EndPointDlg.xaml.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. using MECF.Framework.Common.CommonData;
  16. using CyberX8_Core;
  17. namespace CyberX8_MainPages.Views
  18. {
  19. /// <summary>
  20. /// Interaction logic for RecipeNameInputDlg.xaml
  21. /// </summary>
  22. public partial class EndPointDlg : Window
  23. {
  24. public EndPointConfigItem ConfigItem
  25. {
  26. get;
  27. set;
  28. }
  29. public class AlogarithmTypeItem
  30. {
  31. public string AlogarithmName { get; set; }
  32. }
  33. public List<AlogarithmTypeItem> AlgorithmTypes { get; set; }
  34. public string SelectedConfig { get; set; }
  35. private Recipe currentRecipe;
  36. private int? stepno ;
  37. public EndPointDlg(string para, EndPointConfigItem endPointConfigItem,Recipe recipe)
  38. {
  39. InitializeComponent();
  40. string[] paras = para.Split('.');
  41. if (paras.Length == 2)
  42. {
  43. this.Title = $"RecipeName:{paras[0]},StepNo:{paras[1].ToString()}";
  44. stepno = Convert.ToInt32(paras[1])-1;
  45. }
  46. else
  47. {
  48. this.Title = "Error";
  49. }
  50. AlgorithmTypes = new List<AlogarithmTypeItem>()
  51. {
  52. new AlogarithmTypeItem() { AlogarithmName = "Unknown"},
  53. new AlogarithmTypeItem() { AlogarithmName = "Above_ABS_Value"},
  54. new AlogarithmTypeItem() { AlogarithmName = "Below_ABS_Value"},
  55. new AlogarithmTypeItem() { AlogarithmName = "Drop_Percent"},
  56. new AlogarithmTypeItem() { AlogarithmName = "Up_Percent"},
  57. new AlogarithmTypeItem() { AlogarithmName = "Range_In"},
  58. new AlogarithmTypeItem() { AlogarithmName = "Gradient"},
  59. new AlogarithmTypeItem() { AlogarithmName = "Peek"},
  60. new AlogarithmTypeItem() { AlogarithmName = "Valley"},
  61. new AlogarithmTypeItem() { AlogarithmName = "Min_Drop_Percent"},
  62. new AlogarithmTypeItem() { AlogarithmName = "Min_Up_Percent"},
  63. new AlogarithmTypeItem() { AlogarithmName = "Max_Drop_Percent"},
  64. new AlogarithmTypeItem() { AlogarithmName = "Max_Up_Percent"},
  65. new AlogarithmTypeItem() { AlogarithmName = "Rise_Fall"},
  66. new AlogarithmTypeItem() { AlogarithmName = "Fall_Rise"},
  67. };
  68. Loaded += new RoutedEventHandler(EndPointDlg_Loaded);
  69. SelectedConfig = "BelowValue3";
  70. ConfigItem = endPointConfigItem;
  71. currentRecipe = recipe;
  72. }
  73. void EndPointDlg_Loaded(object sender, RoutedEventArgs e)
  74. {
  75. DataContext = ConfigItem;
  76. }
  77. private void buttonCancel_Click(object sender, RoutedEventArgs e)
  78. {
  79. this.DialogResult = false;
  80. }
  81. private void buttonOK_Click(object sender, RoutedEventArgs e)
  82. {
  83. if (stepno != null)
  84. {
  85. currentRecipe.Steps[(int)stepno].EPDConfig = ConfigItem.ToValue();
  86. this.DialogResult = true;
  87. }
  88. }
  89. private void TextBoxEx_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
  90. {
  91. //if (sender is TextBox txt)
  92. //{
  93. // var regionList = new List<string> { "A", "B", "C", "D"};
  94. // var input = new ExpressionWindow(txt, regionList);
  95. // input.Show();
  96. //}
  97. }
  98. private void TextBoxEx_TextChanged(object sender, TextChangedEventArgs e)
  99. {
  100. //if (sender is TextBox txt)
  101. //{
  102. // var regionList = new List<string> { "A", "B", "C", "D" };
  103. // var res = ExpressionWindow.TransExpression(txt.Text, regionList);
  104. // txt.Foreground = res ? Brushes.Black : Brushes.Red;
  105. //}
  106. }
  107. }
  108. }