using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
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.Navigation;
using System.Windows.Shapes;
using HBLConsole.Service;

namespace HBLConsole.View
{
    /// <summary>
    /// VariableConfig.xaml 的交互逻辑
    /// </summary>
    public partial class VariableConfig : UserControl
    {
        public VariableConfig()
        {
            InitializeComponent();
            this.IsVisibleChanged += VariableConfig_IsVisibleChanged;
        }

        private void VariableConfig_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            var obj = (VariableConfig)sender;
            if (!obj.IsVisible)
            {
                ActionOperate.GetInstance.Send("VariableSave");
            }
        }

        private void Grid_KeyDown(object sender, KeyEventArgs e)
        {
            var uie = e.OriginalSource as TextBox;
            if (uie != null)
            {
                if (e.Key == Key.Enter)
                {
                    uie.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
                    e.Handled = true;
                }
            }

        }
    }
}
