CommonUtils.Core.Windows/TextBoxExtensions.cs

(开头部分) 4KB

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

using System.Collections.Generic;
using System.Windows.Controls;

namespace CommonUtils
{
    public static class TextBoxExtensions
    {
        public static void BindCalendar(this TextBox textBox, Calendar calendar)
        {
            calendar.Hidden();
            textBox.GotFocus += delegate { calendar.Show(); };
            calendar.SelectedDatesChanged += delegate
            {
                if (calendar.SelectedDate == null)
                    return;
                textBox.Text = calendar.SelectedDate.ToString();
                calendar.SelectedDate = null;
                calendar.Hidden();
            };
        }

        /// <summary>
        /// 空判断
        /// </summary>
        public static bool IsNullOrEmpty(this TextBox textBox)
        => string.IsNullOrEmpty(textBox.Text);

        /// <summary>
        /// 空判断
        /// </summary>
        public static bool IsNullOrWhiteSpace(this TextBox textBox)
        => string.IsNullOrWhiteSpace(textBox.Text);

        /// <summary>
        /// 是否为有效文件路径
        /// </summary>
        public static bool IsFilePath(this TextBox textBox)
        => FileUtil.Exists(textBox.Text);

        /// <summary>
        /// 获取文件夹路径,末尾不带斜杠"\\"
        /// </summary>
        public static void SelectFolder(this TextBox textBox, bool save = false)
        {
            string path = WindowsUtil.SelectFolder();
            if (!string.IsNullOrWhiteSpace(path))
            {
                textBox.Text = path;
                if (save)
                    textBox.SaveValue();
            }
        }

        public static void SelectFolderOnDoubleClick(this TextBox textBox, bool save = false)
        {
            textBox.MouseDoubleClick += delegate
            {
                textBox.SelectFolder(save);
            };
        }
后面还有 91 行代码,解锁后查看完整代码

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

AI 解读 AI

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

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