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 @@
</ItemGroup>
<ItemGroup>
<Compile Include="App.xaml.cs" />
<Compile Include="Common.cs" />
<Compile Include="Converter\BoltNo2BoltIndexConverter.cs" />
<Compile Include="Converter\ControllerStateConverter.cs" />
<Compile Include="Converter\EnumToVisibilityConverter.cs" />
......
......@@ -24,7 +24,6 @@ namespace ThickTcpUiInWindow
{
WarningServiceClient mWarningService;
BufferWindow<FlyData_WarningHistory> mWindow;
SysParam mSysParam;
/// <summary>
///
......@@ -37,23 +36,17 @@ namespace ThickTcpUiInWindow
/// <summary>
///
/// </summary>
/// <param name="sysParam"></param>
/// <param name="warningService"></param>
public void Init(
SysParam sysParam,
WarningServiceClient warningService)
{
mSysParam = sysParam;
mWarningService = warningService;
mWindow = new BufferWindow<FlyData_WarningHistory>(mWarningService.NewestList, mSysParam.WindowSize);
mWindow.PropertyChanged += (s, e) =>
Common.BindingWindowSize((windowSize) =>
{
if (e.PropertyName == "Size")
{
mSysParam.WindowSize = mWindow.Size;
mSysParam.Save();
}
};
mWindow = new BufferWindow<FlyData_WarningHistory>(mWarningService.NewestList, windowSize);
return mWindow;
});
grid_window.DataContext = mWindow;
}
......
......@@ -41,13 +41,11 @@ namespace ThickTcpUiInWindow
/// </summary>
/// <param name="warningService"></param>
/// <param name="warningReasonWindow"></param>
/// <param name="sysParam"></param>
/// <param name="flyADService"></param>
/// <param name="wdIoTipType"></param>
public void Init(
FLY.OBJComponents.Client.WarningServiceClient warningService,
FLY.OBJComponents.Client.BufferWindow<FLY.OBJComponents.Common.FlyData_WarningHistory> warningReasonWindow,
SysParam sysParam,
FlyADServiceClient flyADService,
Type wdIoTipType
)
......@@ -55,7 +53,6 @@ namespace ThickTcpUiInWindow
this.wdIoTipType = wdIoTipType;
mWarningService = warningService;
mWindow = warningReasonWindow;
mSysParam = sysParam;
mFlyADService = flyADService;
gridFlows.ItemsSource = mWindow.Record;
}
......@@ -106,7 +103,7 @@ namespace ThickTcpUiInWindow
if (ns != null)
{
PgErrorAllTable p = new PgErrorAllTable();
p.Init(mSysParam, mWarningService);
p.Init(mWarningService);
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