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
{
///
/// DeviceInfoUserControl.xaml 的交互逻辑
///
public partial class DeviceInfoUserControl : UserControl
{
public event Action EditClickEvent;
public event Action TlClickEvent;
public event Action HouseClickEvent;
public event Action HouseSettingClickEvent;
public event Action DelTLEvent;
public event Action 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;
}
///
/// 0离线 1在线 2解绑 3待初始化
///
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;
}
}
}
}