⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 funcdispatcher.cs

📁 破解的飞信源代码
💻 CS
字号:
namespace Imps.Client.Core
{
    using System;
    using System.Windows.Forms;

    public static class FuncDispatcher
    {
        private static Control _mainWnd;

        public static void InvokeDelegateInUiThread(Control host, Delegate method, params object[] args)
        {
            Control control;
            if (method == null)
            {
                throw new ArgumentNullException("method");
            }
            if (((host != null) && (host.Handle != IntPtr.Zero)) && host.Visible)
            {
                control = host;
            }
            else
            {
                control = _mainWnd;
            }
            if ((control != null) && control.IsHandleCreated)
            {
                control.BeginInvoke(method, args);
            }
            else
            {
                method.DynamicInvoke(args);
            }
        }

        public static void InvokeEventHandlerInUiThread(object sender, EventHandler handler, EventArgs e)
        {
            InvokeDelegateInUiThread(null, new OnEventHandlerDelegate(FuncDispatcher.OnEventHandler), new object[] { sender, handler, e });
        }

        public static void InvokeEventHandlerInUiThread<TEventArgs>(object sender, EventHandler<TEventArgs> handler, TEventArgs e) where TEventArgs: EventArgs
        {
            InvokeDelegateInUiThread(null, new OnEventHandlerDelegate<TEventArgs>(FuncDispatcher.OnEventHandler<TEventArgs>), new object[] { sender, handler, e });
        }

        public static void InvokeRaiseEventMethodInUiThread<TEventArgs>(EventHandlerDelegate<TEventArgs> raiseMethod, TEventArgs e) where TEventArgs: EventArgs
        {
            InvokeDelegateInUiThread(null, raiseMethod, new object[] { e });
        }

        public static void OnEventHandler(object sender, EventHandler handler, EventArgs e)
        {
            if (handler != null)
            {
                handler(sender, e);
            }
        }

        public static void OnEventHandler<TEventArgs>(object sender, EventHandler<TEventArgs> handler, TEventArgs e) where TEventArgs: EventArgs
        {
            if (handler != null)
            {
                handler.Invoke(sender, e);
            }
        }

        public static void SetMainWindow(Control mainWnd)
        {
            _mainWnd = mainWnd;
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -