| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312 |
- using ivf_tl_Entity.Entity.balance;
- using ivf_tl_Manage.ViewModels;
- using ivf_tl_Manage.Win;
- using System;
- using System.Collections.Generic;
- 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.Effects;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- namespace ivf_tl_Manage.UserControls
- {
- /// <summary>
- /// DeviceInfoUserControl.xaml 的交互逻辑
- /// </summary>
- public partial class DeviceInfoUserControl : UserControl
- {
- public event Action<long> EditClickEvent;
- public event Action<TLInfo> TlClickEvent;
- public event Action<TLInfo, House> HouseClickEvent;
- public event Action<string, string> HouseSettingClickEvent;
- public event Action<string, long> DelTLEvent;
- public event Action<TLInfo> HiddenTLEvent;
- public DeviceInfoUserControl()
- {
- InitializeComponent();
- }
- private void Del_Click(object sender, RoutedEventArgs e)
- {
- if (!this.IsLoaded) return;
- if (TlInfoSurce != null && TlInfoSurce.id > 0)
- {
- DelTLEvent?.Invoke(TlInfoSurce.tlName, TlInfoSurce.id);
- }
- e.Handled = true;
- }
- private void Edit_Click(object sender, RoutedEventArgs e)
- {
- if (!this.IsLoaded) return;
- if (TlInfoSurce != null && TlInfoSurce.id > 0)
- {
- EditClickEvent?.Invoke(TlInfoSurce.id);
- }
- e.Handled = true;
- }
- private void TLStateInfoUserControl_MouseDown(object sender, MouseButtonEventArgs e)
- {
- if (!this.IsLoaded) return;
- if (TlInfoSurce != null && TlInfoSurce.id > 0)
- {
- TlClickEvent?.Invoke(TlInfoSurce);
- }
- e.Handled = true;
- }
- private void HouseInfoUserControl_MouseDown(object sender, MouseButtonEventArgs e)
- {
- if (!(sender is HouseInfoUserControl source)) return;
- HouseClickEvent?.Invoke(TlInfoSurce, source.HouseSource);
- e.Handled = true;
- }
- private void HouseSetting_Click(object sender, RoutedEventArgs e)
- {
- if (TlInfoSurce != null && TlInfoSurce.id > 0) HouseSettingClickEvent?.Invoke(TlInfoSurce.tlSn, "setting");
- e.Handled = true;
- }
- private void DishRecord_Click(object sender, RoutedEventArgs e)
- {
- if (TlInfoSurce != null && TlInfoSurce.id > 0) HouseSettingClickEvent?.Invoke(TlInfoSurce.tlSn, "DishRecord");
- e.Handled = true;
- }
- private void TLAlarm_Click(object sender, RoutedEventArgs e)
- {
- if (TlInfoSurce != null && TlInfoSurce.id > 0) HouseSettingClickEvent?.Invoke(TlInfoSurce.tlSn, "TLAlarm");
- e.Handled = true;
- }
- private void HouesChart_Click(object sender, RoutedEventArgs e)
- {
- if (TlInfoSurce != null && TlInfoSurce.id > 0) HouseSettingClickEvent?.Invoke(TlInfoSurce.tlSn, "HouesChart");
- e.Handled = true;
- }
- /// <summary>
- /// 0离线 1在线 2解绑 3待初始化
- /// </summary>
- public TLInfo TlInfoSurce
- {
- get { return (TLInfo)GetValue(TlInfoSurceProperty); }
- set { SetValue(TlInfoSurceProperty, value); }
- }
- // Using a DependencyProperty as the backing store for TlInfoSurce. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty TlInfoSurceProperty =
- DependencyProperty.Register("TlInfoSurce", typeof(TLInfo), typeof(DeviceInfoUserControl), new PropertyMetadata(null, new PropertyChangedCallback(TlInfoSurcePropertyChangedCallback)));
- private static void TlInfoSurcePropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- if (!(d is DeviceInfoUserControl source)) return;
- if (e.NewValue != null && e.NewValue is TLInfo newTlInfo)
- {
- source.House1 = newTlInfo.houses.FirstOrDefault(x => x.houseSn == 1);
- source.House2 = newTlInfo.houses.FirstOrDefault(x => x.houseSn == 2);
- source.House3 = newTlInfo.houses.FirstOrDefault(x => x.houseSn == 3);
- source.House4 = newTlInfo.houses.FirstOrDefault(x => x.houseSn == 4);
- source.House5 = newTlInfo.houses.FirstOrDefault(x => x.houseSn == 5);
- source.House6 = newTlInfo.houses.FirstOrDefault(x => x.houseSn == 6);
- source.House7 = newTlInfo.houses.FirstOrDefault(x => x.houseSn == 7);
- source.House8 = newTlInfo.houses.FirstOrDefault(x => x.houseSn == 8);
- source.House9 = newTlInfo.houses.FirstOrDefault(x => x.houseSn == 9);
- source.House10 = newTlInfo.houses.FirstOrDefault(x => x.houseSn == 10);
- source.House11 = newTlInfo.houses.FirstOrDefault(x => x.houseSn == 11);
- }
- }
- public House House1
- {
- get { return (House)GetValue(House1Property); }
- set { SetValue(House1Property, value); }
- }
- // Using a DependencyProperty as the backing store for House1. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty House1Property =
- DependencyProperty.Register("House1", typeof(House), typeof(DeviceInfoUserControl), new PropertyMetadata(new House()));
- public House House2
- {
- get { return (House)GetValue(House2Property); }
- set { SetValue(House2Property, value); }
- }
- // Using a DependencyProperty as the backing store for House2. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty House2Property =
- DependencyProperty.Register("House2", typeof(House), typeof(DeviceInfoUserControl), new PropertyMetadata(new House()));
- public House House3
- {
- get { return (House)GetValue(House3Property); }
- set { SetValue(House3Property, value); }
- }
- // Using a DependencyProperty as the backing store for House3. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty House3Property =
- DependencyProperty.Register("House3", typeof(House), typeof(DeviceInfoUserControl), new PropertyMetadata(new House()));
- public House House4
- {
- get { return (House)GetValue(House4Property); }
- set { SetValue(House4Property, value); }
- }
- // Using a DependencyProperty as the backing store for House4. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty House4Property =
- DependencyProperty.Register("House4", typeof(House), typeof(DeviceInfoUserControl), new PropertyMetadata(new House()));
- public House House5
- {
- get { return (House)GetValue(House5Property); }
- set { SetValue(House5Property, value); }
- }
- // Using a DependencyProperty as the backing store for House5. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty House5Property =
- DependencyProperty.Register("House5", typeof(House), typeof(DeviceInfoUserControl), new PropertyMetadata(new House()));
- public House House6
- {
- get { return (House)GetValue(House6Property); }
- set { SetValue(House6Property, value); }
- }
- // Using a DependencyProperty as the backing store for House6. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty House6Property =
- DependencyProperty.Register("House6", typeof(House), typeof(DeviceInfoUserControl), new PropertyMetadata(new House()));
- public House House7
- {
- get { return (House)GetValue(House7Property); }
- set { SetValue(House7Property, value); }
- }
- // Using a DependencyProperty as the backing store for House7. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty House7Property =
- DependencyProperty.Register("House7", typeof(House), typeof(DeviceInfoUserControl), new PropertyMetadata(new House()));
- public House House8
- {
- get { return (House)GetValue(House8Property); }
- set { SetValue(House8Property, value); }
- }
- // Using a DependencyProperty as the backing store for House8. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty House8Property =
- DependencyProperty.Register("House8", typeof(House), typeof(DeviceInfoUserControl), new PropertyMetadata(new House()));
- public House House9
- {
- get { return (House)GetValue(House9Property); }
- set { SetValue(House9Property, value); }
- }
- // Using a DependencyProperty as the backing store for House9. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty House9Property =
- DependencyProperty.Register("House9", typeof(House), typeof(DeviceInfoUserControl), new PropertyMetadata(new House()));
- public House House10
- {
- get { return (House)GetValue(House10Property); }
- set { SetValue(House10Property, value); }
- }
- // Using a DependencyProperty as the backing store for House10. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty House10Property =
- DependencyProperty.Register("House10", typeof(House), typeof(DeviceInfoUserControl), new PropertyMetadata(new House()));
- public House House11
- {
- get { return (House)GetValue(House11Property); }
- set { SetValue(House11Property, value); }
- }
- // Using a DependencyProperty as the backing store for House11. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty House11Property =
- DependencyProperty.Register("House11", typeof(House), typeof(DeviceInfoUserControl), new PropertyMetadata(new House()));
- private void Hidden_Click(object sender, RoutedEventArgs e)
- {
- if (!this.IsLoaded) return;
- if (TlInfoSurce != null && TlInfoSurce.id > 0)
- {
- HiddenTLEvent?.Invoke(TlInfoSurce);
- }
- e.Handled = true;
- }
- public void SetisEn(int hou)
- {
- bool isen = false;
- switch (hou)
- {
- case 1:
- this.houseInfo1.IsEnabled = isen;
- break;
- case 2:
- this.houseInfo2.IsEnabled = isen;
- break;
- case 3:
- this.houseInfo3.IsEnabled = isen;
- break;
- case 4:
- this.houseInfo4.IsEnabled = isen;
- break;
- case 5:
- this.houseInfo5.IsEnabled = isen;
- break;
- case 6:
- this.houseInfo6.IsEnabled = isen;
- break;
- case 7:
- this.houseInfo7.IsEnabled = isen;
- break;
- case 8:
- this.houseInfo8.IsEnabled = isen;
- break;
- case 9:
- this.houseInfo9.IsEnabled = isen;
- break;
- case 10:
- this.houseInfo10.IsEnabled = isen;
- break;
- }
- }
- }
- }
|