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.IBC.UI.Client
{
    public static class Common
    {
        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;
                }
            };
        }
    }
}