├── logo.png
├── Wu
├── logo.ico
├── Extensions
│ ├── MathExtension.cs
│ ├── ArrayExtension.cs
│ ├── DataTableExtension.cs
│ ├── Judge
│ │ ├── StringJudge.cs
│ │ └── CharJudge.cs
│ ├── ObjectExtension.cs
│ ├── AttributeExtension.cs
│ └── StringExtention.cs
├── GlobalUsings.cs
├── Utils
│ ├── JsonUtil.cs
│ ├── IoUtil.cs
│ ├── DataTableUtil.cs
│ ├── MathUtil.cs
│ ├── User32Util.cs
│ └── DateTimeUtil.cs
├── FzWater
│ └── Mqtt
│ │ ├── DataType.cs
│ │ ├── Data.cs
│ │ ├── Tag.cs
│ │ └── DataFrame.cs
├── MathPro
│ ├── Range.cs
│ └── RangeConverter.cs
└── Wu.csproj
├── Wu.EntityFrameworkCore
├── UnitOfWork
│ ├── ReadMe.txt
│ ├── IRepositoryFactory.cs
│ ├── IUnitOfWorkOfT.cs
│ ├── Collections
│ │ ├── IPagedList.cs
│ │ ├── IQueryablePageListExtensions.cs
│ │ └── IEnumerablePagedListExtensions.cs
│ ├── IUnitOfWork.cs
│ └── UnitOfWorkServiceCollectionExtensions.cs
└── Wu.EntityFrameworkCore.csproj
├── Wu.Wpf.ControlLibrary
├── ShapeControls
│ ├── ReadMe.txt
│ ├── RegularHexagonCtrl.xaml
│ ├── RegularPolygonCtrl.xaml
│ ├── RegularHexagonCtrl.xaml.cs
│ └── RegularPolygonCtrl.xaml.cs
├── Images
│ └── RingText文字环绕控件示例.gif
├── GlobalUsings.cs
├── RingText.xaml
├── AssemblyInfo.cs
├── Wu.Wpf.ControlLibrary.csproj
├── BreatheLight.xaml
├── BreatheLight.xaml.cs
├── Shapes
│ ├── RegularPolygon.cs
│ └── RegularHexagon.cs
└── RingText.xaml.cs
├── Wu.Wpf
├── Common
│ ├── IConfigureService.cs
│ ├── IDialogHostService.cs
│ ├── IDialogHostAware.cs
│ └── DialogHostService.cs
├── AssemblyInfo.cs
├── Converters
│ ├── 说明.txt
│ ├── Null2Collapsed.cs
│ ├── StringIsNullOrWhiteSpace2Hide.cs
│ ├── StringIsNullOrWhiteSpace2True.cs
│ ├── StringIsNullOrWhiteSpace2Visibility.cs
│ ├── LessThanOne2Collapsed.cs
│ ├── StringIsNullOrWhiteSpace2Collapsed.cs
│ ├── MoreThanZero2Collapsed.cs
│ ├── True2Hidden.cs
│ ├── False2Hidden.cs
│ ├── True2Collapsed.cs
│ ├── False2Collapsed.cs
│ ├── Zero2Collapsed.cs
│ ├── NonZero2Collapsed.cs
│ ├── ReverseBool.cs
│ ├── MergeText.cs
│ ├── CnYesNo2Bool.cs
│ ├── EnumDescriptionTypeConverter.cs
│ ├── ValueConverterBase.cs
│ └── EnumBindingSourceExtension.cs
├── Views
│ ├── QuestionView.xaml.cs
│ └── QuestionView.xaml
├── ViewModels
│ ├── DesignViewModels
│ │ └── QuestionDesignViewModel.cs
│ ├── QuestionViewModel.cs
│ └── NavigationViewModel.cs
├── Events
│ ├── MessageEvent.cs
│ └── UpdateLoadingEvent.cs
├── Models
│ ├── MenuBar.cs
│ ├── OpenDrawers.cs
│ └── Paping.cs
├── GlobalUsings.cs
├── Wu.Wpf.csproj
├── Utils.cs
└── Extensions
│ ├── PasswordExtensions.cs
│ ├── TextBoxExtensions.cs
│ ├── ScrollViewerExtensions.cs
│ └── DialogExtensions.cs
├── Wu.CodeSnippets
├── Wu.CodeSnippets.csproj
├── componentbase.snippet
├── bindablebase.snippet
├── propnplc.snippet
├── propf.snippet
├── realizeINotifyPropertyChanged.snippet
├── propn.snippet
├── propr.snippet
├── GeometryGenerator.snippet
├── propd.snippet
├── propdf.snippet
└── propdfb.snippet
├── Test.App
├── App.xaml
├── App.xaml.cs
├── Test.App.csproj
├── AssemblyInfo.cs
├── MainWindow.xaml.cs
└── MainWindow.xaml
├── LICENSE.txt
├── README.md
├── .gitattributes
├── Wu.sln
└── .gitignore
/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Monika1313/Wu/HEAD/logo.png
--------------------------------------------------------------------------------
/Wu/logo.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Monika1313/Wu/HEAD/Wu/logo.ico
--------------------------------------------------------------------------------
/Wu.EntityFrameworkCore/UnitOfWork/ReadMe.txt:
--------------------------------------------------------------------------------
1 | 该部分取自 https://github.com/Arch/UnitOfWork
2 | 仅修改了命名空间,方便个人使用
--------------------------------------------------------------------------------
/Wu.Wpf.ControlLibrary/ShapeControls/ReadMe.txt:
--------------------------------------------------------------------------------
1 | RegularPolygonCtrl 正多边形
2 | RegularHexagonCtrl 正六边形
3 |
4 |
--------------------------------------------------------------------------------
/Wu.Wpf.ControlLibrary/Images/RingText文字环绕控件示例.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Monika1313/Wu/HEAD/Wu.Wpf.ControlLibrary/Images/RingText文字环绕控件示例.gif
--------------------------------------------------------------------------------
/Wu.Wpf/Common/IConfigureService.cs:
--------------------------------------------------------------------------------
1 | namespace Wu.Wpf.Common;
2 |
3 | public interface IConfigureService
4 | {
5 | void Configure();
6 | }
7 |
--------------------------------------------------------------------------------
/Wu.Wpf/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | [assembly: XmlnsDefinition("https://github.com/Monika1313/Wu", "Wu.Wpf.Converters")]
2 | [assembly: XmlnsDefinition("https://github.com/Monika1313/Wu", "Wu.Wpf.Extensions")]
3 | [assembly: XmlnsPrefix("https://github.com/Monika1313/Wu", "wu")]
--------------------------------------------------------------------------------
/Wu.Wpf/Converters/说明.txt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | CnYesNo2Bool 中文 "是" "否" 转换为Bool
5 | False2Collapsed false隐藏 false=Collapsed
6 | MergeText 文本合并
7 | NonZero2Collapsed 不为0隐藏
8 | ReverseBool bool取反
9 | StringIsWhiteOrSpace2Bool null隐藏
10 | True2Collapsed true隐藏
11 | Zero2Collapsed 为0隐藏
--------------------------------------------------------------------------------
/Wu.CodeSnippets/Wu.CodeSnippets.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Wu.Wpf.ControlLibrary/GlobalUsings.cs:
--------------------------------------------------------------------------------
1 | global using System;
2 | global using System.Collections.Generic;
3 | global using System.ComponentModel;
4 | global using System.Windows;
5 | global using System.Windows.Controls;
6 | global using System.Windows.Media;
7 | global using System.Windows.Shapes;
8 |
--------------------------------------------------------------------------------
/Wu.Wpf/Views/QuestionView.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Controls;
2 |
3 | namespace Wu.Wpf.Views;
4 |
5 | ///
6 | /// 弹窗询问窗口
7 | ///
8 | public partial class QuestionView : UserControl
9 | {
10 | public QuestionView()
11 | {
12 | InitializeComponent();
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Test.App/App.xaml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Wu.Wpf/ViewModels/DesignViewModels/QuestionDesignViewModel.cs:
--------------------------------------------------------------------------------
1 | namespace Wu.Wpf.ViewModels.DesignViewModels;
2 |
3 | public class QuestionDesignViewModel : QuestionViewModel
4 | {
5 | private static QuestionDesignViewModel _Instance = new();
6 | public static QuestionDesignViewModel Instance => _Instance ??= new();
7 | public QuestionDesignViewModel()
8 | {
9 |
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Test.App/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 |
9 | namespace Test.App
10 | {
11 | ///
12 | /// Interaction logic for App.xaml
13 | ///
14 | public partial class App : Application
15 | {
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Wu/Extensions/MathExtension.cs:
--------------------------------------------------------------------------------
1 | namespace Wu.Extensions;
2 |
3 | ///
4 | /// System.Math 扩展
5 | ///
6 | public static class MathExtension
7 | {
8 | public static double Round2(this double value)
9 | {
10 | return Math.Round(value, 2);
11 | }
12 |
13 | public static double Round3(this double value)
14 | {
15 | return Math.Round(value, 3);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Test.App/Test.App.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | net6.0-windows
6 | enable
7 | true
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/Wu/GlobalUsings.cs:
--------------------------------------------------------------------------------
1 | global using System;
2 | global using System.Collections.Generic;
3 | global using System.Linq;
4 | global using System.Text;
5 | global using System.Threading.Tasks;
6 | global using System.Data;
7 |
8 | global using System.Security.Cryptography;
9 | global using System.Text.RegularExpressions;
10 |
11 | global using System.Linq.Expressions;
12 | global using System.IO;
13 | global using Newtonsoft.Json;
14 |
15 |
--------------------------------------------------------------------------------
/Wu.Wpf/Events/MessageEvent.cs:
--------------------------------------------------------------------------------
1 | namespace Wu.Wpf.Events;
2 |
3 | ///
4 | /// 消息事件 事件需要继承PubSubEvent
5 | ///
6 | public class MessageEvent : PubSubEvent
7 | {
8 | }
9 |
10 | public class MessageModel
11 | {
12 | ///
13 | /// 过滤器
14 | ///
15 | public string Filter { get; set; }
16 |
17 | ///
18 | /// 消息
19 | ///
20 | public string Message { get; set; }
21 | }
22 |
--------------------------------------------------------------------------------
/Wu/Extensions/ArrayExtension.cs:
--------------------------------------------------------------------------------
1 | namespace Wu.CommTool.Core.Extensions;
2 |
3 | ///
4 | /// 数组扩展方法
5 | ///
6 | public static class ArrayExtension
7 | {
8 | ///
9 | /// 字节数组转换为16进制字符串形式
10 | ///
11 | ///
12 | ///
13 | public static string ToHexString(this byte[] arr)
14 | {
15 | return BitConverter.ToString(arr).Replace('-', ' ');
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Wu.Wpf/Converters/Null2Collapsed.cs:
--------------------------------------------------------------------------------
1 | namespace Wu.Wpf.Converters;
2 |
3 | ///
4 | /// 为Null则隐藏
5 | ///
6 | public class Null2Collapsed : ValueConverterBase
7 | {
8 | public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
9 | {
10 | if (value != null )
11 | {
12 | return Visibility.Visible;
13 | }
14 | return Visibility.Collapsed;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Wu.Wpf/Events/UpdateLoadingEvent.cs:
--------------------------------------------------------------------------------
1 | namespace Wu.Wpf.Events;
2 |
3 | ///
4 | /// 数据更新模型
5 | ///
6 | public class UpdateModel
7 | {
8 | ///
9 | /// 数据更新窗口是否打开
10 | ///
11 | public bool IsOpen { get; set; }
12 |
13 | ///
14 | /// 过滤器
15 | ///
16 | public string Filter { get; set; } = "Main";
17 | }
18 |
19 | public class UpdateLoadingEvent : PubSubEvent
20 | {
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/Wu.Wpf/Common/IDialogHostService.cs:
--------------------------------------------------------------------------------
1 | namespace Wu.Wpf.Common;
2 |
3 | public interface IDialogHostService : IDialogService
4 | {
5 | ///
6 | /// Prism弹窗
7 | ///
8 | /// 模块名称
9 | ///
10 | ///
11 | ///
12 | Task ShowDialog(string name, IDialogParameters parameters, string dialogHostName = "Root");
13 | }
14 |
--------------------------------------------------------------------------------
/Wu.Wpf/Converters/StringIsNullOrWhiteSpace2Hide.cs:
--------------------------------------------------------------------------------
1 | namespace Wu.Wpf.Converters;
2 |
3 | ///
4 | /// string.IsNullOrWhiteSpace
5 | ///
6 | public class StringIsNullOrWhiteSpace2Hide : ValueConverterBase
7 | {
8 | public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
9 | {
10 | if (string.IsNullOrWhiteSpace(value?.ToString()))
11 | return true;
12 | return false;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Wu.Wpf/Converters/StringIsNullOrWhiteSpace2True.cs:
--------------------------------------------------------------------------------
1 | namespace Wu.Wpf.Converters;
2 |
3 | ///
4 | /// string.IsNullOrWhiteSpace null或空=true
5 | ///
6 | public class StringIsNullOrWhiteSpace2True : ValueConverterBase
7 | {
8 | public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
9 | {
10 | if (string.IsNullOrWhiteSpace(value?.ToString()))
11 | return true;
12 | return false;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Wu.Wpf/Converters/StringIsNullOrWhiteSpace2Visibility.cs:
--------------------------------------------------------------------------------
1 | namespace Wu.Wpf.Converters;
2 |
3 | ///
4 | /// string.IsNullOrWhiteSpace
5 | ///
6 | public class StringIsNullOrWhiteSpace2Visibility : ValueConverterBase
7 | {
8 | public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
9 | {
10 | if (string.IsNullOrWhiteSpace(value?.ToString()))
11 | return true;
12 | return false;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Wu.Wpf/Converters/LessThanOne2Collapsed.cs:
--------------------------------------------------------------------------------
1 | namespace Wu.Wpf.Converters;
2 |
3 | public class LessThanOne2Collapsed : ValueConverterBase
4 | {
5 | public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
6 | {
7 | if (value != null && int.TryParse(value.ToString(), out int result))
8 | {
9 | if (result > 0)
10 | {
11 | return Visibility.Visible;
12 | }
13 | }
14 | return Visibility.Collapsed;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Wu.Wpf/Converters/StringIsNullOrWhiteSpace2Collapsed.cs:
--------------------------------------------------------------------------------
1 | namespace Wu.Wpf.Converters;
2 |
3 | ///
4 | /// string.IsNullOrWhiteSpace null或空=不可见
5 | ///
6 | public class StringIsNullOrWhiteSpace2Collapsed : ValueConverterBase
7 | {
8 | public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
9 | {
10 | if (string.IsNullOrWhiteSpace(value?.ToString()))
11 | return Visibility.Collapsed;
12 | return Visibility.Visible;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Wu.Wpf/Converters/MoreThanZero2Collapsed.cs:
--------------------------------------------------------------------------------
1 | namespace Wu.Wpf.Converters;
2 |
3 | public class MoreThanZero2Collapsed : ValueConverterBase
4 | {
5 | public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
6 | {
7 | if (value != null && int.TryParse(value.ToString(), out int result))
8 | {
9 | if (result == 0)
10 | {
11 | return Visibility.Visible;
12 | }
13 | }
14 | return Visibility.Collapsed;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Wu.Wpf/Converters/True2Hidden.cs:
--------------------------------------------------------------------------------
1 | namespace Wu.Wpf.Converters;
2 |
3 | ///
4 | /// bool转换Visibility false为Hidden
5 | ///
6 | public class True2Hidden : ValueConverterBase
7 | {
8 | public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
9 | {
10 | bool b = System.Convert.ToBoolean(value);
11 | if (b)
12 | {
13 | return Visibility.Collapsed;
14 | }
15 | else
16 | {
17 | return Visibility.Hidden;
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Wu.Wpf/Converters/False2Hidden.cs:
--------------------------------------------------------------------------------
1 | namespace Wu.Wpf.Converters;
2 |
3 | ///
4 | /// bool转换Visibility false为Hidden
5 | ///
6 | public class False2Hidden : ValueConverterBase
7 | {
8 | public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
9 | {
10 | bool b = System.Convert.ToBoolean(value);
11 | if (b)
12 | {
13 | return Visibility.Visible;
14 | }
15 | else
16 | {
17 | return Visibility.Hidden;
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Wu.Wpf/Converters/True2Collapsed.cs:
--------------------------------------------------------------------------------
1 | namespace Wu.Wpf.Converters;
2 |
3 | ///
4 | /// bool转换Visibility false为Collapsed
5 | ///
6 | public class True2Collapsed : ValueConverterBase
7 | {
8 | public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
9 | {
10 | bool b = System.Convert.ToBoolean(value);
11 | if (b)
12 | {
13 | return Visibility.Collapsed;
14 | }
15 | else
16 | {
17 | return Visibility.Visible;
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Wu.Wpf.ControlLibrary/RingText.xaml:
--------------------------------------------------------------------------------
1 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/Wu.Wpf/Converters/False2Collapsed.cs:
--------------------------------------------------------------------------------
1 | namespace Wu.Wpf.Converters;
2 |
3 | ///
4 | /// bool转换Visibility false为Collapsed
5 | ///
6 | public class False2Collapsed : ValueConverterBase
7 | {
8 | public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
9 | {
10 | bool b = System.Convert.ToBoolean(value);
11 | if (b)
12 | {
13 | return Visibility.Visible;
14 | }
15 | else
16 | {
17 | return Visibility.Collapsed;
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Wu.Wpf/Converters/Zero2Collapsed.cs:
--------------------------------------------------------------------------------
1 | namespace Wu.Wpf.Converters;
2 |
3 | ///
4 | /// 为0则隐藏
5 | ///
6 | public class Zero2Collapsed : ValueConverterBase
7 | {
8 | public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
9 | {
10 | if (value != null && int.TryParse(value.ToString(), out int result))
11 | {
12 | if (result > 0)
13 | {
14 | return Visibility.Visible;
15 | }
16 | }
17 | return Visibility.Collapsed;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Wu.Wpf/Converters/NonZero2Collapsed.cs:
--------------------------------------------------------------------------------
1 | namespace Wu.Wpf.Converters;
2 |
3 | ///
4 | /// 非零则隐藏
5 | ///
6 | public class NonZero2Collapsed : ValueConverterBase
7 | {
8 | public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
9 | {
10 | if (value != null && int.TryParse(value.ToString(), out int result))
11 | {
12 | if (result.Equals(0))
13 | {
14 | return Visibility.Visible;
15 | }
16 | }
17 | return Visibility.Collapsed;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Wu/Extensions/DataTableExtension.cs:
--------------------------------------------------------------------------------
1 | namespace Wu.Extensions;
2 |
3 | public static class DataTableExtension
4 | {
5 | ///
6 | /// 行倒序重排
7 | ///
8 | ///
9 | ///
10 | public static DataTable Invert(this DataTable dt)
11 | {
12 | DataTable ndt = dt.Clone(); //克隆表格结构 不复制数据
13 | DataRow[] drs = dt.Select(); //获取原始表格行数据
14 | for (int i = dt.Rows.Count; i > 0; --i)
15 | {
16 | ndt.ImportRow(dt.Rows[i - 1]);
17 | }
18 | return ndt;
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/Wu.Wpf/Common/IDialogHostAware.cs:
--------------------------------------------------------------------------------
1 | namespace Wu.Wpf.Common;
2 |
3 | public interface IDialogHostAware
4 | {
5 | ///
6 | /// 窗口名称
7 | ///
8 | public string DialogHostName { get; set; }
9 |
10 | ///
11 | /// 打开过程中执行
12 | ///
13 | /// 接收参数
14 | void OnDialogOpened(IDialogParameters parameters);
15 |
16 | ///
17 | /// 确定
18 | ///
19 | IRelayCommand SaveCommand { get;}
20 |
21 | ///
22 | /// 取消
23 | ///
24 | IRelayCommand CancelCommand { get;}
25 | }
26 |
--------------------------------------------------------------------------------
/Test.App/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | [assembly: ThemeInfo(
4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5 | //(used if a resource is not found in the page,
6 | // or application resource dictionaries)
7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8 | //(used if a resource is not found in the page,
9 | // app, or any theme specific resource dictionaries)
10 | )]
11 |
--------------------------------------------------------------------------------
/Wu/Utils/JsonUtil.cs:
--------------------------------------------------------------------------------
1 | namespace Wu.Utils;
2 |
3 | ///
4 | /// Json
5 | ///
6 | public static class JsonUtil
7 | {
8 | //忽略json循环引用设置
9 | private static JsonSerializerSettings setting = new JsonSerializerSettings
10 | {
11 | ReferenceLoopHandling = ReferenceLoopHandling.Ignore //忽略循环引用
12 | };
13 |
14 | ///
15 | /// json序列化 忽略循环引用
16 | ///
17 | ///
18 | ///
19 | ///
20 | public static string SeriallizeIgnoreLoop(T jsonClass)
21 | {
22 | return JsonConvert.SerializeObject(jsonClass, setting);
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/Wu.Wpf/Models/MenuBar.cs:
--------------------------------------------------------------------------------
1 | namespace Wu.Wpf.Models;
2 |
3 | ///
4 | /// 系统导航菜单
5 | ///
6 | public class MenuBar : BindableBase
7 | {
8 | ///
9 | /// 菜单图标
10 | ///
11 | public string? Icon { get => _Icon; set => SetProperty(ref _Icon, value); }
12 | private string? _Icon;
13 |
14 | ///
15 | /// 菜单名称
16 | ///
17 | public string? Title { get => _Title; set => SetProperty(ref _Title, value); }
18 | private string? _Title;
19 |
20 | ///
21 | /// 菜单命名空间
22 | ///
23 | public string? NameSpace { get => _NameSpace; set => SetProperty(ref _NameSpace, value); }
24 | private string? _NameSpace;
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/Wu.Wpf/Converters/ReverseBool.cs:
--------------------------------------------------------------------------------
1 | namespace Wu.Wpf.Converters;
2 |
3 | ///
4 | /// Bool反转
5 | ///
6 | public class ReverseBool : ValueConverterBase
7 | {
8 | public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
9 | {
10 | if (value == null)
11 | return true;
12 | bool b = System.Convert.ToBoolean(value);
13 | return !b;
14 | }
15 |
16 | //public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
17 | //{
18 | // if (value == null)
19 | // return true;
20 | // bool b = System.Convert.ToBoolean(value);
21 | // return !b;
22 | //}
23 | }
24 |
--------------------------------------------------------------------------------
/Wu.Wpf/Converters/MergeText.cs:
--------------------------------------------------------------------------------
1 | namespace Wu.Wpf.Converters;
2 |
3 | ///
4 | /// 合并文本
5 | ///
6 | public class MergeText : MultiValueConverterBase
7 | {
8 | public override object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
9 | {
10 | if (values == null || values.Length == 0)
11 | {
12 | return string.Empty;
13 | }
14 |
15 | string re = string.Empty;
16 | foreach (var item in values)
17 | {
18 | string str = System.Convert.ToString(item, CultureInfo.InvariantCulture) ?? string.Empty;
19 | if (!string.IsNullOrEmpty(str))
20 | re += str;
21 | }
22 | return re;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Test.App/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 |
16 | namespace Test.App
17 | {
18 | ///
19 | /// Interaction logic for MainWindow.xaml
20 | ///
21 | public partial class MainWindow : Window
22 | {
23 | public MainWindow()
24 | {
25 | InitializeComponent();
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Wu.Wpf/GlobalUsings.cs:
--------------------------------------------------------------------------------
1 | global using MaterialDesignThemes.Wpf;
2 | global using Prism.Commands;
3 | global using Prism.Events;
4 | global using Prism.Ioc;
5 | global using Prism.Mvvm;
6 | global using Prism.Regions;
7 | global using Prism.Services.Dialogs;
8 | global using System;
9 | global using System.ComponentModel;
10 | global using System.Globalization;
11 | global using System.Reflection;
12 | global using System.Threading.Tasks;
13 | global using System.Windows;
14 | global using System.Windows.Data;
15 | global using System.Windows.Markup;
16 | global using Wu.Wpf.Common;
17 | global using Wu.Wpf.Events;
18 | global using Wu.Wpf.Extensions;
19 | global using Wu.Wpf.Converters;
20 | global using CommunityToolkit.Mvvm.ComponentModel;
21 | global using CommunityToolkit.Mvvm.Input;
22 |
--------------------------------------------------------------------------------
/Wu.Wpf.ControlLibrary/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 | using System.Windows.Markup;
3 |
4 | [assembly: ThemeInfo(
5 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
6 | //(used if a resource is not found in the page,
7 | // or application resource dictionaries)
8 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
9 | //(used if a resource is not found in the page,
10 | // app, or any theme specific resource dictionaries)
11 | )]
12 |
13 | [assembly: XmlnsDefinition("https://github.com/Monika1313/Wu", "Wu.Wpf.ControlLibrary")]
14 | [assembly: XmlnsPrefix("https://github.com/Monika1313/Wu", "wu")]
15 |
--------------------------------------------------------------------------------
/Wu.Wpf/Converters/CnYesNo2Bool.cs:
--------------------------------------------------------------------------------
1 | namespace Wu.Wpf.Converters;
2 |
3 | ///
4 | /// 中文 是/否 转换为 true false
5 | ///
6 | public class CnYesNo2Bool : ValueConverterBase
7 | {
8 | public override object? Convert(object value, Type targetType, object parameter, CultureInfo culture)
9 | {
10 | if (value == null || string.IsNullOrWhiteSpace(value?.ToString()))
11 | return null;
12 | if (value is string)
13 | {
14 | if (value.Equals("是"))
15 | return true;
16 | }
17 | return false;
18 | }
19 |
20 | public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
21 | {
22 | if (value is bool val && val == true)
23 | {
24 | return "是";
25 | }
26 | return "否";
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Wu.CodeSnippets/componentbase.snippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | componentbase
6 | componentbase
7 |
8 | Wu
9 |
10 | Expansion
11 |
12 |
13 |
14 |
15 |
16 |
17 | Microsoft.AspNetCore.Components
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Wu/Extensions/Judge/StringJudge.cs:
--------------------------------------------------------------------------------
1 | namespace Wu.Extensions.Judge;
2 |
3 | ///
4 | /// 字符串判断
5 | ///
6 | public static class StringJudge
7 | {
8 | ///
9 | /// 使用正则表达式验证字符串是否为IP
10 | ///
11 | ///
12 | ///
13 | public static bool IsIp(this string ip)
14 | {
15 | if (string.IsNullOrWhiteSpace(ip))
16 | return false;
17 | ip = ip.Trim();
18 | //200-249或250-255或0-199点 匹配3次 最后0-255
19 | return Regex.IsMatch(ip, @"^((2[0-4]\d|25[0-5]|[1]?\d?\d)\.){3}(2[0-4]\d|25[0-5]|[1]?\d\d?)$");
20 | }
21 |
22 | ///
23 | /// 判断字符串是否包含中文
24 | ///
25 | ///
26 | ///
27 | public static bool IsHasChinese(this string str)
28 | {
29 | return Regex.IsMatch(str, @"[\u4e00-\u9fa5]");
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Wu.Wpf.ControlLibrary/Wu.Wpf.ControlLibrary.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0-windows;net7.0-windows;net48
5 | latestMajor
6 | enable
7 | true
8 | True
9 | Wu.Wpf.ControlLibrary
10 | 1.0.1
11 | Monika1313
12 | Wpf用户控件库
13 | https://github.com/Monika1313/Wu
14 | logo.png
15 | https://github.com/Monika1313/Wu
16 | git
17 |
18 |
19 |
20 |
21 | True
22 | \
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Wu/Utils/IoUtil.cs:
--------------------------------------------------------------------------------
1 | namespace Wu.Utils;
2 |
3 | ///
4 | /// IO操作
5 | ///
6 | public class IoUtil
7 | {
8 | /////
9 | ///// 根据文件路径返回文件夹目录
10 | /////
11 | /////
12 | /////
13 | //public static string GetDict(string path)
14 | //{
15 | // //var x = path.Split('\\');
16 | // //string
17 | // return "";
18 | //}
19 |
20 | ///
21 | /// 文件目录是否存在
22 | ///
23 | ///
24 | ///
25 | public static bool Exists(string dict)
26 | {
27 | if (Directory.Exists(dict)) //目录存在返回true
28 | return true;
29 | else //目录不存在创建目录 并返回false
30 | {
31 | Directory.CreateDirectory(dict);
32 | return false;
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Wu.Wpf/Models/OpenDrawers.cs:
--------------------------------------------------------------------------------
1 | namespace Wu.Wpf.Models;
2 |
3 | ///
4 | /// 打开抽屉
5 | ///
6 | public class OpenDrawers : BindableBase
7 | {
8 | ///
9 | /// 左侧抽屉
10 | ///
11 | public bool LeftDrawer { get => _LeftDrawer; set => SetProperty(ref _LeftDrawer, value); }
12 | private bool _LeftDrawer;
13 |
14 | ///
15 | /// 右侧抽屉
16 | ///
17 | public bool RightDrawer { get => _RightDrawer; set => SetProperty(ref _RightDrawer, value); }
18 | private bool _RightDrawer;
19 |
20 | ///
21 | /// 上端抽屉
22 | ///
23 | public bool TopDrawer { get => _TopDrawer; set => SetProperty(ref _TopDrawer, value); }
24 | private bool _TopDrawer;
25 |
26 | ///
27 | /// 底部抽屉
28 | ///
29 | public bool BottomDrawer { get => _BottomDrawer; set => SetProperty(ref _BottomDrawer, value); }
30 | private bool _BottomDrawer;
31 | }
32 |
--------------------------------------------------------------------------------
/Wu/FzWater/Mqtt/DataType.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Wu.FzWater.Mqtt
8 | {
9 | ///
10 | /// 数据的类型
11 | ///
12 | enum DataType : byte
13 | {
14 | @bool = 0x00, //
15 | signedChar = 0x01, //
16 | unsignedChar = 0x02, //
17 | signedShort = 0x03, //
18 | unsignedShort = 0x04, //
19 | signedInt = 0x05, //
20 | unsignedInt = 0x06, //
21 | signedLong = 0x07, //
22 | unsignedLong = 0x08, //
23 | @float = 0x09, //
24 | @double = 0x0A, //
25 | datetime = 0x0B, //
26 | asciiString = 0x0C, //
27 | byteArray = 0x0D //
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Wu/FzWater/Mqtt/Data.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Wu.FzWater.Mqtt
8 | {
9 | ///
10 | /// 数据帧中的消息体的单个数据
11 | ///
12 | public class Data
13 | {
14 | public byte Addr { get; set; } //设备地址
15 | public byte Chanel { get; set; } //通道号
16 | public byte Tag { get; set; } //Tag
17 | public byte Type { get; set; } //数据类型
18 | public int DecimalDigits { get; set; } //小数位数
19 | public dynamic OriginValue { get; set; } //原始数值
20 | public dynamic Value { get; set; } //值 该值由原始数值 根据数据类型和小数位数进行转换
21 | public bool IsBatch { get; set; } //是否批量处理
22 |
23 | public override string ToString() => $"设备地址: {Addr} 通道号: {Chanel} Tag: {Tag.ToString("x").PadLeft(2, '0')} {(Tag)Tag} 值: {Value} "; /*数据类型:{(DataType)Type}; 小数位:{DecimalDigits}; */
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Wu/MathPro/Range.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 |
3 | namespace Wu.MathPro;
4 |
5 | ///
6 | /// 数据范围定义
7 | ///
8 | [TypeConverter(typeof(RangeConverter))]
9 | public class Range
10 | {
11 | ///
12 | /// 起始值
13 | ///
14 | public double From { get; set; }
15 | ///
16 | /// 终止值
17 | ///
18 | public double To { get; set; }
19 | ///
20 | /// 最大值
21 | ///
22 | public double Max => Math.Max(From, To);
23 | ///
24 | /// 最小值
25 | ///
26 | public double Min => Math.Min(From, To);
27 | ///
28 | /// 差值
29 | ///
30 | public double Distance => Math.Abs(Max - Min);
31 |
32 |
33 | ///
34 | /// 默认构造函数
35 | ///
36 | public Range() { }
37 |
38 | public Range(double from, double to)
39 | {
40 | From = from;
41 | To = to;
42 | }
43 |
44 | public override string ToString()
45 | {
46 | return $"{From},{To}";
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/Wu.EntityFrameworkCore/UnitOfWork/IRepositoryFactory.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------
2 | //
3 | // Copyright (c) Arch team. All rights reserved.
4 | //
5 | //-----------------------------------------------------------------------
6 |
7 | namespace Wu.EntityFrameworkCore.UnitOfWork
8 | {
9 | ///
10 | /// Defines the interfaces for interfaces.
11 | ///
12 | public interface IRepositoryFactory
13 | {
14 | ///
15 | /// Gets the specified repository for the .
16 | ///
17 | /// True if providing custom repositry
18 | /// The type of the entity.
19 | /// An instance of type inherited from interface.
20 | IRepository GetRepository(bool hasCustomRepository = false) where TEntity : class;
21 | }
22 | }
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Monika1313
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Wu.Wpf/Models/Paping.cs:
--------------------------------------------------------------------------------
1 | namespace Wu.Wpf.Models;
2 |
3 | ///
4 | /// 分页设置
5 | ///
6 | public class Paping : BindableBase
7 | {
8 | ///
9 | /// 页码
10 | ///
11 | public int PageIndex { get => _PageIndex; set => SetProperty(ref _PageIndex, value); }
12 | private int _PageIndex = 1;
13 |
14 | ///
15 | /// 最大页数
16 | ///
17 | public int MaxPageCount { get => _MaxPageCount; set => SetProperty(ref _MaxPageCount, value); }
18 | private int _MaxPageCount = 1;
19 |
20 | ///
21 | /// 当前选中的按钮距离左右两个方向按钮的最大间隔(4表示间隔4个按钮,如果超过则用省略号表示)
22 | ///
23 | public int MaxPageInterval { get => _MaxPageInterval; set => SetProperty(ref _MaxPageInterval, value); }
24 | private int _MaxPageInterval = 5;
25 |
26 | ///
27 | /// 每页数据数量
28 | ///
29 | public int DataCountPerPage { get => _DataCountPerPage; set => SetProperty(ref _DataCountPerPage, value); }
30 | private int _DataCountPerPage = 100;
31 |
32 | ///
33 | /// 总数据量
34 | ///
35 | public int DataCount { get => _DataCount; set => SetProperty(ref _DataCount, value); }
36 | private int _DataCount = 0;
37 | }
38 |
--------------------------------------------------------------------------------
/Wu.Wpf/Wu.Wpf.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net48;net6.0-windows;net7.0-windows
5 | 10.0
6 | enable
7 | true
8 | True
9 | Monika1313
10 | Wu.Wpf类库
11 | 1.2.0
12 | Wu.Wpf
13 | logo.png
14 | https://github.com/Monika1313/Wu
15 | https://github.com/Monika1313/Wu
16 |
17 |
18 |
19 |
20 | True
21 | \
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/Wu/Extensions/Judge/CharJudge.cs:
--------------------------------------------------------------------------------
1 | namespace Wu.Extensions.Judge;
2 |
3 | public static class CharJudge
4 | {
5 | ///
6 | /// 判断是否为操作数
7 | ///
8 | ///
9 | ///
10 | public static bool IsDigit(this char self) => ".0123456789".Contains(self);
11 |
12 | ///
13 | /// 判断是否为运算符
14 | ///
15 | ///
16 | ///
17 | public static bool IsOperator(this char self) => "+-*/^".Contains(self);
18 |
19 | ///
20 | /// 判断是否为字母
21 | ///
22 | ///
23 | ///
24 | public static bool IsLetter(this char self) => 'a' <= self && self <= 'z' || 'A' <= self && self <= 'Z';
25 |
26 | ///
27 | /// 判断是否为做括号
28 | ///
29 | ///
30 | ///
31 | public static bool IsLeftBracket(this char self) => '(' == self;
32 |
33 | ///
34 | /// 判断是否为右括号
35 | ///
36 | ///
37 | ///
38 | public static bool IsRightBracket(this char self) => ')' == self;
39 | }
40 |
--------------------------------------------------------------------------------
/Wu/Wu.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net48;net6.0;net7.0
5 | latestMajor
6 | disable
7 | enable
8 | True
9 | Wu
10 | Monika1313
11 | Wu通用工具类
12 | 1.0.7
13 | https://github.com/Monika1313/Wu
14 | https://github.com/Monika1313/Wu
15 | logo.png
16 | False
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | True
28 | \
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/Wu.EntityFrameworkCore/UnitOfWork/IUnitOfWorkOfT.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Arch team. All rights reserved.
2 |
3 | using System.Threading.Tasks;
4 | using Microsoft.EntityFrameworkCore;
5 |
6 | namespace Wu.EntityFrameworkCore.UnitOfWork
7 | {
8 | ///
9 | /// Defines the interface(s) for generic unit of work.
10 | ///
11 | public interface IUnitOfWork : IUnitOfWork where TContext : DbContext {
12 | ///
13 | /// Gets the db context.
14 | ///
15 | /// The instance of type .
16 | TContext DbContext { get; }
17 |
18 | ///
19 | /// Saves all changes made in this context to the database with distributed transaction.
20 | ///
21 | /// True if save changes ensure auto record the change history.
22 | /// An optional array.
23 | /// A that represents the asynchronous save operation. The task result contains the number of state entities written to database.
24 | Task SaveChangesAsync(bool ensureAutoHistory = false, params IUnitOfWork[] unitOfWorks);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 1 Wu
2 | ## 1.1 Wu.Extensions
3 | 包含一些String、DateTime等的扩展方法
4 | ## 1.2 Wu.Utils
5 | 包含Crc校验等
6 |
7 |
8 | # 2 Wu.Wpf
9 | |名称|功能|
10 | |-|-|
11 | |IsUIThread|判断是否为UI线程|
12 | |ExecuteFun|在UI线程执行方法|
13 | |ExecuteFunBeginInvoke|在UI线程执行方法|
14 |
15 | ## 2.1 Wu.Wpf.Converters
16 | 转换器
17 | |名称|功能|
18 | |-|-|
19 | |ValueConverterBase|转换器基类|
20 | |ReverseBool|反转Bool|
21 | |False2Collapsed|False转换Collapsed|
22 | |True2Collapsed|True转换Collapsed|
23 | |Zero2Collapsed|0转换Collapsed|
24 | |NonZero2Collapsed|非零转换Collapsed|
25 | |StringIsNullOrWhiteSpace2Collapsed|空字符转换Collapsed|
26 | |StringIsNullOrWhiteSpace2True|空字符转换True|
27 | |EnumDescriptionTypeConverter|使枚举绑定值改为Description|
28 | |[EnumBindingSourceExtension](https://github.com/Monika1313/Wu/blob/master/Wu.Wpf/Converters/EnumBindingSourceExtension.cs)|使枚举支持直接绑定|
29 | |MergeText|合并多段文本|
30 |
31 |
32 | ## Wu.Wpf.Extensions
33 | 扩展方法
34 | |名称|功能|
35 | |-|-|
36 | |PasswordExtensions|使Password支持绑定|
37 | |ScrollViewerExtensions|使ScrollViewer自动移动到最下方|
38 | |TextBoxExtensions|使TextBox支持获取焦点时全选|
39 |
40 |
41 | # Wu.CodeSnippets
42 | 包含一些CodeSnippet代码段
43 |
44 | |名称|功能|
45 | |-|-|
46 | |bindablebase|继承Prism.Mvvm.BindableBase基类|
47 | |propr|声明带属性通知的属性|
48 | |propdf|声明依赖属性|
49 | |propdfb|声明依赖属性带回调|
50 | |realizeINotifyPropertyChanged|继承并实现INotifyPropertyChanged接口|
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/Wu.Wpf.ControlLibrary/ShapeControls/RegularHexagonCtrl.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Wu.Wpf/Converters/EnumDescriptionTypeConverter.cs:
--------------------------------------------------------------------------------
1 | namespace Wu.Wpf.Converters;
2 |
3 | ///
4 | /// 使枚举绑定值改为Description
5 | /// 示例
6 | /// 在枚举类型添加该特性即可 [TypeConverter(typeof(EnumDescriptionTypeConverter))]
7 | /// 绑定参考EnumBindingSourceExtension.cs
8 | ///
9 | public class EnumDescriptionTypeConverter : EnumConverter
10 | {
11 | public EnumDescriptionTypeConverter(Type type) : base(type)
12 | {
13 | }
14 |
15 | public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
16 | {
17 | if (destinationType == typeof(string))
18 | {
19 | if (null != value)
20 | {
21 | FieldInfo fi = value.GetType().GetField(value.ToString());
22 |
23 | if (null != fi)
24 | {
25 | var attributes =
26 | (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);
27 |
28 | return ((attributes.Length > 0) && (!string.IsNullOrEmpty(attributes[0].Description)))
29 | ? attributes[0].Description
30 | : value.ToString();
31 | }
32 | }
33 |
34 | return string.Empty;
35 | }
36 | return base.ConvertTo(context, culture, value, destinationType);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/Wu.Wpf.ControlLibrary/ShapeControls/RegularPolygonCtrl.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Wu.Wpf/ViewModels/QuestionViewModel.cs:
--------------------------------------------------------------------------------
1 | namespace Wu.Wpf.ViewModels;
2 |
3 | ///
4 | /// 询问窗口 ViewModel
5 | ///
6 | public partial class QuestionViewModel : ObservableObject, IDialogHostAware
7 | {
8 | ///
9 | /// 标题
10 | ///
11 | [ObservableProperty]
12 | string title = string.Empty;
13 |
14 | ///
15 | /// 内容
16 | ///
17 | [ObservableProperty]
18 | string content = string.Empty;
19 |
20 | public string DialogHostName { get; set; } = "Root";
21 |
22 | public void OnDialogOpened(IDialogParameters parameters)
23 | {
24 | //接收参数
25 | if (parameters.ContainsKey(nameof(Title)))
26 | Title = parameters.GetValue(nameof(Title));
27 | if (parameters.ContainsKey(nameof(Content)))
28 | Content = parameters.GetValue(nameof(Content));
29 | }
30 |
31 | ///
32 | /// 取消
33 | ///
34 | [RelayCommand]
35 | private void Cancel()
36 | {
37 | //若窗口处于打开状态则关闭
38 | if (!DialogHost.IsDialogOpen(DialogHostName))
39 | return;
40 | DialogHost.Close(DialogHostName, new DialogResult(ButtonResult.No));
41 | }
42 |
43 | ///
44 | /// 保存
45 | ///
46 | [RelayCommand]
47 | private void Save()
48 | {
49 | if (!DialogHost.IsDialogOpen(DialogHostName))
50 | return;
51 | DialogParameters param = new();
52 | //关闭窗口,并返回参数
53 | DialogHost.Close(DialogHostName, new DialogResult(ButtonResult.OK, param));
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/Wu.Wpf/Converters/ValueConverterBase.cs:
--------------------------------------------------------------------------------
1 | namespace Wu.Wpf.Converters;
2 |
3 | ///
4 | /// ValueConverter继承该基类
5 | /// 用法示例: xaml引入该命名空间cvt Converter={cvt:转换器名称}
6 | ///
7 | /// 要实现转换的类型本身
8 | public abstract class ValueConverterBase : MarkupExtension, IValueConverter where T : class, new()
9 | {
10 | public abstract object Convert(object value, Type targetType, object parameter, CultureInfo culture);
11 |
12 | public virtual object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
13 | => throw new NotImplementedException();
14 |
15 | private static T _Instance = new();
16 |
17 | ///
18 | /// 在xmal中使用时,将自动获取到该方法
19 | ///
20 | ///
21 | ///
22 | public override object ProvideValue(IServiceProvider serviceProvider) => _Instance ??= new();
23 | }
24 |
25 | public abstract class MultiValueConverterBase : MarkupExtension, IMultiValueConverter where T : class, new()
26 | {
27 |
28 | private static T _Instance = new();
29 |
30 | ///
31 | /// 在xmal中使用时,将自动获取到该方法
32 | ///
33 | ///
34 | ///
35 | public override object ProvideValue(IServiceProvider serviceProvider) => _Instance ??= new();
36 |
37 | public abstract object Convert(object[] values, Type targetType, object parameter, CultureInfo culture);
38 |
39 | public virtual object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
40 | => throw new NotImplementedException();
41 | }
42 |
--------------------------------------------------------------------------------
/Wu.EntityFrameworkCore/UnitOfWork/Collections/IPagedList.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Arch team. All rights reserved.
2 |
3 | using System.Collections.Generic;
4 |
5 | namespace Wu.EntityFrameworkCore.UnitOfWork.Collections
6 | {
7 | ///
8 | /// Provides the interface(s) for paged list of any type.
9 | ///
10 | /// The type for paging.
11 | public interface IPagedList
12 | {
13 | ///
14 | /// Gets the index start value.
15 | ///
16 | /// The index start value.
17 | int IndexFrom { get; }
18 | ///
19 | /// Gets the page index (current).
20 | ///
21 | int PageIndex { get; }
22 | ///
23 | /// Gets the page size.
24 | ///
25 | int PageSize { get; }
26 | ///
27 | /// Gets the total count of the list of type
28 | ///
29 | int TotalCount { get; }
30 | ///
31 | /// Gets the total pages.
32 | ///
33 | int TotalPages { get; }
34 | ///
35 | /// Gets the current page items.
36 | ///
37 | IList Items { get; }
38 | ///
39 | /// Gets the has previous page.
40 | ///
41 | /// The has previous page.
42 | bool HasPreviousPage { get; }
43 |
44 | ///
45 | /// Gets the has next page.
46 | ///
47 | /// The has next page.
48 | bool HasNextPage { get; }
49 | }
50 |
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/Wu.Wpf/Utils.cs:
--------------------------------------------------------------------------------
1 | namespace Wu.Wpf;
2 |
3 | public static class Utils
4 | {
5 | ///
6 | /// 判断当前线程是否为UI线程
7 | ///
8 | ///
9 | public static bool IsUIThread()
10 | {
11 | var UiThreadId = Application.Current.Dispatcher.Thread.ManagedThreadId; //UI线程ID
12 | var currentThreadId = Environment.CurrentManagedThreadId; //当前线程
13 | //是UI线程
14 | if (UiThreadId.Equals(currentThreadId))
15 | return true;
16 | //不是UI线程
17 | return false;
18 | }
19 |
20 | ///
21 | /// 执行方法 无关UI线程和子线程
22 | ///
23 | /// 执行的方法
24 | public static void ExecuteFun(Action action)
25 | {
26 | //当前线程为主线程 直接执行
27 | if (IsUIThread()) { action(); }
28 | //当前线程为子线程 委托UI线程执行
29 | else { Application.Current.Dispatcher.Invoke(() => { action(); }); }
30 | }
31 |
32 | ///
33 | /// 执行方法 无关UI线程和子线程
34 | ///
35 | /// 执行的方法
36 | public static void ExecuteFunBeginInvoke(Action action)
37 | {
38 | //当前线程为主线程 直接执行
39 | if (IsUIThread()) { action(); }
40 | //当前线程为子线程 委托UI线程执行
41 | else { Application.Current.Dispatcher.BeginInvoke(() => { action(); }); }
42 | }
43 |
44 | ///
45 | /// 计时方法所用的时间 有些方法不支持计时
46 | ///
47 | ///
48 | public static double ElapsedTime(Action action)
49 | {
50 | System.Diagnostics.Stopwatch sw = new();
51 | sw.Start();
52 | action();
53 | sw.Stop();
54 | return sw.ElapsedMilliseconds;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/Wu.CodeSnippets/bindablebase.snippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 继承Prism.Mvvm.BindableBase基类
6 | bindablebase
7 | 继承Prism.Mvvm.BindableBase基类
8 | Wu
9 |
10 | Expansion
11 |
12 |
13 |
14 |
15 |
16 |
17 | Prism.Mvvm
18 |
19 |
20 |
21 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/Wu.EntityFrameworkCore/Wu.EntityFrameworkCore.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0
5 | enable
6 | enable
7 | True
8 | 1.0.2
9 | EFCore
10 | https://github.com/Monika1313/Wu
11 | logo.png
12 | https://github.com/Monika1313/Wu
13 | git
14 |
15 |
16 |
17 |
18 | True
19 | \
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 | all
30 | runtime; build; native; contentfiles; analyzers; buildtransitive
31 |
32 |
33 |
34 |
35 | all
36 | runtime; build; native; contentfiles; analyzers; buildtransitive
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/Wu/FzWater/Mqtt/Tag.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Wu.FzWater.Mqtt
8 | {
9 | ///
10 | /// 数据标签的含义
11 | ///
12 | public enum Tag : byte
13 | {
14 | TLV版本 = 0x00,
15 | 外设掉线警告 = 0x01,
16 | 设备心跳命令 = 0x02,
17 |
18 | 水源故障 = 0x09,
19 | PH值 = 0x17,
20 | 浊度 = 0x18,
21 | 余氯 = 0x19,
22 | 水位高度 = 0x1A,
23 | 蓄水池进水口压力 = 0x1B,
24 | 蓄水池出水口压力 = 0x1C,
25 | 管道流速 = 0x1D,
26 | 管道累计流量 = 0x1E,
27 |
28 | 环境温度 = 0x1F,
29 | 环境湿度 = 0x20,
30 | 环境噪音 = 0x21,
31 | 环境烟火感应 = 0x22,
32 | 环境积水状态 = 0x23,
33 | 门禁状态 = 0x24,
34 |
35 | A相温度 = 0x25,
36 | B相温度 = 0x26,
37 | C相温度 = 0x27,
38 | A相电流 = 0x28,
39 | B相电流 = 0x29,
40 | C相电流 = 0x2A,
41 | CT = 0x2B,
42 | PT = 0x2C,
43 | 频率 = 0x2D,
44 | 总有功功率 = 0x2E,
45 | 总无功功率 = 0x2F,
46 | 功率因数总和 = 0x30,
47 | 有功电度总和 = 0x31,
48 | 无功电度总和 = 0x32,
49 |
50 | 水表流量读数 = 0x33,
51 | 水表压力 = 0x34,
52 | 泵运行状态 = 0x35,
53 | 泵电压值Ua = 0x36,
54 | 泵电流值Ia = 0x37,
55 | 泵运行总有功功率 = 0x38,
56 | 泵运行频率 = 0x39,
57 | 泵工作温度 = 0x3A,
58 | 泵振动幅度 = 0x3B,
59 | 泵运行时间 = 0x3C,
60 | 泵谁流速 = 0x3D,
61 | 累积流量 = 0x3E,
62 | 泵进口压力 = 0x3F,
63 | 泵出口压力 = 0x40,
64 | 故障次数 = 0x41,
65 | 泵设定频率 = 0x42,
66 | 泵设定压力 = 0x43,
67 | 泵电压值Ub = 0x44,
68 | 泵电压值Uc = 0x45,
69 | 泵电流值Ib = 0x46,
70 | 泵电流值Ic = 0x47,
71 | 泵运行总无功功率 = 0x48,
72 | 泵运行总有功电能 = 0x49,
73 | 泵运行总无功电能 = 0x4A,
74 | 泵总有功因数 = 0x4B,
75 | 水质电导率 = 0x4C,
76 | 蓄水池管道设定压力 = 0x4D,
77 | 水质温度 = 0x4E,
78 | 蓄水池门状态 = 0x4F
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/Wu.Wpf/ViewModels/NavigationViewModel.cs:
--------------------------------------------------------------------------------
1 | namespace Wu.ViewModels;
2 |
3 | ///
4 | /// 窗口导航类
5 | ///
6 | public class NavigationViewModel : ObservableObject, INavigationAware
7 | {
8 | private readonly IContainerProvider provider;
9 | public readonly IEventAggregator aggregator;//事件聚合器
10 | public NavigationViewModel() { }
11 |
12 | public NavigationViewModel(IContainerProvider provider)
13 | {
14 | this.provider = provider;
15 | this.aggregator = provider.Resolve();
16 | }
17 |
18 | ///
19 | /// 是否可导航
20 | ///
21 | ///
22 | ///
23 | public virtual bool IsNavigationTarget(NavigationContext navigationContext)
24 | {
25 | return true;
26 | }
27 |
28 | ///
29 | /// 导航自该窗口时触发
30 | ///
31 | ///
32 | public virtual void OnNavigatedFrom(NavigationContext navigationContext)
33 | {
34 |
35 | }
36 |
37 | ///
38 | /// 导航至该窗口时触发
39 | ///
40 | ///
41 | public virtual void OnNavigatedTo(NavigationContext navigationContext)
42 | {
43 |
44 | }
45 |
46 | ///
47 | /// 打开等待窗口
48 | ///
49 | ///
50 | public void UpdateLoading(bool IsOpen)
51 | {
52 | aggregator.UpdateLoading(new UpdateModel()
53 | {
54 | IsOpen = IsOpen
55 | });
56 | }
57 |
58 | ///
59 | /// 打开等待窗口 默认发送至主窗口
60 | ///
61 | ///
62 | public void UpdateLoading(bool IsOpen, string filter = "Main")
63 | {
64 | aggregator.UpdateLoading(new UpdateModel()
65 | {
66 | IsOpen = IsOpen,
67 | Filter = filter
68 | });
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/Wu/MathPro/RangeConverter.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 | using System.Globalization;
3 |
4 | namespace Wu.MathPro;
5 |
6 | ///
7 | /// Range类型转换器
8 | ///
9 | public class RangeConverter : TypeConverter
10 | {
11 | public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
12 | {
13 | if (sourceType == typeof(string))
14 | return true;
15 | return base.CanConvertFrom(context, sourceType);
16 | }
17 |
18 | public override object ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value)
19 | {
20 | //去除字符串中的空格
21 | string spaceRemoved = value.ToString().Replace(" ", string.Empty);
22 | //分割成数组
23 | string[] splited = spaceRemoved.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
24 | if (splited.Length == 2)
25 | {
26 | return new Range(double.Parse(splited[0]), double.Parse(splited[1]));
27 | }
28 | //if (splited.Length == 2 && double.TryParse(splited[0], out double d0) && double.TryParse(splited[1], out double d1))
29 | //{
30 | // return new Range(d0, d1);
31 | // //return new Range(double.Parse(splited[0]), double.Parse(splited[1]));
32 | //}
33 | return base.ConvertFrom(context, culture, value);
34 |
35 | ///* 剔除空格 */
36 | //string spaceRemoved = value.ToString().Replace(" ", string.Empty);
37 |
38 | ///* 逗号分隔 */
39 | //string[] splited = spaceRemoved.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
40 |
41 | //var strs = splited;
42 |
43 | //double d0, d1;
44 | //if (strs.Length == 2
45 | // && double.TryParse(strs[0], out d0)
46 | // && double.TryParse(strs[1], out d1))
47 | //{
48 | // return new Range { From = d0, To = d1 };
49 | //}
50 | //return base.ConvertFrom(context, culture, value);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/Wu.Wpf/Converters/EnumBindingSourceExtension.cs:
--------------------------------------------------------------------------------
1 | namespace Wu.Wpf.Converters;
2 |
3 | ///
4 | /// 绑定枚举列表
5 | ///
6 | ///
7 | /// 示例
8 | /// 1 xaml添加引用 xmlns:wucvt="clr-namespace:Wu.Wpf.Converters;assembly=Wu.Wpf"
9 | /// 2 同时要添加枚举类的引用 xmlns:enums="该处根据实际设置"
10 | /// 3 在需要绑定的地方如此绑定
11 | ///
12 | public class EnumBindingSourceExtension : MarkupExtension
13 | {
14 | private Type _enumType;
15 |
16 | public Type EnumType
17 | {
18 | get { return _enumType; }
19 | set
20 | {
21 | if (value != _enumType)
22 | {
23 | if (null != value)
24 | {
25 | var enumType = Nullable.GetUnderlyingType(value) ?? value;
26 | if (!enumType.IsEnum)
27 | {
28 | throw new ArgumentException("Type must bu for an Enum");
29 | }
30 |
31 | }
32 |
33 | _enumType = value;
34 | }
35 | }
36 | }
37 |
38 | public EnumBindingSourceExtension()
39 | {
40 |
41 | }
42 |
43 | public EnumBindingSourceExtension(Type enumType)
44 | {
45 | EnumType = enumType;
46 | }
47 | public override object ProvideValue(IServiceProvider serviceProvider)
48 | {
49 | if (null == _enumType)
50 | {
51 | throw new InvalidOperationException("The EnumTYpe must be specified.");
52 | }
53 |
54 | var actualEnumType = Nullable.GetUnderlyingType(_enumType) ?? _enumType;
55 | var enumValues = Enum.GetValues(actualEnumType);
56 |
57 | if (actualEnumType == _enumType)
58 | {
59 | return enumValues;
60 | }
61 |
62 | var tempArray = Array.CreateInstance(actualEnumType, enumValues.Length + 1);
63 | enumValues.CopyTo(tempArray, 1);
64 |
65 | return tempArray;
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/Wu.Wpf/Common/DialogHostService.cs:
--------------------------------------------------------------------------------
1 | namespace Wu.Wpf.Common;
2 |
3 | ///
4 | /// 自定义对话主机服务
5 | ///
6 | public class DialogHostService : DialogService, IDialogHostService
7 | {
8 | private readonly IContainerExtension containerExtension;
9 |
10 | public DialogHostService(IContainerExtension containerExtension) : base(containerExtension)
11 | {
12 | this.containerExtension = containerExtension;
13 | }
14 |
15 | public async Task ShowDialog(string name, IDialogParameters parameters, string dialogHostName = "Root")
16 | {
17 | if (parameters == null)
18 | parameters = new DialogParameters();
19 |
20 | //从容器中取出弹出窗口的实例
21 | var content = containerExtension.Resolve