using CPF.Linux;
using CPF.Platform;
using CPF.Skia;
using CPF.Windows;
using ESBasic.Loggers;
using OMCS.Passive;
using Oraycn.ChatRendering;
using OVCS.ClientLinux.Tools;
using System;

namespace OVCS.ClientLinux
{
    /*
     * OVCS采用的是ESFramework通信框架和OMCS网络语音视频框架的免费版本，若想获取其它版本，请联系www.oraycn.com。
     * 
     */
    public class Program
    {    
        public static FileAgileLogger TestLogger;
        // ESFramework 引擎 
        //// OMCS 多媒体设备管理器
        internal static IMultimediaManager MultimediaManager;
        public static MainWindow MainWindow;

        [System.STAThread]
        static void Main(string[] args)
        {

            Application.Initialize(
                 (OperatingSystemType.Windows, new WindowsPlatform(), new SkiaDrawingFactory())
                 //, (OperatingSystemType.OSX, new MacPlatform(), new SkiaDrawingFactory())//如果需要支持Mac才需要
                 , (OperatingSystemType.Linux, new LinuxPlatform(), new SkiaDrawingFactory())//如果需要支持Linux才需要
             );
            System.Threading.ThreadPool.SetMinThreads(50, 12);
            //初始化全局图片资源
            GlobalResourceManager.Initialize(); 
            TestLogger = new FileAgileLogger(AppDomain.CurrentDomain.BaseDirectory + "/AppLog.txt"); 
          

            string ttfDirectoryPath = $"{AppDomain.CurrentDomain.BaseDirectory}FontFamily{ESBasic.Helpers.FileHelper.GetFilePathSeparatorChar()}";
            Application.LoadFont($"{ttfDirectoryPath}微软雅黑.ttf", "微软雅黑");
            RenderSettings.TtfResourceDirPath = ttfDirectoryPath;
            RenderSettings.TextFontName = "微软雅黑";

            MultimediaManager = MultimediaManagerFactory.GetSingleton();
            LoginWindow loginWindow = new LoginWindow(new CustomizeHandler(),  MultimediaManager);
            loginWindow.loginSuccess += LoginWindow_loginSuccess; 
            Application.Run(loginWindow);
            //加载字体
        }

        private static void LoginWindow_loginSuccess(string roomID)
        {
            MainWindow = new MainWindow(roomID,  MultimediaManager);
            MainWindow.Show();
        }
    }
}
