<commit_before>﻿using System;
using System.ComponentModel;
using System.Windows;
using System.Windows.Input;
using System.Windows.Threading;

namespace FlatMVVM.Utils
{
    /// <summary>
    /// Wraps some UI and application functionality.
    /// </summary>
    public static class UIWrapper
    {

        #region Dispatcher Operations

        /// <summary>
        /// 
        /// </summary>
        /// <param name="action"></param>
        /// <returns></returns>
        public static DispatcherOperation DispatchAsync(Action action)
        {
           return Application.Current.Dispatcher.BeginInvoke(action);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="action"></param>
        /// <param name="priority"></param>
        /// <returns></returns>
        public static DispatcherOperation DispatchAsync(Action action, DispatcherPriority priority)
        {
            return Application.Current.Dispatcher.BeginInvoke(action, priority);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="action"></param>
        public static void DispatchSync(Action action)
        {
            Application.Current.Dispatcher.Invoke(action);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="action"></param>
        /// <param name="priority"></param>
        public static void DispatchSync(Action action, DispatcherPriority priority)
        {
            Application.Current.Dispatcher.Invoke(action, priority);
        }

        #endregion

        #region Commands

        /// <summary>
        /// Reevaluates all commands asynchronously.
        /// </summary>
        public static void RefreshCommands()
        {
            DispatchAsync(CommandManager.InvalidateRequerySuggested);
        }

        #endregion

        #region MainWindow

        /// <summary>
        /// Activate current applications MainWindow.
        /// </summary>
        public static void EnableMainWindow()
        {
            Application.Current.MainWindow.IsEnabled = true;
        }

        /// <summary>
        /// Deactivate current applications MainWindow.
        /// </summary>
        public static void DisableMainWindow()
        {
            Application.Current.MainWindow.IsEnabled = false;
        }

        #endregion

        #region DesignTime

        /// <summary>
        /// Check whether code is executed in design mode or not.
        /// </summary>
        /// <returns>True if in design mode; else false.</returns>
        public static bool IsInDesignMode => DesignerProperties.GetIsInDesignMode(new DependencyObject());

        #endregion

        #region Cursor

        /// <summary><commit_msg>Added MainWindow Property to UIWrapper<commit_after>﻿using System;
using System.ComponentModel;
using System.Windows;
using System.Windows.Input;
using System.Windows.Threading;

namespace FlatMVVM.Utils
{
    /// <summary>
    /// Wraps some UI and application functionality.
    /// </summary>
    public static class UIWrapper
    {

        #region Dispatcher Operations

        /// <summary>
        /// 
        /// </summary>
        /// <param name="action"></param>
        /// <returns></returns>
        public static DispatcherOperation DispatchAsync(Action action)
        {
           return Application.Current.Dispatcher.BeginInvoke(action);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="action"></param>
        /// <param name="priority"></param>
        /// <returns></returns>
        public static DispatcherOperation DispatchAsync(Action action, DispatcherPriority priority)
        {
            return Application.Current.Dispatcher.BeginInvoke(action, priority);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="action"></param>
        public static void DispatchSync(Action action)
        {
            Application.Current.Dispatcher.Invoke(action);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="action"></param>
        /// <param name="priority"></param>
        public static void DispatchSync(Action action, DispatcherPriority priority)
        {
            Application.Current.Dispatcher.Invoke(action, priority);
        }

        #endregion

        #region Commands

        /// <summary>
        /// Reevaluates all commands asynchronously.
        /// </summary>
        public static void RefreshCommands()
        {
            DispatchAsync(CommandManager.InvalidateRequerySuggested);
        }

        #endregion

        #region MainWindow

        /// <summary>
        /// Current Application MainWindow.
        /// </summary>
        public static Window MainWindow => Application.Current.MainWindow;

        /// <summary>
        /// Activate current applications MainWindow.
        /// </summary>
        public static void EnableMainWindow()
        {
            Application.Current.MainWindow.IsEnabled = true;
        }

        /// <summary>
        /// Deactivate current applications MainWindow.
        /// </summary>
        public static void DisableMainWindow()
        {
            Application.Current.MainWindow.IsEnabled = false;
        }

        #endregion

        #region DesignTime

        /// <summary>
        /// Check whether code is executed in design mode or not.
        /// </summary>
        /// <returns>True if in design mode; else false.</returns>
        public static bool IsInDesignMode => DesignerProperties.GetIsInDesignMode(new DependencyObject());

        #endregion

        #region Cursor

        /// <summary>
{'fraction_non_alphanumeric': 0.12009803921568628, 'fraction_numerical': 0.0, 'mean_word_length': 1.7217722725107194, 'pattern_counts': {'":': 0, '<': 79, '<?xml version=': 0, '>': 82, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1653446', 'n_tokens_mistral': 1406, 'n_tokens_neox': 1344, 'n_words': 321}