using FLY.IBC.Client;
using FLY.IBC.IService;
using FObjBase;
using MultiLayout.UiModule;
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.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;
using Unity;
namespace FLY.IBC.UI.Client.UiModule
{
///
/// Page_Main.xaml 的交互逻辑
///
public partial class MainPanel2 : UserControl
{
IUnityContainer container;
IIbcSystemService ibcSystemService;
FLY.OBJComponents.Client.SetPLCUpdatePlan setPlan;
public MainPanel2()
{
InitializeComponent();
}
[InjectionMethod]
public void Init(
IUnityContainer container,
IIbcSystemService ibcSystemService)
{
this.container = container;
this.ibcSystemService = ibcSystemService;
grid_ibc.DataContext = ibcSystemService.Item;
string objname = nameof(IIbcSystemService.Item);
setPlan = new FLY.OBJComponents.Client.SetPLCUpdatePlan(
ibcSystemService.PLCos,
objname,
new string[] {
nameof(IBC.Common.IBCData.IsIBCAuto),
nameof(IBC.Common.IBCData.FilmWidth),
nameof(IBC.Common.IBCData.FilmWidthSet),
nameof(IBC.Common.IBCData.IsFilmWidthChanged),
nameof(IBC.Common.IBCData.ErrorCorrection),
nameof(IBC.Common.IBCData.IsInletAirOn),
nameof(IBC.Common.IBCData.InletAirFreq),
nameof(IBC.Common.IBCData.InletAirFreqSet),
nameof(IBC.Common.IBCData.IsOutletAirOn),
nameof(IBC.Common.IBCData.OutletAirFreq),
nameof(IBC.Common.IBCData.OutletAirFreqSet),
nameof(IBC.Common.IBCData.IsOutletAirFreqChanged),
nameof(IBC.Common.IBCData.IsExAirOn),
nameof(IBC.Common.IBCData.ExAirFreq),
nameof(IBC.Common.IBCData.ExAirFreqSet)
});
container.BuildUp(ibcCtrlGraph);
ibcSystemService.Item.PropertyChanged += Item_PropertyChanged;
}
public void SetMode2()
{
exAirName.Text = "下风";
}
private async void Item_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if ((ibcSystemService is IbcSystemServiceClient) && ((ibcSystemService as IbcSystemServiceClient).IsInPushValue))
return;
if (e.PropertyName == nameof(IBC.Common.IBCData.FilmWidthSet))
{
await Task.Delay(1000);//1s后触发通知
//ibcSystemService.Item.IsFilmWidthChanged = false;
ibcSystemService.Item.IsFilmWidthChanged = true;
}
else if (e.PropertyName == nameof(IBC.Common.IBCData.OutletAirFreqSet))
{
await Task.Delay(1000);//1s后触发通知
//ibcSystemService.Item.IsOutletAirFreqChanged = false;
ibcSystemService.Item.IsOutletAirFreqChanged = true;
}
}
private void button_inletAir_plus_Click(object sender, RoutedEventArgs e)
{
if (ibcSystemService.Item.InletAirFreqSet < 49)
ibcSystemService.Item.InletAirFreqSet += 1f;
}
private void button_inletAir_minus_Click(object sender, RoutedEventArgs e)
{
if(ibcSystemService.Item.InletAirFreqSet>1)
ibcSystemService.Item.InletAirFreqSet -= 1f;
}
private void button_outletAir_plus_Click(object sender, RoutedEventArgs e)
{
if (ibcSystemService.Item.OutletAirFreqSet < 49)
ibcSystemService.Item.OutletAirFreqSet += 1f;
}
private void button_outletAir_minus_Click(object sender, RoutedEventArgs e)
{
if(ibcSystemService.Item.OutletAirFreqSet>1)
ibcSystemService.Item.OutletAirFreqSet -= 1f;
}
private void button_k123_Click(object sender, RoutedEventArgs e)
{
WdK123 w = new WdK123();
container.BuildUp(w);
w.Owner = FLY.ControlLibrary.COMMON.GetWindow(this);
w.ShowDialog();
}
private void btnExAirPlusClick(object sender, RoutedEventArgs e)
{
if (ibcSystemService.Item.ExAirFreqSet < 49)
ibcSystemService.Item.ExAirFreqSet += 1f;
}
private void btnExAirMinusClick(object sender, RoutedEventArgs e)
{
if (ibcSystemService.Item.ExAirFreqSet > 1)
ibcSystemService.Item.ExAirFreqSet -= 1f;
}
}
public class UiModule2_MainPanel2 : IUiModule2
{
///
/// 控件标题
/// 它的值取决于culture
///
public string Title=>"IBC.主界面(外风)";
public ComponentType Type => ComponentType.Graph;
public bool IsUnique => true;
///
/// 控件
/// 创建时,需要给它唯一ID,让加载自己的数据
///
///
///
public FrameworkElement GetComponent(int id, IUnityContainer container)
{
MainPanel2 graph = new MainPanel2();
container.BuildUp(graph);
return graph;
}
///
/// 控件缩略图,用于编辑界面时,大致看看
/// 创建时,需要给它唯一ID,让加载自己的数据
///
///
///
public FrameworkElement GetThumbnail()
{
return new System.Windows.Controls.Grid();
}
///
/// 给出全部控件ID, 控件自行删除没有的参数
///
///
public void MatchParam(int[] IDs)
{
}
}
public class UiModule2_MainPanel3 : IUiModule2
{
///
/// 控件标题
/// 它的值取决于culture
///
public string Title => "IBC.主界面(下风)";
public ComponentType Type => ComponentType.Graph;
public bool IsUnique => true;
///
/// 控件
/// 创建时,需要给它唯一ID,让加载自己的数据
///
///
///
public FrameworkElement GetComponent(int id, IUnityContainer container)
{
MainPanel2 graph = new MainPanel2();
container.BuildUp(graph);
graph.SetMode2();
return graph;
}
///
/// 控件缩略图,用于编辑界面时,大致看看
/// 创建时,需要给它唯一ID,让加载自己的数据
///
///
///
public FrameworkElement GetThumbnail()
{
return new System.Windows.Controls.Grid();
}
///
/// 给出全部控件ID, 控件自行删除没有的参数
///
///
public void MatchParam(int[] IDs)
{
}
}
}