| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- 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
- {
- /// <summary>
- /// SettingForm.xaml 的交互逻辑
- /// </summary>
- public partial class SettingForm : Window
- {
- private Dictionary<string, UserControl> _userControl;
- public readonly MainViewModel Maincontroller;
- /// <summary>
- /// 配置文件读取
- /// </summary>
- private readonly ReadConfigUtil _config;
- private SettingViewModel _settingView;
- List<Wavekey> 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<string>((from wave in waves select wave.WaveKey).ToList());
- //}
- InitializeComponent();
- _userControl = new Dictionary<string, UserControl>()
- {
- {"加热相关", 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();
- }
- }
- }
|