Commit 5e2479d3 authored by 潘栩锋's avatar 潘栩锋 🚴

1. 添加 FLY.Thick.Base.UI windowSize绑定模板

parent 925e79d0
using FLY.OBJComponents.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace ThickTcpUiInWindow
{
/// <summary>
/// 公共类
/// </summary>
public static class Common
{
/// <summary>
/// 绑定 Application.Current.Properties["WindowSize"] 到 BufferWindow.Size
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="createWindow"></param>
public static void BindingWindowSize<T>(Func<int, BufferWindow<T>> createWindow)
{
int windowSize = 30;
if (Application.Current.Properties["WindowSize"] is int)
windowSize = (int)Application.Current.Properties["WindowSize"];
var window = createWindow(windowSize);
window.PropertyChanged += (s, e) =>
{
if (e.PropertyName == "Size")
{
var w = s as BufferWindow<T>;
Application.Current.Properties["WindowSize"] = w.Size;
}
};
}
}
}
...@@ -98,6 +98,7 @@ ...@@ -98,6 +98,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="App.xaml.cs" /> <Compile Include="App.xaml.cs" />
<Compile Include="Common.cs" />
<Compile Include="Converter\BoltNo2BoltIndexConverter.cs" /> <Compile Include="Converter\BoltNo2BoltIndexConverter.cs" />
<Compile Include="Converter\ControllerStateConverter.cs" /> <Compile Include="Converter\ControllerStateConverter.cs" />
<Compile Include="Converter\EnumToVisibilityConverter.cs" /> <Compile Include="Converter\EnumToVisibilityConverter.cs" />
......
...@@ -24,7 +24,6 @@ namespace ThickTcpUiInWindow ...@@ -24,7 +24,6 @@ namespace ThickTcpUiInWindow
{ {
WarningServiceClient mWarningService; WarningServiceClient mWarningService;
BufferWindow<FlyData_WarningHistory> mWindow; BufferWindow<FlyData_WarningHistory> mWindow;
SysParam mSysParam;
/// <summary> /// <summary>
/// ///
...@@ -37,23 +36,17 @@ namespace ThickTcpUiInWindow ...@@ -37,23 +36,17 @@ namespace ThickTcpUiInWindow
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
/// <param name="sysParam"></param>
/// <param name="warningService"></param> /// <param name="warningService"></param>
public void Init( public void Init(
SysParam sysParam,
WarningServiceClient warningService) WarningServiceClient warningService)
{ {
mSysParam = sysParam;
mWarningService = warningService; mWarningService = warningService;
mWindow = new BufferWindow<FlyData_WarningHistory>(mWarningService.NewestList, mSysParam.WindowSize); Common.BindingWindowSize((windowSize) =>
mWindow.PropertyChanged += (s, e) =>
{ {
if (e.PropertyName == "Size") mWindow = new BufferWindow<FlyData_WarningHistory>(mWarningService.NewestList, windowSize);
{ return mWindow;
mSysParam.WindowSize = mWindow.Size; });
mSysParam.Save();
}
};
grid_window.DataContext = mWindow; grid_window.DataContext = mWindow;
} }
......
...@@ -41,13 +41,11 @@ namespace ThickTcpUiInWindow ...@@ -41,13 +41,11 @@ namespace ThickTcpUiInWindow
/// </summary> /// </summary>
/// <param name="warningService"></param> /// <param name="warningService"></param>
/// <param name="warningReasonWindow"></param> /// <param name="warningReasonWindow"></param>
/// <param name="sysParam"></param>
/// <param name="flyADService"></param> /// <param name="flyADService"></param>
/// <param name="wdIoTipType"></param> /// <param name="wdIoTipType"></param>
public void Init( public void Init(
FLY.OBJComponents.Client.WarningServiceClient warningService, FLY.OBJComponents.Client.WarningServiceClient warningService,
FLY.OBJComponents.Client.BufferWindow<FLY.OBJComponents.Common.FlyData_WarningHistory> warningReasonWindow, FLY.OBJComponents.Client.BufferWindow<FLY.OBJComponents.Common.FlyData_WarningHistory> warningReasonWindow,
SysParam sysParam,
FlyADServiceClient flyADService, FlyADServiceClient flyADService,
Type wdIoTipType Type wdIoTipType
) )
...@@ -55,7 +53,6 @@ namespace ThickTcpUiInWindow ...@@ -55,7 +53,6 @@ namespace ThickTcpUiInWindow
this.wdIoTipType = wdIoTipType; this.wdIoTipType = wdIoTipType;
mWarningService = warningService; mWarningService = warningService;
mWindow = warningReasonWindow; mWindow = warningReasonWindow;
mSysParam = sysParam;
mFlyADService = flyADService; mFlyADService = flyADService;
gridFlows.ItemsSource = mWindow.Record; gridFlows.ItemsSource = mWindow.Record;
} }
...@@ -106,7 +103,7 @@ namespace ThickTcpUiInWindow ...@@ -106,7 +103,7 @@ namespace ThickTcpUiInWindow
if (ns != null) if (ns != null)
{ {
PgErrorAllTable p = new PgErrorAllTable(); PgErrorAllTable p = new PgErrorAllTable();
p.Init(mSysParam, mWarningService); p.Init(mWarningService);
ns.Navigate(p); ns.Navigate(p);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment