using BPASmart.Model; using BPASmart.VariableManager.ViewModels; using BPA.Helper; 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; namespace BPASmart.VariableManager.Views { /// /// VariableConfig.xaml 的交互逻辑 /// public partial class VariableConfig : UserControl { public VariableConfig() { InitializeComponent(); this.IsVisibleChanged += VariableConfig_IsVisibleChanged; this.Unloaded += VariableConfig_Unloaded; } private void VariableConfig_Unloaded(object sender, RoutedEventArgs e) { Json.Save(FileConfigModel.VarConfigPath); } private void VariableConfig_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) { var obj = (VariableConfig)sender; if (!obj.IsVisible) { DelegationNotifi.GetInstance.VariableSave?.Invoke(); DelegationNotifi.GetInstance.VariableSave = null; DelegationNotifi.GetInstance.VarNameChanged = null; } else { this.DataContext = new VariableConfigViewModel(this.Name); } } private void TabGrid_SizeChanged(object sender, SizeChangedEventArgs e) { var res = TabGrid.ColumnDefinitions; if (res != null && res.Count >= 3) { object[] widths = new object[] { 0, 0 }; widths[0] = res.ElementAt(1).ActualWidth; widths[1] = res.ElementAt(2).ActualWidth; ActionManage.GetInstance.Send("TabGridSizeChanged", widths); } } private void TextBox_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; } } } } }