using CCDCount.DLL;
using CCDCount.DLL.SqlDataClass;
using CCDCount.MODEL.SqlDataModel;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Threading;

namespace CCDCountWpf
{
    public static class MessageBus
    {
        //public static List<MainThreadClass> MainThreadS = new List<MainThreadClass>();

        public static MainThreadClass NowSettingLoadMainThread = null;

        public static CameraClass CameraClass = new CameraClass();

        public static UserMessSqliteDataClass UserMessageClass = new UserMessSqliteDataClass($"{AppDomain.CurrentDomain.BaseDirectory}DATA\\UserData\\UserMessage.db");

        public static UserMesDataModelClass NowLoginUserMessage = null;


        public static string NowLoadCammeraSN = string.Empty;
    }
    public static class ShowMessageBus
    {
        public static ShowBindingClass ShowBinding = new ShowBindingClass();
    }

    public static class PlcSettingMessageBus
    {
        public static PLCManagementClass pLCManagement = null;

        public static PlcMessageShowBindingClass PlcMessageShowBindage = new PlcMessageShowBindingClass();
    }
    /// <summary>
    /// App.xaml 的交互逻辑
    /// </summary>
    public partial class App : Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            // 处理 UI 线程异常
            this.DispatcherUnhandledException += (sender, args) =>
            {
                if (args.Exception is System.InvalidCastException &&
                    args.Exception.Message.Contains("Microsoft.Web.WebView2"))
                {
                    // 忽略 WebView2 相关的 COM 异常
                    args.Handled = true;
                }
            };
        }
    }
}
