using System.Linq; using System.Windows; using System.Windows.Controls; using System.Collections.Generic; using SHJX.Service.Common.ReadXML; using SHJX.Service.Librarys.setting; using SHJX.Service.Model.Global; using SHJX.Service.ModelView; using SHJX.Service.Model.Dao; using System.Collections.ObjectModel; using SHJX.Service.Dao; namespace SHJX.Service.View.View { /// /// SettingForm.xaml 的交互逻辑 /// public partial class SettingForm : Window { private Dictionary _userControl; public readonly MainViewModel Maincontroller; /// /// 配置文件读取 /// private readonly ReadConfigUtil _config; private SettingViewModel _settingView; List waves; public SettingForm() { InitForm(); } public SettingForm(MainViewModel controllor,ReadConfigUtil config) { Maincontroller = controllor; _config = config; InitForm(); } private void InitForm() { Owner = Application.Current.MainWindow; _settingView = new SettingViewModel(_config); DataContext = _settingView; //waves = Maincontroller.Maincontroller.DataManager.GetWavekeys(); //if (waves.Any()) //{ // Wavekeys = new ObservableCollection((from wave in waves select wave.WaveKey).ToList()); //} InitializeComponent(); _userControl = new Dictionary() { {"加热相关", new HeatControl(_settingView)}, {"设备相关", new LiquidControl(_settingView)}, {"手动校准", new ManualControl(_settingView,_config)}, {"其他设置", new OtherControl(_settingView)} }; if (CurrentUser.UserName.ToUpper().Equals("ADMIN")) { _userControl.Add("滴定相关", new TitrationControl(_settingView)); } foreach (var item in _userControl.Keys) { TabItem tab = new TabItem { Header = item }; Menu.Items.Add(tab); } Menu.SelectedItem = Menu.Items[0]; } private void Menu_SelectionChanged(object sender, SelectionChangedEventArgs e) { var ibs = (sender as TabControl)?.SelectedItem as TabItem; StackPanelMain.Children.Clear(); StackPanelMain.Children.Add(_userControl.FirstOrDefault(item => item.Key.Equals(ibs?.Header)).Value); } private void Cancel_Click(object sender, RoutedEventArgs e) { Close(); } private void btn_setting_close_Click(object sender, RoutedEventArgs e) { Close(); } private void SettingTag_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { DragMove(); } } }