using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace OVCS.ClientWpf.Tools
{
    public class UiSafeInvoker
    {
        public static void ActionOnUI(Action _action)
        {
            if (System.Windows.Application.Current == null) return;
            System.Windows.Application.Current.Dispatcher.Invoke(new Action(() =>
            {
                _action();
            }));
        }

        public static void BeginActionOnUI(Action _action)
        {
            if (System.Windows.Application.Current == null) return;
            System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
            {
                _action();
            }));
        }

        public static void ActionOnUI<TArg>(Action<TArg> _action, TArg _arg)
        {
            if (System.Windows.Application.Current == null) return;
            System.Windows.Application.Current.Dispatcher.Invoke(new Action(() =>
            {
                _action(_arg);
            }));
        }

        public static void ActionOnUI<TArg, TArg1>(Action<TArg, TArg1> _action, TArg _arg, TArg1 _arg1)
        {
            if (System.Windows.Application.Current == null) return;
            System.Windows.Application.Current.Dispatcher.Invoke(new Action(() =>
            {
                _action(_arg, _arg1);
            }));
        }

        public static void ActionOnUI<TArg, TArg1, TArg2>(Action<TArg, TArg1, TArg2> _action, TArg _arg, TArg1 _arg1, TArg2 _arg2)
        {
            if (System.Windows.Application.Current == null) return;
            System.Windows.Application.Current.Dispatcher.Invoke(new Action(() =>
            {
                _action(_arg, _arg1, _arg2);
            }));
        }

        public static void ActionOnUI<TArg, TArg1, TArg2, TArg3>(Action<TArg, TArg1, TArg2, TArg3> _action, TArg _arg, TArg1 _arg1, TArg2 _arg2, TArg3 _arg3)
        {
            if (System.Windows.Application.Current == null) return;
            System.Windows.Application.Current.Dispatcher.Invoke(new Action(() =>
            {
                _action(_arg, _arg1, _arg2, _arg3);
            }));
        }

        public static void ActionOnUI<TArg, TArg1, TArg2, TArg3, TArg4>(Action<TArg, TArg1, TArg2, TArg3, TArg4> _action, TArg _arg, TArg1 _arg1, TArg2 _arg2, TArg3 _arg3, TArg4 _arg4)
        {
            if (System.Windows.Application.Current == null) return;
            System.Windows.Application.Current.Dispatcher.Invoke(new Action(() =>
            {
                _action(_arg, _arg1, _arg2, _arg3, _arg4);
            }));

        }

        public static void ActionOnUI<TArg, TArg1, TArg2, TArg3, TArg4, TArg5>(Action<TArg, TArg1, TArg2, TArg3, TArg4, TArg5> _action, TArg _arg, TArg1 _arg1, TArg2 _arg2, TArg3 _arg3, TArg4 _arg4, TArg5 _arg5)
        {
            if (System.Windows.Application.Current == null) return;
            System.Windows.Application.Current.Dispatcher.Invoke(new Action(() =>
            {
                _action(_arg, _arg1, _arg2, _arg3, _arg4, _arg5);
            }));
        }

        public static void ActionOnUI<TArg, TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>(Action<TArg, TArg1, TArg2, TArg3, TArg4, TArg5, TArg6> _action, TArg _arg, TArg1 _arg1, TArg2 _arg2, TArg3 _arg3, TArg4 _arg4, TArg5 _arg5, TArg6 _arg6)
        {
            if (System.Windows.Application.Current == null) return;
            System.Windows.Application.Current.Dispatcher.Invoke(new Action(() =>
            {
                _action(_arg, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6);
            }));
        }
    }
}
