1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using FLY.OBJComponents.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace FLY.Thick.Base.UI
{
/// <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;
}
};
}
}
}