using FLY.Thick.FilmCasting.Server;
using FLY.Thick.FilmCasting.Server.OBJProxy;
using FLY.Thick.FilmCasting.Server.WsProxy;
using FLY.Thick.FilmCasting.WebAPI;
using System;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Navigation;
using Unity;
using WebSocketSharp.Server;

namespace FLY.Thick.FilmCasting.UI.Server
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : NavigationWindow
    {
        FLY.AppHelper.WindowNotifyIconHelper notifyiconhelper;
        Func<Task> launched;
        IUnityContainer container;



        public MainWindow()
        {
            InitializeComponent();
            PgLoading p = new PgLoading();
            this.Navigate(p);
            this.Loaded += NavigationWindow_Loaded;
        }
        public void Init(IUnityContainer container, Func<Task> launched)
        {
            this.container = container;
            this.launched = launched;
        }
        private async void NavigationWindow_Loaded(object sender, RoutedEventArgs e)
        {
            notifyiconhelper = new FLY.AppHelper.WindowNotifyIconHelper(this, this.Title);

            await Task.Delay(1);
            await launched();
            this.Hide();

            Width = 900;
            Height = 600;
            PgMain p = new PgMain();
            container.BuildUp(p);
            this.Navigate(p);
            this.NavigationService.RemoveBackEntry();
        }
    }

}
