CommonUtils.Framework/WindowsUtil.cs

(开头部分) 5KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.IO;
using System.Security.Permissions;
using System.Text;
using System.Web.UI.WebControls;
using System.Windows.Forms;
using System.Windows.Threading;

namespace CommonUtils
{
    /// <summary>
    /// 窗口管理
    /// </summary>
    public static class WindowsUtil
    {
        /// <summary>
        /// UI停止刷新
        /// </summary>
        private static object StopFrame(object frame)
        {
            ((DispatcherFrame)frame).Continue = false;
            return null;
        }

        /// <summary>
        /// UI刷新
        /// this.Dispatcher x.Dispatcher Application.Current.Dispatcher
        /// </summary>
        [SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
        public static void RefreshUi(Dispatcher dispatcher)
        {
            DispatcherFrame frame = new DispatcherFrame();
            dispatcher.BeginInvoke(DispatcherPriority.Background, new DispatcherOperationCallback(StopFrame), frame);
            Dispatcher.PushFrame(frame);
        }

        /// <summary>
        /// 线程调用,自带UI刷新
        /// this.Dispatcher x.Dispatcher Application.Current.Dispatcher
        /// </summary> 
        public static void DispatcherInvoke(Action action, Dispatcher dispatcher)
        {
            dispatcher.Invoke(action);
            RefreshUi(dispatcher);
        }

        /// <summary>
        /// 获取文件夹路径,末尾不带斜杠"\\"
        /// if void main() add[STAThread]
        /// </summary>
        public static string SelectFolder(string path = null)
        {
            const string cacheKey = "FolderBrowserDialog.SelectedPath";

            if (string.IsNullOrEmpty(path))
                path = CacheUtil.GetFromFile<string>(cacheKey);

            var dialog = new FolderBrowserDialog();

            if (!string.IsNullOrEmpty(path))
后面还有 123 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。