using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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 EPDViewerLib;
namespace Aitex.UI.RecipeEditor.View
{
    /// 
    /// Interaction logic for RecipeNameInputDlg.xaml
    /// 
    public partial class EndPointDlg : Window
    {
        //public EndPointConfigItem ConfigItem
        //{
        //    get;
        //    set;
        //}
        public class AlogarithmTypeItem
        {
            public string AlogarithmName { get; set; }
        }
        public List AlgorithmTypes { get; set; }
        public string SelectedConfig { get; set; }
        public EndPointDlg( )
        {
            InitializeComponent();
            AlgorithmTypes = new List()
            {
                new AlogarithmTypeItem() { AlogarithmName = "Unknown"},
                new AlogarithmTypeItem() { AlogarithmName = "Above_ABS_Value"},
                new AlogarithmTypeItem() { AlogarithmName = "Below_ABS_Value"},
                new AlogarithmTypeItem() { AlogarithmName = "Drop_Percent"},
                new AlogarithmTypeItem() { AlogarithmName = "Up_Percent"},
                new AlogarithmTypeItem() { AlogarithmName = "Range_In"},
                new AlogarithmTypeItem() { AlogarithmName = "Gradient"},
                new AlogarithmTypeItem() { AlogarithmName = "Peek"},
                new AlogarithmTypeItem() { AlogarithmName = "Valley"},
                new AlogarithmTypeItem() { AlogarithmName = "Min_Drop_Percent"},
                new AlogarithmTypeItem() { AlogarithmName = "Min_Up_Percent"},
                new AlogarithmTypeItem() { AlogarithmName = "Max_Drop_Percent"},
                new AlogarithmTypeItem() { AlogarithmName = "Max_Up_Percent"},
                new AlogarithmTypeItem() { AlogarithmName = "Rise_Fall"},
                new AlogarithmTypeItem() { AlogarithmName = "Fall_Rise"},
            };
            //Loaded += new RoutedEventHandler(EndPointDlg_Loaded);
            SelectedConfig = "BelowValue3";
        }
        //void EndPointDlg_Loaded(object sender, RoutedEventArgs e)
        //{
        //    DataContext = ConfigItem;
        //}
        private void buttonCancel_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }
        private void buttonOK_Click(object sender, RoutedEventArgs e)
        {            
            this.DialogResult = true;
        }
        private void TextBoxEx_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (sender is TextBox txt)
            {
                var regionList = new List { "A", "B", "C", "D"};
                var input = new ExpressionWindow(txt, regionList);
                input.Show();
            }
        }
        private void TextBoxEx_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (sender is TextBox txt)
            {
                var regionList = new List { "A", "B", "C", "D" };
                var res = ExpressionWindow.TransExpression(txt.Text, regionList);
                txt.Foreground = res ? Brushes.Black : Brushes.Red;
            }
        }
    }
}