Compare commits

..

150 Commits

Author SHA1 Message Date
Sunny
42a042beb3 * UIDataGridView: 修复数据更新时是否自动滚动到最后一行 2025-04-21 22:54:29 +08:00
Sunny
123427892e * UITabControl: 更新部分注释 2025-04-21 22:15:14 +08:00
Sunny
0b7f218b3c * UITabControl: 修复不可关闭的主页被关闭了 #IC1XIU 2025-04-17 22:20:30 +08:00
Sunny
c5e5a11188 * UINavMenu: 增加节点文字居中的属性 2025-04-17 13:48:50 +08:00
Sunny
8bf338e488 3.8.3 2025-04-06 20:20:28 +08:00
Sunny
0d989a75ea * EnumEx: DisplayText特性改为原生的Description特性 2025-04-06 16:42:44 +08:00
Sunny
00897c5cc5 * UIBreadcrumb: 增加SetItemColor,设置单个节点颜色,可以用RemoveItemColor移除 2025-04-03 23:24:27 +08:00
Sunny
cd04f9cf19 * UIDigitalLabel: 增加ShowText属性,可以显示文字 #IBY64V 2025-04-03 22:43:44 +08:00
Sunny
7fd73a8808 * UILedLabel: 重构显示位置,并增加Padding属性关联显示 2025-03-31 21:03:58 +08:00
Sunny
b9c87e15e8 * UIComboBox: 修复过滤下拉框跟随主题配色 2025-03-18 22:36:33 +08:00
Sunny
4f75336ed5 * 增加控件在工具箱说明文字 2025-03-18 22:12:54 +08:00
Sunny
8fce03fff2 * 增加控件在工具箱说明文字 2025-03-17 23:50:55 +08:00
Sunny
42c453820c * 更新一些控件的字体图标 2025-03-16 13:27:59 +08:00
Sunny
dc503f0eea * UIDoubleUpDown: 增加按钮字体图标的大小属性
* UIIntegerUpDown: 增加按钮字体图标的大小属性
2025-03-16 13:20:12 +08:00
Sunny
76426019e3 更新Demo 2025-03-09 21:17:23 +08:00
Sunny
f40426c113 V3.8.2 2025-03-09 20:55:59 +08:00
Sunny
28a1f1a451 * UIBarChart: 增加Y轴零度线偏移量,Option.ZeroLineOffset 2025-03-05 21:12:11 +08:00
Sunny
ec00734884 * UIBattery: 增加图标旋转角度,增加图标偏移位置,调整图标最大值 2025-03-04 21:18:52 +08:00
Sunny
282c1ae17c * UITabControl: 增加标签页分割线属性ShowTabDivider,#IBLERL 2025-02-13 10:45:17 +08:00
Sunny
76910ac4ff * UITabControlMenu: 修复切换主题色时,TabPage未设置背景色,#IBKDR7 2025-02-07 21:12:24 +08:00
Sunny
a07043ae07 * UITabControl: 修复切换主题色时,TabPage未设置背景色,#IBKDR7 2025-02-07 21:09:34 +08:00
Sunny
8decdf00cf * UIColorPicker: 增加手动输入ARGB值调色 #IBHL0H 2025-02-04 22:13:55 +08:00
Sunny
c451a61a66 更新Demo 2025-02-04 21:36:42 +08:00
Sunny
2c3022a322 + UIStatusBox: 增加根据状态显示图片控件 2025-01-18 17:33:21 +08:00
Sunny
b0093af77a * UIMenuButton: 更改属性描述 2025-01-15 17:49:06 +08:00
Sunny
8727038717 * UIForm: 修复窗体边框显示不全 #IBGJBS 2025-01-09 20:44:27 +08:00
Sunny
b9daa7e005 更新版本日期 2025-01-07 22:19:21 +08:00
Sunny
031be368e4 * UFontAwesomeV6: 更新为Font Awesome version: 6.7.2 2025-01-06 21:54:57 +08:00
Sunny
6a5d7bea2f 更新描述 2025-01-02 21:51:25 +08:00
Sunny
8a5f6ea7b0 更改描述 2025-01-02 21:47:14 +08:00
Sunny
36b7d41336 V3.8.1 2024-12-27 23:34:17 +08:00
Sunny
66fec152d4 V3.8.1 2024-12-27 22:28:21 +08:00
Sunny
1d60a09987 重构 2024-12-27 21:37:59 +08:00
Sunny
6b5d644bd9 重构 2024-12-27 21:28:27 +08:00
Sunny
b01e4e14e1 + UIMenuButton: 增加下拉菜单按钮 2024-12-26 21:35:08 +08:00
Sunny
5d9e0a6f53 + UIMenuButton: 增加下拉菜单按钮 2024-12-26 21:32:53 +08:00
Sunny
65a35f5bad 增加了两处翻译 2024-12-23 22:49:45 +08:00
Sunny
c0c3298fd1 * UITitlePanel: 增加Padding设置 #IBB1UF 2024-12-14 20:11:13 +08:00
Sunny
2c70e734c4 * UITabControl: 增加未选页签颜色 #IB7U69 2024-12-12 23:11:35 +08:00
Sunny
d0c731fe97 * UITabControl: 修复标签文字越界显示 #IB8571 2024-12-12 22:31:28 +08:00
Sunny
09ba37daa3 * UIVerificationCode: 可以自定义颜色 #IBABW1 2024-12-12 20:49:26 +08:00
Sunny
000c567255 * UIComboDataGridView: 修复一个报错 #IB8YK9 2024-12-04 21:40:44 +08:00
Sunny
beb21ebb91 * UICalendar: 切换语言实时刷新 2024-12-02 21:34:22 +08:00
Sunny
452e9e6e15 * UIScrollingText: 停止滚动时,可以设置默认显示位置 2024-12-02 21:25:39 +08:00
Sunny
120dbf2151 * UICheckBoxGroup: 修复TitleTop为0时,条目显示错位的问题 #IB7STO
* UIRadioButtonGroup: 修复TitleTop为0时,条目显示错位的问题 #IB7STO
2024-11-29 10:59:06 +08:00
Sunny
98d280d9f0 * UITabControl: 修复了SelectedIndex=-1时的报错 2024-11-29 09:35:54 +08:00
Sunny
f831a92cf7 * UIComboDataGridView: 解决下拉框显示过滤编辑框不能一直显示 #IB7AFB 2024-11-28 21:05:48 +08:00
Sunny
661b44090c 更新Demo 2024-11-27 22:50:09 +08:00
Sunny
741d10939a * UFontAwesomeV6: 更新为Font Awesome version: 6.7.1 2024-11-27 22:33:15 +08:00
Sunny
22677c9974 更新Demo 2024-11-19 23:08:47 +08:00
Sunny
9dbc2e80bd 3.8.0.1 2024-11-19 22:31:12 +08:00
Sunny
28cc5b3823 V3.8.0 2024-11-19 22:10:21 +08:00
Sunny
c6650b3c0e * UINotifier: 点击提示关闭,增加输出提示 2024-11-19 12:33:30 +08:00
Sunny
1708d57ef1 重构 2024-11-19 09:46:37 +08:00
Sunny
7e6ee8e98b * UIPanel: 增加透明度 2024-11-19 09:40:43 +08:00
Sunny
3c2ba689eb 更新 2024-11-15 10:30:17 +08:00
Sunny
4760de7dd1 * UILineChart: 增加了鼠标移上绘制十字线颜色 2024-11-14 10:17:21 +08:00
Sunny
c676e92fda * UILineChart: 增加了鼠标移上绘制十字线样式 2024-11-13 11:05:53 +08:00
Sunny
92607169d5 * UIComboDataGridView: 增加下拉框滚动条宽度调整属性 2024-11-12 15:03:45 +08:00
Sunny
e4c483dfeb * UINavBar: 增加StyleDropDown属性,手动修改Style时设置此属性以修改下拉框主题 2024-11-11 11:24:12 +08:00
Sunny
af41257d35 * UIComboBox: 增加StyleDropDown属性,手动修改Style时设置此属性以修改下拉框主题
* UIComboBox: 删除ScrollBarColor、ScrollBarBackColor、ScrollBarStyleInherited属性
* UIColorPicker:  增加StyleDropDown属性,手动修改Style时设置此属性以修改下拉框主题
* UIComboDataGridView: 增加StyleDropDown属性,手动修改Style时设置此属性以修改下拉框主题
* UIComboTreeView: 增加StyleDropDown属性,手动修改Style时设置此属性以修改下拉框主题
* UIDatePicker: 增加StyleDropDown属性,手动修改Style时设置此属性以修改下拉框主题
* UIDatetimePicker: 增加StyleDropDown属性,手动修改Style时设置此属性以修改下拉框主题
* UIDatePicker: 增加StyleDropDown属性,手动修改Style时设置此属性以修改下拉框主题
* UINumPadTextBox: 增加StyleDropDown属性,手动修改Style时设置此属性以修改下拉框主题
2024-11-10 22:43:32 +08:00
Sunny
76b13321e6 * UControl: UITreeView增加了一个刷新节点状态的扩展函数 2024-11-06 14:33:31 +08:00
Sunny
63952daa11 * UIScrollBar: 修复了一些重载事件 2024-11-04 14:00:21 +08:00
Sunny
b68740f828 重构 2024-11-03 23:24:23 +08:00
Sunny
45d2eed8b9 * UIPage: 增加标题栏图片属性IconImage,优先于Symbol 2024-10-30 21:46:30 +08:00
Sunny
ecc5d49b90 * UIBaseForm: IconImage增加IconImageSize属性,可调整大小 2024-10-29 22:55:52 +08:00
Sunny
88bce81140 * UIComboBox: 增加了SelectionChangeCommitted事件,下拉框显示鼠标点击条目时响应 2024-10-28 22:46:47 +08:00
Sunny
2d98153089 * UIBarChart: 增加了一个快捷的显示数据函数ShowData 2024-10-25 10:44:56 +08:00
Sunny
49c9419590 * UIDigitalLabel: 增加DPI支持 2024-10-22 21:05:30 +08:00
Sunny
e9ffd02edc V3.7.2 2024-10-06 21:31:18 +08:00
Sunny
a411027eb1 * UIBaseForm: 增加属性IconImage,以改善Icon转Image显示不佳,状态栏显示仍然用Icon属性 2024-10-05 22:11:46 +08:00
Sunny
e67f03d9da * 重构多语翻译类 2024-10-05 21:09:26 +08:00
Sunny
7af419a5c0 * 重构多语翻译类 2024-09-29 22:27:03 +08:00
Sunny
5f09fe5626 * 重构多语翻译类 2024-09-27 23:34:14 +08:00
Sunny
2daddaef65 * 重构多语翻译类 2024-09-26 23:33:08 +08:00
Sunny
7bdde150c2 增加示例说明 2024-09-24 22:22:18 +08:00
Sunny
ecc1433b37 更新文档 2024-09-24 22:08:38 +08:00
Sunny
2ae270d571 更新文档 2024-09-23 22:21:59 +08:00
Sunny
9a3320c10f 更新文档 2024-09-22 22:21:11 +08:00
Sunny
aec616b1cf 增加文档 2024-09-22 21:18:27 +08:00
Sunny
b3ef1e1288 更新忽略项 2024-09-22 21:18:14 +08:00
Sunny
f12bef2dd8 * 重构多语翻译类 2024-09-17 22:49:54 +08:00
Sunny
2c24db60d9 * 重构多语翻译类 2024-09-16 21:54:35 +08:00
Sunny
1ccaaad57c * 重构多语翻译类 2024-09-16 21:47:57 +08:00
Sunny
3a506824d1 * 多页面框架重构 2024-09-16 17:33:34 +08:00
Sunny
c0fbc85a76 * 重构多语翻译类 2024-09-14 22:05:03 +08:00
Sunny
98c7a8f81e * 重构多语翻译类 2024-09-13 23:43:27 +08:00
Sunny
fd053e6553 * 重构多语翻译类 2024-09-10 23:31:49 +08:00
Sunny
6543a103a4 * UICheckBoxGroup: 2024-09-09: V3.7.0 更改计算节点位置的方法,解决问题:#IAPY94
* UIRadioButtonGroup: 2024-09-09: V3.7.0 更改计算节点位置的方法,解决问题:#IAPY94
2024-09-09 15:47:06 +08:00
Sunny
7fb69265ee * UIDataGridView: 解决有隐藏行时,滚动条滚动时出错的问题 #IAOW3A 2024-09-04 21:33:52 +08:00
Sunny
d1957cb75c * UINumPadTextBox: 增加ShowDropDown()弹窗方法 2024-09-03 16:34:42 +08:00
Sunny
6794b58d65 * UIRadioButton: 修改AutoSize属性可以保存在Design.cs文件里面,#IAKYX4
* UICheckBox: 修改AutoSize属性可以保存在Design.cs文件里面,#IAKYX4
2024-08-30 21:18:08 +08:00
Sunny
4dd0a284ac * UIDatePicker: 修复格式化字符串包含/时显示错误
* UIDateTimePicker: 修复格式化字符串包含/时显示错误
2024-08-28 21:55:55 +08:00
Sunny
51c6da4833 * UIDataGridView: 增加属性AutoScrollToBottom,数据更新时是否自动滚动到最后一行 2024-08-27 14:14:36 +08:00
Sunny
c2b4db9fc7 * UIDoubleUpDown: 增加加按钮字体图标的偏移位置
* UIIntegerUpDown: 增加加按钮字体图标的偏移位置
2024-08-27 14:07:21 +08:00
Sunny
83446dfcce V3.7.0 2024-08-27 10:40:48 +08:00
Sunny
073c2dbf0b * UIIntegerUpDown: 修改编辑框字体与显示字体一致
* UIDoubleUpDown: 修改编辑框字体与显示字体一致
* UITextBox: AutoSize时根据字体自动调整控件高度
2024-08-27 10:12:05 +08:00
Sunny
fcb55cbae4 * UICheckBox: 修复AutoSize在文字改变时未自动显示的问题,#IAKYX4
* UIRadioButton: 修复AutoSize在文字改变时未自动显示的问题,#IAKYX4
2024-08-26 22:49:49 +08:00
Sunny
7cf009af36 * UITextBox: 修复微软雅黑字体显示不完整的问题 2024-08-26 22:30:41 +08:00
Sunny
d1613f40d2 * UIMessageBox: UIMessageBox增加了快捷调用UIMessageForm2的方法 2024-08-26 11:32:35 +08:00
Sunny
e8ac774e0d * UIMessageBox: 修复一个Bug 2024-08-26 10:57:48 +08:00
Sunny
f6a6d75d5f 3.6.9 2024-08-17 23:07:45 +08:00
Sunny
cc4e37d1c1
update README.md.
Signed-off-by: Sunny <yhuse@163.com>
2024-08-12 08:59:33 +00:00
Sunny
0fd93be25c * UIComboDataGridView: 修改下拉界面滚动条跟随主题
* UIComboTreeView: 修改下拉界面滚动条跟随主题
2024-08-12 16:42:43 +08:00
Sunny
f1543d9226 * UITextBox: 解决原生控件字体在微软雅黑时,显示不完整的问题 2024-08-12 16:31:42 +08:00
Sunny
c3f232baa0 + 增加应用公共类库 2024-08-12 15:06:58 +08:00
Sunny
f8b903b6ed * UIMessageForm2: 重构文字显示位置,重绘 2024-08-10 22:07:53 +08:00
Sunny
c328bb7f02 * 弹窗增加线程安全调用 2024-08-10 20:47:20 +08:00
Sunny
753d5b13d9 * UIFormHelper: 重构弹窗,窗体扩展打开默认以窗体居中,取消TopMost参数,默认为true 2024-08-09 23:58:38 +08:00
Sunny
089a624620 * UINavMenuHelper: 窗体移除时调用Close() 2024-08-07 15:11:29 +08:00
Sunny
c64bdddaf8 * 解决弹窗报错 2024-08-07 11:31:00 +08:00
Sunny
1317d552b5 * UITreeView: 不显示连线时,重绘节点前展开与收缩的图标 2024-08-06 20:13:39 +08:00
Sunny
f865be8731 * UIColorPicker: 增加ShowDropDown()函数 2024-08-05 14:48:00 +08:00
Sunny
47d1057945 * 重构公共类 2024-08-03 10:57:02 +08:00
Sunny
cfa40a5381 * UIEditForm: 代码生成增加文件选择和文件夹选择功能 2024-08-02 22:57:26 +08:00
Sunny
12359d1bb4 * UIFormHelper: 弹窗默认修改为以当前窗体居中,showMask=true或者centerParent=false时以屏幕居中 2024-07-30 17:50:33 +08:00
Sunny
073f4cb22c * UIForm: 最大化后,鼠标单击标题栏最上方,不恢复正常大小 2024-07-28 23:39:19 +08:00
Sunny
fcd8b00784 * UIForm: 修复鼠标点击事件
* UIForm2: 修复鼠标点击事件
2024-07-26 10:56:40 +08:00
Sunny
d06628903b * UIDateTimeItem: 修改单击选择日期后立即刷新,双击可选择并关闭下拉框 2024-07-25 21:37:10 +08:00
Sunny
f786f071f0 * UIComboDataGridView: 过滤字符串可以包含'*','[',']','%'字符 2024-07-23 16:47:28 +08:00
Sunny
855719997c * 修改国际化的Demo 2024-07-23 14:33:14 +08:00
Sunny
d4a6cc80cc * FMain: Demo增加注释 2024-07-21 21:31:41 +08:00
Sunny
bc393b226e * FMain: Demo增加注释 2024-07-21 21:30:25 +08:00
Sunny
bdaf058240 * UIForm2: 修改属性与UIForm兼容 2024-07-21 21:20:58 +08:00
Sunny
35ad7bc7a5 * UFontAwesomeV6: 更新为Font Awesome version: 6.6.0 2024-07-21 21:09:12 +08:00
Sunny
57534ad9c3 * UIForm: 修改为初始化最大化后恢复时界面尺寸大小正常 2024-07-21 20:56:10 +08:00
Sunny
abab088e0b * UIRichTextBox: 修改滚动条颜色跟随主题 2024-07-20 21:48:24 +08:00
Sunny
bac0f32fd2 * UIForm2: 修改最大化时按钮位置 2024-07-20 16:26:18 +08:00
Sunny
0f062f387d * UIForm: 最大化时,鼠标拖拽标题超过一定范围后再恢复Normal显示 2024-07-20 15:10:51 +08:00
Sunny
25f5fe5284 * UIForm2: 修改最大化时按钮位置 2024-07-20 14:55:24 +08:00
Sunny
c5bc2c04e0 3.6.8.1 2024-07-19 18:10:41 +08:00
Sunny
a0acf12632
update README.md.
Signed-off-by: Sunny <yhuse@163.com>
2024-07-19 02:53:36 +00:00
Sunny
7fc1010705
update README.md.
Signed-off-by: Sunny <yhuse@163.com>
2024-07-19 02:53:01 +00:00
Sunny
899f07a273
update README.md.
Signed-off-by: Sunny <yhuse@163.com>
2024-07-19 02:44:16 +00:00
Sunny
2120e496a6
update SunnyUI.Demo.exe.md.
Signed-off-by: Sunny <yhuse@163.com>
2024-07-19 02:41:53 +00:00
Sunny
e5d88c2b1f
add SunnyUI.Demo.exe.md.
Signed-off-by: Sunny <yhuse@163.com>
2024-07-19 02:40:51 +00:00
Sunny
30834dce34 3.6.8 2024-07-19 09:36:30 +08:00
Sunny
ff578a46cf 3.6.8 2024-07-19 09:36:22 +08:00
Sunny
de35afe1a7 更新 2024-07-18 22:36:19 +08:00
Sunny
3f2d4d542b * UIStyles: 增加了一个设置控件容器内子控件自定义主题色的方法 2024-07-17 16:21:19 +08:00
Sunny
41f23482cd * UIDateTimeItem: 修改时间界面水平分割线颜色和位置
* UITimeItem: 修改时间界面水平分割线颜色和位置
2024-07-14 20:17:42 +08:00
Sunny
17adb334bf * UIDatePicker: 修改选择日期在下拉框中显示方式
* UIDatetimePicker: 修改选择日期在下拉框中显示方式
2024-07-13 23:08:57 +08:00
Sunny
759f6f0901 * UIComboTreeView: 修改下拉框全选按钮跟随主题,修改一处内置国际化翻译 2024-07-13 22:26:04 +08:00
Sunny
1e03aed0a7 * UILabel: 文字位置默认TopLeft 2024-07-10 11:07:00 +08:00
Sunny
3333fe2aba * UILineChart: 增加了Y轴自定义坐标显示 2024-07-01 22:57:32 +08:00
Sunny
688ff477d1 * UFontAwesomeV6: 减小文件大小 2024-06-27 09:57:15 +08:00
Sunny
3f2bdd86e5 * UFontAwesomeV6: 更新为Font Awesome version: 6.5.2 2024-06-26 14:20:40 +08:00
Sunny
48afcf2305 * UIDataGridView: 增加AddDateTimeColumn,解决默认时间列不显示秒数的问题 2024-06-19 21:38:34 +08:00
Sunny
91d6601d52 - FastLZ: 删除FastLZ类,源码见:https://gitee.com/yhuse/SunnyUI/blob/V3.6.7/SunnyUI/Common/UFastLZ.cs
可参考项目: https://www.nuget.org/packages/DotFastLZ.Compression
2024-06-19 21:17:57 +08:00
Sunny
23ae9da234 * IniUTF8Config: 增加一种默认编码为UTF8的Ini配置文件读写类 2024-06-19 21:14:04 +08:00
456 changed files with 17078 additions and 8853 deletions

11
.gitignore vendored
View File

@ -25,6 +25,7 @@ x86/
bld/
[Oo]bj/
[Ll]og/
[Bb]in/
# Visual Studio 2015/2017 cache/options directory
.vs/
@ -346,3 +347,13 @@ healthchecksdb
/Bin/net40
/Bin/net7.0-windows
/Bin/net8.0-windows
/SunnyUI.Demo/Bin/SunnyUI.Common.dll
/SunnyUI.Demo/Bin/SunnyUI.Demo.exe
/SunnyUI.Demo/Bin/SunnyUI.Demo.exe.config
/SunnyUI.Demo/Bin/SunnyUI.dll
/docs/.vitepress/cache/deps
/run.bat
/package.json
/package-lock.json
/docs/markdown-examples.md
/docs/api-examples.md

View File

@ -2,13 +2,15 @@
[![star](https://gitee.com/yhuse/SunnyUI/badge/star.svg?theme=gvp)](https://gitee.com/yhuse/SunnyUI/stargazers)
[![fork](https://gitee.com/yhuse/SunnyUI/badge/fork.svg?theme=gvp)](https://gitee.com/yhuse/SunnyUI/members)
- 帮助文档: https://gitee.com/yhuse/SunnyUI/wikis/pages
- Gitee: https://gitee.com/yhuse/SunnyUI
- GitHub: https://github.com/yhuse/SunnyUI
- Nuget: https://www.nuget.org/packages/SunnyUI/
- Blog: https://www.cnblogs.com/yhuse
- 帮助文档: [https://gitee.com/yhuse/SunnyUI/wikis/pages](https://gitee.com/yhuse/SunnyUI/wikis/pages)
- 更新日志: [https://gitee.com/yhuse/SunnyUI/wikis/更新日志](https://gitee.com/yhuse/SunnyUI/wikis/%E6%9B%B4%E6%96%B0%E6%97%A5%E5%BF%97)
- Gitee: [https://gitee.com/yhuse/SunnyUI](https://gitee.com/yhuse/SunnyUI)
- GitHub: [https://github.com/yhuse/SunnyUI](https://github.com/yhuse/SunnyUI)
- Nuget: [https://www.nuget.org/packages/SunnyUI/](https://www.nuget.org/packages/SunnyUI/)
- Blog: [https://www.cnblogs.com/yhuse](https://www.cnblogs.com/yhuse)
- 因为评论没有查找不利于解决问题故关闭项目评论功能。如果是问题或者建议请按照Issues模版添加Issue。
- 添加Issue: [https://gitee.com/yhuse/SunnyUI/issues/new](https://gitee.com/yhuse/SunnyUI/issues/new)
- V3.6.8+Demo编译可执行文件: [https://gitee.com/yhuse/SunnyUI.Demo](https://gitee.com/yhuse/SunnyUI.Demo)
欢迎交流QQ群 56829229 (SunnyUI技术交流群)请给源码项目点个Star吧
**个人学习交流免费,商业应用需要授权**联系QQ**17612584** 咨询授权事宜。
@ -21,10 +23,11 @@ SunnyUI.Net项目已加入[dotNET China](https://gitee.com/dotnetchina) 组织
![dotnetchina](https://images.gitee.com/uploads/images/2021/0324/120117_2da9922c_416720.png "132645_21007ea0_974299.png")
#### 软件介绍
- SunnyUI.NET 是基于.NET Framework 4.0+、.NET6、.NET7、.NET8 框架的 C# WinForm 开源控件库、工具类库、扩展类库、多页面开发框架。
- SunnyUI.NET 是基于.Net Framework4.0+、.Net8、.Net9 框架的 C# WinForm 开源控件库、工具类库、扩展类库、多页面开发框架。
- 源码编译环境:
1. **VS2022 17.4**,安装.NetFramework4.0目标包的方法见https://www.cnblogs.com/yhuse/p/15536393.html
- 动态库应用环境: **VS2010**及以上均可,支持.Net Framework 4.0+、.Net 6、.Net7
1. **VS2022**,安装.NetFramework4.0目标包的方法见https://www.cnblogs.com/yhuse/p/15536393.html
2. 编译源码,.Net8需要VS2022 17.12+版本或者修改SunnyUI.csproj文件的TargetFrameworks属性以适应VS环境
- 动态库应用环境: **VS2010**及以上均可,支持.Net Framework4.0+、.Net8、.Net9
1. 推荐通过Nuget安装Install-Package SunnyUI或者通过Nuget搜索SunnyUI安装。
2. 不支持(.Net Framework 4 **Client Profile**)。

4
SunnyUI.Demo.exe.md Normal file
View File

@ -0,0 +1,4 @@
V3.6.8
此版本开始SunnyUI.Demo的生成的可执行文件不包含在SunnyUI项目中
如需要查看,请移步:[SunnyUI.Demo.exe](https://gitee.com/yhuse/SunnyUI.Demo)
或者用[VS2022 v17.8](https://learn.microsoft.com/en-us/visualstudio/releases/2022/release-notes-v17.8)版本编译源码,此版本开始支持.net8

Binary file not shown.

Binary file not shown.

View File

@ -1,3 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/></startup></configuration>

Binary file not shown.

View File

@ -18,6 +18,13 @@ namespace Sunny.UI.Demo
DateTime dt = new DateTime(2020, 10, 4);
UILineOption option = new UILineOption();
//设置图表边框空白部分尺寸
option.Grid.Left = 60;
option.Grid.Right = 60;
option.Grid.Top = 60;
option.Grid.Bottom = 60;
option.ToolTip.Visible = true;
option.Title = new UITitle();
option.Title.Text = "SunnyUI";
@ -40,6 +47,7 @@ namespace Sunny.UI.Demo
//数据点显示小数位数
series.YAxisDecimalPlaces = 2;
//增加曲线时可以设置曲线颜色例如Color.Lime
series = option.AddSeries(new UILineSeries("Line2", Color.Lime));
series.Add(dt.AddHours(3), 3.3);
series.Add(dt.AddHours(4), 2.3);
@ -116,6 +124,9 @@ namespace Sunny.UI.Demo
//设置曲线显示最大点数,超过后自动清理
series.SetMaxCount(50);
//设置曲线平滑
series.Smooth = true;
//坐标轴显示小数位数
option.XAxis.AxisLabel.DecimalPlaces = 1;
option.YAxis.AxisLabel.DecimalPlaces = 1;

View File

@ -196,7 +196,7 @@ namespace Sunny.UI.Demo
this.uiAvatar2.AvatarSize = 55;
this.uiAvatar2.Font = new System.Drawing.Font("宋体", 12F);
this.uiAvatar2.Icon = Sunny.UI.UIAvatar.UIIcon.Image;
this.uiAvatar2.Image = global::Sunny.UI.Demo.Properties.Resources.SunnyUISmall;
this.uiAvatar2.Image = global::Sunny.UI.Demo.Properties.Resources.SunnyUI72;
this.uiAvatar2.Location = new System.Drawing.Point(30, 85);
this.uiAvatar2.MinimumSize = new System.Drawing.Size(1, 1);
this.uiAvatar2.Name = "uiAvatar2";

View File

@ -84,10 +84,17 @@ namespace Sunny.UI.Demo
this.uiToolTip1 = new Sunny.UI.UIToolTip(this.components);
this.uiSwitch5 = new Sunny.UI.UISwitch();
this.uiSwitch6 = new Sunny.UI.UISwitch();
this.uiMenuButton1 = new Sunny.UI.UIMenuButton();
this.uiLine6 = new Sunny.UI.UILine();
this.uiContextMenuStrip1 = new Sunny.UI.UIContextMenuStrip();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)(this.uiImageButton4)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.uiImageButton3)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.uiImageButton2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.uiImageButton1)).BeginInit();
this.uiContextMenuStrip1.SuspendLayout();
this.SuspendLayout();
//
// uiSwitch3
@ -1004,11 +1011,69 @@ namespace Sunny.UI.Demo
this.uiSwitch6.TabIndex = 117;
this.uiSwitch6.Text = "uiSwitch6";
//
// uiMenuButton1
//
this.uiMenuButton1.Cursor = System.Windows.Forms.Cursors.Hand;
this.uiMenuButton1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiMenuButton1.Location = new System.Drawing.Point(30, 554);
this.uiMenuButton1.Menu = this.uiContextMenuStrip1;
this.uiMenuButton1.MinimumSize = new System.Drawing.Size(1, 1);
this.uiMenuButton1.Name = "uiMenuButton1";
this.uiMenuButton1.Size = new System.Drawing.Size(180, 35);
this.uiMenuButton1.Symbol = 361642;
this.uiMenuButton1.TabIndex = 118;
this.uiMenuButton1.Text = "下拉菜单按钮";
this.uiMenuButton1.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
//
// uiLine6
//
this.uiLine6.BackColor = System.Drawing.Color.Transparent;
this.uiLine6.Font = new System.Drawing.Font("宋体", 12F);
this.uiLine6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
this.uiLine6.Location = new System.Drawing.Point(30, 516);
this.uiLine6.MinimumSize = new System.Drawing.Size(16, 16);
this.uiLine6.Name = "uiLine6";
this.uiLine6.Size = new System.Drawing.Size(312, 20);
this.uiLine6.TabIndex = 119;
this.uiLine6.Text = "UIMenuButton";
this.uiLine6.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// uiContextMenuStrip1
//
this.uiContextMenuStrip1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(243)))), ((int)(((byte)(249)))), ((int)(((byte)(255)))));
this.uiContextMenuStrip1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiContextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.ToolStripMenuItem,
this.ToolStripMenuItem,
this.ToolStripMenuItem});
this.uiContextMenuStrip1.Name = "uiContextMenuStrip1";
this.uiContextMenuStrip1.Size = new System.Drawing.Size(123, 70);
//
// 菜单一ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "菜单一ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(122, 22);
this.ToolStripMenuItem.Text = "菜单一";
//
// 菜单二ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "菜单二ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(122, 22);
this.ToolStripMenuItem.Text = "菜单二";
//
// 菜单三ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "菜单三ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(122, 22);
this.ToolStripMenuItem.Text = "菜单三";
//
// FButton
//
this.AllowShowTitle = true;
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.ClientSize = new System.Drawing.Size(800, 614);
this.Controls.Add(this.uiLine6);
this.Controls.Add(this.uiMenuButton1);
this.Controls.Add(this.uiSymbolButton24);
this.Controls.Add(this.uiSwitch6);
this.Controls.Add(this.uiSwitch5);
@ -1072,6 +1137,7 @@ namespace Sunny.UI.Demo
((System.ComponentModel.ISupportInitialize)(this.uiImageButton3)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.uiImageButton2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.uiImageButton1)).EndInit();
this.uiContextMenuStrip1.ResumeLayout(false);
this.ResumeLayout(false);
}
@ -1132,5 +1198,11 @@ namespace Sunny.UI.Demo
private UIToolTip uiToolTip1;
private UISwitch uiSwitch5;
private UISwitch uiSwitch6;
private UIMenuButton uiMenuButton1;
private UILine uiLine6;
private UIContextMenuStrip uiContextMenuStrip1;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
}
}

View File

@ -120,4 +120,7 @@
<metadata name="uiToolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="uiContextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>133, 17</value>
</metadata>
</root>

View File

@ -30,54 +30,54 @@ namespace Sunny.UI.Demo
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Windows.Forms.TreeNode treeNode1 = new System.Windows.Forms.TreeNode("节点0");
System.Windows.Forms.TreeNode treeNode2 = new System.Windows.Forms.TreeNode("节点1");
System.Windows.Forms.TreeNode treeNode3 = new System.Windows.Forms.TreeNode("节点2");
System.Windows.Forms.TreeNode treeNode4 = new System.Windows.Forms.TreeNode("节点3");
System.Windows.Forms.TreeNode treeNode5 = new System.Windows.Forms.TreeNode("节点0", new System.Windows.Forms.TreeNode[] {
treeNode1,
treeNode2,
treeNode3,
treeNode4});
System.Windows.Forms.TreeNode treeNode6 = new System.Windows.Forms.TreeNode("节点4");
System.Windows.Forms.TreeNode treeNode7 = new System.Windows.Forms.TreeNode("节点5");
System.Windows.Forms.TreeNode treeNode8 = new System.Windows.Forms.TreeNode("节点6");
System.Windows.Forms.TreeNode treeNode9 = new System.Windows.Forms.TreeNode("节点7");
System.Windows.Forms.TreeNode treeNode10 = new System.Windows.Forms.TreeNode("节点1", new System.Windows.Forms.TreeNode[] {
treeNode6,
treeNode7,
treeNode8,
treeNode9});
System.Windows.Forms.TreeNode treeNode11 = new System.Windows.Forms.TreeNode("节点2");
System.Windows.Forms.TreeNode treeNode12 = new System.Windows.Forms.TreeNode("节点3");
System.Windows.Forms.TreeNode treeNode13 = new System.Windows.Forms.TreeNode("节点00");
System.Windows.Forms.TreeNode treeNode14 = new System.Windows.Forms.TreeNode("节点01");
System.Windows.Forms.TreeNode treeNode15 = new System.Windows.Forms.TreeNode("节点02");
System.Windows.Forms.TreeNode treeNode16 = new System.Windows.Forms.TreeNode("节点03");
System.Windows.Forms.TreeNode treeNode17 = new System.Windows.Forms.TreeNode("节点0", new System.Windows.Forms.TreeNode[] {
treeNode13,
treeNode14,
treeNode15,
treeNode16});
System.Windows.Forms.TreeNode treeNode18 = new System.Windows.Forms.TreeNode("节点11");
System.Windows.Forms.TreeNode treeNode19 = new System.Windows.Forms.TreeNode("节点12");
System.Windows.Forms.TreeNode treeNode20 = new System.Windows.Forms.TreeNode("节点13");
System.Windows.Forms.TreeNode treeNode21 = new System.Windows.Forms.TreeNode("节点14");
System.Windows.Forms.TreeNode treeNode22 = new System.Windows.Forms.TreeNode("节点1", new System.Windows.Forms.TreeNode[] {
treeNode18,
treeNode19,
treeNode20,
treeNode21});
System.Windows.Forms.TreeNode treeNode23 = new System.Windows.Forms.TreeNode("节点2");
System.Windows.Forms.TreeNode treeNode24 = new System.Windows.Forms.TreeNode("节点3");
System.Windows.Forms.TreeNode treeNode25 = new System.Windows.Forms.TreeNode("节点0");
System.Windows.Forms.TreeNode treeNode26 = new System.Windows.Forms.TreeNode("节点1");
System.Windows.Forms.TreeNode treeNode27 = new System.Windows.Forms.TreeNode("节点2");
System.Windows.Forms.TreeNode treeNode28 = new System.Windows.Forms.TreeNode("节点3");
System.Windows.Forms.TreeNode treeNode29 = new System.Windows.Forms.TreeNode("节点0");
System.Windows.Forms.TreeNode treeNode30 = new System.Windows.Forms.TreeNode("节点1");
System.Windows.Forms.TreeNode treeNode31 = new System.Windows.Forms.TreeNode("节点2");
System.Windows.Forms.TreeNode treeNode32 = new System.Windows.Forms.TreeNode("节点3");
System.Windows.Forms.TreeNode treeNode33 = new System.Windows.Forms.TreeNode("节点0");
System.Windows.Forms.TreeNode treeNode34 = new System.Windows.Forms.TreeNode("节点1");
System.Windows.Forms.TreeNode treeNode35 = new System.Windows.Forms.TreeNode("节点2");
System.Windows.Forms.TreeNode treeNode36 = new System.Windows.Forms.TreeNode("节点3");
System.Windows.Forms.TreeNode treeNode37 = new System.Windows.Forms.TreeNode("节点0", new System.Windows.Forms.TreeNode[] {
treeNode33,
treeNode34,
treeNode35,
treeNode36});
System.Windows.Forms.TreeNode treeNode38 = new System.Windows.Forms.TreeNode("节点4");
System.Windows.Forms.TreeNode treeNode39 = new System.Windows.Forms.TreeNode("节点5");
System.Windows.Forms.TreeNode treeNode40 = new System.Windows.Forms.TreeNode("节点6");
System.Windows.Forms.TreeNode treeNode41 = new System.Windows.Forms.TreeNode("节点7");
System.Windows.Forms.TreeNode treeNode42 = new System.Windows.Forms.TreeNode("节点1", new System.Windows.Forms.TreeNode[] {
treeNode38,
treeNode39,
treeNode40,
treeNode41});
System.Windows.Forms.TreeNode treeNode43 = new System.Windows.Forms.TreeNode("节点2");
System.Windows.Forms.TreeNode treeNode44 = new System.Windows.Forms.TreeNode("节点3");
System.Windows.Forms.TreeNode treeNode45 = new System.Windows.Forms.TreeNode("节点00");
System.Windows.Forms.TreeNode treeNode46 = new System.Windows.Forms.TreeNode("节点01");
System.Windows.Forms.TreeNode treeNode47 = new System.Windows.Forms.TreeNode("节点02");
System.Windows.Forms.TreeNode treeNode48 = new System.Windows.Forms.TreeNode("节点03");
System.Windows.Forms.TreeNode treeNode49 = new System.Windows.Forms.TreeNode("节点0", new System.Windows.Forms.TreeNode[] {
treeNode45,
treeNode46,
treeNode47,
treeNode48});
System.Windows.Forms.TreeNode treeNode50 = new System.Windows.Forms.TreeNode("节点11");
System.Windows.Forms.TreeNode treeNode51 = new System.Windows.Forms.TreeNode("节点12");
System.Windows.Forms.TreeNode treeNode52 = new System.Windows.Forms.TreeNode("节点13");
System.Windows.Forms.TreeNode treeNode53 = new System.Windows.Forms.TreeNode("节点14");
System.Windows.Forms.TreeNode treeNode54 = new System.Windows.Forms.TreeNode("节点1", new System.Windows.Forms.TreeNode[] {
treeNode50,
treeNode51,
treeNode52,
treeNode53});
System.Windows.Forms.TreeNode treeNode55 = new System.Windows.Forms.TreeNode("节点2");
System.Windows.Forms.TreeNode treeNode56 = new System.Windows.Forms.TreeNode("节点3");
System.Windows.Forms.TreeNode treeNode57 = new System.Windows.Forms.TreeNode("节点0");
System.Windows.Forms.TreeNode treeNode58 = new System.Windows.Forms.TreeNode("节点1");
System.Windows.Forms.TreeNode treeNode59 = new System.Windows.Forms.TreeNode("节点2");
System.Windows.Forms.TreeNode treeNode60 = new System.Windows.Forms.TreeNode("节点3");
System.Windows.Forms.TreeNode treeNode61 = new System.Windows.Forms.TreeNode("节点0");
System.Windows.Forms.TreeNode treeNode62 = new System.Windows.Forms.TreeNode("节点1");
System.Windows.Forms.TreeNode treeNode63 = new System.Windows.Forms.TreeNode("节点2");
System.Windows.Forms.TreeNode treeNode64 = new System.Windows.Forms.TreeNode("节点3");
this.uiComboTreeView3 = new Sunny.UI.UIComboTreeView();
this.uiComboTreeView4 = new Sunny.UI.UIComboTreeView();
this.uiComboTreeView2 = new Sunny.UI.UIComboTreeView();
@ -114,6 +114,7 @@ namespace Sunny.UI.Demo
this.uiDatetimePicker2 = new Sunny.UI.UIDatetimePicker();
this.uiTimePicker2 = new Sunny.UI.UITimePicker();
this.uiNumPadTextBox5 = new Sunny.UI.UINumPadTextBox();
this.uiDatePicker5 = new Sunny.UI.UIDatePicker();
this.SuspendLayout();
//
// uiComboTreeView3
@ -126,35 +127,35 @@ namespace Sunny.UI.Demo
this.uiComboTreeView3.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.uiComboTreeView3.MinimumSize = new System.Drawing.Size(63, 0);
this.uiComboTreeView3.Name = "uiComboTreeView3";
treeNode1.Name = "节点0";
treeNode1.Text = "节点0";
treeNode2.Name = "节点1";
treeNode2.Text = "节点1";
treeNode3.Name = "节点2";
treeNode3.Text = "节点2";
treeNode4.Name = "节点3";
treeNode4.Text = "节点3";
treeNode5.Name = "节点0";
treeNode5.Text = "节点0";
treeNode6.Name = "节点4";
treeNode6.Text = "节点4";
treeNode7.Name = "节点5";
treeNode7.Text = "节点5";
treeNode8.Name = "节点6";
treeNode8.Text = "节点6";
treeNode9.Name = "节点7";
treeNode9.Text = "节点7";
treeNode10.Name = "节点1";
treeNode10.Text = "节点1";
treeNode11.Name = "节点2";
treeNode11.Text = "节点2";
treeNode12.Name = "节点3";
treeNode12.Text = "节点3";
treeNode33.Name = "节点0";
treeNode33.Text = "节点0";
treeNode34.Name = "节点1";
treeNode34.Text = "节点1";
treeNode35.Name = "节点2";
treeNode35.Text = "节点2";
treeNode36.Name = "节点3";
treeNode36.Text = "节点3";
treeNode37.Name = "节点0";
treeNode37.Text = "节点0";
treeNode38.Name = "节点4";
treeNode38.Text = "节点4";
treeNode39.Name = "节点5";
treeNode39.Text = "节点5";
treeNode40.Name = "节点6";
treeNode40.Text = "节点6";
treeNode41.Name = "节点7";
treeNode41.Text = "节点7";
treeNode42.Name = "节点1";
treeNode42.Text = "节点1";
treeNode43.Name = "节点2";
treeNode43.Text = "节点2";
treeNode44.Name = "节点3";
treeNode44.Text = "节点3";
this.uiComboTreeView3.Nodes.AddRange(new System.Windows.Forms.TreeNode[] {
treeNode5,
treeNode10,
treeNode11,
treeNode12});
treeNode37,
treeNode42,
treeNode43,
treeNode44});
this.uiComboTreeView3.Padding = new System.Windows.Forms.Padding(0, 0, 30, 2);
this.uiComboTreeView3.ShowLines = true;
this.uiComboTreeView3.Size = new System.Drawing.Size(150, 29);
@ -172,35 +173,35 @@ namespace Sunny.UI.Demo
this.uiComboTreeView4.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.uiComboTreeView4.MinimumSize = new System.Drawing.Size(63, 0);
this.uiComboTreeView4.Name = "uiComboTreeView4";
treeNode13.Name = "节点0";
treeNode13.Text = "节点00";
treeNode14.Name = "节点1";
treeNode14.Text = "节点01";
treeNode15.Name = "节点2";
treeNode15.Text = "节点02";
treeNode16.Name = "节点3";
treeNode16.Text = "节点03";
treeNode17.Name = "节点0";
treeNode17.Text = "节点0";
treeNode18.Name = "节点4";
treeNode18.Text = "节点11";
treeNode19.Name = "节点5";
treeNode19.Text = "节点12";
treeNode20.Name = "节点6";
treeNode20.Text = "节点13";
treeNode21.Name = "节点7";
treeNode21.Text = "节点14";
treeNode22.Name = "节点1";
treeNode22.Text = "节点1";
treeNode23.Name = "节点2";
treeNode23.Text = "节点2";
treeNode24.Name = "节点3";
treeNode24.Text = "节点3";
treeNode45.Name = "节点0";
treeNode45.Text = "节点00";
treeNode46.Name = "节点1";
treeNode46.Text = "节点01";
treeNode47.Name = "节点2";
treeNode47.Text = "节点02";
treeNode48.Name = "节点3";
treeNode48.Text = "节点03";
treeNode49.Name = "节点0";
treeNode49.Text = "节点0";
treeNode50.Name = "节点4";
treeNode50.Text = "节点11";
treeNode51.Name = "节点5";
treeNode51.Text = "节点12";
treeNode52.Name = "节点6";
treeNode52.Text = "节点13";
treeNode53.Name = "节点7";
treeNode53.Text = "节点14";
treeNode54.Name = "节点1";
treeNode54.Text = "节点1";
treeNode55.Name = "节点2";
treeNode55.Text = "节点2";
treeNode56.Name = "节点3";
treeNode56.Text = "节点3";
this.uiComboTreeView4.Nodes.AddRange(new System.Windows.Forms.TreeNode[] {
treeNode17,
treeNode22,
treeNode23,
treeNode24});
treeNode49,
treeNode54,
treeNode55,
treeNode56});
this.uiComboTreeView4.Padding = new System.Windows.Forms.Padding(0, 0, 30, 2);
this.uiComboTreeView4.ShowLines = true;
this.uiComboTreeView4.Size = new System.Drawing.Size(150, 29);
@ -219,19 +220,19 @@ namespace Sunny.UI.Demo
this.uiComboTreeView2.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.uiComboTreeView2.MinimumSize = new System.Drawing.Size(63, 0);
this.uiComboTreeView2.Name = "uiComboTreeView2";
treeNode25.Name = "节点0";
treeNode25.Text = "节点0";
treeNode26.Name = "节点1";
treeNode26.Text = "节点1";
treeNode27.Name = "节点2";
treeNode27.Text = "节点2";
treeNode28.Name = "节点3";
treeNode28.Text = "节点3";
treeNode57.Name = "节点0";
treeNode57.Text = "节点0";
treeNode58.Name = "节点1";
treeNode58.Text = "节点1";
treeNode59.Name = "节点2";
treeNode59.Text = "节点2";
treeNode60.Name = "节点3";
treeNode60.Text = "节点3";
this.uiComboTreeView2.Nodes.AddRange(new System.Windows.Forms.TreeNode[] {
treeNode25,
treeNode26,
treeNode27,
treeNode28});
treeNode57,
treeNode58,
treeNode59,
treeNode60});
this.uiComboTreeView2.Padding = new System.Windows.Forms.Padding(0, 0, 30, 2);
this.uiComboTreeView2.Size = new System.Drawing.Size(150, 29);
this.uiComboTreeView2.SymbolSize = 24;
@ -262,19 +263,19 @@ namespace Sunny.UI.Demo
this.uiComboTreeView1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.uiComboTreeView1.MinimumSize = new System.Drawing.Size(63, 0);
this.uiComboTreeView1.Name = "uiComboTreeView1";
treeNode29.Name = "节点0";
treeNode29.Text = "节点0";
treeNode30.Name = "节点1";
treeNode30.Text = "节点1";
treeNode31.Name = "节点2";
treeNode31.Text = "节点2";
treeNode32.Name = "节点3";
treeNode32.Text = "节点3";
treeNode61.Name = "节点0";
treeNode61.Text = "节点0";
treeNode62.Name = "节点1";
treeNode62.Text = "节点1";
treeNode63.Name = "节点2";
treeNode63.Text = "节点2";
treeNode64.Name = "节点3";
treeNode64.Text = "节点3";
this.uiComboTreeView1.Nodes.AddRange(new System.Windows.Forms.TreeNode[] {
treeNode29,
treeNode30,
treeNode31,
treeNode32});
treeNode61,
treeNode62,
treeNode63,
treeNode64});
this.uiComboTreeView1.Padding = new System.Windows.Forms.Padding(0, 0, 30, 2);
this.uiComboTreeView1.Size = new System.Drawing.Size(150, 29);
this.uiComboTreeView1.SymbolSize = 24;
@ -855,11 +856,34 @@ namespace Sunny.UI.Demo
this.uiNumPadTextBox5.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
this.uiNumPadTextBox5.Watermark = "";
//
// uiDatePicker5
//
this.uiDatePicker5.CanEmpty = true;
this.uiDatePicker5.FillColor = System.Drawing.Color.White;
this.uiDatePicker5.Font = new System.Drawing.Font("宋体", 12F);
this.uiDatePicker5.Location = new System.Drawing.Point(188, 293);
this.uiDatePicker5.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.uiDatePicker5.MaxLength = 10;
this.uiDatePicker5.MinimumSize = new System.Drawing.Size(63, 0);
this.uiDatePicker5.Name = "uiDatePicker5";
this.uiDatePicker5.Padding = new System.Windows.Forms.Padding(0, 0, 30, 2);
this.uiDatePicker5.ShowToday = true;
this.uiDatePicker5.Size = new System.Drawing.Size(150, 29);
this.uiDatePicker5.SymbolDropDown = 61555;
this.uiDatePicker5.SymbolNormal = 61555;
this.uiDatePicker5.SymbolSize = 24;
this.uiDatePicker5.TabIndex = 90;
this.uiDatePicker5.Text = "2020-04-16";
this.uiDatePicker5.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
this.uiDatePicker5.Value = new System.DateTime(2020, 4, 16, 0, 0, 0, 0);
this.uiDatePicker5.Watermark = "";
//
// FCombobox
//
this.AllowShowTitle = true;
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.ClientSize = new System.Drawing.Size(765, 665);
this.Controls.Add(this.uiDatePicker5);
this.Controls.Add(this.uiNumPadTextBox5);
this.Controls.Add(this.uiTimePicker2);
this.Controls.Add(this.uiDatetimePicker2);
@ -900,6 +924,7 @@ namespace Sunny.UI.Demo
this.ShowTitle = true;
this.Symbol = 61776;
this.Text = "Combobox";
this.Shown += new System.EventHandler(this.FCombobox_Shown);
this.ResumeLayout(false);
}
@ -941,5 +966,6 @@ namespace Sunny.UI.Demo
private UIDatetimePicker uiDatetimePicker2;
private UITimePicker uiTimePicker2;
private UINumPadTextBox uiNumPadTextBox5;
private UIDatePicker uiDatePicker5;
}
}

View File

@ -40,8 +40,6 @@ namespace Sunny.UI.Demo
uiComboDataGridView1.DataGridView.AddColumn("数据列2", "Column2");
uiComboDataGridView1.DataGridView.AddColumn("数据列3", "Column3");
uiComboDataGridView1.DataGridView.ReadOnly = true;
uiComboDataGridView1.SelectIndexChange += UiComboDataGridView1_SelectIndexChange;
uiComboDataGridView1.ShowFilter = true;
uiComboDataGridView1.DataGridView.DataSource = dt;//用DataTable做数据源过滤用List不行
uiComboDataGridView1.FilterColumnName = "Column1;Column3"; //不设置则全部列过滤,可加分号过滤多列
@ -52,16 +50,11 @@ namespace Sunny.UI.Demo
uiComboDataGridView2.DataGridView.AddColumn("数据列2", "Column2");
uiComboDataGridView2.DataGridView.AddColumn("数据列3", "Column3");
uiComboDataGridView2.DataGridView.ReadOnly = true;
uiComboDataGridView2.ShowFilter = true;
uiComboDataGridView2.DataGridView.DataSource = dt;
uiComboDataGridView2.FilterColumnName = "Column1"; //不设置则全部列过滤
uiComboBox1.SetTipsText(uiToolTip1, "Hello World.");
//日期选择框文本设置为空
uiDatePicker3.CanEmpty = true;
uiDatePicker3.Text = "";
uiDatePicker4.Value = uiDatePicker1.Value = uiDatePicker2.Value = uiDatePicker3.Value = DateTime.Now.Date;
uiDatetimePicker2.Value = uiDatetimePicker1.Value = DateTime.Now;
uiTimePicker1.Value = uiTimePicker2.Value = DateTime.Now;
@ -156,7 +149,7 @@ namespace Sunny.UI.Demo
if (value != null && value is DataGridViewSelectedRowCollection)
{
DataGridViewSelectedRowCollection collection = (DataGridViewSelectedRowCollection)value;
foreach (var item in collection)
foreach (object item in collection)
{
DataGridViewRow row = (DataGridViewRow)item;
uiComboDataGridView2.Text += row.Cells[0].Value.ToString();//通过索引显示值
@ -169,5 +162,12 @@ namespace Sunny.UI.Demo
{
this.ShowInfoTip("Hello world.");
}
private void FCombobox_Shown(object sender, EventArgs e)
{
//日期选择框文本设置为空
uiDatePicker5.CanEmpty = true;
uiDatePicker5.Text = "";
}
}
}

View File

@ -12,7 +12,7 @@ namespace Sunny.UI.Demo
var styles = UIStyles.PopularStyles();
foreach (UIStyle style in styles)
{
ToolStripMenuItem item = new ToolStripMenuItem(style.DisplayText()) { Tag = style };
ToolStripMenuItem item = new ToolStripMenuItem(style.Description()) { Tag = style };
item.Click += Item_Click;
uiContextMenuStrip1.Items.Add(item);
}

View File

@ -67,7 +67,9 @@ namespace Sunny.UI.Demo
//
// uiLine1
//
this.uiLine1.BackColor = System.Drawing.Color.Transparent;
this.uiLine1.Font = new System.Drawing.Font("宋体", 12F);
this.uiLine1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
this.uiLine1.Location = new System.Drawing.Point(30, 55);
this.uiLine1.MinimumSize = new System.Drawing.Size(16, 16);
this.uiLine1.Name = "uiLine1";
@ -75,7 +77,6 @@ namespace Sunny.UI.Demo
this.uiLine1.TabIndex = 21;
this.uiLine1.Text = "UITreeView";
this.uiLine1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.uiLine1.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
//
// uiTreeView1
//
@ -138,13 +139,12 @@ namespace Sunny.UI.Demo
treeNode15,
treeNode16,
treeNode20});
this.uiTreeView1.ShowLines = true;
this.uiTreeView1.ScrollBarStyleInherited = false;
this.uiTreeView1.ShowText = false;
this.uiTreeView1.Size = new System.Drawing.Size(266, 313);
this.uiTreeView1.TabIndex = 20;
this.uiTreeView1.Text = null;
this.uiTreeView1.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
this.uiTreeView1.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
//
// FTreeView
//

View File

@ -31,8 +31,12 @@
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FMain));
this.uiContextMenuStrip1 = new Sunny.UI.UIContextMenuStrip();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.NHome = new System.Windows.Forms.ToolStripMenuItem();
this.NAbout = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
this.NZhCN = new System.Windows.Forms.ToolStripMenuItem();
this.NZhTW = new System.Windows.Forms.ToolStripMenuItem();
this.NEnUS = new System.Windows.Forms.ToolStripMenuItem();
this.StyleManager = new Sunny.UI.UIStyleManager(this.components);
this.uiNavBar1 = new Sunny.UI.UINavBar();
this.uiAvatar1 = new Sunny.UI.UIAvatar();
@ -52,32 +56,63 @@
// uiContextMenuStrip1
//
this.uiContextMenuStrip1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(243)))), ((int)(((byte)(249)))), ((int)(((byte)(255)))));
this.uiContextMenuStrip1.Font = new System.Drawing.Font("宋体", 12F);
this.uiContextMenuStrip1.Font = new System.Drawing.Font("Tahoma", 12F);
this.uiContextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.ToolStripMenuItem,
this.ToolStripMenuItem1});
this.NHome,
this.NAbout,
this.toolStripMenuItem1,
this.NZhCN,
this.NZhTW,
this.NEnUS});
this.uiContextMenuStrip1.Name = "uiContextMenuStrip1";
this.uiContextMenuStrip1.Size = new System.Drawing.Size(107, 48);
this.uiContextMenuStrip1.Size = new System.Drawing.Size(143, 130);
//
// 关于ToolStripMenuItem
// NHome
//
this.ToolStripMenuItem.Name = "关于ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(106, 22);
this.ToolStripMenuItem.Text = "主页";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
this.NHome.Name = "NHome";
this.NHome.Size = new System.Drawing.Size(142, 24);
this.NHome.Text = "主页";
this.NHome.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 关于ToolStripMenuItem1
// NAbout
//
this.ToolStripMenuItem1.Name = "关于ToolStripMenuItem1";
this.ToolStripMenuItem1.Size = new System.Drawing.Size(106, 22);
this.ToolStripMenuItem1.Text = "关于";
this.ToolStripMenuItem1.Click += new System.EventHandler(this.ToolStripMenuItem1_Click);
this.NAbout.Name = "NAbout";
this.NAbout.Size = new System.Drawing.Size(142, 24);
this.NAbout.Text = "关于";
this.NAbout.Click += new System.EventHandler(this.ToolStripMenuItem1_Click);
//
// toolStripMenuItem1
//
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
this.toolStripMenuItem1.Size = new System.Drawing.Size(139, 6);
//
// NZhCN
//
this.NZhCN.Name = "NZhCN";
this.NZhCN.Size = new System.Drawing.Size(142, 24);
this.NZhCN.Text = "简体中文";
this.NZhCN.Click += new System.EventHandler(this.NZhCN_Click);
//
// NZhTW
//
this.NZhTW.Name = "NZhTW";
this.NZhTW.Size = new System.Drawing.Size(142, 24);
this.NZhTW.Text = "繁体中文";
this.NZhTW.Click += new System.EventHandler(this.NZhTW_Click);
//
// NEnUS
//
this.NEnUS.Name = "NEnUS";
this.NEnUS.Size = new System.Drawing.Size(142, 24);
this.NEnUS.Text = "English";
this.NEnUS.Click += new System.EventHandler(this.NEnUS_Click);
//
// StyleManager
//
this.StyleManager.DPIScale = true;
this.StyleManager.GlobalFont = true;
this.StyleManager.GlobalFontName = "Tahoma";
this.StyleManager.MultiLanguageSupport = true;
//
// uiNavBar1
//
@ -160,6 +195,7 @@
this.uiPanel3.Location = new System.Drawing.Point(842, 0);
this.uiPanel3.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.uiPanel3.MinimumSize = new System.Drawing.Size(1, 1);
this.uiPanel3.MultiLanguageSupport = false;
this.uiPanel3.Name = "uiPanel3";
this.uiPanel3.RadiusSides = Sunny.UI.UICornerRadiusSides.None;
this.uiPanel3.RectSides = ((System.Windows.Forms.ToolStripStatusLabelBorderSides)((System.Windows.Forms.ToolStripStatusLabelBorderSides.Left | System.Windows.Forms.ToolStripStatusLabelBorderSides.Top)));
@ -175,6 +211,7 @@
this.uiPanel2.Location = new System.Drawing.Point(0, 0);
this.uiPanel2.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.uiPanel2.MinimumSize = new System.Drawing.Size(1, 1);
this.uiPanel2.MultiLanguageSupport = false;
this.uiPanel2.Name = "uiPanel2";
this.uiPanel2.RadiusSides = Sunny.UI.UICornerRadiusSides.None;
this.uiPanel2.RectSides = ((System.Windows.Forms.ToolStripStatusLabelBorderSides)((System.Windows.Forms.ToolStripStatusLabelBorderSides.Top | System.Windows.Forms.ToolStripStatusLabelBorderSides.Right)));
@ -190,11 +227,14 @@
this.uiNavMenu1.DrawMode = System.Windows.Forms.TreeViewDrawMode.OwnerDrawAll;
this.uiNavMenu1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiNavMenu1.FullRowSelect = true;
this.uiNavMenu1.HotTracking = true;
this.uiNavMenu1.ItemHeight = 35;
this.uiNavMenu1.Location = new System.Drawing.Point(2, 162);
this.uiNavMenu1.Name = "uiNavMenu1";
this.uiNavMenu1.ShowLines = false;
this.uiNavMenu1.ShowOneNode = true;
this.uiNavMenu1.ShowPlusMinus = false;
this.uiNavMenu1.ShowRootLines = false;
this.uiNavMenu1.Size = new System.Drawing.Size(286, 650);
this.uiNavMenu1.TabIndex = 4;
this.uiNavMenu1.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
@ -224,6 +264,7 @@
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.ClientSize = new System.Drawing.Size(1132, 846);
this.CloseAskString = "您确认要退出程序吗?";
this.Controls.Add(this.uiTabControl1);
this.Controls.Add(this.uiNavMenu1);
this.Controls.Add(this.uiPanel1);
@ -231,11 +272,14 @@
this.ExtendBox = true;
this.ExtendMenu = this.uiContextMenuStrip1;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.IconImage = global::Sunny.UI.Demo.Properties.Resources.Sunny24;
this.MainTabControl = this.uiTabControl1;
this.Name = "FMain";
this.Padding = new System.Windows.Forms.Padding(2, 36, 2, 2);
this.Resizable = true;
this.ShowDragStretch = true;
this.Text = "Form1";
this.ZoomScaleRect = new System.Drawing.Rectangle(15, 15, 1132, 846);
this.HotKeyEventHandler += new Sunny.UI.HotKeyEventHandler(this.Form1_HotKeyEventHandler);
this.PageSelected += new Sunny.UI.OnUIPageChanged(this.Form1_PageSelected);
this.ReceiveParams += new Sunny.UI.OnReceiveParams(this.Form1_ReceiveParams);
@ -249,8 +293,8 @@
#endregion
private UIContextMenuStrip uiContextMenuStrip1;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem NHome;
private System.Windows.Forms.ToolStripMenuItem NAbout;
private UIStyleManager StyleManager;
private UINavBar uiNavBar1;
private UIPanel uiPanel1;
@ -262,5 +306,9 @@
private UIPanel uiPanel3;
private System.Windows.Forms.Timer timer1;
private UIPanel uiPanel4;
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem NZhCN;
private System.Windows.Forms.ToolStripMenuItem NZhTW;
private System.Windows.Forms.ToolStripMenuItem NEnUS;
}
}

View File

@ -5,12 +5,23 @@ using System.Windows.Forms;
namespace Sunny.UI.Demo
{
public partial class FMain : UIForm2
/// <summary>
/// WindowsXP、Windows7、Windows10、Windows11 建议使用 UIForm
/// Windows10、Windows11 可尝试使用 UIForm2更接近原生窗体使用体验用 UIForm 也可以
/// </summary>
public partial class FMain : UIForm
{
public FMain()
{
InitializeComponent();
//关联窗体承载多页面框架的容器UITabControl
//窗体上如果只有一个UITabControl也会自动关联超过一个需要手动关联
this.MainTabControl = uiTabControl1;
uiNavBar1.TabControl = uiTabControl1;
uiNavMenu1.TabControl = uiTabControl1;
//设置初始页面索引(关联页面,唯一不重复即可)
int pageIndex = 1000;
//uiNavBar1设置节点也可以在Nodes属性里配置
@ -86,7 +97,7 @@ namespace Sunny.UI.Demo
var styles = UIStyles.PopularStyles();
foreach (UIStyle style in styles)
{
uiNavBar1.CreateChildNode(uiNavBar1.Nodes[4], style.DisplayText(), style.Value());
uiNavBar1.CreateChildNode(uiNavBar1.Nodes[4], style.Description(), style.Value());
}
var node = uiNavBar1.CreateChildNode(uiNavBar1.Nodes[4], "字体图标", 99999);
@ -94,17 +105,17 @@ namespace Sunny.UI.Demo
node = uiNavBar1.CreateChildNode(uiNavBar1.Nodes[4], "多彩主题", UIStyle.Colorful.Value());
uiNavBar1.SetNodeSymbol(node, 558295);
//左侧导航主节点关联页面
uiNavMenu1.CreateNode(AddPage(new FSymbols()));
uiNavMenu1.CreateNode(AddPage(new FColorful()));
uiNavMenu1.CreateNode(AddPage(new FSymbols(), 99999));
uiNavMenu1.CreateNode(AddPage(new FColorful(), UIStyle.Colorful.Value()));
//直接增加一个页面,不在左侧列表显示
//AddPage(new FColorful());
AddPage(new FCommon());
//选中第一个节点
uiNavMenu1.SelectPage(1002);
uiPanel2.Text = Text = Version;
//设置全局热键
RegisterHotKey(UI.ModifierKeys.Shift, Keys.F8);
//根据页面类型获取页面
@ -166,6 +177,11 @@ namespace Sunny.UI.Demo
Process.Start("https://gitee.com/yhuse/SunnyUI");
}
/// <summary>
/// 全局热键事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Form1_HotKeyEventHandler(object sender, HotKeyEventArgs e)
{
if (e.hotKey.ModifierKey == UI.ModifierKeys.Shift && e.hotKey.Key == Keys.F8)
@ -184,5 +200,56 @@ namespace Sunny.UI.Demo
{
uiPanel3.Text = DateTime.Now.DateTimeString();
}
private void NZhCN_Click(object sender, EventArgs e)
{
UIStyles.CultureInfo = CultureInfos.zh_CN;
}
private void NZhTW_Click(object sender, EventArgs e)
{
UIStyles.CultureInfo = CultureInfos.zh_TW;
}
private void NEnUS_Click(object sender, EventArgs e)
{
UIStyles.CultureInfo = CultureInfos.en_US;
}
/// <summary>
/// 重载多语翻译
/// </summary>
public override void Translate()
{
//必须保留
base.Translate();
//读取翻译代码中的多语资源
CodeTranslator.Load(this);
//设置多语资源
this.CloseAskString = CodeTranslator.Current.CloseAskString;
this.uiNavMenu1.Nodes[0].Text = this.uiNavBar1.Nodes[0].Text = CodeTranslator.Current.Controls;
this.uiNavMenu1.Nodes[1].Text = this.uiNavBar1.Nodes[1].Text = CodeTranslator.Current.Forms;
this.uiNavMenu1.Nodes[2].Text = this.uiNavBar1.Nodes[2].Text = CodeTranslator.Current.Charts;
this.uiNavMenu1.Nodes[3].Text = this.uiNavBar1.Nodes[3].Text = CodeTranslator.Current.Industrial;
this.uiNavBar1.Nodes[4].Text = CodeTranslator.Current.Theme;
this.uiNavMenu1.Nodes[4].Text = CodeTranslator.Current.Symbols;
this.uiNavMenu1.Nodes[5].Text = CodeTranslator.Current.Colorful;
this.uiNavBar1.Invalidate();
this.uiNavMenu1.Invalidate();
}
private class CodeTranslator : IniCodeTranslator<CodeTranslator>
{
public string CloseAskString { get; set; } = "您确认要退出程序吗?";
public string Controls { get; set; } = "控件";
public string Forms { get; set; } = "窗体";
public string Charts { get; set; } = "图表";
public string Industrial { get; set; } = "工控";
public string Theme { get; set; } = "主题";
public string Symbols { get; set; } = "字体图标";
public string Colorful { get; set; } = "多彩主题";
}
}
}

View File

@ -235,6 +235,7 @@ namespace Sunny.UI.Demo
// uiLabel1
//
this.uiLabel1.Font = new System.Drawing.Font("宋体", 12F);
this.uiLabel1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
this.uiLabel1.Location = new System.Drawing.Point(30, 288);
this.uiLabel1.Name = "uiLabel1";
this.uiLabel1.Size = new System.Drawing.Size(698, 23);
@ -263,6 +264,7 @@ namespace Sunny.UI.Demo
// uiLabel2
//
this.uiLabel2.Font = new System.Drawing.Font("宋体", 12F);
this.uiLabel2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
this.uiLabel2.Location = new System.Drawing.Point(176, 383);
this.uiLabel2.Name = "uiLabel2";
this.uiLabel2.Size = new System.Drawing.Size(172, 23);
@ -272,7 +274,9 @@ namespace Sunny.UI.Demo
//
// uiLine1
//
this.uiLine1.BackColor = System.Drawing.Color.Transparent;
this.uiLine1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiLine1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
this.uiLine1.Location = new System.Drawing.Point(30, 430);
this.uiLine1.MinimumSize = new System.Drawing.Size(1, 1);
this.uiLine1.Name = "uiLine1";
@ -283,7 +287,9 @@ namespace Sunny.UI.Demo
//
// uiLine2
//
this.uiLine2.BackColor = System.Drawing.Color.Transparent;
this.uiLine2.Font = new System.Drawing.Font("宋体", 12F);
this.uiLine2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
this.uiLine2.Location = new System.Drawing.Point(30, 55);
this.uiLine2.MinimumSize = new System.Drawing.Size(16, 16);
this.uiLine2.Name = "uiLine2";
@ -298,12 +304,15 @@ namespace Sunny.UI.Demo
this.cbFont.DropDownStyle = Sunny.UI.UIDropDownStyle.DropDownList;
this.cbFont.FillColor = System.Drawing.Color.White;
this.cbFont.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.cbFont.ItemHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(155)))), ((int)(((byte)(200)))), ((int)(((byte)(255)))));
this.cbFont.ItemSelectForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255)))));
this.cbFont.Location = new System.Drawing.Point(101, 473);
this.cbFont.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.cbFont.MinimumSize = new System.Drawing.Size(63, 0);
this.cbFont.Name = "cbFont";
this.cbFont.Padding = new System.Windows.Forms.Padding(0, 0, 30, 2);
this.cbFont.Size = new System.Drawing.Size(469, 29);
this.cbFont.SymbolSize = 24;
this.cbFont.TabIndex = 79;
this.cbFont.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
this.cbFont.Watermark = "";
@ -311,6 +320,7 @@ namespace Sunny.UI.Demo
// uiLabel3
//
this.uiLabel3.Font = new System.Drawing.Font("宋体", 12F);
this.uiLabel3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
this.uiLabel3.Location = new System.Drawing.Point(30, 524);
this.uiLabel3.Name = "uiLabel3";
this.uiLabel3.Size = new System.Drawing.Size(172, 23);
@ -321,6 +331,7 @@ namespace Sunny.UI.Demo
// uiLabel4
//
this.uiLabel4.Font = new System.Drawing.Font("宋体", 12F);
this.uiLabel4.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
this.uiLabel4.Location = new System.Drawing.Point(30, 476);
this.uiLabel4.Name = "uiLabel4";
this.uiLabel4.Size = new System.Drawing.Size(85, 23);
@ -359,6 +370,7 @@ namespace Sunny.UI.Demo
// uiLabel5
//
this.uiLabel5.Font = new System.Drawing.Font("宋体", 12F);
this.uiLabel5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
this.uiLabel5.Location = new System.Drawing.Point(511, 524);
this.uiLabel5.Name = "uiLabel5";
this.uiLabel5.Size = new System.Drawing.Size(59, 23);
@ -396,7 +408,7 @@ namespace Sunny.UI.Demo
this.Padding = new System.Windows.Forms.Padding(0, 35, 0, 0);
this.PageIndex = 999;
this.ShowTitle = true;
this.Symbol = 262210;
this.Symbol = 558295;
this.Text = "多彩主题";
this.ResumeLayout(false);

View File

@ -88,7 +88,7 @@
this.btnError.StyleCustomMode = true;
this.btnError.Symbol = 61532;
this.btnError.TabIndex = 29;
this.btnError.Text = "Error";
this.btnError.Text = "错误";
this.btnError.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnError.Click += new System.EventHandler(this.btnError_Click);
//
@ -114,7 +114,7 @@
this.btnWarn.StyleCustomMode = true;
this.btnWarn.Symbol = 61553;
this.btnWarn.TabIndex = 28;
this.btnWarn.Text = "Warn";
this.btnWarn.Text = "警告";
this.btnWarn.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnWarn.Click += new System.EventHandler(this.btnWarn_Click);
//
@ -140,7 +140,7 @@
this.btnSuccess.StyleCustomMode = true;
this.btnSuccess.Symbol = 61528;
this.btnSuccess.TabIndex = 27;
this.btnSuccess.Text = "Success";
this.btnSuccess.Text = "成功";
this.btnSuccess.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnSuccess.Click += new System.EventHandler(this.btnSuccess_Click);
//
@ -156,7 +156,7 @@
this.btnAsk.StyleCustomMode = true;
this.btnAsk.Symbol = 61529;
this.btnAsk.TabIndex = 26;
this.btnAsk.Text = "Query";
this.btnAsk.Text = "确认";
this.btnAsk.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnAsk.Click += new System.EventHandler(this.btnAsk_Click);
//
@ -187,7 +187,7 @@
this.btnInfo.StyleCustomMode = true;
this.btnInfo.Symbol = 61530;
this.btnInfo.TabIndex = 37;
this.btnInfo.Text = "Info";
this.btnInfo.Text = "提示";
this.btnInfo.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnInfo.Click += new System.EventHandler(this.btnInfo_Click);
//
@ -326,7 +326,7 @@
this.uiLine5.Location = new System.Drawing.Point(30, 292);
this.uiLine5.MinimumSize = new System.Drawing.Size(16, 16);
this.uiLine5.Name = "uiLine5";
this.uiLine5.Size = new System.Drawing.Size(670, 20);
this.uiLine5.Size = new System.Drawing.Size(442, 20);
this.uiLine5.TabIndex = 58;
this.uiLine5.Text = "UINotifier";
this.uiLine5.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
@ -344,7 +344,7 @@
this.uiSymbolButton2.StyleCustomMode = true;
this.uiSymbolButton2.Symbol = 61530;
this.uiSymbolButton2.TabIndex = 57;
this.uiSymbolButton2.Text = "Info";
this.uiSymbolButton2.Text = "提示";
this.uiSymbolButton2.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiSymbolButton2.Click += new System.EventHandler(this.uiSymbolButton2_Click);
//
@ -370,7 +370,7 @@
this.uiSymbolButton4.StyleCustomMode = true;
this.uiSymbolButton4.Symbol = 61532;
this.uiSymbolButton4.TabIndex = 55;
this.uiSymbolButton4.Text = "Error";
this.uiSymbolButton4.Text = "错误";
this.uiSymbolButton4.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiSymbolButton4.Click += new System.EventHandler(this.uiSymbolButton4_Click);
//
@ -396,7 +396,7 @@
this.uiSymbolButton5.StyleCustomMode = true;
this.uiSymbolButton5.Symbol = 61553;
this.uiSymbolButton5.TabIndex = 54;
this.uiSymbolButton5.Text = "Warn";
this.uiSymbolButton5.Text = "警告";
this.uiSymbolButton5.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiSymbolButton5.Click += new System.EventHandler(this.uiSymbolButton5_Click);
//
@ -422,7 +422,7 @@
this.uiSymbolButton6.StyleCustomMode = true;
this.uiSymbolButton6.Symbol = 61528;
this.uiSymbolButton6.TabIndex = 53;
this.uiSymbolButton6.Text = "Success";
this.uiSymbolButton6.Text = "成功";
this.uiSymbolButton6.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiSymbolButton6.Click += new System.EventHandler(this.uiSymbolButton6_Click);
//
@ -434,9 +434,9 @@
this.uiLine6.Location = new System.Drawing.Point(30, 450);
this.uiLine6.MinimumSize = new System.Drawing.Size(16, 16);
this.uiLine6.Name = "uiLine6";
this.uiLine6.Size = new System.Drawing.Size(328, 20);
this.uiLine6.Size = new System.Drawing.Size(668, 20);
this.uiLine6.TabIndex = 59;
this.uiLine6.Text = "ULocalize";
this.uiLine6.Text = "国际化";
this.uiLine6.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// btnEN
@ -450,7 +450,7 @@
this.btnEN.Size = new System.Drawing.Size(100, 35);
this.btnEN.Symbol = 57571;
this.btnEN.TabIndex = 61;
this.btnEN.Text = "EN";
this.btnEN.Text = "English";
this.btnEN.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnEN.Click += new System.EventHandler(this.btnEN_Click);
//
@ -466,7 +466,7 @@
this.btnCH.StyleCustomMode = true;
this.btnCH.Symbol = 57571;
this.btnCH.TabIndex = 60;
this.btnCH.Text = "CH";
this.btnCH.Text = "中文";
this.btnCH.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnCH.Click += new System.EventHandler(this.btnCH_Click);
//
@ -505,7 +505,7 @@
this.uiSymbolButton7.StyleCustomMode = true;
this.uiSymbolButton7.Symbol = 61532;
this.uiSymbolButton7.TabIndex = 64;
this.uiSymbolButton7.Text = "Error";
this.uiSymbolButton7.Text = "错误";
this.uiSymbolButton7.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiSymbolButton7.Click += new System.EventHandler(this.uiSymbolButton7_Click);
//
@ -531,7 +531,7 @@
this.uiSymbolButton8.StyleCustomMode = true;
this.uiSymbolButton8.Symbol = 61553;
this.uiSymbolButton8.TabIndex = 63;
this.uiSymbolButton8.Text = "Warn";
this.uiSymbolButton8.Text = "警告";
this.uiSymbolButton8.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiSymbolButton8.Click += new System.EventHandler(this.uiSymbolButton8_Click);
//
@ -557,7 +557,7 @@
this.uiSymbolButton9.StyleCustomMode = true;
this.uiSymbolButton9.Symbol = 61528;
this.uiSymbolButton9.TabIndex = 62;
this.uiSymbolButton9.Text = "Success";
this.uiSymbolButton9.Text = "成功";
this.uiSymbolButton9.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiSymbolButton9.Click += new System.EventHandler(this.uiSymbolButton9_Click);
//
@ -585,7 +585,7 @@
this.uiSymbolButton3.Size = new System.Drawing.Size(100, 35);
this.uiSymbolButton3.Symbol = 62144;
this.uiSymbolButton3.TabIndex = 68;
this.uiSymbolButton3.Text = "Login";
this.uiSymbolButton3.Text = "登录";
this.uiSymbolButton3.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiSymbolButton3.Click += new System.EventHandler(this.uiSymbolButton3_Click);
//
@ -600,7 +600,7 @@
this.uiSymbolButton10.Size = new System.Drawing.Size(100, 35);
this.uiSymbolButton10.Symbol = 61447;
this.uiSymbolButton10.TabIndex = 67;
this.uiSymbolButton10.Text = "Login";
this.uiSymbolButton10.Text = "登录";
this.uiSymbolButton10.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiSymbolButton10.Click += new System.EventHandler(this.uiSymbolButton10_Click);
//
@ -637,10 +637,10 @@
this.uiLine10.BackColor = System.Drawing.Color.Transparent;
this.uiLine10.Font = new System.Drawing.Font("宋体", 12F);
this.uiLine10.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
this.uiLine10.Location = new System.Drawing.Point(372, 450);
this.uiLine10.Location = new System.Drawing.Point(486, 292);
this.uiLine10.MinimumSize = new System.Drawing.Size(16, 16);
this.uiLine10.Name = "uiLine10";
this.uiLine10.Size = new System.Drawing.Size(328, 20);
this.uiLine10.Size = new System.Drawing.Size(214, 20);
this.uiLine10.TabIndex = 74;
this.uiLine10.Text = "选择文件夹";
this.uiLine10.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
@ -649,7 +649,7 @@
//
this.uiSymbolButton13.Cursor = System.Windows.Forms.Cursors.Hand;
this.uiSymbolButton13.Font = new System.Drawing.Font("宋体", 12F);
this.uiSymbolButton13.Location = new System.Drawing.Point(372, 482);
this.uiSymbolButton13.Location = new System.Drawing.Point(484, 324);
this.uiSymbolButton13.MinimumSize = new System.Drawing.Size(1, 1);
this.uiSymbolButton13.Name = "uiSymbolButton13";
this.uiSymbolButton13.Padding = new System.Windows.Forms.Padding(28, 0, 0, 0);
@ -692,7 +692,7 @@
//
this.AllowShowTitle = true;
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.ClientSize = new System.Drawing.Size(800, 549);
this.ClientSize = new System.Drawing.Size(800, 590);
this.Controls.Add(this.uiLine11);
this.Controls.Add(this.uiSymbolButton12);
this.Controls.Add(this.uiLine1);

View File

@ -4,65 +4,71 @@ using System.Threading;
namespace Sunny.UI.Demo
{
public partial class FDialogs : UIPage
public partial class FDialogs : UIPage, ITranslate
{
public FDialogs()
{
InitializeComponent();
}
public override void Init()
{
base.Init();
btnCH.PerformClick();
}
private void btnInfo_Click(object sender, EventArgs e)
{
this.ShowInfoDialog("默认信息提示框");
this.ShowInfoDialog2("默认信息提示框");
this.ShowInfoDialog2(CodeTranslator.Current.Default);
this.ShowInfoDialog(CodeTranslator.Current.Default);
}
private void btnAsk_Click(object sender, EventArgs e)
{
if (this.ShowAskDialog("确认信息提示框"))
if (this.ShowAskDialog2(CodeTranslator.Current.Confirm, true))
{
this.ShowSuccessTip("您点击了确定按钮");
this.ShowSuccessTip(CodeTranslator.Current.PressedOK);
}
else
{
this.ShowErrorTip("您点击了取消按钮");
this.ShowErrorTip(CodeTranslator.Current.PressedCancel);
}
if (this.ShowAskDialog2("确认信息提示框"))
if (this.ShowAskDialog(CodeTranslator.Current.Confirm))
{
this.ShowSuccessTip("您点击了确定按钮");
this.ShowSuccessTip(CodeTranslator.Current.PressedOK);
}
else
{
this.ShowErrorTip("您点击了取消按钮");
this.ShowErrorTip(CodeTranslator.Current.PressedCancel);
}
}
private void btnSuccess_Click(object sender, EventArgs e)
{
this.ShowSuccessDialog("正确信息提示框", false, 3000);
this.ShowSuccessDialog2("正确信息提示框", false, 3000);
this.ShowSuccessDialog2(CodeTranslator.Current.Success, false, 3000);
this.ShowSuccessDialog(CodeTranslator.Current.Success, false, 3000);
}
private void btnWarn_Click(object sender, EventArgs e)
{
this.ShowWarningDialog("警告信息提示框");
this.ShowWarningDialog2("警告信息提示框");
this.ShowWarningDialog2(CodeTranslator.Current.Warning);
this.ShowWarningDialog(CodeTranslator.Current.Warning);
}
private void btnError_Click(object sender, EventArgs e)
{
this.ShowErrorDialog("错误信息提示框");
this.ShowErrorDialog2("错误信息提示框");
this.ShowErrorDialog2(CodeTranslator.Current.Error);
this.ShowErrorDialog(CodeTranslator.Current.Error);
}
private void btnStatus2_Click(object sender, EventArgs e)
{
this.ShowStatusForm(100, "数据加载中......", 0);
this.ShowStatusForm(100, CodeTranslator.Current.Loading + "......", 0);
for (int i = 0; i < 88; i++)
{
SystemEx.Delay(50);
this.SetStatusFormDescription("数据加载中(" + i + "%)......");
this.SetStatusFormDescription(CodeTranslator.Current.Loading + "(" + i + "%)......");
this.SetStatusFormStepIt();
}
@ -71,8 +77,8 @@ namespace Sunny.UI.Demo
private void btnStringInput_Click(object sender, EventArgs e)
{
string value = "请输入字符串";
if (this.ShowInputStringDialog(ref value, true, "请输入字符串:", true))
string value = CodeTranslator.Current.InputString;
if (this.ShowInputStringDialog(ref value, true, CodeTranslator.Current.InputString, true))
{
this.ShowInfoDialog(value);
}
@ -117,12 +123,12 @@ namespace Sunny.UI.Demo
private void uiSymbolButton2_Click(object sender, EventArgs e)
{
this.ShowInfoNotifier("Info", InfoNotifierClick);
this.ShowInfoNotifier("Hello SunnyUI!", InfoNotifierClick);
}
private void InfoNotifierClick(object sender, EventArgs e)
private void InfoNotifierClick(object sender, DescriptionEventArgs e)
{
this.ShowInfoTip("嗨,你点击了右下角的弹窗消息");
this.ShowInfoTip(e.Description);
}
private void uiSymbolButton6_Click(object sender, EventArgs e)
@ -140,29 +146,19 @@ namespace Sunny.UI.Demo
this.ShowErrorNotifier("Error");
}
private void btnCH_Click(object sender, EventArgs e)
{
UILocalizeHelper.SetCH();
}
private void btnEN_Click(object sender, EventArgs e)
{
UILocalizeHelper.SetEN();
}
private void uiSymbolButton9_Click(object sender, EventArgs e)
{
this.ShowSuccessTip("轻便消息提示框 - 成功");
this.ShowSuccessTip(CodeTranslator.Current.Success);
}
private void uiSymbolButton8_Click(object sender, EventArgs e)
{
this.ShowWarningTip("轻便消息提示框 - 警告");
this.ShowWarningTip(CodeTranslator.Current.Warning);
}
private void uiSymbolButton7_Click(object sender, EventArgs e)
{
this.ShowErrorTip("轻便消息提示框 - 错误");
this.ShowErrorTip(CodeTranslator.Current.Error);
}
private void uiSymbolButton10_Click(object sender, EventArgs e)
@ -171,7 +167,7 @@ namespace Sunny.UI.Demo
frm.ShowDialog();
if (frm.IsLogin)
{
UIMessageTip.ShowOk("登录成功");
UIMessageTip.ShowOk(CodeTranslator.Current.LoginSuccess);
}
frm.Dispose();
@ -192,7 +188,7 @@ namespace Sunny.UI.Demo
frm.ShowDialog();
if (frm.IsLogin)
{
UIMessageTip.ShowOk("登录成功");
UIMessageTip.ShowOk(CodeTranslator.Current.LoginSuccess);
}
frm.Dispose();
@ -205,24 +201,24 @@ namespace Sunny.UI.Demo
private void uiSymbolButton11_Click(object sender, EventArgs e)
{
this.ShowWaitForm("准备开始...");
this.ShowWaitForm(CodeTranslator.Current.Prepare);
Thread.Sleep(1000);
this.SetWaitFormDescription(UILocalize.SystemProcessing + "20%");
this.SetWaitFormDescription(UIStyles.CurrentResources.SystemProcessing + "20%");
Thread.Sleep(1000);
this.SetWaitFormDescription(UILocalize.SystemProcessing + "40%");
this.SetWaitFormDescription(UIStyles.CurrentResources.SystemProcessing + "40%");
Thread.Sleep(1000);
this.SetWaitFormDescription(UILocalize.SystemProcessing + "60%");
this.SetWaitFormDescription(UIStyles.CurrentResources.SystemProcessing + "60%");
Thread.Sleep(1000);
this.SetWaitFormDescription(UILocalize.SystemProcessing + "80%");
this.SetWaitFormDescription(UIStyles.CurrentResources.SystemProcessing + "80%");
Thread.Sleep(1000);
this.SetWaitFormDescription(UILocalize.SystemProcessing + "100%");
this.SetWaitFormDescription(UIStyles.CurrentResources.SystemProcessing + "100%");
this.HideWaitForm();
}
private void uiSymbolButton13_Click(object sender, EventArgs e)
{
string dir = "";
if (DirEx.SelectDirEx("扩展打开文件夹", ref dir))
if (DirEx.SelectDirEx(CodeTranslator.Current.OpenDir, ref dir))
{
UIMessageTip.ShowOk(dir);
}
@ -234,5 +230,43 @@ namespace Sunny.UI.Demo
Thread.Sleep(2000);
this.HideProcessForm();
}
private void btnCH_Click(object sender, EventArgs e)
{
UIStyles.CultureInfo = CultureInfos.zh_CN;
}
private void btnEN_Click(object sender, EventArgs e)
{
UIStyles.CultureInfo = CultureInfos.en_US;
}
/// <summary>
/// 重载多语翻译
/// </summary>
public override void Translate()
{
//必须保留
base.Translate();
//读取翻译代码中的多语资源
CodeTranslator.Load(this);
}
private class CodeTranslator : IniCodeTranslator<CodeTranslator>
{
public string Default { get; set; } = "默认信息提示框";
public string Confirm { get; set; } = "确认信息提示框";
public string PressedOK { get; set; } = "您点击了确定按钮";
public string PressedCancel { get; set; } = "您点击了取消按钮";
public string Success { get; set; } = "正确信息提示框";
public string Warning { get; set; } = "警告信息提示框";
public string Error { get; set; } = "错误信息提示框";
public string Loading { get; set; } = "数据加载中";
public string InputString { get; set; } = "请输入字符串";
public string PressedNotifier { get; set; } = "嗨,你点击了右下角的弹窗消息";
public string LoginSuccess { get; set; } = "登录成功";
public string Prepare { get; set; } = "准备开始";
public string OpenDir { get; set; } = "打开文件夹";
}
}
}

View File

@ -56,6 +56,7 @@ namespace Sunny.UI.Demo
this.uiDigitalLabel2 = new Sunny.UI.UIDigitalLabel();
this.uiDigitalLabel1 = new Sunny.UI.UIDigitalLabel();
this.uiLine4 = new Sunny.UI.UILine();
this.uiBattery7 = new Sunny.UI.UIBattery();
this.SuspendLayout();
//
// uiBattery6
@ -170,7 +171,7 @@ namespace Sunny.UI.Demo
this.uiLedStopwatch1.Name = "uiLedStopwatch1";
this.uiLedStopwatch1.Size = new System.Drawing.Size(190, 34);
this.uiLedStopwatch1.TabIndex = 61;
this.uiLedStopwatch1.Text = "12:50";
this.uiLedStopwatch1.Text = "01:05";
//
// uiLedDisplay1
//
@ -359,11 +360,25 @@ namespace Sunny.UI.Demo
this.uiLine4.Text = "UIDigitalLabel";
this.uiLine4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// uiBattery7
//
this.uiBattery7.Font = new System.Drawing.Font("宋体", 12F);
this.uiBattery7.Location = new System.Drawing.Point(42, 410);
this.uiBattery7.MinimumSize = new System.Drawing.Size(1, 1);
this.uiBattery7.Name = "uiBattery7";
this.uiBattery7.Size = new System.Drawing.Size(73, 105);
this.uiBattery7.SymbolOffset = new System.Drawing.Point(1, 3);
this.uiBattery7.SymbolRotate = 270;
this.uiBattery7.SymbolSize = 100;
this.uiBattery7.TabIndex = 110;
this.uiBattery7.Text = "uiBattery7";
//
// FLed
//
this.AllowShowTitle = true;
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.ClientSize = new System.Drawing.Size(800, 555);
this.Controls.Add(this.uiBattery7);
this.Controls.Add(this.uiLine4);
this.Controls.Add(this.uiDigitalLabel2);
this.Controls.Add(this.uiDigitalLabel1);
@ -426,5 +441,6 @@ namespace Sunny.UI.Demo
private UIDigitalLabel uiDigitalLabel2;
private UIDigitalLabel uiDigitalLabel1;
private UILine uiLine4;
private UIBattery uiBattery7;
}
}

View File

@ -19,7 +19,7 @@
private void timer1_Tick(object sender, System.EventArgs e)
{
value++;
uiBattery1.Power = value;
uiBattery7.Power = uiBattery1.Power = value;
uiLedDisplay1.Text = value + " Ω";
uiDigitalLabel2.Value += 0.1;
}

View File

@ -45,6 +45,12 @@ namespace Sunny.UI.Demo
this.uiLedBulb6 = new Sunny.UI.UILedBulb();
this.uiLight5 = new Sunny.UI.UILight();
this.uiLight6 = new Sunny.UI.UILight();
this.uiStatusBox1 = new Sunny.UI.UIStatusBox();
this.uiLine1 = new Sunny.UI.UILine();
this.uiButton1 = new Sunny.UI.UIButton();
this.uiButton2 = new Sunny.UI.UIButton();
this.uiButton3 = new Sunny.UI.UIButton();
((System.ComponentModel.ISupportInitialize)(this.uiStatusBox1)).BeginInit();
this.SuspendLayout();
//
// uiLedBulb4
@ -78,7 +84,9 @@ namespace Sunny.UI.Demo
//
// uiLine8
//
this.uiLine8.BackColor = System.Drawing.Color.Transparent;
this.uiLine8.Font = new System.Drawing.Font("宋体", 12F);
this.uiLine8.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
this.uiLine8.Location = new System.Drawing.Point(381, 55);
this.uiLine8.MinimumSize = new System.Drawing.Size(16, 16);
this.uiLine8.Name = "uiLine8";
@ -144,7 +152,9 @@ namespace Sunny.UI.Demo
//
// uiLine2
//
this.uiLine2.BackColor = System.Drawing.Color.Transparent;
this.uiLine2.Font = new System.Drawing.Font("宋体", 12F);
this.uiLine2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
this.uiLine2.Location = new System.Drawing.Point(30, 55);
this.uiLine2.MinimumSize = new System.Drawing.Size(16, 16);
this.uiLine2.Name = "uiLine2";
@ -223,11 +233,113 @@ namespace Sunny.UI.Demo
this.uiLight6.TabIndex = 75;
this.uiLight6.Text = "uiLight6";
//
// uiStatusBox1
//
this.uiStatusBox1.Image = global::Sunny.UI.Demo.Properties.Resources.led_g;
this.uiStatusBox1.Location = new System.Drawing.Point(30, 272);
this.uiStatusBox1.Name = "uiStatusBox1";
this.uiStatusBox1.Size = new System.Drawing.Size(36, 36);
this.uiStatusBox1.Status1 = global::Sunny.UI.Demo.Properties.Resources.led_g;
this.uiStatusBox1.Status2 = global::Sunny.UI.Demo.Properties.Resources.led_y;
this.uiStatusBox1.Status3 = global::Sunny.UI.Demo.Properties.Resources.led_r;
this.uiStatusBox1.TabIndex = 77;
this.uiStatusBox1.TabStop = false;
//
// uiLine1
//
this.uiLine1.BackColor = System.Drawing.Color.Transparent;
this.uiLine1.Font = new System.Drawing.Font("宋体", 12F);
this.uiLine1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
this.uiLine1.Location = new System.Drawing.Point(30, 230);
this.uiLine1.MinimumSize = new System.Drawing.Size(16, 16);
this.uiLine1.Name = "uiLine1";
this.uiLine1.Size = new System.Drawing.Size(319, 20);
this.uiLine1.TabIndex = 79;
this.uiLine1.Text = "UILight";
this.uiLine1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// uiButton1
//
this.uiButton1.Cursor = System.Windows.Forms.Cursors.Hand;
this.uiButton1.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(110)))), ((int)(((byte)(190)))), ((int)(((byte)(40)))));
this.uiButton1.FillColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(110)))), ((int)(((byte)(190)))), ((int)(((byte)(40)))));
this.uiButton1.FillHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(139)))), ((int)(((byte)(203)))), ((int)(((byte)(83)))));
this.uiButton1.FillPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(88)))), ((int)(((byte)(152)))), ((int)(((byte)(32)))));
this.uiButton1.FillSelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(88)))), ((int)(((byte)(152)))), ((int)(((byte)(32)))));
this.uiButton1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiButton1.LightColor = System.Drawing.Color.FromArgb(((int)(((byte)(245)))), ((int)(((byte)(251)))), ((int)(((byte)(241)))));
this.uiButton1.Location = new System.Drawing.Point(78, 273);
this.uiButton1.MinimumSize = new System.Drawing.Size(1, 1);
this.uiButton1.Name = "uiButton1";
this.uiButton1.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(110)))), ((int)(((byte)(190)))), ((int)(((byte)(40)))));
this.uiButton1.RectHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(139)))), ((int)(((byte)(203)))), ((int)(((byte)(83)))));
this.uiButton1.RectPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(88)))), ((int)(((byte)(152)))), ((int)(((byte)(32)))));
this.uiButton1.RectSelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(88)))), ((int)(((byte)(152)))), ((int)(((byte)(32)))));
this.uiButton1.Size = new System.Drawing.Size(75, 35);
this.uiButton1.Style = Sunny.UI.UIStyle.Custom;
this.uiButton1.TabIndex = 80;
this.uiButton1.Text = "切换";
this.uiButton1.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiButton1.Click += new System.EventHandler(this.uiButton1_Click);
//
// uiButton2
//
this.uiButton2.Cursor = System.Windows.Forms.Cursors.Hand;
this.uiButton2.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(155)))), ((int)(((byte)(40)))));
this.uiButton2.FillColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(155)))), ((int)(((byte)(40)))));
this.uiButton2.FillHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(227)))), ((int)(((byte)(175)))), ((int)(((byte)(83)))));
this.uiButton2.FillPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(176)))), ((int)(((byte)(124)))), ((int)(((byte)(32)))));
this.uiButton2.FillSelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(176)))), ((int)(((byte)(124)))), ((int)(((byte)(32)))));
this.uiButton2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiButton2.LightColor = System.Drawing.Color.FromArgb(((int)(((byte)(253)))), ((int)(((byte)(249)))), ((int)(((byte)(241)))));
this.uiButton2.Location = new System.Drawing.Point(159, 273);
this.uiButton2.MinimumSize = new System.Drawing.Size(1, 1);
this.uiButton2.Name = "uiButton2";
this.uiButton2.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(155)))), ((int)(((byte)(40)))));
this.uiButton2.RectHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(227)))), ((int)(((byte)(175)))), ((int)(((byte)(83)))));
this.uiButton2.RectPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(176)))), ((int)(((byte)(124)))), ((int)(((byte)(32)))));
this.uiButton2.RectSelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(176)))), ((int)(((byte)(124)))), ((int)(((byte)(32)))));
this.uiButton2.Size = new System.Drawing.Size(75, 35);
this.uiButton2.Style = Sunny.UI.UIStyle.Custom;
this.uiButton2.TabIndex = 81;
this.uiButton2.Text = "切换";
this.uiButton2.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiButton2.Click += new System.EventHandler(this.uiButton2_Click);
//
// uiButton3
//
this.uiButton3.Cursor = System.Windows.Forms.Cursors.Hand;
this.uiButton3.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80)))));
this.uiButton3.FillColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80)))));
this.uiButton3.FillHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(115)))), ((int)(((byte)(115)))));
this.uiButton3.FillPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(184)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.uiButton3.FillSelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(184)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.uiButton3.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiButton3.LightColor = System.Drawing.Color.FromArgb(((int)(((byte)(253)))), ((int)(((byte)(243)))), ((int)(((byte)(243)))));
this.uiButton3.Location = new System.Drawing.Point(240, 273);
this.uiButton3.MinimumSize = new System.Drawing.Size(1, 1);
this.uiButton3.Name = "uiButton3";
this.uiButton3.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80)))));
this.uiButton3.RectHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(115)))), ((int)(((byte)(115)))));
this.uiButton3.RectPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(184)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.uiButton3.RectSelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(184)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.uiButton3.Size = new System.Drawing.Size(75, 35);
this.uiButton3.Style = Sunny.UI.UIStyle.Custom;
this.uiButton3.TabIndex = 82;
this.uiButton3.Text = "切换";
this.uiButton3.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiButton3.Click += new System.EventHandler(this.uiButton3_Click);
//
// FLight
//
this.AllowShowTitle = true;
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.uiButton3);
this.Controls.Add(this.uiButton2);
this.Controls.Add(this.uiButton1);
this.Controls.Add(this.uiLine1);
this.Controls.Add(this.uiStatusBox1);
this.Controls.Add(this.uiLight5);
this.Controls.Add(this.uiLight6);
this.Controls.Add(this.uiLedBulb5);
@ -247,6 +359,7 @@ namespace Sunny.UI.Demo
this.ShowTitle = true;
this.Symbol = 362751;
this.Text = "Light";
((System.ComponentModel.ISupportInitialize)(this.uiStatusBox1)).EndInit();
this.ResumeLayout(false);
}
@ -267,5 +380,10 @@ namespace Sunny.UI.Demo
private UILedBulb uiLedBulb6;
private UILight uiLight5;
private UILight uiLight6;
private UIStatusBox uiStatusBox1;
private UILine uiLine1;
private UIButton uiButton1;
private UIButton uiButton2;
private UIButton uiButton3;
}
}

View File

@ -6,5 +6,27 @@
{
InitializeComponent();
}
public enum LightState
{
Green = 1,
Yellow = 2,
Red = 3
}
private void uiButton1_Click(object sender, System.EventArgs e)
{
uiStatusBox1.Status = (int)LightState.Green;
}
private void uiButton2_Click(object sender, System.EventArgs e)
{
uiStatusBox1.Status = (int)LightState.Yellow;
}
private void uiButton3_Click(object sender, System.EventArgs e)
{
uiStatusBox1.Status = (int)LightState.Red;
}
}
}

View File

@ -13,6 +13,13 @@ namespace Sunny.UI.Demo
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
//增加一个繁体中文的内置资源配置
UIStyles.BuiltInResources.TryAdd(CultureInfos.zh_TW.LCID, new zh_TW_Resources());
//从项目方案生成多语言配置文件生成文件在可执行文件夹的Language目录下
//生成后界面没有修改的情况下,可注释掉下一行,只运行一次即可
//TranslateHelper.LoadCsproj(@"D:\Source\SunnyUI\SunnyUI.Demo\SunnyUI.Demo.csproj");
Application.Run(new FMain());
}
}

View File

@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.6.6.0")]
[assembly: AssemblyFileVersion("3.6.6.0")]
[assembly: AssemblyVersion("3.8.0.1")]
[assembly: AssemblyFileVersion("3.8.0.1")]

View File

@ -470,6 +470,36 @@ namespace Sunny.UI.Demo.Properties {
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap led_g {
get {
object obj = ResourceManager.GetObject("led_g", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap led_r {
get {
object obj = ResourceManager.GetObject("led_r", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap led_y {
get {
object obj = ResourceManager.GetObject("led_y", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
@ -600,6 +630,16 @@ namespace Sunny.UI.Demo.Properties {
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap Sunny24 {
get {
object obj = ResourceManager.GetObject("Sunny24", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
@ -623,9 +663,9 @@ namespace Sunny.UI.Demo.Properties {
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap SunnyUISmall {
internal static System.Drawing.Bitmap SunnyUI72 {
get {
object obj = ResourceManager.GetObject("SunnyUISmall", resourceCulture);
object obj = ResourceManager.GetObject("SunnyUI72", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}

View File

@ -214,6 +214,15 @@
<data name="lazio" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\lazio.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="led_g" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\led_g.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="led_r" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\led_r.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="led_y" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\led_y.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="mallorca" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\mallorca.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
@ -253,14 +262,17 @@
<data name="sevilla" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\sevilla.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Sunny24" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Sunny24.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="SunnyLogin" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\SunnyLogin.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="SunnyUI" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\SunnyUI.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="SunnyUISmall" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\SunnyUISmall.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<data name="SunnyUI72" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\SunnyUI72.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Tom" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Tom.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -41,15 +41,34 @@
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="SunnyUI, Version=3.6.7.0, Culture=neutral, PublicKeyToken=27d7d2e821d97aeb, processorArchitecture=MSIL">
<HintPath>..\packages\SunnyUI.3.6.7\lib\net472\SunnyUI.dll</HintPath>
<Reference Include="SunnyUI, Version=3.8.3.0, Culture=neutral, PublicKeyToken=27d7d2e821d97aeb, processorArchitecture=MSIL">
<HintPath>..\packages\SunnyUI.3.8.3\lib\net472\SunnyUI.dll</HintPath>
</Reference>
<Reference Include="SunnyUI.Common, Version=3.6.7.0, Culture=neutral, PublicKeyToken=5a271fb7ba597231, processorArchitecture=MSIL">
<HintPath>..\packages\SunnyUI.Common.3.6.7\lib\net472\SunnyUI.Common.dll</HintPath>
<Reference Include="SunnyUI.COM, Version=9.0.3.1, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SunnyUI.COM.9.0.3.1\lib\net472\SunnyUI.COM.dll</HintPath>
</Reference>
<Reference Include="SunnyUI.Common, Version=3.8.3.0, Culture=neutral, PublicKeyToken=5a271fb7ba597231, processorArchitecture=MSIL">
<HintPath>..\packages\SunnyUI.Common.3.8.3\lib\net472\SunnyUI.Common.dll</HintPath>
</Reference>
<Reference Include="SunnyUI.FrameDecoder, Version=7.6.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SunnyUI.FrameDecoder.7.6.0\lib\net472\SunnyUI.FrameDecoder.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.5.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.6.1\lib\net462\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.Design" />
<Reference Include="System.Memory, Version=4.0.5.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.6.3\lib\net462\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.6.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.6.1\lib\net462\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.1.2\lib\net462\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
@ -394,6 +413,7 @@
<DependentUpon>FCommon.cs</DependentUpon>
</Compile>
<Compile Include="Units\UMapperDemo.cs" />
<Compile Include="Units\UZhTW.cs" />
<EmbeddedResource Include="Charts\FDoughnutChart.resx">
<DependentUpon>FDoughnutChart.cs</DependentUpon>
</EmbeddedResource>
@ -750,6 +770,11 @@
<None Include="Resources\9.png" />
<None Include="Resources\Home_32x32.png" />
<None Include="Resources\Tom.gif" />
<None Include="Resources\Sunny24.png" />
<None Include="Resources\SunnyUI72.png" />
<None Include="Resources\led_g.png" />
<None Include="Resources\led_r.png" />
<None Include="Resources\led_y.png" />
<Content Include="SunnyUI.ico" />
</ItemGroup>
<ItemGroup />

View File

@ -0,0 +1,55 @@
using System.Globalization;
namespace Sunny.UI.Demo
{
/// <summary>
/// 多語言字符串定義
/// </summary>
public class zh_TW_Resources : UIBuiltInResources
{
public override CultureInfo CultureInfo { get; } = CultureInfos.zh_TW;
public override string InfoTitle { get; set; } = "提示";
public override string SuccessTitle { get; set; } = "正確";
public override string WarningTitle { get; set; } = "警告";
public override string ErrorTitle { get; set; } = "錯誤";
public override string AskTitle { get; set; } = "提示";
public override string InputTitle { get; set; } = "輸入";
public override string SelectTitle { get; set; } = "選擇";
public override string CloseAll { get; set; } = "全部關閉";
public override string OK { get; set; } = "確定";
public override string Cancel { get; set; } = "取消";
public override string GridNoData { get; set; } = "[ 無資料 ]";
public override string GridDataLoading { get; set; } = "資料加載中,請稍候...";
public override string GridDataSourceException { get; set; } = "資料源必須為DataTable或者List";
public override string SystemProcessing { get; set; } = "系統正在處理中,請稍候...";
public override string Monday { get; set; } = "一";
public override string Tuesday { get; set; } = "二";
public override string Wednesday { get; set; } = "三";
public override string Thursday { get; set; } = "四";
public override string Friday { get; set; } = "五";
public override string Saturday { get; set; } = "六";
public override string Sunday { get; set; } = "日";
public override string Prev { get; set; } = "上一頁";
public override string Next { get; set; } = "下一頁";
public override string SelectPageLeft { get; set; } = "第";
public override string SelectPageRight { get; set; } = "頁";
public override string January { get; set; } = "一月";
public override string February { get; set; } = "二月";
public override string March { get; set; } = "三月";
public override string April { get; set; } = "四月";
public override string May { get; set; } = "五月";
public override string June { get; set; } = "六月";
public override string July { get; set; } = "七月";
public override string August { get; set; } = "八月";
public override string September { get; set; } = "九月";
public override string October { get; set; } = "十月";
public override string November { get; set; } = "十一月";
public override string December { get; set; } = "十二月";
public override string Today { get; set; } = "今天";
public override string Search { get; set; } = "搜尋";
public override string Clear { get; set; } = "清除";
public override string Open { get; set; } = "打開";
public override string Save { get; set; } = "保存";
public override string All { get; set; } = "全部";
}
}

View File

@ -1,3 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/></startup></configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /></startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="SunnyUI.Common" publicKeyToken="5a271fb7ba597231" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.7.0.0" newVersion="3.7.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.3.0" newVersion="6.0.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@ -1,5 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="SunnyUI" version="3.6.7" targetFramework="net472" />
<package id="SunnyUI.Common" version="3.6.7" targetFramework="net472" />
<package id="SunnyUI" version="3.8.3" targetFramework="net472" />
<package id="SunnyUI.COM" version="9.0.3.1" targetFramework="net472" />
<package id="SunnyUI.Common" version="3.8.3" targetFramework="net472" />
<package id="SunnyUI.FrameDecoder" version="7.6.0" targetFramework="net472" />
<package id="System.Buffers" version="4.6.1" targetFramework="net472" />
<package id="System.Memory" version="4.6.3" targetFramework="net472" />
<package id="System.Numerics.Vectors" version="4.6.1" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.1.2" targetFramework="net472" />
</packages>

View File

@ -2,3 +2,139 @@
# Default severity for analyzer diagnostics with category 'Style'
dotnet_analyzer_diagnostic.category-Style.severity = none
# WFO1000: A property should determine its property content serialization with the DesignerSerializationVisibilityAttribute, DefaultValueAttribute or the ShouldSerializeProperty method
dotnet_diagnostic.WFO1000.severity = silent
csharp_using_directive_placement = outside_namespace:silent
csharp_style_expression_bodied_methods = false:silent
csharp_style_expression_bodied_constructors = false:silent
csharp_style_expression_bodied_operators = false:silent
csharp_style_expression_bodied_properties = true:silent
csharp_style_expression_bodied_indexers = true:silent
csharp_style_expression_bodied_accessors = true:silent
csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = false:silent
csharp_style_conditional_delegate_call = true:suggestion
csharp_style_var_for_built_in_types = false:silent
csharp_space_around_binary_operators = before_and_after
csharp_indent_labels = one_less_than_current
csharp_style_var_when_type_is_apparent = false:silent
csharp_style_var_elsewhere = false:silent
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_braces = true:silent
csharp_style_namespace_declarations = block_scoped:silent
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_style_prefer_primary_constructors = true:suggestion
csharp_prefer_system_threading_lock = true:suggestion
csharp_prefer_static_local_function = true:suggestion
csharp_prefer_static_anonymous_function = true:suggestion
csharp_style_prefer_readonly_struct = true:suggestion
csharp_style_prefer_readonly_struct_member = true:suggestion
csharp_style_allow_embedded_statements_on_same_line_experimental = true:silent
csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true:silent
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true:silent
csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = true:silent
csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true:silent
csharp_style_prefer_switch_expression = true:suggestion
csharp_style_prefer_pattern_matching = true:silent
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
csharp_style_prefer_not_pattern = true:suggestion
csharp_style_prefer_extended_property_pattern = true:suggestion
csharp_style_throw_expression = true:suggestion
csharp_style_prefer_null_check_over_type_check = true:suggestion
csharp_prefer_simple_default_expression = true:suggestion
csharp_style_prefer_local_over_anonymous_function = true:suggestion
csharp_style_prefer_index_operator = true:suggestion
csharp_style_prefer_range_operator = true:suggestion
csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion
csharp_style_prefer_tuple_swap = true:suggestion
csharp_style_prefer_utf8_string_literals = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion
csharp_style_deconstructed_variable_declaration = true:suggestion
csharp_style_unused_value_assignment_preference = discard_variable:suggestion
csharp_style_unused_value_expression_statement_preference = discard_variable:silent
[*.{cs,vb}]
#### 命名样式 ####
# 命名规则
dotnet_naming_rule.interface_should_be_以_i_开始.severity = suggestion
dotnet_naming_rule.interface_should_be_以_i_开始.symbols = interface
dotnet_naming_rule.interface_should_be_以_i_开始.style = 以_i_开始
dotnet_naming_rule.类型_should_be_帕斯卡拼写法.severity = suggestion
dotnet_naming_rule.类型_should_be_帕斯卡拼写法.symbols = 类型
dotnet_naming_rule.类型_should_be_帕斯卡拼写法.style = 帕斯卡拼写法
dotnet_naming_rule.非字段成员_should_be_帕斯卡拼写法.severity = suggestion
dotnet_naming_rule.非字段成员_should_be_帕斯卡拼写法.symbols = 非字段成员
dotnet_naming_rule.非字段成员_should_be_帕斯卡拼写法.style = 帕斯卡拼写法
# 符号规范
dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.interface.required_modifiers =
dotnet_naming_symbols.类型.applicable_kinds = class, struct, interface, enum
dotnet_naming_symbols.类型.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.类型.required_modifiers =
dotnet_naming_symbols.非字段成员.applicable_kinds = property, event, method
dotnet_naming_symbols.非字段成员.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.非字段成员.required_modifiers =
# 命名样式
dotnet_naming_style.以_i_开始.required_prefix = I
dotnet_naming_style.以_i_开始.required_suffix =
dotnet_naming_style.以_i_开始.word_separator =
dotnet_naming_style.以_i_开始.capitalization = pascal_case
dotnet_naming_style.帕斯卡拼写法.required_prefix =
dotnet_naming_style.帕斯卡拼写法.required_suffix =
dotnet_naming_style.帕斯卡拼写法.word_separator =
dotnet_naming_style.帕斯卡拼写法.capitalization = pascal_case
dotnet_naming_style.帕斯卡拼写法.required_prefix =
dotnet_naming_style.帕斯卡拼写法.required_suffix =
dotnet_naming_style.帕斯卡拼写法.word_separator =
dotnet_naming_style.帕斯卡拼写法.capitalization = pascal_case
end_of_line = crlf
dotnet_style_qualification_for_field = false:silent
dotnet_style_qualification_for_property = false:silent
dotnet_style_qualification_for_method = false:silent
dotnet_style_qualification_for_event = false:silent
tab_width = 4
indent_size = 4
dotnet_style_operator_placement_when_wrapping = beginning_of_line
dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
dotnet_code_quality_unused_parameters = all:suggestion
dotnet_style_readonly_field = true:suggestion
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
dotnet_style_allow_multiple_blank_lines_experimental = true:silent
dotnet_style_allow_statement_immediately_after_block_experimental = true:silent
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
dotnet_style_prefer_auto_properties = true:silent
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
dotnet_style_prefer_conditional_expression_over_return = true:silent
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_compound_assignment = true:suggestion
dotnet_style_prefer_simplified_interpolation = true:suggestion
dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion
dotnet_style_namespace_match_folder = true:suggestion
dotnet_style_predefined_type_for_locals_parameters_members = true:silent
dotnet_style_predefined_type_for_member_access = true:silent
dotnet_diagnostic.CA2022.severity = silent

View File

@ -1,6 +1,6 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* CopyRight (C) 2012-2025 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse
@ -31,7 +31,9 @@
* 2023-05-13: V3.3.6 Option.BarInterval,Bar之间间隔-1
* 2023-05-14: V3.3.6 DrawString函数
* 2023-06-06: V3.3.7 Y轴文字居中
* 2025-06-08: V3.6.6 X轴文字带角度显示时居中
* 2024-06-08: V3.6.6 X轴文字带角度显示时居中
* 2024-10-25: V3.7.2 ShowData
* 2025-03-05: V3.8.1 Y轴零度线偏移量Option.ZeroLineOffset
******************************************************************************/
using System;
@ -48,6 +50,7 @@ namespace Sunny.UI
/// 柱状图
/// </summary>
[ToolboxItem(true)]
[Description("柱状图控件")]
public class UIBarChart : UIChart
{
private bool NeedDraw;
@ -209,7 +212,7 @@ namespace Sunny.UI
float ww = Math.Min(x2, series.MaxWidth);
xx -= ww / 2.0f;
float YZeroPos = YScale.CalcYPixel(0, DrawOrigin.Y, DrawSize.Height);
float YZeroPos = YScale.CalcYPixel(Option.ZeroLineOffset, DrawOrigin.Y, DrawSize.Height);
float VPos = YScale.CalcYPixel(series.Data[j], DrawOrigin.Y, DrawSize.Height);
if (VPos <= YZeroPos)
@ -255,7 +258,7 @@ namespace Sunny.UI
float ww = Math.Min(x2, series.MaxWidth);
float xl = (DrawBarWidth - Option.SeriesCount * ww - (Option.SeriesCount - 1) * Option.BarInterval) / 2.0f;
float xx = barX + xl + i * ww + i * Option.BarInterval;
float YZeroPos = YScale.CalcYPixel(0, DrawOrigin.Y, DrawSize.Height);
float YZeroPos = YScale.CalcYPixel(Option.ZeroLineOffset, DrawOrigin.Y, DrawSize.Height);
float VPos = YScale.CalcYPixel(series.Data[j], DrawOrigin.Y, DrawSize.Height);
if (VPos <= YZeroPos)
@ -536,6 +539,11 @@ namespace Sunny.UI
double[] YLabels = YScale.CalcLabels();
float[] labels = YScale.CalcYPixels(YLabels, DrawOrigin.Y, DrawSize.Height);
float wmax = 0;
using Pen pn = new Pen(ForeColor);
pn.DashStyle = DashStyle.Dash;
pn.DashPattern = new float[] { 3, 3 };
for (int i = 0; i < labels.Length; i++)
{
if (labels[i] > DrawOrigin.Y) continue;
@ -546,17 +554,16 @@ namespace Sunny.UI
if (YLabels[i].IsNanOrInfinity()) continue;
if (!Option.YAxis.ShowGridLine) continue;
if (!YLabels[i].EqualsDouble(0))
{
using Pen pn = new Pen(ForeColor);
pn.DashStyle = DashStyle.Dash;
pn.DashPattern = new float[] { 3, 3 };
g.DrawLine(pn, DrawOrigin.X, labels[i], Width - Option.Grid.Right, labels[i]);
}
else
{
g.DrawLine(ForeColor, DrawOrigin.X, labels[i], Width - Option.Grid.Right, labels[i]);
}
//if (!YLabels[i].EqualsDouble(Option.ZeroLineOffset))
//{
g.DrawLine(pn, DrawOrigin.X, labels[i], Width - Option.Grid.Right, labels[i]);
//}
//else
//{
// g.DrawLine(ForeColor, DrawOrigin.X, labels[i], Width - Option.Grid.Right, labels[i]);
//}
}
if (Option.YAxis.AxisLabel.Show)
@ -575,6 +582,9 @@ namespace Sunny.UI
float yy = Option.Grid.Top + DrawSize.Height / 2.0f;
g.DrawRotateString(Option.YAxis.Name, TempFont, ForeColor, new PointF(xx, yy), 270);
}
float YZeroPos = YScale.CalcYPixel(Option.ZeroLineOffset, DrawOrigin.Y, DrawSize.Height);
g.DrawLine(ForeColor, DrawOrigin.X, YZeroPos, Width - Option.Grid.Right, YZeroPos);
}
private void DrawAxisScales(Graphics g)
@ -646,5 +656,23 @@ namespace Sunny.UI
public UIBarSeries Series { get; set; }
}
public void ShowData(string[] labels, double[] values, string title = "")
{
int len = Math.Min(labels.Length, values.Length);
if (len == 0) return;
UIBarOption option = new UIBarOption();
option.Title.Text = title;
var series = new UIBarSeries();
for (int i = 0; i < len; i++)
{
option.XAxis.Data.Add(labels[i]);
series.AddData(values[i]);
}
option.Series.Add(series);
SetOption(option);
}
}
}

View File

@ -1,6 +1,6 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* CopyRight (C) 2012-2025 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse
@ -87,6 +87,11 @@ namespace Sunny.UI
public int BarInterval { get; set; } = -1;
/// <summary>
/// Y轴零度线偏移
/// </summary>
public double ZeroLineOffset { get; set; } = 0;
public void AddSeries(UIBarSeries series)
{
if (series == null)

View File

@ -1,6 +1,6 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* CopyRight (C) 2012-2025 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse
@ -73,7 +73,7 @@ namespace Sunny.UI
tip.Visible = false;
}
protected readonly UITransparentPanel tip = new UITransparentPanel();
internal readonly UITransparentPanel tip = new UITransparentPanel();
private UIChartStyleType chartStyleType = UIChartStyleType.Plain;
[DefaultValue(UIChartStyleType.Plain)]

View File

@ -1,6 +1,6 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* CopyRight (C) 2012-2025 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse

View File

@ -1,6 +1,6 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* CopyRight (C) 2012-2025 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse
@ -32,7 +32,7 @@ using System.Windows.Forms;
namespace Sunny.UI
{
[ToolboxItem(true), Description("甜甜圈图")]
[ToolboxItem(true), Description("甜甜圈图控件")]
public sealed class UIDoughnutChart : UIChart
{
/// <summary>
@ -249,9 +249,9 @@ namespace Sunny.UI
{
Angle angle = Angles[pieIndex][azIndex];
PointF pf = angle.Center;
if (Drawing.CalcDistance(e.Location, pf) > angle.Outer) continue;
if (Drawing.CalcDistance(e.Location, pf) < angle.Inner) continue;
double az = Drawing.CalcAngle(e.Location, pf);
if (e.Location.CalcDistance(pf) > angle.Outer) continue;
if (e.Location.CalcDistance(pf) < angle.Inner) continue;
double az = e.Location.CalcAngle(pf);
if (az >= angle.Start && az <= angle.Start + angle.Sweep)
{
SetPieAndAzIndex(pieIndex, azIndex);

View File

@ -1,6 +1,6 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* CopyRight (C) 2012-2025 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse
@ -52,6 +52,9 @@
* 2023-10-05: V3.5.0 X轴和Y轴鼠标选择区域并返回选中范围
* 2023-10-20: V3.5.1 线DashStyle样式
* 2023-11-22: V3.6.0
* 2024-07-01: V3.6.7 Y轴自定义坐标显示
* 2024-11-13: V3.7.2 线
* 2024-11-14: V3.7.2 线
******************************************************************************/
using System;
@ -66,10 +69,19 @@ using System.Windows.Forms;
namespace Sunny.UI
{
[ToolboxItem(true)]
[Description("曲线图控件")]
public class UILineChart : UIChart
{
protected bool NeedDraw;
[DefaultValue(MouseLineType.None)]
[Description("鼠标移上绘制十字线样式"), Category("SunnyUI")]
public MouseLineType MouseLine { get; set; }
[DefaultValue(typeof(Color), "Red")]
[Description("鼠标移上绘制十字线颜色"), Category("SunnyUI")]
public Color MouseLineColor { get; set; } = Color.Red;
/// <summary>
/// 重载控件尺寸变更
/// </summary>
@ -97,7 +109,7 @@ namespace Sunny.UI
NeedDraw = false;
if (Option?.Series == null || Option.Series.Count == 0) return;
if (DrawSize.Width <= 0 || DrawSize.Height <= 0) return;
CalcAxises();
CalcAxes();
foreach (var series in Option.Series.Values)
{
@ -136,7 +148,7 @@ namespace Sunny.UI
protected UIScale YScale;
protected UIScale Y2Scale;
protected void CalcAxises()
protected void CalcAxes()
{
if (Option.XAxisType == UIAxisType.DateTime)
XScale = new UIDateScale();
@ -288,6 +300,23 @@ namespace Sunny.UI
DrawAxisScales(g);
DrawPointSymbols(g);
DrawOther(g);
if (MousePoint.InRect(DrawRect))
{
switch (MouseLine)
{
case MouseLineType.Horizontal:
g.DrawLine(MouseLineColor, DrawRect.Left + 1, MousePoint.Y, DrawRect.Right - 1, MousePoint.Y);
break;
case MouseLineType.Vertical:
g.DrawLine(MouseLineColor, MousePoint.X, DrawRect.Top + 1, MousePoint.X, DrawRect.Bottom - 1);
break;
case MouseLineType.Cross:
g.DrawLine(MouseLineColor, DrawRect.Left + 1, MousePoint.Y, DrawRect.Right - 1, MousePoint.Y);
g.DrawLine(MouseLineColor, MousePoint.X, DrawRect.Top + 1, MousePoint.X, DrawRect.Bottom - 1);
break;
}
}
}
private void DrawAxis(Graphics g)
@ -445,6 +474,11 @@ namespace Sunny.UI
else
label = YLabels[i].ToString("F" + Option.YAxis.AxisLabel.DecimalPlaces);
if (Option.YAxis.HaveCustomLabels && Option.YAxis.CustomLabels.GetLabel(i).IsValid())
{
label = Option.YAxis.CustomLabels.GetLabel(i);
}
Size sf = TextRenderer.MeasureText(label, TempFont);
widthMax = Math.Max(widthMax, sf.Width);
@ -842,6 +876,7 @@ namespace Sunny.UI
private readonly List<UILineSelectPoint> selectPoints = new List<UILineSelectPoint>();
private readonly List<UILineSelectPoint> selectPointsTemp = new List<UILineSelectPoint>();
public Point MousePoint;
/// <summary>
/// 重载鼠标移动事件
/// </summary>
@ -949,7 +984,7 @@ namespace Sunny.UI
using Graphics g = this.CreateGraphics();
using var TempFont = Font.DPIScaleFont(UIStyles.DefaultSubFontSize);
Size sf = TextRenderer.MeasureText(sb.ToString(), TempFont);
tip.Size = new Size(sf.Width + 4, sf.Height + 4);
tip.Size = new Size(sf.Width + 4, sf.Height + 10);
int x = e.Location.X + 15;
int y = e.Location.Y + 20;
@ -1008,6 +1043,9 @@ namespace Sunny.UI
}
}
MousePoint = e.Location;
if (MouseLine != MouseLineType.None) Invalidate();
}
public delegate void OnPointValue(object sender, UILineSelectPoint[] points);

View File

@ -1,6 +1,6 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* CopyRight (C) 2012-2025 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse
@ -33,6 +33,14 @@ using System.Linq;
namespace Sunny.UI
{
public enum MouseLineType
{
None,
Horizontal,
Vertical,
Cross
}
public enum UISeriesDataOrder
{
X,

View File

@ -1,6 +1,6 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* CopyRight (C) 2012-2025 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse

View File

@ -1,6 +1,6 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* CopyRight (C) 2012-2025 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse
@ -32,6 +32,7 @@ using System.Windows.Forms;
namespace Sunny.UI
{
[ToolboxItem(true)]
[Description("饼状图控件")]
public sealed class UIPieChart : UIChart
{
/// <summary>
@ -273,9 +274,9 @@ namespace Sunny.UI
if (!e.Location.InRect(rect)) continue;
PointF pf = new PointF(rect.Left + rect.Width / 2.0f, rect.Top + rect.Height / 2.0f);
if (Drawing.CalcDistance(e.Location, pf) * 2 > rect.Width) continue;
if (e.Location.CalcDistance(pf) * 2 > rect.Width) continue;
double az = Drawing.CalcAngle(e.Location, pf);
double az = e.Location.CalcAngle(pf);
for (int azIndex = 0; azIndex < Option.Series[pieIndex].Data.Count; azIndex++)
{
Angle angle = Angles[pieIndex][azIndex];

View File

@ -1,6 +1,6 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* CopyRight (C) 2012-2025 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse

View File

@ -1,6 +1,6 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* CopyRight (C) 2012-2025 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,133 @@
using System;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using Microsoft.Win32;
namespace Sunny.UI
{
public static class ApplicationEx
{
private static readonly string StartUpPath = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run";
/// <summary>
/// 获取当前应用程序的 GUID
/// </summary>
/// <returns>应用程序的 GUID</returns>
public static Guid AppGuid()
{
var asm = Assembly.GetEntryAssembly();
if (asm == null) return Guid.Empty;
object[] attr = (asm.GetCustomAttributes(typeof(GuidAttribute), true));
return attr.Length > 0 && attr[0] is GuidAttribute ga ? new Guid(ga.Value) : Guid.Empty;
}
/// <summary>
/// 获取指定特殊文件夹的路径,并处理路径格式
/// </summary>
/// <param name="specialFolder">特殊文件夹枚举</param>
/// <returns>处理后的文件夹路径</returns>
public static string Folder(this Environment.SpecialFolder specialFolder) => Environment.GetFolderPath(specialFolder).DealPath();
/// <summary>
/// 获取指定特殊文件夹下的应用程序文件夹路径,并在必要时创建该文件夹
/// </summary>
/// <param name="specialFolder">特殊文件夹枚举</param>
/// <param name="createIfNotExists">如果文件夹不存在,是否创建</param>
/// <returns>应用程序文件夹路径</returns>
public static string FolderWithApplication(this Environment.SpecialFolder specialFolder, bool createIfNotExists = true)
{
var dir = (specialFolder.Folder() + Application.ProductName).DealPath();
if (createIfNotExists) Dir.CreateDir(dir);
return dir;
}
/// <summary>
/// 获取当前漫游用户的应用程序特定数据的公共储存库的目录
/// C:\Users\{YourUserName}\AppData\Roaming\{Application.ProductName}\
/// </summary>
/// <returns>应用程序数据文件夹路径</returns>
public static string ApplicationDataFolder() => Environment.SpecialFolder.ApplicationData.FolderWithApplication();
/// <summary>
/// 获取当前非漫游用户使用的应用程序特定数据的公共储存库的目录
/// C:\Users\{YourUserName}\AppData\Local\{Application.ProductName}\
/// </summary>
/// <returns>本地应用程序数据文件夹路径</returns>
public static string LocalApplicationDataFolder() => Environment.SpecialFolder.LocalApplicationData.FolderWithApplication();
/// <summary>
/// 获取所有用户使用的应用程序特定数据的公共储存库的目录
/// C:\ProgramData \{Application.ProductName}\
/// </summary>
/// <returns>公共应用程序数据文件夹路径</returns>
public static string CommonApplicationDataFolder() => Environment.SpecialFolder.CommonApplicationData.FolderWithApplication();
/// <summary>
/// 增加当前程序到开机自动运行
/// </summary>
/// <param name="arguments">启动参数</param>
public static void AddToStartup(string arguments)
{
using var key = Registry.CurrentUser.OpenSubKey(StartUpPath, true);
key?.SetValue(Application.ProductName, $"\"{Application.ExecutablePath}\" {arguments}");
}
/// <summary>
/// 增加当前程序到开机自动运行
/// </summary>
public static void AddToStartup()
{
using var key = Registry.CurrentUser.OpenSubKey(StartUpPath, true);
key?.SetValue(Application.ProductName, $"\"{Application.ExecutablePath}\"");
}
/// <summary>
/// 从开机自动运行移除当前程序
/// </summary>
public static void RemoveFromStartup()
{
using var key = Registry.CurrentUser.OpenSubKey(StartUpPath, true);
if (Application.ProductName != null) key?.DeleteValue(Application.ProductName, false);
}
/// <summary>
/// 判断当前程序是否开机自动运行
/// </summary>
/// <returns>是否开机自动运行</returns>
public static bool StartupEnabled()
{
using var key = Registry.CurrentUser.OpenSubKey(StartUpPath, false);
return key != null && key.GetValue(Application.ProductName) != null;
}
/// <summary>
/// 检查并更新当前程序开机自动运行路径
/// </summary>
public static void CheckAndUpdateStartupPath()
{
if (!StartupEnabled()) return;
string arg = string.Empty;
// 从注册表键值中读取启动参数
using var key = Registry.CurrentUser.OpenSubKey(StartUpPath, true);
if (key == null) return;
string oldValue = key.GetValue(Application.ProductName)?.ToString();
if (oldValue == null) return;
if (oldValue.StartsWith("\""))
{
arg = string.Join("\"", oldValue.Split('\"').Skip(2)).Trim();
}
else if (oldValue.Contains(" "))
{
arg = string.Join(" ", oldValue.Split(' ').Skip(1));
}
if (string.IsNullOrEmpty(arg))
AddToStartup();
else
AddToStartup(arg);
}
}
}

View File

@ -1,11 +1,33 @@
namespace Sunny.UI
{
/// <summary>
/// 提供程序集引用的常量定义。
/// </summary>
internal static class AssemblyRefEx
{
/// <summary>
/// 程序集版本号。
/// </summary>
internal const string Version = "4.0.0.0";
/// <summary>
/// Microsoft 公钥。
/// </summary>
internal const string MicrosoftPublicKey = "b03f5f7f11d50a3a";
/// <summary>
/// System.Design 程序集引用。
/// </summary>
internal const string SystemDesign = "System.Design, Version=" + Version + ", Culture=neutral, PublicKeyToken=" + MicrosoftPublicKey;
/// <summary>
/// System.Drawing.Design 程序集引用。
/// </summary>
internal const string SystemDrawingDesign = "System.Drawing.Design, Version=" + Version + ", Culture=neutral, PublicKeyToken=" + MicrosoftPublicKey;
/// <summary>
/// System.Drawing 程序集引用。
/// </summary>
internal const string SystemDrawing = "System.Drawing, Version=" + Version + ", Culture=neutral, PublicKeyToken=" + MicrosoftPublicKey;
}
}

View File

@ -1,6 +1,6 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* CopyRight (C) 2012-2025 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse
@ -57,10 +57,14 @@ namespace Sunny.UI
BackgroundLoop
}
private static SoundPlayer _SoundPlayer;
private static SoundPlayer _soundPlayer;
#region Methods
/// <summary>
/// 停止播放声音。
/// </summary>
/// <param name="sound">SoundPlayer 对象。</param>
private static void InternalStop(SoundPlayer sound)
{
new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Assert();
@ -74,60 +78,66 @@ namespace Sunny.UI
}
}
/// <summary>播放。wav声音文件。</summary>
/// <param name="location">String包含声音文件的名称 </param>
/// <PermissionSet><IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" /><IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" /><IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlThread" /><IPermission class="System.Net.WebPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" /></PermissionSet>
/// <summary>
/// 播放 .wav 声音文件。
/// </summary>
/// <param name="location">包含声音文件的名称的字符串。</param>
public static void Play(string location)
{
Play(location, AudioPlayMode.Background);
}
/// <summary>
/// 播放。wav声音文件.
/// 播放 .wav 声音文件。
/// </summary>
/// <param name="location">AudioPlayMode枚举模式播放声音。默认情况下AudioPlayMode.Background。</param>
/// <param name="playMode">String包含声音文件的名称</param>
/// <param name="location">包含声音文件的名称的字符串。</param>
/// <param name="playMode">AudioPlayMode 枚举,指示播放模式。</param>
public static void Play(string location, AudioPlayMode playMode)
{
ValidateAudioPlayModeEnum(playMode, "playMode");
string text1 = ValidateFilename(location);
SoundPlayer player1 = new SoundPlayer(text1);
Play(player1, playMode);
ValidateAudioPlayModeEnum(playMode, nameof(playMode));
var validatedLocation = ValidateFilename(location);
SoundPlayer player = new SoundPlayer(validatedLocation);
Play(player, playMode);
}
/// <summary>
/// 根据播放模式播放声音。
/// </summary>
/// <param name="sound">SoundPlayer 对象。</param>
/// <param name="mode">AudioPlayMode 枚举,指示播放模式。</param>
private static void Play(SoundPlayer sound, AudioPlayMode mode)
{
if (_SoundPlayer != null)
if (_soundPlayer != null)
{
InternalStop(_SoundPlayer);
InternalStop(_soundPlayer);
}
_SoundPlayer = sound;
_soundPlayer = sound;
switch (mode)
{
case AudioPlayMode.WaitToComplete:
_SoundPlayer.PlaySync();
return;
_soundPlayer.PlaySync();
break;
case AudioPlayMode.Background:
_SoundPlayer.Play();
return;
_soundPlayer.Play();
break;
case AudioPlayMode.BackgroundLoop:
_SoundPlayer.PlayLooping();
return;
_soundPlayer.PlayLooping();
break;
}
}
/// <summary>
/// 播放系统声音。
/// </summary>
/// <param name="systemSound">对象代表系统播放声音。</param>
/// <param name="systemSound">SystemSound 对象代表系统播放声音。</param>
public static void PlaySystemSound(SystemSound systemSound)
{
if (systemSound == null)
{
throw new ArgumentNullException();
throw new ArgumentNullException(nameof(systemSound));
}
systemSound.Play();
@ -136,26 +146,35 @@ namespace Sunny.UI
/// <summary>
/// 停止在后台播放声音。
/// </summary>
/// <filterpriority>1</filterpriority>
public static void Stop()
{
SoundPlayer player1 = new SoundPlayer();
InternalStop(player1);
SoundPlayer player = new SoundPlayer();
InternalStop(player);
}
/// <summary>
/// 验证 AudioPlayMode 枚举值。
/// </summary>
/// <param name="value">AudioPlayMode 枚举值。</param>
/// <param name="paramName">参数名称。</param>
private static void ValidateAudioPlayModeEnum(AudioPlayMode value, string paramName)
{
if ((value < AudioPlayMode.WaitToComplete) || (value > AudioPlayMode.BackgroundLoop))
if (!Enum.IsDefined(typeof(AudioPlayMode), value))
{
throw new InvalidEnumArgumentException(paramName, (int)value, typeof(AudioPlayMode));
}
}
/// <summary>
/// 验证文件名。
/// </summary>
/// <param name="location">文件名字符串。</param>
/// <returns>验证后的文件名。</returns>
private static string ValidateFilename(string location)
{
if (string.IsNullOrEmpty(location))
{
throw new ArgumentNullException();
throw new ArgumentNullException(nameof(location));
}
return location;
@ -170,18 +189,18 @@ namespace Sunny.UI
public static class Mp3Player
{
/// <summary>
/// 播放
/// 播放 MP3 文件。
/// </summary>
/// <param name="MP3_FileName">文件名</param>
/// <param name="Repeat">重复</param>
public static void Play(string MP3_FileName, bool Repeat)
/// <param name="mp3FileName">文件名。</param>
/// <param name="repeat">是否重复播放。</param>
public static void Play(string mp3FileName, bool repeat)
{
Win32.WinMM.mciSendString("open \"" + MP3_FileName + "\" type mpegvideo alias MediaFile", null, 0, IntPtr.Zero);
Win32.WinMM.mciSendString("play MediaFile" + (Repeat ? " repeat" : string.Empty), null, 0, IntPtr.Zero);
Win32.WinMM.mciSendString($"open \"{mp3FileName}\" type mpegvideo alias MediaFile", null, 0, IntPtr.Zero);
Win32.WinMM.mciSendString($"play MediaFile{(repeat ? " repeat" : string.Empty)}", null, 0, IntPtr.Zero);
}
/// <summary>
/// 暂停
/// 暂停播放。
/// </summary>
public static void Pause()
{
@ -189,7 +208,7 @@ namespace Sunny.UI
}
/// <summary>
/// 停止
/// 停止播放。
/// </summary>
public static void Stop()
{

View File

@ -0,0 +1,743 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2023 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse
* Gitee: https://gitee.com/yhuse/SunnyUI
* GitHub: https://github.com/yhuse/SunnyUI
*
* SunnyUI.Common.dll can be used for free under the MIT license.
* If you use this code, please keep this note.
* 使
******************************************************************************
* : UBaseConfig.cs
* :
* : V3.1
* : 2020-01-01
*
* 2020-01-01: V2.2.0
******************************************************************************/
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.ComponentModel;
using System.Reflection;
using System.Xml.Serialization;
namespace Sunny.UI
{
/// <summary>
/// 配置文件基类
/// </summary>
/// <typeparam name="TConfig">类型</typeparam>
public abstract class BaseConfig<TConfig> where TConfig : BaseConfig<TConfig>, new()
{
/// <summary>
/// 实体对象
/// </summary>
protected static TConfig current;
/// <summary>
/// 配置文件描述
/// </summary>
public static string Description
{
get
{
var fileanddesc = ConfigHelper.GetConfigFile<TConfig>();
return fileanddesc.Item2;
}
}
/// <summary>
/// 配置文件名
/// </summary>
public static string ConfigFile
{
get
{
var fileanddesc = ConfigHelper.GetConfigFile<TConfig>();
return fileanddesc.Item1;
}
}
/// <summary>
/// 当前可执行文件路径,末尾包括\
/// </summary>
/// <returns>结果</returns>
private static string CurrentDir()
{
return Environment.CurrentDirectory.DealPath();
}
/// <summary>
/// 当前实例。通过置空可以使其重新加载。
/// </summary>
public static TConfig Current
{
get
{
if (current != null)
{
return current;
}
// 现在没有对象尝试加载若返回null则实例化一个新的
current = CreateNew();
if (!current.Load(CurrentDir() + ConfigFile))
{
try
{
// 根据配置,有可能不保存,直接返回默认
current.Save();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
return current;
}
set => current = value;
}
private static TConfig CreateNew()
{
TConfig config = new TConfig();
config.SetDefault();
return config;
}
/// <summary>保存到配置文件中去</summary>
public void Save()
{
Save(null);
}
/// <summary>
/// 加载指定配置文件
/// </summary>
/// <returns>结果</returns>
public bool Load()
{
return Load(null);
}
/// <summary>
/// 加密
/// </summary>
/// <param name="str">字符串</param>
/// <returns>加密后字符串</returns>
public string Encrypt(string str)
{
Random random = new Random();
var value = random.Next(100000, 999999);
string tmp = str + value.ToString();
return tmp.DesEncrypt();
}
/// <summary>
/// 解密
/// </summary>
/// <param name="str">字符串</param>
/// <returns>解密后字符串</returns>
public string Decrypt(string str)
{
string result = str.DesDecrypt();
return result.Left(result.Length - 6);
}
/// <summary>加载指定配置文件</summary>
/// <param name="filename">文件名</param>
/// <returns>结果</returns>
public abstract bool Load(string filename);
/// <summary>保存到配置文件中去</summary>
/// <param name="filename">文件名</param>
public abstract void Save(string filename);
/// <summary>
/// 设置默认值
/// </summary>
public virtual void SetDefault()
{
}
}
/// <summary>
/// 忽略此属性的配置存储
/// </summary>
[AttributeUsage(AttributeTargets.Property)]
public class MapperIgnoreAttribute : Attribute
{
}
/// <summary>
/// 忽略此属性的配置存储
/// </summary>
[AttributeUsage(AttributeTargets.Property)]
public class IgnoreAttribute : Attribute
{
}
/// <summary>
/// 配置文件帮助类
/// </summary>
public static class ConfigHelper
{
/// <summary>
/// 类型是否能够转为指定基类
/// </summary>
/// <param name="type">类型</param>
/// <param name="baseType">基类</param>
/// <returns>是否能够转为指定基类</returns>
public static bool As(this Type type, Type baseType)
{
if (type == null)
{
return false;
}
// 如果基类是泛型定义
if (baseType.IsGenericTypeDefinition && type.IsGenericType && !type.IsGenericTypeDefinition)
{
type = type.GetGenericTypeDefinition();
}
if (type == baseType)
{
return true;
}
if (baseType.IsAssignableFrom(type))
{
return true;
}
var rs = false;
// 接口
if (baseType.IsInterface)
{
if (type.GetInterface(baseType.FullName) != null)
{
rs = true;
}
else
foreach (var e in type.GetInterfaces())
{
if (e.IsGenericType && baseType.IsGenericTypeDefinition ? e.GetGenericTypeDefinition() == baseType : e == baseType)
{
rs = true;
break;
}
}
}
// 判断是否子类时,支持只反射加载的程序集
if (!rs && type.Assembly.ReflectionOnly)
{
// 反射加载时,需要特殊处理接口
while (!rs && type != typeof(object))
{
if (type == null)
{
continue;
}
if (type.FullName == baseType.FullName && type.AssemblyQualifiedName == baseType.AssemblyQualifiedName)
{
rs = true;
}
type = type.BaseType;
}
}
return rs;
}
/// <summary>是否泛型字典</summary>
/// <param name="type">类型</param>
/// <returns>是否泛型字典</returns>
public static bool IsDictionary(this Type type) => type != null && type.IsGenericType && type.As(typeof(IDictionary<,>));
/// <summary>是否泛型列表</summary>
/// <param name="type">类型</param>
/// <returns>是否泛型列表</returns>
public static bool IsList(this Type type)
{
return type != null && type.IsGenericType && type.As(typeof(IList<>));
//return Array.IndexOf(type.GetInterfaces(), typeof(IEnumerable)) > -1;
}
/// <summary>获取成员绑定的显示名优先DisplayName然后Description</summary>
/// <param name="member">member</param>
/// <returns>显示名</returns>
public static string DisplayName(this PropertyInfo member)
{
var att = member.GetCustomAttribute<DisplayNameAttribute>();
if (att != null && !att.DisplayName.IsNullOrWhiteSpace())
{
return att.DisplayName;
}
return "";
}
/// <summary>获取成员绑定的显示名优先DisplayName然后Description</summary>
/// <param name="member">member</param>
/// <returns>显示名</returns>
public static string Description(this PropertyInfo member)
{
var att2 = member.GetCustomAttribute<DescriptionAttribute>();
if (att2 != null && !att2.Description.IsNullOrWhiteSpace())
{
return att2.Description;
}
return "";
}
/// <summary>
/// 获取需要的属性,删除忽略的属性
/// </summary>
/// <param name="type">类型</param>
/// <returns>属性列表</returns>
public static List<PropertyInfo> GetNeedProperties(this Type type)
{
var list = type.GetProperties();
List<PropertyInfo> result = new List<PropertyInfo>();
foreach (var info in list)
{
if (info.GetCustomAttribute<XmlIgnoreAttribute>() != null)
{
continue;
}
if (info.GetCustomAttribute<ConfigIgnoreAttribute>() != null)
{
continue;
}
if (info.GetCustomAttribute<MapperIgnoreAttribute>() != null)
{
continue;
}
if (info.GetCustomAttribute<IgnoreAttribute>() != null)
{
continue;
}
result.Add(info);
}
return result;
}
/// <summary>
/// 获取配置文件路径
/// </summary>
/// <typeparam name="TConfig">类型</typeparam>
/// <returns>文件名</returns>
public static Tuple<string, string> GetConfigFile<TConfig>()
{
string filename;
string description = "配置文件";
var att = typeof(TConfig).GetCustomAttribute<ConfigFileAttribute>();
if (att == null || att.FileName.IsNullOrWhiteSpace())
{
filename = $"{typeof(TConfig).Name}.cfg";
}
else
{
filename = att.FileName;
if (!att.Description.IsNullOrEmpty())
{
description = att.Description;
}
}
return new Tuple<string, string>(filename, description);
}
/// <summary>
/// 初始化属性
/// </summary>
/// <param name="config">配置类</param>
/// <typeparam name="TConfig">类型</typeparam>
/// <returns>节点</returns>
/// <exception cref="ApplicationException">ApplicationException</exception>
public static ConcurrentDictionary<string, Ident> InitIdents<TConfig>(TConfig config)
{
ConcurrentDictionary<string, Ident> idents = new ConcurrentDictionary<string, Ident>();
var list = config.GetType().GetNeedProperties();
foreach (PropertyInfo info in list)
{
Ident ident = new Ident
{
Key = info.Name,
Show = true,
Description = info.Description(),
IsList = info.PropertyType.IsList()
};
var section = info.GetCustomAttribute<ConfigSectionAttribute>();
ident.Section = section != null ? section.Section : "";
var propertyatt = info.GetCustomAttribute<ConfigPropertyAttribute>();
ident.Caption = propertyatt != null ? propertyatt.Caption : "";
ident.Unit = propertyatt != null ? propertyatt.Unit : "";
ident.Description = propertyatt != null ? propertyatt.Description : "";
var indexatt = info.GetCustomAttribute<ConfigIndexAttribute>();
ident.Index = indexatt?.Index ?? short.MaxValue + idents.Count;
ident.Show = indexatt == null || indexatt.Show;
if (ident.Description.IsNullOrEmpty())
{
ident.Description = info.DisplayName() ?? info.Description();
}
if (ident.Description.IsNullOrEmpty())
{
ident.Description = "";
}
if (!idents.ContainsKey(ident.Key))
{
idents.TryAdd(ident.Key, ident);
}
}
return idents;
}
/// <summary>
/// 类型默认值
/// </summary>
/// <param name="targetType">类型</param>
/// <returns>默认值</returns>
public static object DefaultValue(Type targetType)
{
return targetType.IsValueType ? Activator.CreateInstance(targetType) : null;
}
/// <summary>
/// 读取对象数值
/// </summary>
/// <param name="config">配置文件</param>
/// <param name="idents">节点</param>
/// <typeparam name="TConfig">类型</typeparam>
/// <exception cref="ApplicationException">ApplicationException</exception>
public static void LoadConfigValue<TConfig>(TConfig config, ConcurrentDictionary<string, Ident> idents)
{
var list = config.GetType().GetNeedProperties();
foreach (PropertyInfo info in list)
{
object defaultobj = info.GetValue(config, null);
Type type = info.PropertyType;
if (type == typeof(string))
{
object value = idents[info.Name].Value;
info.SetValue(config, Convert.ChangeType(value == null ? defaultobj : value, type), null);
continue;
}
if (ConvertEx.CanConvent(type))
{
object value = ConvertEx.StringToObject(idents[info.Name].Value, type, defaultobj);
info.SetValue(config, Convert.ChangeType(value, type), null);
continue;
}
if (type.IsList())
{
Type[] genericTypes = type.GetGenericArguments();
if (genericTypes.Length != 1)
{
throw new ApplicationException("转换出错: " + type.FullName);
}
Type childtype = genericTypes[0];
Type typeDataList = typeof(List<>).MakeGenericType(childtype);
MethodInfo methodInfo = typeDataList.GetMethod("Add", BindingFlags.Public | BindingFlags.Instance);
if (methodInfo == null)
{
continue;
}
object listvalue = typeDataList.InvokeMember(null, BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.CreateInstance, null, null, new object[] { });
foreach (string strvalue in idents[info.Name].Values)
{
if (childtype == typeof(string))
{
object value = strvalue;
methodInfo.Invoke(listvalue, new[] { value });
}
else if (ConvertEx.CanConvent(childtype))
{
object value = ConvertEx.StringToObject(strvalue, childtype, DefaultValue(childtype));
methodInfo.Invoke(listvalue, new[] { value });
}
}
info.SetValue(config, listvalue, null);
continue;
}
throw new ApplicationException("不支持此类型: " + type.FullName);
}
}
/// <summary>
/// 设置对象数值
/// </summary>
/// <param name="config">配置文件</param>
/// <param name="idents">节点</param>
/// <typeparam name="TConfig">类型</typeparam>
/// <exception cref="ApplicationException">ApplicationException</exception>
public static void SaveConfigValue<TConfig>(TConfig config, ConcurrentDictionary<string, Ident> idents)
{
var list = config.GetType().GetNeedProperties();
foreach (PropertyInfo info in list)
{
object obj = info.GetValue(config, null);
Type type = info.PropertyType;
if (ConvertEx.CanConvent(type))
{
string value = ConvertEx.ObjectToString(obj, type);
idents[info.Name].Value = value;
continue;
}
if (type.IsList())
{
Type[] genericTypes = type.GetGenericArguments();
if (genericTypes.Length != 1)
{
throw new ApplicationException("转换出错: " + type.FullName);
}
Type childtype = genericTypes[0];
IEnumerable en = obj as IEnumerable;
if (en == null)
{
throw new ApplicationException("转换出错: " + type.FullName);
}
idents[info.Name].Values.Clear();
foreach (object child in en)
{
if (ConvertEx.CanConvent(childtype))
{
idents[info.Name].Values.Add(ConvertEx.ObjectToString(child, childtype));
}
else
{
throw new ApplicationException("不支持此类型: " + type.FullName);
}
}
continue;
}
throw new ApplicationException("不支持此类型: " + type.FullName);
}
}
}
/// <summary>配置文件特性</summary>
[AttributeUsage(AttributeTargets.Class)]
public class ConfigFileAttribute : Attribute
{
/// <summary>
/// 配置文件名
/// </summary>
public string FileName { get; }
/// <summary>
/// 描述
/// </summary>
public string Description { get; }
/// <summary>
/// 配置文件
/// </summary>
public ConfigFileAttribute() : this(string.Empty, string.Empty)
{
}
/// <summary>配置文件</summary>
/// <param name="fileName">文件名</param>
/// <param name="description">描述</param>
public ConfigFileAttribute(string fileName, string description = "")
{
FileName = fileName;
Description = description;
}
}
/// <summary>
/// 数据节点
/// </summary>
public class Ident
{
/// <summary>
/// 节
/// </summary>
public string Section { get; set; }
/// <summary>
/// 键
/// </summary>
public string Key { get; set; }
/// <summary>
/// 值
/// </summary>
public string Value { get; set; }
/// <summary>
/// 描述
/// </summary>
public string Description { get; set; }
/// <summary>
/// 名称
/// </summary>
public string Caption { get; set; }
/// <summary>
/// 单位
/// </summary>
public string Unit { get; set; }
/// <summary>
/// 序号
/// </summary>
public int Index { get; set; }
/// <summary>
/// 是否显示
/// </summary>
public bool Show { get; set; }
/// <summary>
/// ToString()
/// </summary>
/// <returns>String</returns>
public override string ToString()
{
return Index + " [" + Section + "] " + Key + " = ?";
}
/// <summary>
/// 是否是列表类型
/// </summary>
public bool IsList { get; set; }
/// <summary>
/// 列表值
/// </summary>
public List<string> Values = new List<string>();
}
/// <summary>
/// 配置属性节点特性
/// </summary>
[AttributeUsage(AttributeTargets.Property)]
public class ConfigSectionAttribute : Attribute
{
/// <summary>
/// 节
/// </summary>
public string Section { get; }
/// <summary>属性节点特性</summary>
/// <param name="section">节</param>
public ConfigSectionAttribute(string section)
{
Section = section;
}
}
/// <summary>
/// 配置属性描述特性
/// </summary>
[AttributeUsage(AttributeTargets.Property)]
public class ConfigPropertyAttribute : Attribute
{
/// <summary>
/// 标题
/// </summary>
public string Caption { get; }
/// <summary>
/// 单位
/// </summary>
public string Unit { get; }
/// <summary>
/// 描述
/// </summary>
public string Description { get; }
/// <summary>
/// 配置文件属性
/// </summary>
/// <param name="caption">标题</param>
/// <param name="unit">单位</param>
/// <param name="description">描述</param>
public ConfigPropertyAttribute(string caption, string description = "", string unit = "")
{
Caption = caption;
Unit = unit;
Description = description;
}
}
/// <summary>
/// 忽略此属性的配置存储
/// </summary>
[AttributeUsage(AttributeTargets.Property)]
public class ConfigIgnoreAttribute : Attribute
{
}
/// <summary>
/// 配置序号描述特性
/// </summary>
[AttributeUsage(AttributeTargets.Property)]
public class ConfigIndexAttribute : Attribute
{
/// <summary>
/// 序号
/// </summary>
public int Index { get; }
/// <summary>
/// 是否显示
/// </summary>
public bool Show { get; }
/// <summary>配置序号特性</summary>
/// <param name="index">序号</param>
/// <param name="show">是否显示</param>
public ConfigIndexAttribute(int index, bool show = true)
{
Index = index;
Show = show;
}
}
}

View File

@ -1,6 +1,6 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* CopyRight (C) 2012-2025 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse
@ -153,20 +153,16 @@ namespace Sunny.UI
/// </summary>
public class BmpFile
{
BmpHead head;
byte[] data;
/// <summary>
/// 慢于 bitmap.Save(XX,ImageFormat.Bmp)只是为了解释BMP文件数据格式
/// </summary>
/// <param name="bitmap"></param>
public BmpFile(Bitmap bitmap)
{
head = new BmpHead();
var head = new BmpHead();
head.Init(bitmap);
data = new byte[head.FileSize];
Array.Copy(head.ToBytes(), 0, data, 0, (int)head.BitmapDataOffset);
Data = new byte[head.FileSize];
Array.Copy(head.ToBytes(), 0, Data, 0, (int)head.BitmapDataOffset);
var sourceArea = new Rectangle(0, 0, bitmap.Width, bitmap.Height);
var bitmapData = bitmap.LockBits(sourceArea, ImageLockMode.ReadOnly, PixelFormat.Format32bppPArgb);
@ -200,10 +196,10 @@ namespace Sunny.UI
/// <param name="bmpData">数据从左上角开始为每个点的B、G、R循环</param>
public BmpFile(int width, int height, byte[] bmpData)
{
head = new BmpHead();
var head = new BmpHead();
head.Init(width, height);
data = new byte[head.FileSize];
Array.Copy(head.ToBytes(), 0, data, 0, (int)head.BitmapDataOffset);
Data = new byte[head.FileSize];
Array.Copy(head.ToBytes(), 0, Data, 0, (int)head.BitmapDataOffset);
if (bmpData.Length != width * height * 3) return;
//BMP文件的数据从左下角开始每行向上。System.Drawing.Bitmap数据是从左上角开始每行向下
@ -212,7 +208,7 @@ namespace Sunny.UI
{
int offset = height - 1 - i;
offset *= width * 3;
Array.Copy(bmpData, offset, data, idx, width * 3);
Array.Copy(bmpData, offset, Data, idx, width * 3);
idx += width * 3;
}
}
@ -220,7 +216,7 @@ namespace Sunny.UI
/// <summary>
/// 二进制数据
/// </summary>
public byte[] Data => data;
public byte[] Data { get; }
/// <summary>
/// 保存文件
@ -228,7 +224,7 @@ namespace Sunny.UI
/// <param name="fileName">文件名</param>
public void SaveToFile(string fileName)
{
File.WriteAllBytes(fileName, data);
File.WriteAllBytes(fileName, Data);
}
/// <summary>
@ -237,7 +233,7 @@ namespace Sunny.UI
/// <returns>图片</returns>
public Bitmap Bitmap()
{
MemoryStream ms = new MemoryStream(data);
var ms = new MemoryStream(Data);
ms.Position = 0;
return new Bitmap(ms);
}

View File

@ -1,146 +0,0 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse
* Gitee: https://gitee.com/yhuse/SunnyUI
* GitHub: https://github.com/yhuse/SunnyUI
*
* SunnyUI.dll can be used for free under the GPL-3.0 license.
* If you use this code, please keep this note.
* 使
******************************************************************************
* : UCompress.cs
* :
* : V3.4
* : 2023-07-17
*
* 2023-07-17: V3.4.0
******************************************************************************/
using System;
using System.Runtime.InteropServices;
namespace Sunny.UI
{
public enum DataFrameCompressType
{
[DisplayText("None")]
None = 0,
[DisplayText("FastLZ")]
FastLZ = 1,
[DisplayText("ZLib")]
ZLib = 2,
[DisplayText("GZip")]
GZip = 3,
[DisplayText("Deflate")]
Deflate = 4
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
public struct DataFrame
{
public DateTime DateTime;
public byte[] Data;
public int Index;
public int CRC;
public DataFrame(DateTime dateTime, byte[] data, int index, int crc)
{
DateTime = dateTime;
Data = data;
Index = index;
CRC = crc;
}
public static DataFrame Empty()
{
#if NET40
return new DataFrame(DateTime.MinValue, new byte[0], -1, 0);
#else
return new DataFrame(DateTime.MinValue, Array.Empty<byte>(), -1, 0);
#endif
}
}
public static class DataFrameCompressHelper
{
public static byte[] Compress(DataFrame frame, DataFrameCompressType compressType, out int compressedLength, out int decompressLength)
{
byte[] compressed;
decompressLength = frame.Data.Length;
switch (compressType)
{
case DataFrameCompressType.None:
compressed = frame.Data;
break;
case DataFrameCompressType.FastLZ:
if (FastLZ.CheckFastLZDll())
{
compressed = FastLZ.Compress(frame.Data, 0, frame.Data.Length);
decompressLength = Math.Max(frame.Data.Length * 2, 66);
}
else
{
throw new NullReferenceException("FastLZx86.dll and FastLZx64.dll not exists.");
}
break;
case DataFrameCompressType.ZLib:
compressed = frame.Data.ZLibCompress();
break;
case DataFrameCompressType.GZip:
compressed = frame.Data.GZipCompress();
break;
case DataFrameCompressType.Deflate:
compressed = frame.Data.DeflateCompress();
break;
default:
compressed = frame.Data;
break;
}
compressedLength = compressed.Length;
return compressed;
}
public static byte[] Decompress(byte[] package, DataFrameCompressType compressType, int decompressLength)
{
byte[] data;
switch (compressType)
{
case DataFrameCompressType.None:
data = package;
break;
case DataFrameCompressType.FastLZ:
if (FastLZ.CheckFastLZDll())
{
data = FastLZ.Decompress(package, 0, package.Length, decompressLength);
}
else
{
throw new NullReferenceException("FastLZx86.dll and FastLZx64.dll not exists.");
}
break;
case DataFrameCompressType.ZLib:
data = package.ZLibDecompress();
break;
case DataFrameCompressType.GZip:
data = package.GZipDecompress();
break;
case DataFrameCompressType.Deflate:
data = package.DeflateDecompress();
break;
default:
data = package;
break;
}
return data;
}
}
}

View File

@ -1,6 +1,6 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* CopyRight (C) 2012-2025 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse
@ -18,6 +18,7 @@
*
* 2020-01-01: V2.2.0
* 2023-04-02: V3.3.4 null的Bug
* 2024-11-06: V3.7.2 UITreeView增加了一个刷新节点状态的扩展函数
******************************************************************************/
using System;
@ -372,14 +373,11 @@ namespace Sunny.UI
internal static void HideComboDropDown(this Control ctrl)
{
var ctrls = ctrl?.FindForm()?.GetInterfaceControls("IHideDropDown", true);
var ctrls = ctrl?.FindForm()?.GetInterfaceControls<IHideDropDown>(true);
if (ctrls == null) return;
foreach (var control in ctrls)
{
if (control is IHideDropDown item)
{
item.HideDropDown();
}
control.HideDropDown();
}
}
@ -390,21 +388,43 @@ namespace Sunny.UI
/// <param name="interfaceName">接口名称</param>
/// <param name="includeChild"></param>
/// <returns>控件列表</returns>
public static List<Control> GetInterfaceControls(this Control ctrl, string interfaceName, bool includeChild = false)
public static List<T> GetInterfaceControls<T>(this Control ctrl, bool includeChild = false)
{
List<Control> values = new List<Control>();
List<T> values = new();
if (ctrl.IsNull()) return values;
foreach (Control obj in ctrl.Controls)
{
if (obj.GetType().GetInterface(interfaceName) != null)
if (obj is T it && it != null)
{
values.Add(obj);
values.Add(it);
}
if (includeChild && obj.Controls.Count > 0)
{
values.AddRange(obj.GetInterfaceControls(interfaceName, true));
values.AddRange(obj.GetInterfaceControls<T>(includeChild));
}
}
return values;
}
internal static List<T> GetTranslateControls<T>(this Control ctrl)
{
List<T> values = new();
if (ctrl.IsNull()) return values;
foreach (Control obj in ctrl.Controls)
{
if (obj is T it && it != null)
{
values.Add(it);
}
if (obj.Controls.Count > 0)
{
if (obj is UIPage) continue;
values.AddRange(obj.GetTranslateControls<T>());
}
}
@ -511,32 +531,38 @@ namespace Sunny.UI
/// <returns>全选状态(Checked),半选状态(Indeterminate),未选状态(Unchecked)</returns>
public static CheckState CheckState(this TreeNode node)
{
if (GetChildNodeCheckedState(node))
if (node.Nodes.Count > 0)
{
return System.Windows.Forms.CheckState.Indeterminate;
var count = node.Nodes.Cast<TreeNode>().Where(n => n.Checked).ToList().Count;
if (count == 0)
{
return System.Windows.Forms.CheckState.Unchecked;
}
else if (count == node.Nodes.Count)
{
return System.Windows.Forms.CheckState.Checked;
}
else
{
return System.Windows.Forms.CheckState.Indeterminate;
}
}
return node.Checked ? System.Windows.Forms.CheckState.Checked : System.Windows.Forms.CheckState.Unchecked;
}
private static bool GetChildNodeCheckedState(TreeNode node)
public static void RefreshCheckState(this TreeNode node)
{
if (node.TreeView is not UITreeView.TreeViewEx tv) return;
System.Windows.Forms.CheckState state = node.CheckState();
if (node.Nodes.Count > 0)
{
var count = node.Nodes.Cast<TreeNode>().Where(n => n.Checked).ToList().Count;
if (count > 0 && count < node.Nodes.Count)
{
return true;
}
else
{
foreach (TreeNode nd in node.Nodes)
{
return GetChildNodeCheckedState(nd);
}
}
if (state == System.Windows.Forms.CheckState.Checked && !node.Checked) node.Checked = true;
if (state == System.Windows.Forms.CheckState.Unchecked && node.Checked) node.Checked = false;
}
return false;
tv.DicNodeStatus[node.GetHashCode()] = state == System.Windows.Forms.CheckState.Indeterminate;
tv.Invalidate();
}
public static void Disabled(this Control ctrl)

View File

@ -0,0 +1,371 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2023 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse
* Gitee: https://gitee.com/yhuse/SunnyUI
* GitHub: https://github.com/yhuse/SunnyUI
*
* SunnyUI.Common.dll can be used for free under the MIT license.
* If you use this code, please keep this note.
* 使
******************************************************************************
* : UConvertEx.cs
* :
* : V3.1
* : 2020-01-01
*
* 2020-11-20: V3.0.0
******************************************************************************/
using System;
using System.Drawing;
namespace Sunny.UI
{
/// <summary>
/// 对象转换扩展类
/// </summary>
public static class ConvertEx
{
/// <summary>
/// 可以对象和字符串互相转换的类型
/// </summary>
/// <param name="type">类型</param>
/// <returns>结果</returns>
public static bool CanConvent(Type type)
{
bool result = false;
TypeCode typeCode = Type.GetTypeCode(type);
switch (typeCode)
{
case TypeCode.String:
case TypeCode.Char:
case TypeCode.SByte:
case TypeCode.Byte:
case TypeCode.Int16:
case TypeCode.UInt16:
case TypeCode.Int32:
case TypeCode.UInt32:
case TypeCode.Int64:
case TypeCode.UInt64:
case TypeCode.Single:
case TypeCode.Double:
case TypeCode.Decimal:
case TypeCode.Boolean:
case TypeCode.DateTime:
result = true;
break;
case TypeCode.Object:
if (type == typeof(Point) ||
type == typeof(PointF) ||
type == typeof(Color) ||
type == typeof(Size) ||
type == typeof(SizeF))
{
result = true;
}
break;
}
return result;
}
/// <summary>
/// 字符串转对象
/// </summary>
/// <param name="str">字符串</param>
/// <param name="type">类型</param>
/// <param name="defaultobj">默认对象</param>
/// <returns>对象</returns>
public static object StringToObject(string str, Type type, object defaultobj)
{
object obj = defaultobj;
if (type == typeof(string))
{
return str;
}
if (str.IsNullOrEmpty())
{
return defaultobj;
}
TypeCode typeCode = Type.GetTypeCode(type);
switch (typeCode)
{
case TypeCode.Char:
obj = str.ToChar((char)defaultobj);
break;
case TypeCode.SByte:
obj = str.ToSByte((sbyte)defaultobj);
break;
case TypeCode.Byte:
obj = str.ToByte((byte)defaultobj);
break;
case TypeCode.Int16:
obj = str.ToShort((short)defaultobj);
break;
case TypeCode.UInt16:
obj = str.ToUShort((ushort)defaultobj);
break;
case TypeCode.Int32:
obj = str.ToInt((int)defaultobj);
break;
case TypeCode.UInt32:
obj = str.ToUInt((uint)defaultobj);
break;
case TypeCode.Int64:
obj = str.ToLong((long)defaultobj);
break;
case TypeCode.UInt64:
obj = str.ToULong((ulong)defaultobj);
break;
case TypeCode.Single:
obj = str.ToFloat((float)defaultobj);
break;
case TypeCode.Double:
obj = str.ToDouble((double)defaultobj);
break;
case TypeCode.Decimal:
obj = str.ToDecimal((decimal)defaultobj);
break;
case TypeCode.Boolean:
if (str.ToUpper().Equals(bool.TrueString.ToUpper()))
{
obj = true;
}
if (str.ToUpper().Equals(bool.FalseString.ToUpper()))
{
obj = false;
}
break;
case TypeCode.DateTime:
try
{
DateTime dt = str.ToDateTime(DateTimeEx.DateTimeFormat);
obj = dt;
}
catch (Exception e)
{
Console.WriteLine(e);
}
break;
case TypeCode.Object:
obj = StringToObjectEx(str, type, defaultobj);
break;
default:
throw new ApplicationException("不支持此类型: " + type.FullName);
}
if (type == typeof(DateTime))
{
}
return obj;
}
/// <summary>
/// 字符串转对象扩展
/// </summary>
/// <param name="str">字符串</param>
/// <param name="type">类型</param>
/// <param name="defaultobj">默认对象</param>
/// <returns>对象</returns>
private static object StringToObjectEx(string str, Type type, object defaultobj)
{
object obj = defaultobj;
if (type == typeof(Point))
{
string[] strs = str.ToUpper().Replace("X:", "").Replace("Y:", "").Trim().Split(";");
if (strs.Length == 2)
{
if (int.TryParse(strs[0], out var x) && int.TryParse(strs[1], out var y))
{
obj = new Point(x, y);
}
}
}
else if (type == typeof(PointF))
{
string[] strs = str.ToUpper().Replace("X:", "").Replace("Y:", "").Trim().Split(";");
if (strs.Length == 2)
{
if (float.TryParse(strs[0], out var x) && float.TryParse(strs[1], out var y))
{
obj = new PointF(x, y);
}
}
}
else if (type == typeof(Color))
{
string[] strs = str.ToUpper().Replace("A:", "").Replace("R:", "").Replace("G:", "").Replace("B:", "").Trim().Split(";");
if (strs.Length == 4)
{
if (int.TryParse(strs[0], out var a) && int.TryParse(strs[1], out var r) && int.TryParse(strs[2], out var g) && int.TryParse(strs[3], out var b))
{
if (a.InRange(0, 255) && r.InRange(0, 255) && g.InRange(0, 255) && b.InRange(0, 255))
{
obj = Color.FromArgb(a, r, g, b);
}
}
}
}
else if (type == typeof(Size))
{
string[] strs = str.ToUpper().Replace("W:", "").Replace("H:", "").Trim().Split(";");
if (strs.Length == 2)
{
if (int.TryParse(strs[0], out var x) && int.TryParse(strs[1], out var y))
{
obj = new Size(x, y);
}
}
}
else if (type == typeof(SizeF))
{
string[] strs = str.ToUpper().Replace("W:", "").Replace("H:", "").Trim().Split(";");
if (strs.Length == 2)
{
if (float.TryParse(strs[0], out var x) && float.TryParse(strs[1], out var y))
{
obj = new SizeF(x, y);
}
}
}
else
{
throw new ApplicationException("不支持此类型: " + type.FullName);
}
return obj;
}
/// <summary>
/// 对象转字符串
/// </summary>
/// <param name="obj">对象</param>
/// <param name="type">类型</param>
/// <returns>字符串</returns>
public static string ObjectToString(object obj, Type type)
{
string value;
TypeCode typeCode = Type.GetTypeCode(type);
switch (typeCode)
{
case TypeCode.String:
if (obj == null)
{
obj = "";
}
value = obj.ToString();
break;
case TypeCode.Char:
case TypeCode.SByte:
case TypeCode.Byte:
case TypeCode.Int16:
case TypeCode.UInt16:
case TypeCode.Int32:
case TypeCode.UInt32:
case TypeCode.Int64:
case TypeCode.UInt64:
case TypeCode.Single:
case TypeCode.Double:
case TypeCode.Decimal:
value = obj.ToString();
break;
case TypeCode.Boolean:
value = (bool)obj ? bool.TrueString : bool.FalseString;
break;
case TypeCode.DateTime:
value = ((DateTime)obj).ToString(DateTimeEx.DateTimeFormat);
break;
case TypeCode.Object:
value = ObjectToStringEx(obj, type);
break;
default:
throw new ApplicationException("不支持此类型: " + type.FullName);
}
return value;
}
/// <summary>
/// 对象转字符串扩展
/// </summary>
/// <param name="obj">对象</param>
/// <param name="type">类型</param>
/// <returns>字符串</returns>
private static string ObjectToStringEx(object obj, Type type)
{
string value;
if (type == typeof(Point))
{
Point point = (Point)obj;
value = "X:" + point.X + "; Y:" + point.Y;
}
else if (type == typeof(PointF))
{
PointF point = (PointF)obj;
value = "X:" + point.X + "; Y:" + point.Y;
}
else if (type == typeof(Color))
{
Color color = (Color)obj;
value = "A:" + color.A + "; R:" + color.R + "; G:" + color.G + "; B:" + color.B;
}
else if (type == typeof(Size))
{
Size size = (Size)obj;
value = "W:" + size.Width + "; H:" + size.Height;
}
else if (type == typeof(SizeF))
{
SizeF size = (SizeF)obj;
value = "W:" + size.Width + "; H:" + size.Height;
}
else
{
throw new ApplicationException("不支持此类型: " + type.FullName);
}
return value;
}
}
}

View File

@ -0,0 +1,382 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2023 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse
* Gitee: https://gitee.com/yhuse/SunnyUI
* GitHub: https://github.com/yhuse/SunnyUI
*
* SunnyUI.dll can be used for free under the GPL-3.0 license.
* If you use this code, please keep this note.
* 使
******************************************************************************
* : UDateTimeInt64.cs
* :
* : V2.2
* : 2020-09-23
*
* 2020-09-23: V2.2.8
* 2020-10-10: V2.2.8 Double互转
******************************************************************************/
using System;
namespace Sunny.UI
{
/// <summary>
/// 日期与长整形和浮点型互转
/// Value长整形为1970年1月1日0时起的毫秒数
/// DoubleValue双精度浮点数1970年1月1日0时起的天数
/// </summary>
public struct DateTimeInt64 : IComparable, IEquatable<DateTimeInt64>, IEquatable<long>, IEquatable<DateTime>
{
public long Value { get; set; }
public const long Jan1st1970Ticks = 621355968000000000; //Jan1st1970.Ticks;
public const long Dec31th9999Ticks = 3155378975999990000; //DateTime.MaxValue.Ticks;
public const string DefaultFormatString = DateTimeEx.DateTimeFormatEx;
public const double MillisecondsPerDay = 86400000.0;
/// <summary>
/// 返回当前时间的毫秒数, 这个毫秒其实就是自1970年1月1日0时起的毫秒数
/// </summary>
public static long CurrentDateTimeToTicks()
{
return (DateTime.UtcNow.Ticks - Jan1st1970Ticks) / 10000;
}
public double DoubleValue
{
get { return Value * 1.0 / MillisecondsPerDay; }
set { Value = (long)(value * MillisecondsPerDay); }
}
/// <summary>
/// 返回指定时间的毫秒数, 这个毫秒其实就是自1970年1月1日0时起的毫秒数
/// </summary>
public static long DateTimeToTicks(DateTime datetime)
{
return (datetime.ToUniversalTime().Ticks - Jan1st1970Ticks) / 10000;
}
/// <summary>
/// 从一个代表自1970年1月1日0时起的毫秒数转换为DateTime (北京时间)
/// </summary>
public static DateTime TicksToDateTime(long ticks)
{
#pragma warning disable CS0618 // 类型或成员已过时
return TimeZone.CurrentTimeZone.ToLocalTime(TicksToUTCDateTime(ticks));
#pragma warning restore CS0618 // 类型或成员已过时
}
/// <summary>
/// 从一个代表自1970年1月1日0时起的毫秒数转换为DateTime (UTC时间)
/// </summary>
public static DateTime TicksToUTCDateTime(long ticks)
{
return new DateTime(ticks * 10000 + Jan1st1970Ticks);
}
public DateTimeInt64(long ticks)
{
ticks = MakeValidDate(ticks);
Value = ticks;
}
public DateTimeInt64(double doubleTicks)
{
doubleTicks = MakeValidDate((long)(doubleTicks * MillisecondsPerDay));
Value = (long)doubleTicks;
}
public DateTimeInt64(DateTime dateTime)
{
Value = DateTimeToTicks(dateTime);
}
public DateTimeInt64(int year, int month, int day)
{
Value = DateTimeToTicks(new DateTime(year, month, day));
}
public DateTimeInt64(int year, int month, int day, int hour, int minute, int second)
{
Value = DateTimeToTicks(new DateTime(year, month, day, hour, minute, second));
}
public DateTimeInt64(int year, int month, int day, int hour, int minute, int second, int millisecond)
{
Value = DateTimeToTicks(new DateTime(year, month, day, hour, minute, second, millisecond));
}
public DateTimeInt64(DateTimeInt64 dtValue)
{
Value = dtValue.Value;
}
public bool IsValidDate
{
get { return Value >= 0 && Value <= Dec31th9999Ticks - Jan1st1970Ticks; }
}
public DateTime DateTime
{
get { return TicksToDateTime(Value); }
set { Value = DateTimeToTicks(value); }
}
public static bool CheckValidDate(long ticks)
{
return ticks >= 0 && ticks <= Dec31th9999Ticks - Jan1st1970Ticks;
}
public static long MakeValidDate(long ticks)
{
if (ticks < 0)
ticks = 0;
if (ticks > Dec31th9999Ticks - Jan1st1970Ticks)
ticks = Dec31th9999Ticks - Jan1st1970Ticks;
return ticks;
}
public void AddMilliseconds(double milliseconds)
{
Value = DateTimeToTicks(DateTime.AddMilliseconds(milliseconds));
}
public void AddSeconds(double seconds)
{
Value = DateTimeToTicks(DateTime.AddSeconds(seconds));
}
public void AddMinutes(double minutes)
{
Value = DateTimeToTicks(DateTime.AddMinutes(minutes));
}
public void AddHours(double hours)
{
Value = DateTimeToTicks(DateTime.AddHours(hours));
}
public void AddDays(double days)
{
Value = DateTimeToTicks(DateTime.AddDays(days));
}
public void AddMonths(int months)
{
Value = DateTimeToTicks(DateTime.AddMonths(months));
}
public void AddYears(int years)
{
Value = DateTimeToTicks(DateTime.AddYears(years));
}
public static long operator -(DateTimeInt64 dtValue1, DateTimeInt64 dtValue2)
{
return dtValue1.Value - dtValue2.Value;
}
public static long operator +(DateTimeInt64 dtValue1, DateTimeInt64 dtValue2)
{
return dtValue1.Value + dtValue2.Value;
}
public static DateTimeInt64 operator -(DateTimeInt64 dtValue1, long dtValue2)
{
dtValue1.Value -= dtValue2;
return dtValue1;
}
public static DateTimeInt64 operator +(DateTimeInt64 dtValue1, long dtValue2)
{
dtValue1.Value += dtValue2;
return dtValue1;
}
public static DateTimeInt64 operator ++(DateTimeInt64 dtValue)
{
dtValue.AddDays(1);
return dtValue;
}
public static DateTimeInt64 operator --(DateTimeInt64 dtValue)
{
dtValue.AddDays(-1);
return dtValue;
}
public static implicit operator long(DateTimeInt64 dtValue)
{
return dtValue.Value;
}
public static implicit operator DateTimeInt64(long ticks)
{
return new DateTimeInt64(ticks);
}
public static implicit operator DateTimeInt64(DateTime dt)
{
return new DateTimeInt64(dt);
}
public static implicit operator DateTime(DateTimeInt64 dt)
{
return dt.DateTime;
}
public static implicit operator double(DateTimeInt64 dtValue)
{
return dtValue.DoubleValue;
}
public static implicit operator DateTimeInt64(double ticks)
{
return new DateTimeInt64(ticks);
}
public static bool operator ==(DateTimeInt64 dtValue1, DateTimeInt64 dtValue2)
{
return dtValue1.Value == dtValue2.Value;
}
public static bool operator !=(DateTimeInt64 dtValue1, DateTimeInt64 dtValue2)
{
return dtValue1.Value != dtValue2.Value;
}
public static bool operator ==(DateTimeInt64 dtValue, long ticks)
{
return dtValue.Value == ticks;
}
public static bool operator !=(DateTimeInt64 dtValue, long ticks)
{
return dtValue.Value != ticks;
}
public static bool operator <(DateTimeInt64 dtValue1, DateTimeInt64 dtValue2)
{
return dtValue1.Value < dtValue2.Value;
}
public static bool operator >(DateTimeInt64 dtValue1, DateTimeInt64 dtValue2)
{
return dtValue1.Value > dtValue2.Value;
}
public static bool operator <=(DateTimeInt64 dtValue1, DateTimeInt64 dtValue2)
{
return dtValue1.Value <= dtValue2.Value;
}
public static bool operator >=(DateTimeInt64 dtValue1, DateTimeInt64 dtValue2)
{
return dtValue1.Value >= dtValue2.Value;
}
public static bool operator <(DateTimeInt64 dtValue, long ticks)
{
return dtValue.Value < ticks;
}
public static bool operator >(DateTimeInt64 dtValue, long ticks)
{
return dtValue.Value > ticks;
}
public static bool operator <=(DateTimeInt64 dtValue, long ticks)
{
return dtValue.Value <= ticks;
}
public static bool operator >=(DateTimeInt64 dtValue, long ticks)
{
return dtValue.Value >= ticks;
}
public override bool Equals(object obj)
{
if (obj is DateTimeInt64 dtValue)
{
return dtValue.Value == Value;
}
else if (obj is long longValue)
{
return longValue == Value;
}
else
{
return false;
}
}
public override int GetHashCode()
{
return Value.GetHashCode();
}
int IComparable.CompareTo(object obj)
{
if (!(obj is DateTimeInt64)) throw new ArgumentException();
return (Value).CompareTo(((DateTimeInt64)obj).Value);
}
public string ToString(long ticks)
{
return ToString(ticks, DefaultFormatString);
}
public override string ToString()
{
return ToString(Value, DefaultFormatString);
}
public string ToString(string fmtStr)
{
return ToString(Value, fmtStr);
}
public static string ToString(long dtValue, string fmtStr)
{
DateTime dt = TicksToDateTime(dtValue);
return dt.ToString(fmtStr);
}
public bool Equals(DateTimeInt64 dtValue)
{
return Value == dtValue.Value;
}
public bool Equals(long ticks)
{
return Value == ticks;
}
public bool Equals(DateTime datetime)
{
return Value == (new DateTimeInt64(datetime)).Value;
}
public string DateTimeString => DateTime.DateTimeString();
public string DateString => DateTime.DateString();
public string TimeString => DateTime.TimeString();
public string HourMinuteString => DateTime.ToString("HH:mm");
public int Year => DateTime.Year;
public int Month => DateTime.Month;
public int Day => DateTime.Day;
public int Hour => DateTime.Hour;
public int Minute => DateTime.Minute;
public int Second => DateTime.Second;
public int Millisecond => DateTime.Millisecond;
}
}

View File

@ -1,6 +1,6 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* CopyRight (C) 2012-2025 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse
@ -19,10 +19,7 @@
* 2020-01-01: V2.2.0
******************************************************************************/
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using System.Windows.Forms;
namespace Sunny.UI
@ -32,48 +29,6 @@ namespace Sunny.UI
/// </summary>
public static class DirEx
{
/// <summary>
/// 创建一个目录
/// </summary>
/// <param name="dir">目录的绝对路径</param>
public static bool CreateDir(string dir)
{
if (dir.IsNullOrEmpty())
{
throw new ArgumentNullException(dir, "目录不能为空。");
}
if (!Path.IsPathRooted(dir))
{
throw new ArgumentException(dir, "不包含根路径。");
}
//
//
try
{
if (!Directory.Exists(dir))
{
Directory.CreateDirectory(dir);
}
return Directory.Exists(dir);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
return false;
}
}
/// <summary>
/// 返回当前基目录
/// </summary>
/// <returns>基目录</returns>
public static string CurrentDir()
{
return AppDomain.CurrentDomain.BaseDirectory.DealPath();
}
/// <summary>
/// 选择文件夹
/// </summary>
@ -119,163 +74,5 @@ namespace Sunny.UI
System.Diagnostics.Process.Start("Explorer.exe", dir);
}
}
/// <summary>
/// 获取指定目录中的匹配项(文件或目录)
/// </summary>
/// <param name="dir">要搜索的目录</param>
/// <param name="regexPattern">项名模式正则。null表示忽略模式匹配返回所有项</param>
/// <param name="depth">递归深度。负数表示不限0表示仅顶级</param>
/// <param name="throwEx">是否抛异常</param>
/// <returns>结果</returns>
public static string[] GetFileSystemEntries(string dir, string regexPattern = null, int depth = 0, bool throwEx = false)
{
List<string> lst = new List<string>();
try
{
foreach (string item in Directory.GetFileSystemEntries(dir))
{
try
{
string filename = Path.GetFileName(item);
if (regexPattern == null || Regex.IsMatch(filename, regexPattern, RegexOptions.IgnoreCase | RegexOptions.Multiline))
{
lst.Add(item);
}
//递归
if (depth != 0 && (File.GetAttributes(item) & FileAttributes.Directory) == FileAttributes.Directory)
{
lst.AddRange(GetFileSystemEntries(item, regexPattern, depth - 1, throwEx));
}
}
catch
{
if (throwEx)
{
throw;
}
}
}
}
catch
{
if (throwEx)
{
throw;
}
}
return lst.ToArray();
}
/// <summary>
/// 获取指定目录中的匹配文件
/// </summary>
/// <param name="dir">要搜索的目录</param>
/// <param name="regexPattern">文件名模式正则。null表示忽略模式匹配返回所有文件</param>
/// <param name="depth">递归深度。负数表示不限0表示仅顶级</param>
/// <param name="throwEx">是否抛异常</param>
/// <returns>结果</returns>
public static string[] GetFiles(string dir, string regexPattern = null, int depth = 0, bool throwEx = false)
{
List<string> lst = new List<string>();
try
{
foreach (string item in Directory.GetFileSystemEntries(dir))
{
try
{
bool isFile = (File.GetAttributes(item) & FileAttributes.Directory) != FileAttributes.Directory;
string filename = Path.GetFileName(item);
if (isFile && (regexPattern == null || Regex.IsMatch(filename, regexPattern, RegexOptions.IgnoreCase | RegexOptions.Multiline)))
{
lst.Add(item);
}
//递归
if (depth != 0 && !isFile)
{
lst.AddRange(GetFiles(item, regexPattern, depth - 1, throwEx));
}
}
catch
{
if (throwEx)
{
throw;
}
}
}
}
catch
{
if (throwEx)
{
throw;
}
}
return lst.ToArray();
}
/// <summary>
/// 获取指定目录中的匹配目录
/// </summary>
/// <param name="dir">要搜索的目录</param>
/// <param name="regexPattern">目fu录名模式正则。null表示忽略模式匹配返回所有目录</param>
/// <param name="depth">递归深度。负数表示不限0表示仅顶级</param>
/// <param name="throwEx">是否抛异常</param>
/// <returns>结果</returns>
public static string[] GetDirectories(string dir, string regexPattern = null, int depth = 0, bool throwEx = false)
{
List<string> lst = new List<string>();
try
{
foreach (string item in Directory.GetDirectories(dir))
{
try
{
string filename = Path.GetFileName(item);
if (filename == null)
{
continue;
}
if (regexPattern == null || Regex.IsMatch(filename, regexPattern, RegexOptions.IgnoreCase | RegexOptions.Multiline))
{
lst.Add(item);
}
//递归
if (depth != 0)
{
lst.AddRange(GetDirectories(item, regexPattern, depth - 1, throwEx));
}
}
catch
{
if (throwEx)
{
throw;
}
}
}
}
catch
{
if (throwEx)
{
throw;
}
}
return lst.ToArray();
}
}
}

View File

@ -1,6 +1,6 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* CopyRight (C) 2012-2025 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse

View File

@ -1,6 +1,6 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* CopyRight (C) 2012-2025 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse

View File

@ -1,356 +0,0 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse
* Gitee: https://gitee.com/yhuse/SunnyUI
* GitHub: https://github.com/yhuse/SunnyUI
*
* SunnyUI.dll can be used for free under the GPL-3.0 license.
* If you use this code, please keep this note.
* 使
******************************************************************************
* : FastLZ.cs
* : FastLZ压缩解压类
* : V3.1
* : 2022-03-31
* : https://ariya.github.io/FastLZ/
*
* FastLZ (MIT license) is an ANSI C/C90 implementation of Lempel-Ziv 77
* algorithm (LZ77) of lossless data compression. It is suitable to compress
* series of text/paragraphs, sequences of raw pixel data, or any other blocks
* of data with lots of repetition. It is not intended to be used on images,
* videos, and other formats of data typically already in an optimal
* compressed form.
*
* 2022-03-31: V3.1.2
* 2022-07-07: V3.2.1
* 2022-07-07: V3.2.1 FastLZx86.dllFastLZx64.dll资源文件
******************************************************************************
*
* int fastlz_compress_level(int level, const void* input, int length, void* output);
*
* level 12
* 1
* 2
* 使fastlz_decompress进行解压缩
*
* input
* length 16
* output 5%66
*
*
******************************************************************************
*
* int fastlz_decompress(const void* input, int length, void* output, int maxout);
*
* input
* length
* output
* maxout maxout中指定的值
*
* 0
*
******************************************************************************
* CompressExDecompressEx
* 168!\r\n结尾
* 20:
* 4(!FLZ)
* 4SecondsUnix时间戳Jan1st1970开始的秒数
* 4Milliseconds
* 4(maxout)
* 4()
* 8:
* 4
* 1(*)
* 1(CRC,,0)
* 2(\r\n)
******************************************************************************
* FastLZx86.dllFastLZx64.dll见项目 https://gitee.com/yhuse/SunnyUI.FastLZ
******************************************************************************/
using System;
using System.IO;
using System.Runtime.InteropServices;
namespace Sunny.UI
{
public static unsafe class FastLZx86
{
[DllImport("FastLZx86.dll", EntryPoint = "FastLZ_Compress", CallingConvention = CallingConvention.Cdecl)]
public static extern int FastLZ_Compress(void* input, int length, void* output);
[DllImport("FastLZx86.dll", EntryPoint = "FastLZ_Compress_level", CallingConvention = CallingConvention.Cdecl)]
public static extern int FastLZ_Compress_level(int level, void* input, int length, void* output);
[DllImport("FastLZx86.dll", EntryPoint = "FastLZ_Decompress", CallingConvention = CallingConvention.Cdecl)]
public static extern int FastLZ_Decompress(void* input, int length, void* output, int maxout);
}
public static unsafe class FastLZx64
{
[DllImport("FastLZx64.dll", EntryPoint = "FastLZ_Compress", CallingConvention = CallingConvention.Cdecl)]
public static extern int FastLZ_Compress(void* input, int length, void* output);
[DllImport("FastLZx64.dll", EntryPoint = "FastLZ_Compress_level", CallingConvention = CallingConvention.Cdecl)]
public static extern int FastLZ_Compress_level(int level, void* input, int length, void* output);
[DllImport("FastLZx64.dll", EntryPoint = "FastLZ_Decompress", CallingConvention = CallingConvention.Cdecl)]
public static extern int FastLZ_Decompress(void* input, int length, void* output, int maxout);
}
public enum FastLZCompressionLevel
{
Level1 = 1,
Level2 = 2
}
/// <summary>
/// FastLZ压缩解压类
/// </summary>
public static unsafe class FastLZ
{
/// <summary>
/// 是否64位
/// </summary>
/// <returns></returns>
private static bool Is64bitApp()
{
return IntPtr.Size == 8;
}
/// <summary>
/// 压缩(原生)
/// </summary>
/// <param name="input">输入</param>
/// <param name="begin">起始位置</param>
/// <param name="length">长度</param>
/// <returns>压缩结果</returns>
public static byte[] Compress(byte[] input, int begin, int length)
{
CheckFastLZDll();
byte[] output = new byte[Math.Max(length * 2, 66)];
fixed (void* pSrc1 = &input[begin])
fixed (void* pSrc2 = output)
{
int outlen = Is64bitApp() ? FastLZx64.FastLZ_Compress(pSrc1, length, pSrc2) : FastLZx86.FastLZ_Compress(pSrc1, length, pSrc2);
byte[] result = new byte[outlen];
Array.Copy(output, 0, result, 0, outlen);
return result;
}
}
/// <summary>
/// 压缩(原生)
/// </summary>
/// <param name="level">压缩级别</param>
/// <param name="input">输入</param>
/// <param name="begin">起始位置</param>
/// <param name="length">长度</param>
/// <returns>压缩结果</returns>
public static byte[] Compress(FastLZCompressionLevel level, byte[] input, int begin, int length)
{
CheckFastLZDll();
byte[] output = new byte[Math.Max(length * 2, 66)];
fixed (void* pSrc1 = &input[begin])
fixed (void* pSrc2 = output)
{
int outlen = Is64bitApp() ? FastLZx64.FastLZ_Compress_level((int)level, pSrc1, length, pSrc2) : FastLZx86.FastLZ_Compress_level((int)level, pSrc1, length, pSrc2);
byte[] result = new byte[outlen];
Array.Copy(output, 0, result, 0, outlen);
return result;
}
}
/// <summary>
/// 解压缩(原生)
/// </summary>
/// <param name="input">输入</param>
/// <param name="begin">起始位置</param>
/// <param name="length">长度</param>
/// <param name="maxout">解压结果最大长度</param>
/// <returns>解压缩结果</returns>
public static byte[] Decompress(byte[] input, int begin, int length, int maxout)
{
CheckFastLZDll();
byte[] output = new byte[maxout + 66];
fixed (byte* pSrc1 = &input[begin])
fixed (byte* pSrc2 = output)
{
int outlen = Is64bitApp() ? FastLZx64.FastLZ_Decompress(pSrc1, length, pSrc2, output.Length) : FastLZx86.FastLZ_Decompress(pSrc1, length, pSrc2, output.Length);
byte[] result = new byte[outlen];
Array.Copy(output, 0, result, 0, outlen);
return result;
}
}
private static byte[] ExHead = "!FLZ".ToEnBytes(4);
private const int ExHeadAllLength = 20;
private const int ExTailAllLength = 8;
private static DateTime Jan1st1970 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
/// <summary>
/// 压缩(扩展)
/// </summary>
/// <param name="input">输入</param>
/// <param name="begin">起始位置</param>
/// <param name="length">长度</param>
/// <param name="datetime">时间</param>
/// <param name="index">索引</param>
/// <returns>压缩结果</returns>
public static byte[] CompressEx(byte[] input, int begin, int length, DateTime dateTime, int index)
{
CheckFastLZDll();
byte[] result = CompressEx(input, begin, length);
if (result.Length > 0)
{
TimeSpan span = dateTime - Jan1st1970;
int totalSeconds = (int)span.TotalSeconds;
int milliseconds = span.Milliseconds;
Array.Copy(BitConverter.GetBytes(totalSeconds), 0, result, 4, 4);
Array.Copy(BitConverter.GetBytes(milliseconds), 0, result, 8, 4);
Array.Copy(BitConverter.GetBytes(index), 0, result, result.Length - 8, 4);
}
return result;
}
/// <summary>
/// 压缩(扩展)
/// </summary>
/// <param name="input">输入</param>
/// <param name="begin">起始位置</param>
/// <param name="length">长度</param>
/// <returns>压缩结果</returns>
public static byte[] CompressEx(byte[] input, int begin, int length)
{
CheckFastLZDll();
byte[] result = new byte[0];
if (begin + length > input.Length) return result;
byte[] output = new byte[Math.Max(length * 2, 66)];
fixed (void* pSrc1 = &input[begin])
fixed (void* pSrc2 = output)
{
int outlen = Is64bitApp() ? FastLZx64.FastLZ_Compress(pSrc1, length, pSrc2) : FastLZx86.FastLZ_Compress(pSrc1, length, pSrc2);
result = new byte[outlen + ExHeadAllLength + ExTailAllLength];
Array.Copy(ExHead, 0, result, 0, ExHead.Length);
Array.Copy(BitConverter.GetBytes((int)0), 0, result, 4, 4);
Array.Copy(BitConverter.GetBytes((int)0), 0, result, 8, 4);
Array.Copy(BitConverter.GetBytes((int)output.Length), 0, result, 12, 4);
Array.Copy(BitConverter.GetBytes((int)outlen), 0, result, 16, 4);
Array.Copy(output, 0, result, ExHeadAllLength, outlen);
Array.Copy(BitConverter.GetBytes((int)0), 0, result, result.Length - 8, 4);
result[result.Length - 4] = 42; //*
result[result.Length - 3] = 0; //CRC
result[result.Length - 2] = 13; //\r
result[result.Length - 1] = 10; //\n
return result;
}
}
/// <summary>
/// 解压缩(扩展)
/// </summary>
/// <param name="input">输入</param>
/// <param name="begin">起始位置</param>
/// <param name="length">长度</param>
/// <returns>解压缩结果</returns>
public static byte[] DecompressEx(byte[] input, int begin, int length)
{
CheckFastLZDll();
byte[] result = new byte[0];
if (input.Length <= 2 + ExHeadAllLength + ExTailAllLength) return result;
if (begin + length > input.Length) return result;
if (input[begin] != 33) return result;
if (input[begin + length - 4] != 42) return result;
if (length != BitConverter.ToInt32(input, begin + 16) + ExHeadAllLength + ExTailAllLength) return result;
byte[] output = new byte[BitConverter.ToInt32(input, begin + ExHead.Length)];
fixed (byte* pSrc1 = &input[begin + ExHeadAllLength])
fixed (byte* pSrc2 = output)
{
length = length - ExHeadAllLength - ExTailAllLength;
int outlen = Is64bitApp() ? FastLZx64.FastLZ_Decompress(pSrc1, length, pSrc2, output.Length) : FastLZx86.FastLZ_Decompress(pSrc1, length, pSrc2, output.Length);
result = new byte[outlen];
Array.Copy(output, 0, result, 0, outlen);
return result;
}
}
/// <summary>
/// 解压缩(扩展)
/// </summary>
/// <param name="input">输入</param>
/// <param name="begin">起始位置</param>
/// <param name="length">长度</param>
/// <param name="datetime">时间</param>
/// <param name="index">索引</param>
/// <returns>解压缩结果</returns>
public static byte[] DecompressEx(byte[] input, int begin, int length, out DateTime datetime, out int index)
{
CheckFastLZDll();
byte[] result = DecompressEx(input, begin, length);
datetime = Jan1st1970;
index = 0;
if (result.Length > 0)
{
datetime = Jan1st1970.AddSeconds(BitConverter.ToInt32(input, begin + 4)).AddMilliseconds(BitConverter.ToInt32(input, begin + 8));
index = BitConverter.ToInt32(input, begin + length - 8);
}
return result;
}
private static bool FileExist = false;
public static bool CheckFastLZDll()
{
if (FileExist) return true;
if (File.Exists(DirEx.CurrentDir() + "FastLZx86.dll") && File.Exists(DirEx.CurrentDir() + "FastLZx64.dll"))
{
FileExist = true;
return true;
}
try
{
CreateResourceToFile(DirEx.CurrentDir() + "FastLZx86.dll", "Sunny.UI.Common.FastLZx86.dat");
CreateResourceToFile(DirEx.CurrentDir() + "FastLZx64.dll", "Sunny.UI.Common.FastLZx64.dat");
}
catch
{
return false;
}
FileExist = File.Exists(DirEx.CurrentDir() + "FastLZx86.dll") && File.Exists(DirEx.CurrentDir() + "FastLZx64.dll");
return FileExist;
}
/// <summary>
/// 从系统资源中保存文件
/// </summary>
/// <param name="file">文件名</param>
/// <param name="resource">资源名称</param>
private static void CreateResourceToFile(string file, string resource)
{
if (!File.Exists(file))
{
Stream stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(resource);
if (stream != null)
{
byte[] buffer = new byte[stream.Length];
stream.Read(buffer, 0, (int)stream.Length);
stream.Close();
File.WriteAllBytes(file, buffer);
}
}
}
}
}

View File

@ -1,6 +1,6 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* CopyRight (C) 2012-2025 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse
@ -43,7 +43,7 @@ namespace Sunny.UI
/// <param name="targetFileName"></param>
/// <param name="bFailIfExists"></param>
/// <returns></returns>
public static bool Copy(this string sourceFileName, string targetFileName, bool bFailIfExists = true)
public static bool Copy(string sourceFileName, string targetFileName, bool bFailIfExists = true)
{
if (File.Exists(sourceFileName))
{
@ -53,15 +53,6 @@ namespace Sunny.UI
return false;
}
/// <summary>
/// 调用WINAPI删除文件
/// </summary>
/// <param name="lpFileName">文件</param>
public static int DeleteFile(string lpFileName)
{
return Win32.Kernel.DeleteFile(lpFileName);
}
/// <summary>
/// 打开文件夹对话框
/// </summary>
@ -71,7 +62,7 @@ namespace Sunny.UI
/// <returns>打开是否成功</returns>
public static bool OpenDialog(ref string filename, string filter = "", string defaultExt = "")
{
using OpenFileDialog od = new OpenFileDialog { Title = UILocalize.Open };
using OpenFileDialog od = new OpenFileDialog { Title = UIStyles.CurrentResources.Open };
try
{
@ -98,7 +89,7 @@ namespace Sunny.UI
/// <returns>保存是否成功</returns>
public static bool SaveDialog(ref string filename, string filter = "", string defaultExt = "")
{
using SaveFileDialog od = new SaveFileDialog { Title = UILocalize.Save };
using SaveFileDialog od = new SaveFileDialog { Title = UIStyles.CurrentResources.Save };
try
{
od.FileName = filename;

View File

@ -1,6 +1,6 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* CopyRight (C) 2012-2025 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse
@ -382,7 +382,6 @@ namespace Sunny.UI
/// <summary>
/// 创建圆角路径
/// </summary>
/// <param name="g">绘图图面</param>
/// <param name="rect">区域</param>
/// <param name="radius">圆角大小</param>
/// <param name="cornerLeftTop">左上角</param>

View File

@ -1,6 +1,6 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* CopyRight (C) 2012-2025 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse

View File

@ -1,6 +1,6 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* CopyRight (C) 2012-2025 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse
@ -33,6 +33,70 @@ namespace Sunny.UI
/// </summary>
public static class GraphicsEx
{
public static string TruncateText(Graphics graphics, string text, Font font, float maxWidth)
{
// If the text is empty or null, return it as-is.
if (string.IsNullOrEmpty(text)) return text;
// Measure the original string.
SizeF size = graphics.MeasureString(text, font);
// If the original string fits within the width, return it as-is.
if (size.Width <= maxWidth) return text;
// Otherwise, truncate the string until it fits.
string truncatedText = text;
for (int i = text.Length; i > 0; i--)
{
truncatedText = text.Left(i) + "...";
size = graphics.MeasureString(truncatedText, font);
if (size.Width <= maxWidth)
break;
}
return truncatedText;
}
public static void DrawTruncateString(this Graphics g, string text, Font font, Color color, Rectangle rect, float maxWidth, HorizontalAlignment alignment)
{
text = TruncateText(g, text, font, maxWidth);
g.DrawString(text, font, color, rect, alignment.ToContentAlignment());
}
internal static ContentAlignment ToContentAlignment(this HorizontalAlignment alignment)
{
switch (alignment)
{
case HorizontalAlignment.Left: return ContentAlignment.MiddleLeft;
case HorizontalAlignment.Center: return ContentAlignment.MiddleCenter;
case HorizontalAlignment.Right: return ContentAlignment.MiddleRight;
}
return ContentAlignment.MiddleLeft;
}
internal static HorizontalAlignment ToHorizontalAlignment(this ContentAlignment alignment)
{
switch (alignment)
{
case ContentAlignment.TopLeft:
case ContentAlignment.MiddleLeft:
case ContentAlignment.BottomLeft:
return HorizontalAlignment.Left;
case ContentAlignment.TopCenter:
case ContentAlignment.MiddleCenter:
case ContentAlignment.BottomCenter:
return HorizontalAlignment.Center;
case ContentAlignment.TopRight:
case ContentAlignment.MiddleRight:
case ContentAlignment.BottomRight:
return HorizontalAlignment.Right;
}
return HorizontalAlignment.Left;
}
public static void DrawString(this Graphics g, string text, Font font, Color color, Rectangle rect, ContentAlignment alignment, int offsetX = 0, int offsetY = 0)
{
if (text.IsNullOrEmpty()) return;

View File

@ -1,864 +0,0 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse
* Gitee: https://gitee.com/yhuse/SunnyUI
* GitHub: https://github.com/yhuse/SunnyUI
*
* SunnyUI.dll can be used for free under the GPL-3.0 license.
* If you use this code, please keep this note.
* 使
******************************************************************************
* : UHook.cs
* :
* : V3.1
* : 2020-01-01
*
* 2020-01-01: V2.2.0
******************************************************************************/
using Sunny.UI.Win32;
using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;
#pragma warning disable 1591
namespace Sunny.UI
{
/// <summary>
/// Abstract base class for Mouse and Keyboard hooks
/// </summary>
public abstract class GlobalHook
{
#region Windows API Code
[StructLayout(LayoutKind.Sequential)]
protected class POINT
{
public int x;
public int y;
}
[StructLayout(LayoutKind.Sequential)]
protected class MouseHookStruct
{
public POINT pt;
public int hwnd;
public int wHitTestCode;
public int dwExtraInfo;
}
[StructLayout(LayoutKind.Sequential)]
protected class MouseLLHookStruct
{
public POINT pt;
public int mouseData;
public int flags;
public int time;
public int dwExtraInfo;
}
[StructLayout(LayoutKind.Sequential)]
protected class KeyboardHookStruct
{
public int vkCode;
public int scanCode;
public int flags;
public int time;
public int dwExtraInfo;
}
[DllImport("user32.dll", CharSet = CharSet.Auto,
CallingConvention = CallingConvention.StdCall, SetLastError = true)]
protected static extern int SetWindowsHookEx(
int idHook,
HookProc lpfn,
IntPtr hMod,
int dwThreadId);
[DllImport("user32.dll", CharSet = CharSet.Auto,
CallingConvention = CallingConvention.StdCall, SetLastError = true)]
protected static extern int UnhookWindowsHookEx(int idHook);
[DllImport("user32.dll", CharSet = CharSet.Auto,
CallingConvention = CallingConvention.StdCall)]
protected static extern int CallNextHookEx(
int idHook,
int nCode,
int wParam,
IntPtr lParam);
[DllImport("user32")]
protected static extern int ToAscii(
int uVirtKey,
int uScanCode,
byte[] lpbKeyState,
byte[] lpwTransKey,
int fuState);
[DllImport("user32")]
protected static extern int GetKeyboardState(byte[] pbKeyState);
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
protected static extern short GetKeyState(int vKey);
protected delegate int HookProc(int nCode, int wParam, IntPtr lParam);
protected const int WH_MOUSE_LL = 14;
protected const int WH_KEYBOARD_LL = 13;
protected const int WH_MOUSE = 7;
protected const int WH_KEYBOARD = 2;
protected const int WM_MOUSEMOVE = 0x200;
protected const int WM_LBUTTONDOWN = 0x201;
protected const int WM_RBUTTONDOWN = 0x204;
protected const int WM_MBUTTONDOWN = 0x207;
protected const int WM_LBUTTONUP = 0x202;
protected const int WM_RBUTTONUP = 0x205;
protected const int WM_MBUTTONUP = 0x208;
protected const int WM_LBUTTONDBLCLK = 0x203;
protected const int WM_RBUTTONDBLCLK = 0x206;
protected const int WM_MBUTTONDBLCLK = 0x209;
protected const int WM_MOUSEWHEEL = 0x020A;
protected const int WM_KEYDOWN = 0x100;
protected const int WM_KEYUP = 0x101;
protected const int WM_SYSKEYDOWN = 0x104;
protected const int WM_SYSKEYUP = 0x105;
protected const byte VK_SHIFT = 0x10;
protected const byte VK_CAPITAL = 0x14;
protected const byte VK_NUMLOCK = 0x90;
protected const byte VK_LSHIFT = 0xA0;
protected const byte VK_RSHIFT = 0xA1;
protected const byte VK_LCONTROL = 0xA2;
protected const byte VK_RCONTROL = 0x3;
protected const byte VK_LALT = 0xA4;
protected const byte VK_RALT = 0xA5;
protected const byte LLKHF_ALTDOWN = 0x20;
#endregion Windows API Code
#region Private Variables
protected int _hookType;
protected int _handleToHook;
protected bool _isStarted;
protected HookProc _hookCallback;
#endregion Private Variables
#region Properties
public bool IsStarted
{
get
{
return _isStarted;
}
}
#endregion Properties
#region Constructor
public GlobalHook()
{
Application.ApplicationExit += Application_ApplicationExit;
}
#endregion Constructor
#region Methods
public void Start()
{
if (!_isStarted && _hookType != 0)
{
// Make sure we keep a reference to this delegate!
// If not, GC randomly collects it, and a NullReference exception is thrown
_hookCallback = HookCallbackProcedure;
_handleToHook = SetWindowsHookEx(_hookType, _hookCallback, (IntPtr)Kernel.GetModuleHandle(null), 0);
//Marshal.GetHINSTANCE(Assembly.GetExecutingAssembly().GetModules()[0]), 0);
// Were we able to sucessfully start hook?
if (_handleToHook != 0)
{
_isStarted = true;
}
}
}
public void Stop()
{
if (_isStarted)
{
UnhookWindowsHookEx(_handleToHook);
_isStarted = false;
}
}
protected virtual int HookCallbackProcedure(int nCode, Int32 wParam, IntPtr lParam)
{
// This method must be overriden by each extending hook
return 0;
}
protected void Application_ApplicationExit(object sender, EventArgs e)
{
if (_isStarted)
{
Stop();
}
}
#endregion Methods
}
/// <summary>
/// Captures global keyboard events
/// </summary>
public class KeyboardHook : GlobalHook
{
#region Events
public event KeyEventHandler KeyDown;
public event KeyEventHandler KeyUp;
public event KeyPressEventHandler KeyPress;
#endregion Events
#region Constructor
public KeyboardHook()
{
_hookType = WH_KEYBOARD_LL;
}
#endregion Constructor
#region Methods
protected override int HookCallbackProcedure(int nCode, int wParam, IntPtr lParam)
{
bool handled = false;
if (nCode > -1 && (KeyDown != null || KeyUp != null || KeyPress != null))
{
KeyboardHookStruct keyboardHookStruct =
(KeyboardHookStruct)Marshal.PtrToStructure(lParam, typeof(KeyboardHookStruct));
// Is Control being held down?
bool control = ((GetKeyState(VK_LCONTROL) & 0x80) != 0) ||
((GetKeyState(VK_RCONTROL) & 0x80) != 0);
// Is Shift being held down?
bool shift = ((GetKeyState(VK_LSHIFT) & 0x80) != 0) ||
((GetKeyState(VK_RSHIFT) & 0x80) != 0);
// Is Alt being held down?
bool alt = ((GetKeyState(VK_LALT) & 0x80) != 0) ||
((GetKeyState(VK_RALT) & 0x80) != 0);
// Is CapsLock on?
bool capslock = (GetKeyState(VK_CAPITAL) != 0);
// Create event using keycode and control/shift/alt values found above
KeyEventArgs e = new KeyEventArgs(
(Keys)(
keyboardHookStruct.vkCode |
(control ? (int)Keys.Control : 0) |
(shift ? (int)Keys.Shift : 0) |
(alt ? (int)Keys.Alt : 0)
));
// Handle KeyDown and KeyUp events
switch (wParam)
{
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
if (KeyDown != null)
{
KeyDown(this, e);
handled = e.Handled;
}
break;
case WM_KEYUP:
case WM_SYSKEYUP:
if (KeyUp != null)
{
KeyUp(this, e);
handled = e.Handled;
}
break;
}
// Handle KeyPress event
if (wParam == WM_KEYDOWN &&
!handled &&
!e.SuppressKeyPress &&
KeyPress != null)
{
byte[] keyState = new byte[256];
byte[] inBuffer = new byte[2];
GetKeyboardState(keyState);
if (ToAscii(keyboardHookStruct.vkCode,
keyboardHookStruct.scanCode,
keyState,
inBuffer,
keyboardHookStruct.flags) == 1)
{
char key = (char)inBuffer[0];
if ((capslock ^ shift) && Char.IsLetter(key))
key = Char.ToUpper(key);
KeyPressEventArgs e2 = new KeyPressEventArgs(key);
KeyPress(this, e2);
handled = e.Handled;
}
}
}
if (handled)
{
return 1;
}
else
{
return CallNextHookEx(_handleToHook, nCode, wParam, lParam);
}
}
#endregion Methods
}
/// <summary>
/// Captures global mouse events
/// </summary>
public class MouseHook : GlobalHook
{
#region MouseEventType Enum
private enum MouseEventType
{
None,
MouseDown,
MouseUp,
DoubleClick,
MouseWheel,
MouseMove
}
#endregion MouseEventType Enum
#region Events
public event MouseEventHandler MouseDown;
public event MouseEventHandler MouseUp;
public event MouseEventHandler MouseMove;
public event MouseEventHandler MouseWheel;
public event MouseEventHandler Click;
public event MouseEventHandler DoubleClick;
#endregion Events
#region Constructor
public MouseHook()
{
_hookType = WH_MOUSE_LL;
}
#endregion Constructor
#region Methods
protected override int HookCallbackProcedure(int nCode, int wParam, IntPtr lParam)
{
if (nCode > -1 && (MouseDown != null || MouseUp != null || MouseMove != null))
{
MouseLLHookStruct mouseHookStruct =
(MouseLLHookStruct)Marshal.PtrToStructure(lParam, typeof(MouseLLHookStruct));
MouseButtons button = GetButton(wParam);
MouseEventType eventType = GetEventType(wParam);
MouseEventArgs e = new MouseEventArgs(
button,
(eventType == MouseEventType.DoubleClick ? 2 : 1),
mouseHookStruct.pt.x,
mouseHookStruct.pt.y,
(eventType == MouseEventType.MouseWheel ? (short)((mouseHookStruct.mouseData >> 16) & 0xffff) : 0));
// Prevent multiple Right Click events (this probably happens for popup menus)
if (button == MouseButtons.Right && mouseHookStruct.flags != 0)
{
eventType = MouseEventType.None;
}
switch (eventType)
{
case MouseEventType.MouseDown:
MouseDown?.Invoke(this, e);
break;
case MouseEventType.MouseUp:
Click?.Invoke(this, e);
MouseUp?.Invoke(this, e);
break;
case MouseEventType.DoubleClick:
DoubleClick?.Invoke(this, e);
break;
case MouseEventType.MouseWheel:
MouseWheel?.Invoke(this, e);
break;
case MouseEventType.MouseMove:
MouseMove?.Invoke(this, e);
break;
}
}
return CallNextHookEx(_handleToHook, nCode, wParam, lParam);
}
private MouseButtons GetButton(Int32 wParam)
{
switch (wParam)
{
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
case WM_LBUTTONDBLCLK:
return MouseButtons.Left;
case WM_RBUTTONDOWN:
case WM_RBUTTONUP:
case WM_RBUTTONDBLCLK:
return MouseButtons.Right;
case WM_MBUTTONDOWN:
case WM_MBUTTONUP:
case WM_MBUTTONDBLCLK:
return MouseButtons.Middle;
default:
return MouseButtons.None;
}
}
private MouseEventType GetEventType(Int32 wParam)
{
switch (wParam)
{
case WM_LBUTTONDOWN:
case WM_RBUTTONDOWN:
case WM_MBUTTONDOWN:
return MouseEventType.MouseDown;
case WM_LBUTTONUP:
case WM_RBUTTONUP:
case WM_MBUTTONUP:
return MouseEventType.MouseUp;
case WM_LBUTTONDBLCLK:
case WM_RBUTTONDBLCLK:
case WM_MBUTTONDBLCLK:
return MouseEventType.DoubleClick;
case WM_MOUSEWHEEL:
return MouseEventType.MouseWheel;
case WM_MOUSEMOVE:
return MouseEventType.MouseMove;
default:
return MouseEventType.None;
}
}
#endregion Methods
}
/// <summary>
/// Standard Keyboard Shortcuts used by most applications
/// </summary>
public enum StandardShortcut
{
Copy,
Cut,
Paste,
SelectAll,
Save,
Open,
New,
Close,
Print
}
/// <summary>
/// Simulate keyboard key presses
/// </summary>
public static class KeyboardSimulator
{
#region Windows API Code
private const int KEYEVENTF_EXTENDEDKEY = 0x1;
private const int KEYEVENTF_KEYUP = 0x2;
[DllImport("user32.dll")]
private static extern void keybd_event(byte key, byte scan, int flags, int extraInfo);
#endregion Windows API Code
#region Methods
public static void KeyDown(Keys key)
{
keybd_event(ParseKey(key), 0, 0, 0);
}
public static void KeyUp(Keys key)
{
keybd_event(ParseKey(key), 0, KEYEVENTF_KEYUP, 0);
}
public static void KeyPress(Keys key)
{
KeyDown(key);
KeyUp(key);
}
public static void SimulateStandardShortcut(StandardShortcut shortcut)
{
switch (shortcut)
{
case StandardShortcut.Copy:
KeyDown(Keys.Control);
KeyPress(Keys.C);
KeyUp(Keys.Control);
break;
case StandardShortcut.Cut:
KeyDown(Keys.Control);
KeyPress(Keys.X);
KeyUp(Keys.Control);
break;
case StandardShortcut.Paste:
KeyDown(Keys.Control);
KeyPress(Keys.V);
KeyUp(Keys.Control);
break;
case StandardShortcut.SelectAll:
KeyDown(Keys.Control);
KeyPress(Keys.A);
KeyUp(Keys.Control);
break;
case StandardShortcut.Save:
KeyDown(Keys.Control);
KeyPress(Keys.S);
KeyUp(Keys.Control);
break;
case StandardShortcut.Open:
KeyDown(Keys.Control);
KeyPress(Keys.O);
KeyUp(Keys.Control);
break;
case StandardShortcut.New:
KeyDown(Keys.Control);
KeyPress(Keys.N);
KeyUp(Keys.Control);
break;
case StandardShortcut.Close:
KeyDown(Keys.Alt);
KeyPress(Keys.F4);
KeyUp(Keys.Alt);
break;
case StandardShortcut.Print:
KeyDown(Keys.Control);
KeyPress(Keys.P);
KeyUp(Keys.Control);
break;
}
}
private static byte ParseKey(Keys key)
{
// Alt, Shift, and Control need to be changed for API function to work with them
switch (key)
{
case Keys.Alt:
return 18;
case Keys.Control:
return 17;
case Keys.Shift:
return 16;
default:
return (byte)key;
}
}
#endregion Methods
}
/// <summary>
/// And X, Y point on the screen
/// </summary>
public struct MousePoint
{
public MousePoint(Point p)
{
X = p.X;
Y = p.Y;
}
public int X;
public int Y;
public static implicit operator Point(MousePoint p)
{
return new Point(p.X, p.Y);
}
}
/// <summary>
/// Mouse buttons that can be pressed
/// </summary>
public enum MouseButton
{
Left = 0x2,
Right = 0x8,
Middle = 0x20
}
/// <summary>
/// Operations that simulate mouse events
/// </summary>
public static class MouseSimulator
{
#region Windows API Code
[DllImport("user32.dll")]
private static extern int ShowCursor(bool show);
[DllImport("user32.dll")]
private static extern void mouse_event(int flags, int dX, int dY, int buttons, int extraInfo);
private const int MOUSEEVENTF_MOVE = 0x1;
private const int MOUSEEVENTF_LEFTDOWN = 0x2;
private const int MOUSEEVENTF_LEFTUP = 0x4;
private const int MOUSEEVENTF_RIGHTDOWN = 0x8;
private const int MOUSEEVENTF_RIGHTUP = 0x10;
private const int MOUSEEVENTF_MIDDLEDOWN = 0x20;
private const int MOUSEEVENTF_MIDDLEUP = 0x40;
private const int MOUSEEVENTF_WHEEL = 0x800;
private const int MOUSEEVENTF_ABSOLUTE = 0x8000;
#endregion Windows API Code
#region Properties
/// <summary>
/// Gets or sets a structure that represents both X and Y mouse coordinates
/// </summary>
public static MousePoint Position
{
get
{
return new MousePoint(Cursor.Position);
}
set
{
Cursor.Position = value;
}
}
/// <summary>
/// Gets or sets only the mouse's x coordinate
/// </summary>
public static int X
{
get
{
return Cursor.Position.X;
}
set
{
Cursor.Position = new Point(value, Y);
}
}
/// <summary>
/// Gets or sets only the mouse's y coordinate
/// </summary>
public static int Y
{
get
{
return Cursor.Position.Y;
}
set
{
Cursor.Position = new Point(X, value);
}
}
#endregion Properties
#region Methods
/// <summary>
/// Press a mouse button down
/// </summary>
/// <param name="button"></param>
public static void MouseDown(MouseButton button)
{
mouse_event(((int)button), 0, 0, 0, 0);
}
public static void MouseDown(MouseButtons button)
{
switch (button)
{
case MouseButtons.Left:
MouseDown(MouseButton.Left);
break;
case MouseButtons.Middle:
MouseDown(MouseButton.Middle);
break;
case MouseButtons.Right:
MouseDown(MouseButton.Right);
break;
}
}
/// <summary>
/// Let a mouse button up
/// </summary>
/// <param name="button"></param>
public static void MouseUp(MouseButton button)
{
mouse_event(((int)button) * 2, 0, 0, 0, 0);
}
public static void MouseUp(MouseButtons button)
{
switch (button)
{
case MouseButtons.Left:
MouseUp(MouseButton.Left);
break;
case MouseButtons.Middle:
MouseUp(MouseButton.Middle);
break;
case MouseButtons.Right:
MouseUp(MouseButton.Right);
break;
}
}
/// <summary>
/// Click a mouse button (down then up)
/// </summary>
/// <param name="button"></param>
public static void Click(MouseButton button)
{
MouseDown(button);
MouseUp(button);
}
public static void Click(MouseButtons button)
{
switch (button)
{
case MouseButtons.Left:
Click(MouseButton.Left);
break;
case MouseButtons.Middle:
Click(MouseButton.Middle);
break;
case MouseButtons.Right:
Click(MouseButton.Right);
break;
}
}
/// <summary>
/// Double click a mouse button (down then up twice)
/// </summary>
/// <param name="button"></param>
public static void DoubleClick(MouseButton button)
{
Click(button);
Click(button);
}
public static void DoubleClick(MouseButtons button)
{
switch (button)
{
case MouseButtons.Left:
DoubleClick(MouseButton.Left);
break;
case MouseButtons.Middle:
DoubleClick(MouseButton.Middle);
break;
case MouseButtons.Right:
DoubleClick(MouseButton.Right);
break;
}
}
/// <summary>
/// Show a hidden current on currently application
/// </summary>
public static void Show()
{
ShowCursor(true);
}
/// <summary>
/// Hide mouse cursor only on current application's forms
/// </summary>
public static void Hide()
{
ShowCursor(false);
}
#endregion Methods
}
}

View File

@ -1,6 +1,6 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* CopyRight (C) 2012-2025 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse

View File

@ -1,6 +1,6 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* CopyRight (C) 2012-2025 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse

View File

@ -1,6 +1,6 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* CopyRight (C) 2012-2025 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse
@ -35,11 +35,9 @@ namespace Sunny.UI
/// <summary>
/// INI 配置文件类
/// </summary>
/// <typeparam name="TConfig">类型</typeparam>
public class IniConfig<TConfig> : BaseConfig<TConfig> where TConfig : IniConfig<TConfig>, new()
/// <typeparam name="T">类型</typeparam>
public class IniConfig<T> : BaseConfig<T> where T : IniConfig<T>, new()
{
#region
/// <summary>
/// Ini文件编码格式
/// </summary>
@ -92,12 +90,12 @@ namespace Sunny.UI
{
if (filename.IsNullOrWhiteSpace())
{
filename = DirEx.CurrentDir() + ConfigFile;
filename = Dir.CurrentDir() + ConfigFile;
}
if (filename.IsNullOrWhiteSpace())
{
throw new ApplicationException($"未指定{typeof(TConfig).Name}的配置文件路径!");
throw new ApplicationException($"未指定{typeof(T).Name}的配置文件路径!");
}
if (!File.Exists(filename))
@ -150,12 +148,12 @@ namespace Sunny.UI
{
if (filename.IsNullOrWhiteSpace())
{
filename = DirEx.CurrentDir() + ConfigFile;
filename = Dir.CurrentDir() + ConfigFile;
}
if (filename.IsNullOrWhiteSpace())
{
throw new ApplicationException($"未指定{typeof(TConfig).Name}的配置文件路径!");
throw new ApplicationException($"未指定{typeof(T).Name}的配置文件路径!");
}
ConcurrentDictionary<string, Ident> idents = ConfigHelper.InitIdents(current);
@ -169,7 +167,8 @@ namespace Sunny.UI
ConfigHelper.SaveConfigValue(Current, idents);
StringBuilder strs = new StringBuilder();
strs.AppendLine(";<?ini version=\"" + UIGlobal.Version + "\" encoding=\"" + IniEncoding.BodyName + "\"?>");
strs.AppendLine(";<?Ini Version=\"" + UIGlobal.Version + "\" Encoding=\"" + IniEncoding.BodyName + "\"?>");
strs.AppendLine(";<?Update Time=\"" + DateTime.Now.DateTimeString() + "\"?>");
strs.AppendLine("");
Dictionary<string, List<Ident>> listidents = new Dictionary<string, List<Ident>>();
foreach (var ident in idents.Values)
@ -218,7 +217,7 @@ namespace Sunny.UI
}
listidents.Clear();
DirEx.CreateDir(Path.GetDirectoryName(filename));
Dir.CreateDir(Path.GetDirectoryName(filename));
string filetmp = filename + "." + RandomEx.RandomPureChar(3);
File.Delete(filetmp);
StreamWriter sw = new StreamWriter(filetmp, false, IniEncoding);
@ -236,7 +235,198 @@ namespace Sunny.UI
MessageBox.Show("配置文件存储失败: " + filename + " ," + ex.Message);
}
}
}
#endregion
/// <summary>
/// INI 配置文件类
/// </summary>
/// <typeparam name="T">类型</typeparam>
public class IniUTF8Config<T> : BaseConfig<T> where T : IniUTF8Config<T>, new()
{
[ConfigIgnore]
public object this[string property]
{
get
{
PropertyInfo info = Current.GetType().GetProperty(property);
if (info == null)
{
throw new ArgumentNullException("属性名称不存在:" + property);
}
return info.GetValue(this, null);
}
set
{
PropertyInfo info = Current.GetType().GetProperty(property);
if (info == null)
{
throw new ArgumentNullException("属性名称不存在:" + property);
}
try
{
Type propertyType = info.PropertyType;
info.SetValue(Current, Convert.ChangeType(value, propertyType), null);
}
catch (Exception)
{
throw new ArgumentException("属性值转换失败:" + property + ", " + value);
}
}
}
/// <summary>加载指定配置文件</summary>
/// <param name="filename">文件名</param>
/// <returns>结果</returns>
public override bool Load(string filename)
{
if (filename.IsNullOrWhiteSpace())
{
filename = Dir.CurrentDir() + ConfigFile;
}
if (filename.IsNullOrWhiteSpace())
{
throw new ApplicationException($"未指定{typeof(T).Name}的配置文件路径!");
}
if (!File.Exists(filename))
{
return false;
}
try
{
ConcurrentDictionary<string, Ident> idents = ConfigHelper.InitIdents(current);
foreach (var ident in idents.Values)
{
if (ident.Section.IsNullOrEmpty())
{
ident.Section = "Setup";
}
}
IniFile ini = new IniFile(filename, Encoding.UTF8);
foreach (var ident in idents.Values)
{
if (ident.IsList)
{
ident.Values.Clear();
NameValueCollection list = ini.GetSectionValues(ident.Section + "-" + ident.Key);
foreach (var pair in list)
{
ident.Values.Add(ini.Read(ident.Section + "-" + ident.Key, pair.ToString(), ""));
}
}
else
{
ident.Value = ini.Read(ident.Section, ident.Key, "");
}
}
ConfigHelper.LoadConfigValue(current, idents);
return true;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return false;
}
}
/// <summary>保存到配置文件中去</summary>
/// <param name="filename">文件名</param>
public override void Save(string filename)
{
if (filename.IsNullOrWhiteSpace())
{
filename = Dir.CurrentDir() + ConfigFile;
}
if (filename.IsNullOrWhiteSpace())
{
throw new ApplicationException($"未指定{typeof(T).Name}的配置文件路径!");
}
ConcurrentDictionary<string, Ident> idents = ConfigHelper.InitIdents(current);
foreach (var ident in idents.Values)
{
if (ident.Section.IsNullOrEmpty())
{
ident.Section = "Setup";
}
}
ConfigHelper.SaveConfigValue(Current, idents);
StringBuilder strs = new StringBuilder();
strs.AppendLine(";<?Ini Version=\"" + UIGlobal.Version + "\" Encoding=\"" + Encoding.UTF8.BodyName + "\"?>");
strs.AppendLine(";<?Update Time=\"" + DateTime.Now.DateTimeString() + "\"?>");
strs.AppendLine("");
Dictionary<string, List<Ident>> listidents = new Dictionary<string, List<Ident>>();
foreach (var ident in idents.Values)
{
string section = ident.IsList ? ident.Section + "-" + ident.Key : ident.Section;
if (!listidents.ContainsKey(section))
{
listidents.Add(section, new List<Ident>());
}
listidents[section].Add(ident);
}
foreach (var values in listidents)
{
strs.AppendLine("[" + values.Key + "]");
SortedList<int, Ident> slist = new SortedList<int, Ident>();
foreach (var ident in values.Value)
{
slist.Add(ident.Index, ident);
}
foreach (var ident in slist.Values)
{
if (!ident.Description.IsNullOrEmpty())
{
strs.AppendLine(";<!--" + ident.Description + "-->");
}
if (ident.IsList)
{
for (int i = 0; i < ident.Values.Count; i++)
{
strs.AppendLine("Value" + i + "=" + ident.Values[i]);
}
}
else
{
strs.AppendLine(ident.Key + "=" + ident.Value);
}
}
strs.AppendLine("");
}
listidents.Clear();
Dir.CreateDir(Path.GetDirectoryName(filename));
string filetmp = filename + "." + RandomEx.RandomPureChar(3);
File.Delete(filetmp);
StreamWriter sw = new StreamWriter(filetmp, false, Encoding.UTF8);
sw.WriteLine(strs.ToString());
sw.Flush();
sw.Dispose();
try
{
File.Delete(filename);
File.Move(filetmp, filename);
}
catch (Exception ex)
{
MessageBox.Show("配置文件存储失败: " + filename + " ," + ex.Message);
}
}
}
}

View File

@ -1,6 +1,6 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* CopyRight (C) 2012-2025 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse
@ -22,7 +22,6 @@
* 2023-08-11: v3.4.1
******************************************************************************/
using Sunny.UI.Win32;
using System;
using System.Collections.Specialized;
using System.ComponentModel;
@ -31,6 +30,7 @@ using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using Sunny.UI.Win32;
namespace Sunny.UI
{
@ -65,7 +65,7 @@ namespace Sunny.UI
FileName = fileName;
FileInfo fi = new FileInfo(FileName);
DirEx.CreateDir(fi.DirectoryName);
Dir.CreateDir(fi.DirectoryName);
if (!Directory.Exists(fi.DirectoryName))
{
@ -78,7 +78,7 @@ namespace Sunny.UI
//文件不存在,建立文件
using (StreamWriter sw = new StreamWriter(fileName, false, IniEncoding))
{
sw.WriteLine(";<?ini version=\"" + UIGlobal.Version + "\" encoding=\"" + IniEncoding.BodyName + "\"?>");
sw.WriteLine(";<?Ini Version=\"" + UIGlobal.Version + "\" Encoding=\"" + Encoding.UTF8.BodyName + "\"?>");
sw.WriteLine("");
}
}
@ -149,7 +149,7 @@ namespace Sunny.UI
/// <returns>结果</returns>
public string Read(string section, string key, string Default)
{
byte[] buffer = new byte[4096];
byte[] buffer = new byte[4096 * 16];
if (Default == null)
{
Default = "";
@ -299,57 +299,6 @@ namespace Sunny.UI
/// </summary>
public class IniFile : IniBase
{
/// <summary>
/// 写结构
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="value">value</param>
/// <typeparam name="T">T</typeparam>
public void WriteStruct<T>(string section, string key, T value) where T : struct
{
Write(section, key, value.ToBytes());
}
/// <summary>
/// 读结构
/// </summary>
/// <typeparam name="T">T</typeparam>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="Default">Normal</param>
/// <returns>结果</returns>
public T ReadStruct<T>(string section, string key, T Default) where T : struct
{
//得到结构体的大小
int size = Default.Size();
byte[] bytes = Read(section, key, "").ToHexBytes();
return size > bytes.Length ? Default : bytes.ToStruct<T>();
}
/// <summary>
/// 写Byte数组
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="value">value</param>
public void Write(string section, string key, byte[] value)
{
Write(section, key, value.ToHexString());
}
/// <summary>
/// 读Byte数组
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="Default">Normal</param>
/// <returns>结果</returns>
public byte[] ReadBytes(string section, string key, byte[] Default)
{
return Read(section, key, Default.ToHexString()).ToHexBytes();
}
/// <summary>
/// 写Char
/// </summary>

View File

@ -0,0 +1,790 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2023 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse
* Gitee: https://gitee.com/yhuse/SunnyUI
* GitHub: https://github.com/yhuse/SunnyUI
*
* SunnyUI.dll can be used for free under the GPL-3.0 license.
* If you use this code, please keep this note.
* 使
******************************************************************************
* : UIniFileEx.cs
* : INI WinAPI
* : V3.1
* : 2021-10-27
*
* 2021-10-27: V2.2.0
******************************************************************************/
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
namespace Sunny.UI
{
public class IniFileEx
{
private readonly Dictionary<string, NameValueCollection> data = new Dictionary<string, NameValueCollection>();
private static readonly Regex regRemoveEmptyLines =
new Regex
(
@"(\s*;[\d\D]*?\r?\n)+|\r?\n(\s*\r?\n)*",
RegexOptions.Multiline | RegexOptions.Compiled
);
private static readonly Regex regParseIniData =
new Regex
(
@"
(?<IsSection>
^\s*\[(?<SectionName>[^\]]+)?\]\s*$
)
|
(?<IsKeyValue>
^\s*(?<Key>[^(\s*\=\s*)]+)?\s*\=\s*(?<Value>[\d\D]*)$
)",
RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace
);
public IniFileEx(string fileName) : this(fileName, Encoding.Default) { }
public IniFileEx(string fileName, Encoding encoding)
{
FileName = fileName;
Encoding = encoding;
using FileStream fs = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None);
ReadIniData(fs, encoding);
}
/// <summary>
/// 文件名
/// </summary>
[Description("文件名")]
public string FileName { get; set; } //INI文件名
public Encoding Encoding { get; set; }
private void ReadIniData(Stream stream, Encoding encoding)
{
string lastSection = string.Empty;
data.Add(lastSection, new NameValueCollection());
if (stream != null && encoding != null)
{
using StreamReader reader = new StreamReader(stream, encoding);
string iniData = reader.ReadToEnd();
iniData = regRemoveEmptyLines.Replace(iniData, "\n");
string[] lines = iniData.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
foreach (string s in lines)
{
Match m = regParseIniData.Match(s);
if (m.Success)
{
if (m.Groups["IsSection"].Length > 0)
{
string sName = m.Groups["SectionName"].Value.ToLowerInvariant();
if (lastSection != sName)
{
lastSection = sName;
if (!data.ContainsKey(sName))
{
data.Add(sName, new NameValueCollection());
}
}
}
else if (m.Groups["IsKeyValue"].Length > 0)
{
data[lastSection].Add(m.Groups["Key"].Value, m.Groups["Value"].Value);
}
}
}
}
}
public NameValueCollection this[string section]
{
get
{
section = section.ToLowerInvariant();
if (!data.ContainsKey(section))
data.Add(section, new NameValueCollection());
return data[section];
}
}
public string this[string section, string key]
{
get => this[section][key];
set => this[section][key] = value;
}
public object this[string section, string key, Type t]
{
get
{
if (t == null || t == (Type)Type.Missing)
return this[section][key];
return GetValue(section, key, null, t);
}
set
{
if (t == null || t == (Type)Type.Missing)
this[section][key] = string.Empty;
else
SetValue(section, key, value);
}
}
public string[] KeyNames(string section)
{
return this[section].AllKeys;
}
public string[] SectionValues(string section)
{
return this[section].GetValues(0);
}
private object GetValue(string section, string key, object defaultValue, Type t)
{
section = section.ToLowerInvariant();
key = key.ToLowerInvariant();
if (!data.ContainsKey(section)) return defaultValue;
string v = data[section][key];
if (string.IsNullOrEmpty(v)) return defaultValue;
TypeConverter conv = TypeDescriptor.GetConverter(t);
if (!conv.CanConvertFrom(typeof(string))) return defaultValue;
try
{
return conv.ConvertFrom(v);
}
catch
{
return defaultValue;
}
}
private T GetValue<T>(string section, string key, T defaultValue)
{
return (T)GetValue(section, key, defaultValue, typeof(T));
}
private void SetValue(string section, string key, object value)
{
if (value == null)
{
this[section][key] = string.Empty;
}
else
{
TypeConverter conv = TypeDescriptor.GetConverter(value);
if (!conv.CanConvertTo(typeof(string)))
{
this[section][key] = value.ToString();
}
else
{
this[section][key] = (string)conv.ConvertTo(value, typeof(string));
}
}
UpdateFile();
}
public void Write(string section, string key, string value)
{
SetValue(section, key, value);
}
public string Read(string section, string key, string Default)
{
return GetValue(section, key, Default);
}
/// <summary>
/// 读取指定的Section的所有Value到列表中
/// </summary>
/// <param name="section">section</param>
public NameValueCollection GetSectionValues(string section)
{
return this[section];
}
public void UpdateFile()
{
Save();
}
public void Save()
{
Save(FileName, Encoding);
}
public void Save(string fileName, Encoding encoding)
{
using FileStream fs = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None);
Save(fs, encoding);
}
private void Save(Stream stream, Encoding encoding)
{
using StreamWriter sw = new StreamWriter(stream, encoding);
foreach (var cur in data)
{
if (!string.IsNullOrEmpty(cur.Key))
{
sw.WriteLine("[{0}]", cur.Key);
}
NameValueCollection col = cur.Value;
foreach (string key in col.Keys)
{
if (!string.IsNullOrEmpty(key))
{
string value = col[key];
if (!string.IsNullOrEmpty(value))
sw.WriteLine("{0}={1}", key, value);
}
}
}
sw.Flush();
}
public bool HasSection(string section)
{
return data.ContainsKey(section.ToLowerInvariant());
}
public bool HasKey(string section, string key)
{
return
data.ContainsKey(section) &&
!string.IsNullOrEmpty(data[section][key]);
}
/// <summary>
/// 写结构
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="value">value</param>
/// <typeparam name="T">T</typeparam>
public void WriteStruct<T>(string section, string key, T value) where T : struct
{
Write(section, key, value.ToBytes());
}
/// <summary>
/// 读结构
/// </summary>
/// <typeparam name="T">T</typeparam>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="Default">Normal</param>
/// <returns>结果</returns>
public T ReadStruct<T>(string section, string key, T Default) where T : struct
{
//得到结构体的大小
int size = StructEx.Size(Default);
byte[] bytes = Read(section, key, "").ToHexBytes();
return size > bytes.Length ? Default : bytes.ToStruct<T>();
}
/// <summary>
/// 写Byte数组
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="value">value</param>
public void Write(string section, string key, byte[] value)
{
Write(section, key, value.ToHexString());
}
/// <summary>
/// 读Byte数组
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="Default">Normal</param>
/// <returns>结果</returns>
public byte[] ReadBytes(string section, string key, byte[] Default)
{
return Read(section, key, Default.ToHexString()).ToHexBytes();
}
/// <summary>
/// 写Char
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="value">value</param>
public void Write(string section, string key, char value)
{
Write(section, key, value.ToString());
}
/// <summary>
/// 读Char
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="Default">Normal</param>
/// <returns>结果</returns>
public char ReadChar(string section, string key, char Default = ' ')
{
return Read(section, key, Default.ToString()).ToChar(Default);
}
/// <summary>
/// 写Decimal
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="value">value</param>
public void Write(string section, string key, decimal value)
{
Write(section, key, value.ToString(CultureInfo.InvariantCulture));
}
/// <summary>
/// 读Decimal
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="Default">Normal</param>
/// <returns>结果</returns>
public decimal ReadDecimal(string section, string key, decimal Default = 0)
{
return Read(section, key, Default.ToString(CultureInfo.InvariantCulture)).ToDecimal(Default);
}
/// <summary>
/// 写整数
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="value">value</param>
public void Write(string section, string key, short value)
{
Write(section, key, value.ToString());
}
/// <summary>
/// 读整数
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="Default">Normal</param>
/// <returns>结果</returns>
public short ReadShort(string section, string key, short Default = 0)
{
return Read(section, key, Default.ToString()).ToShort(Default);
}
/// <summary>
/// 写整数
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="value">value</param>
public void Write(string section, string key, ushort value)
{
Write(section, key, value.ToString());
}
/// <summary>
/// 读整数
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="Default">Normal</param>
/// <returns>结果</returns>
public ushort ReadUShort(string section, string key, ushort Default = 0)
{
return Read(section, key, Default.ToString()).ToUShort(Default);
}
/// <summary>
/// 写整数
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="value">value</param>
public void Write(string section, string key, int value)
{
Write(section, key, value.ToString());
}
/// <summary>
/// 读整数
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="Default">Normal</param>
/// <returns>结果</returns>
public int ReadInt(string section, string key, int Default = 0)
{
return Read(section, key, Default.ToString()).ToInt(Default);
}
/// <summary>
/// 写整数
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="value">value</param>
public void Write(string section, string key, uint value)
{
Write(section, key, value.ToString());
}
/// <summary>
/// 读整数
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="Default">Normal</param>
/// <returns>结果</returns>
public uint ReadUInt(string section, string key, uint Default = 0)
{
return Read(section, key, Default.ToString()).ToUInt(Default);
}
/// <summary>
/// 写整数
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="value">value</param>
public void Write(string section, string key, ulong value)
{
Write(section, key, value.ToString());
}
/// <summary>
/// 读整数
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="Default">Normal</param>
/// <returns>结果</returns>
public ulong ReadULong(string section, string key, ulong Default = 0)
{
return Read(section, key, Default.ToString()).ToULong(Default);
}
/// <summary>
/// 写整数
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="value">value</param>
public void Write(string section, string key, long value)
{
Write(section, key, value.ToString());
}
/// <summary>
/// 读整数
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="Default">Normal</param>
/// <returns>结果</returns>
public long ReadLong(string section, string key, long Default = 0)
{
return Read(section, key, Default.ToString()).ToLong(Default);
}
/// <summary>
/// 写布尔
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="value">value</param>
public void Write(string section, string key, bool value)
{
Write(section, key, value ? bool.TrueString : bool.FalseString);
}
/// <summary>
/// 读布尔
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="Default">Normal</param>
/// <returns>结果</returns>
public bool ReadBool(string section, string key, bool Default = false)
{
string str = Read(section, key, Default.ToString());
if (string.Equals(str, bool.TrueString, StringComparison.CurrentCultureIgnoreCase))
{
return true;
}
if (string.Equals(str, bool.FalseString, StringComparison.CurrentCultureIgnoreCase))
{
return false;
}
return Default;
}
/// <summary>
/// 写Double
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="value">value</param>
public void Write(string section, string key, double value)
{
Write(section, key, value.ToString(CultureInfo.InvariantCulture));
}
/// <summary>
/// 读Double
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="Default">Normal</param>
/// <returns>结果</returns>
public double ReadDouble(string section, string key, double Default = 0)
{
return Read(section, key, Default.ToString(CultureInfo.InvariantCulture)).ToDouble(Default);
}
/// <summary>
/// 写Float
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="value">value</param>
public void Write(string section, string key, float value)
{
Write(section, key, value.ToString(CultureInfo.InvariantCulture));
}
/// <summary>
/// 读Float
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="Default">Normal</param>
/// <returns>结果</returns>
public float ReadFloat(string section, string key, float Default = 0)
{
return Read(section, key, Default.ToString(CultureInfo.InvariantCulture)).ToFloat(Default);
}
/// <summary>
/// 写Byte
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="value">value</param>
public void Write(string section, string key, byte value)
{
Write(section, key, value.ToString());
}
/// <summary>
/// 读Byte
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="Default">Normal</param>
/// <returns>结果</returns>
public byte ReadByte(string section, string key, byte Default = 0)
{
return Read(section, key, Default.ToString()).ToByte(Default);
}
/// <summary>
/// 写SByte
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="value">value</param>
public void Write(string section, string key, sbyte value)
{
Write(section, key, value.ToString());
}
/// <summary>
/// 读Byte
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="Default">Normal</param>
/// <returns>结果</returns>
public sbyte ReadSByte(string section, string key, sbyte Default = 0)
{
return Read(section, key, Default.ToString()).ToSByte(Default);
}
/// <summary>
/// 写DateTime
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="value">value</param>
public void Write(string section, string key, DateTime value)
{
Write(section, key, value.ToString(DateTimeEx.DateTimeFormat));
}
/// <summary>
/// 读DateTime
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="Default">Normal</param>
/// <returns>结果</returns>
public DateTime ReadDateTime(string section, string key, DateTime Default)
{
string str = Read(section, key, Default.ToString(CultureInfo.InvariantCulture));
try
{
return str.ToDateTime(DateTimeEx.DateTimeFormat);
}
catch (Exception)
{
return Default;
}
}
/// <summary>
/// 写Point
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="value">value</param>
public void Write(string section, string key, Point value)
{
Write(section, key, ConvertEx.ObjectToString(value, typeof(Point)));
}
/// <summary>
/// 读Point
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="Default">Normal</param>
/// <returns>结果</returns>
public Point ReadPoint(string section, string key, Point Default)
{
string str = Read(section, key, "");
return (Point)ConvertEx.StringToObject(str, typeof(Point), Default);
}
/// <summary>
/// 写PointF
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="value">value</param>
public void Write(string section, string key, PointF value)
{
Write(section, key, ConvertEx.ObjectToString(value, typeof(PointF)));
}
/// <summary>
/// 读PointF
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="Default">Normal</param>
/// <returns>结果</returns>
public PointF ReadPointF(string section, string key, PointF Default)
{
string str = Read(section, key, "");
return (PointF)ConvertEx.StringToObject(str, typeof(PointF), Default);
}
/// <summary>
/// 写Size
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="value">value</param>
public void Write(string section, string key, Size value)
{
Write(section, key, ConvertEx.ObjectToString(value, typeof(Size)));
}
/// <summary>
/// 读Size
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="Default">Normal</param>
/// <returns>结果</returns>
public Size ReadSize(string section, string key, Size Default)
{
string str = Read(section, key, "");
return (Size)ConvertEx.StringToObject(str, typeof(Size), Default);
}
/// <summary>
/// 写SizeF
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="value">value</param>
public void Write(string section, string key, SizeF value)
{
Write(section, key, ConvertEx.ObjectToString(value, typeof(SizeF)));
}
/// <summary>
/// 读SizeF
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="Default">Normal</param>
/// <returns>结果</returns>
public SizeF ReadSizeF(string section, string key, SizeF Default)
{
string str = Read(section, key, "");
return (SizeF)ConvertEx.StringToObject(str, typeof(SizeF), Default);
}
/// <summary>
/// 写Color
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="value">value</param>
public void Write(string section, string key, Color value)
{
Write(section, key, ConvertEx.ObjectToString(value, typeof(Color)));
}
/// <summary>
/// 读Color
/// </summary>
/// <param name="section">section</param>
/// <param name="key">key</param>
/// <param name="Default">Normal</param>
/// <returns>结果</returns>
public Color ReadColor(string section, string key, Color Default)
{
string str = Read(section, key, "");
return (Color)ConvertEx.StringToObject(str, typeof(Color), Default);
}
}
}

View File

@ -1,6 +1,6 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* CopyRight (C) 2012-2025 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse
@ -97,8 +97,10 @@ namespace Sunny.UI
string jsonStr = Serialize(obj);
try
{
DirEx.CreateDir(Path.GetDirectoryName(filename));
File.WriteAllText(filename, jsonStr, encoding);
StreamWriter streamWriter = new StreamWriter(filename, false, encoding);
streamWriter.Write(jsonStr);
streamWriter.Flush();
streamWriter.Close();
}
catch (Exception e)
{

View File

@ -1,354 +0,0 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse
* Gitee: https://gitee.com/yhuse/SunnyUI
* GitHub: https://github.com/yhuse/SunnyUI
*
* SunnyUI.Common.dll can be used for free under the MIT license.
* If you use this code, please keep this note.
* 使
******************************************************************************
* : UIFormHelper.cs
* :
* : V3.1
* : 2020-01-01
*
* 2020-04-19: V2.2.0
* 2021-07-24: V3.0.5
******************************************************************************/
namespace Sunny.UI
{
/// <summary>
/// 多语言字符串定义
/// </summary>
public static class UILocalize
{
/// <summary>
/// 提示
/// </summary>
public static string InfoTitle = "提示";
/// <summary>
/// 正确
/// </summary>
public static string SuccessTitle = "正确";
/// <summary>
/// 警告
/// </summary>
public static string WarningTitle = "警告";
/// <summary>
/// 错误
/// </summary>
public static string ErrorTitle = "错误";
/// <summary>
/// 提示
/// </summary>
public static string AskTitle = "提示";
/// <summary>
/// 输入
/// </summary>
public static string InputTitle = "输入";
/// <summary>
/// 选择
/// </summary>
public static string SelectTitle = "选择";
/// <summary>
/// 全部关闭
/// </summary>
public static string CloseAll = "全部关闭";
/// <summary>
/// 确定
/// </summary>
public static string OK = "确定";
/// <summary>
/// 取消
/// </summary>
public static string Cancel = "取消";
/// <summary>
/// [ 无数据 ]
/// </summary>
public static string GridNoData = "[ 无数据 ]";
/// <summary>
/// 数据加载中,请稍候...
/// </summary>
public static string GridDataLoading = "数据加载中,请稍候...";
/// <summary>
/// 数据源必须为DataTable或者List
/// </summary>
public static string GridDataSourceException = "数据源必须为DataTable或者List";
/// <summary>
/// "系统正在处理中,请稍候..."
/// </summary>
public static string SystemProcessing = "系统正在处理中,请稍候...";
/// <summary>
/// 星期一
/// </summary>
public static string Monday = "一";
/// <summary>
/// 星期二
/// </summary>
public static string Tuesday = "二";
/// <summary>
/// 星期三
/// </summary>
public static string Wednesday = "三";
/// <summary>
/// 星期四
/// </summary>
public static string Thursday = "四";
/// <summary>
/// 星期五
/// </summary>
public static string Friday = "五";
/// <summary>
/// 星期六
/// </summary>
public static string Saturday = "六";
/// <summary>
/// 星期日
/// </summary>
public static string Sunday = "日";
/// <summary>
/// 上一页
/// </summary>
public static string Prev = "上一页";
/// <summary>
/// 下一页
/// </summary>
public static string Next = "下一页";
/// <summary>
/// 第
/// </summary>
public static string SelectPageLeft = "第";
/// <summary>
/// 页
/// </summary>
public static string SelectPageRight = "页";
/// <summary>
/// 一月
/// </summary>
public static string January = "一月";
/// <summary>
/// 二月
/// </summary>
public static string February = "二月";
/// <summary>
/// 三月
/// </summary>
public static string March = "三月";
/// <summary>
/// 四月
/// </summary>
public static string April = "四月";
/// <summary>
/// 五月
/// </summary>
public static string May = "五月";
/// <summary>
/// 六月
/// </summary>
public static string June = "六月";
/// <summary>
/// 七月
/// </summary>
public static string July = "七月";
/// <summary>
/// 八月
/// </summary>
public static string August = "八月";
/// <summary>
/// 九月
/// </summary>
public static string September = "九月";
/// <summary>
/// 十月
/// </summary>
public static string October = "十月";
/// <summary>
/// 十一月
/// </summary>
public static string November = "十一月";
/// <summary>
/// 十二月
/// </summary>
public static string December = "十二月";
/// <summary>
/// 今天
/// </summary>
public static string Today = "今天";
/// <summary>
/// 搜索
/// </summary>
public static string Search = "搜索";
/// <summary>
/// 清除
/// </summary>
public static string Clear = "清除";
public static string Open = "打开";
public static string Save = "保存";
}
/// <summary>
/// 多语言字符串帮助类
/// </summary>
public static class UILocalizeHelper
{
/// <summary>
/// 设置为英文
/// </summary>
public static void SetEN()
{
UILocalize.InfoTitle = "Info";
UILocalize.SuccessTitle = "Success";
UILocalize.WarningTitle = "Warning";
UILocalize.ErrorTitle = "Error";
UILocalize.AskTitle = "Query";
UILocalize.InputTitle = "Input";
UILocalize.SelectTitle = "Select";
UILocalize.CloseAll = "Close all";
UILocalize.OK = "OK";
UILocalize.Cancel = "Cancel";
UILocalize.GridNoData = "[ No data ]";
UILocalize.GridDataLoading = "Data loading, please wait...";
UILocalize.GridDataSourceException = "The data source must be DataTable or List";
UILocalize.SystemProcessing = "The system is processing, please wait...";
UILocalize.Monday = "MON";
UILocalize.Tuesday = "TUE";
UILocalize.Wednesday = "WED";
UILocalize.Thursday = "THU";
UILocalize.Friday = "FRI";
UILocalize.Saturday = "SAT";
UILocalize.Sunday = "SUN";
UILocalize.Prev = "Previous";
UILocalize.Next = "Next";
UILocalize.SelectPageLeft = "Page";
UILocalize.SelectPageRight = "";
UILocalize.January = "Jan.";
UILocalize.February = "Feb.";
UILocalize.March = "Mar.";
UILocalize.April = "Apr.";
UILocalize.May = "May";
UILocalize.June = "Jun.";
UILocalize.July = "Jul.";
UILocalize.August = "Aug.";
UILocalize.September = "Sep.";
UILocalize.October = "Oct.";
UILocalize.November = "Nov.";
UILocalize.December = "Dec.";
UILocalize.Today = "Today";
UILocalize.Search = "Search";
UILocalize.Clear = "Clear";
UILocalize.Open = "Open";
UILocalize.Save = "Save";
UIStyles.Translate();
}
/// <summary>
/// 设置为中文
/// </summary>
public static void SetCH()
{
UILocalize.InfoTitle = "提示";
UILocalize.SuccessTitle = "正确";
UILocalize.WarningTitle = "警告";
UILocalize.ErrorTitle = "错误";
UILocalize.AskTitle = "提示";
UILocalize.InputTitle = "输入";
UILocalize.SelectTitle = "选择";
UILocalize.CloseAll = "全部关闭";
UILocalize.OK = "确定";
UILocalize.Cancel = "取消";
UILocalize.GridNoData = "[ 无数据 ]";
UILocalize.GridDataLoading = "数据加载中,请稍候...";
UILocalize.GridDataSourceException = "数据源必须为DataTable或者List";
UILocalize.SystemProcessing = "系统正在处理中,请稍候...";
UILocalize.Monday = "一";
UILocalize.Tuesday = "二";
UILocalize.Wednesday = "三";
UILocalize.Thursday = "四";
UILocalize.Friday = "五";
UILocalize.Saturday = "六";
UILocalize.Sunday = "日";
UILocalize.Prev = "上一页";
UILocalize.Next = "下一页";
UILocalize.SelectPageLeft = "第";
UILocalize.SelectPageRight = "页";
UILocalize.January = "一月";
UILocalize.February = "二月";
UILocalize.March = "三月";
UILocalize.April = "四月";
UILocalize.May = "五月";
UILocalize.June = "六月";
UILocalize.July = "七月";
UILocalize.August = "八月";
UILocalize.September = "九月";
UILocalize.October = "十月";
UILocalize.November = "十一月";
UILocalize.December = "十二月";
UILocalize.Today = "今天";
UILocalize.Search = "搜索";
UILocalize.Clear = "清除";
UILocalize.Open = "打开";
UILocalize.Save = "保存";
UIStyles.Translate();
}
}
}

View File

@ -1,6 +1,6 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* CopyRight (C) 2012-2025 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse
@ -194,29 +194,11 @@ namespace Sunny.UI
public string Value { get; set; }
}
/// <summary>
/// 析构函数
/// </summary>
public void Dispose()
protected override void FinalStop()
{
Stop();
try
{
var mmf = MemoryMappedFile.OpenExisting(MapName);
mmf.Dispose();
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
/// <summary>
/// 析构函数
/// </summary>
~MMFile()
{
Dispose();
var mmf = MemoryMappedFile.OpenExisting(MapName);
mmf.Dispose();
base.FinalStop();
}
}

203
SunnyUI/Common/UMapper.cs Normal file
View File

@ -0,0 +1,203 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2023 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse
* Gitee: https://gitee.com/yhuse/SunnyUI
* GitHub: https://github.com/yhuse/SunnyUI
*
* SunnyUI.dll can be used for free under the GPL-3.0 license.
* If you use this code, please keep this note.
* 使
******************************************************************************
* : UMapper.cs
* : StructList和数组
* : V3.1
* : 2021-09-30
*
* 2021-09-30: V3.0.7
******************************************************************************/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
namespace Sunny.UI
{
/// <summary>
/// 轻量级的对象映射框架
/// </summary>
public static class Mapper
{
private static void Execute<T1, T2>(T1 source, T2 dest)
where T1 : class, new()
where T2 : class, new()
{
if (source == null || dest == null)
{
return;
}
var listSource = source.GetType().GetNeedProperties().ToDictionary(prop => prop.Name);
var listDest = dest.GetType().GetNeedProperties().ToDictionary(prop => prop.Name);
foreach (var item in listDest)
{
if (listSource.NotContainsKey(item.Key)) continue;
var sourceInfo = listSource[item.Key];
Type sourceType = sourceInfo.PropertyType;
object sourceValue = sourceInfo.GetValue(source, null);
var destInfo = item.Value;
Type destType = item.Value.PropertyType;
if (!sourceType.Equals(destType)) continue;
if (sourceType.IsValueType)
{
//Console.WriteLine("ValueType: " + item.Key + ", " + sourceType.FullName);
destInfo.SetValue(dest, sourceValue, null);
}
else
{
if (sourceType == typeof(string))
{
//Console.WriteLine("String: " + item.Key + ", " + sourceType.FullName);
destInfo.SetValue(dest, sourceValue, null);
continue;
}
if (sourceType.IsList())
{
//Console.WriteLine("List: " + item.Key + ", " + sourceType.FullName);
Type[] sourceTypes = sourceType.GetGenericArguments();
Type[] destTypes = destType.GetGenericArguments();
if (sourceTypes.Length != 1) continue;
if (destTypes.Length != 1) continue;
if (!sourceTypes[0].Equals(destTypes[0])) continue;
if (sourceValue == null)
{
destInfo.SetValue(dest, null, null);
}
else
{
Type typeDataList = typeof(List<>).MakeGenericType(destTypes[0]);
MethodInfo AddInfo = typeDataList.GetMethod("Add", BindingFlags.Public | BindingFlags.Instance);
if (AddInfo == null) continue;
if (sourceTypes[0].IsValueType || sourceTypes[0] == typeof(string))
{
object listvalue = typeDataList.InvokeMember(null, BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.CreateInstance, null, null, new object[] { });
IEnumerable sourceList = sourceValue as IEnumerable;
foreach (var listItem in sourceList)
{
AddInfo.Invoke(listvalue, new[] { listItem });
}
destInfo.SetValue(dest, listvalue, null);
}
else
{
//暂时不考虑
}
}
continue;
}
if (sourceType.IsArray)
{
//Console.WriteLine("Array: " + item.Key + ", " + sourceType.FullName);
if (sourceValue == null)
{
destInfo.SetValue(dest, null, null);
}
else
{
ICollection sourceList = sourceValue as ICollection;
Type type = sourceType.GetElementType();
var array = Array.CreateInstance(type, sourceList.Count);
int index = 0;
foreach (var listItem in sourceList)
{
array.SetValue(listItem, index++);
}
destInfo.SetValue(dest, array, null);
}
continue;
}
if (sourceType.IsDictionary())
{
continue;
}
//类没有无参构造函数的话,创建有问题
//if (sourceType.IsClass)
//{
// if (sourceValue == null)
// {
// destInfo.SetValue(dest, null, null);
// }
// else
// {
// object obj = Activator.CreateInstance(sourceType, null);
// obj.MapperFrom(sourceValue);
// destInfo.SetValue(dest, obj, null);
// }
//
// continue;
//}
}
}
}
/// <summary>
/// T1映射到T2
/// </summary>
/// <typeparam name="T1">T1</typeparam>
/// <typeparam name="T2">T2</typeparam>
/// <param name="source">源</param>
/// <param name="dest">目标</param>
public static void MapperTo<T1, T2>(this T1 source, T2 dest)
where T1 : class, new()
where T2 : class, new()
{
Execute(source, dest);
}
/// <summary>
/// T1从T2映射
/// </summary>
/// <typeparam name="T1">T1</typeparam>
/// <typeparam name="T2">T2</typeparam>
/// <param name="source">源</param>
/// <param name="dest">目标</param>
public static void MapperFrom<T1, T2>(this T1 dest, T2 source)
where T1 : class, new()
where T2 : class, new()
{
Execute(source, dest);
}
/// <summary>
/// 获取数组的类类型
/// </summary>
/// <param name="t">类型</param>
/// <returns>类类型</returns>
public static Type GetArrayElementType(this Type t)
{
if (!t.IsArray) return null;
string name = t.FullName.Replace("[]", string.Empty);
return t.Assembly.GetType(name);
}
}
}

View File

@ -1,6 +1,6 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* CopyRight (C) 2012-2025 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse

View File

@ -1,6 +1,6 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* CopyRight (C) 2012-2025 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse

View File

@ -1,6 +1,6 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* CopyRight (C) 2012-2025 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse

View File

@ -1,6 +1,6 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* CopyRight (C) 2012-2025 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse

View File

@ -1,6 +1,6 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* CopyRight (C) 2012-2025 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse
@ -169,7 +169,7 @@ namespace Sunny.UI
{
Process process = new Process();
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; //隐藏压缩窗口
process.StartInfo.FileName = DirEx.CurrentDir() + "7z.exe";
process.StartInfo.FileName = Dir.CurrentDir() + "7z.exe";
process.StartInfo.CreateNoWindow = false;
process.StartInfo.Arguments = arguments;
process.Start();

View File

@ -1,189 +0,0 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse
* Gitee: https://gitee.com/yhuse/SunnyUI
* GitHub: https://github.com/yhuse/SunnyUI
*
* SunnyUI.dll can be used for free under the GPL-3.0 license.
* If you use this code, please keep this note.
* 使
******************************************************************************
* : USuspendCtrlAltDel.cs
* : winlogon线程来屏蔽Ctrl+Alt+Delete
* : V3.1
* : 2020-01-01
*
* 2020-09-17: V2.2.7
******************************************************************************/
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace Sunny.UI
{
/// <summary>
/// 通过挂起winlogon.exe线程来屏蔽Ctrl+Alt+Delete
/// 程序需要管理员权限
/// 需要提升进程权限为SE_PRIVILEGE_ENABLED权限
/// winlogon管理着开关机登录界面等功能
/// 调用Suspend挂起winlogon.exe用完后需要Resume否则无法调用关机界面
/// </summary>
public static class SuspendCtrlAltDelete
{
/// <summary>
/// 获取权限
/// </summary>
public static void GetSeDebugPrivilege()
{
IntPtr hToken;
LUID luidSEDebugNameValue = new LUID();
if (!OpenProcessToken(Process.GetCurrentProcess().Handle, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, out hToken))
{
Console.WriteLine("OpenProcessToken() failed, error = {0} . SeDebugPrivilege is not available", Marshal.GetLastWin32Error());
return;
}
else
{
Console.WriteLine("OpenProcessToken() successfully");
}
if (!LookupPrivilegeValue(null, SE_DEBUG_NAME, ref luidSEDebugNameValue))
{
Console.WriteLine("LookupPrivilegeValue() failed, error = {0} .SeDebugPrivilege is not available", Marshal.GetLastWin32Error());
CloseHandle(hToken);
return;
}
else
{
Console.WriteLine("LookupPrivilegeValue() successfully");
}
TOKEN_PRIVILEGES tkpPrivileges = new TOKEN_PRIVILEGES();
tkpPrivileges.PrivilegeCount = 1;
tkpPrivileges.Privilege.Luid = luidSEDebugNameValue;
tkpPrivileges.Privilege.Attributes = SE_PRIVILEGE_ENABLED;
if (!AdjustTokenPrivileges(hToken, false, ref tkpPrivileges, 0, IntPtr.Zero, 0))
{
Console.WriteLine("LookupPrivilegeValue() failed, error = {0} .SeDebugPrivilege is not available", Marshal.GetLastWin32Error());
}
else
{
Console.WriteLine("SeDebugPrivilege is now available");
}
CloseHandle(hToken);
}
/// <summary>
/// 挂起
/// </summary>
public static void Suspend()
{
Process[] processes = Process.GetProcesses();
foreach (Process process in processes)
{
if (process.ProcessName == "winlogon")
{
IntPtr p = OpenThread(PROCESS_ALL_ACCESS, false, (IntPtr)process.Threads[0].Id);
SuspendThread(p);
CloseHandle(p);
}
}
}
/// <summary>
/// 恢复
/// </summary>
public static void Resume()
{
Process[] processes = Process.GetProcesses();
foreach (Process process in processes)
{
if (process.ProcessName == "winlogon")
{
IntPtr p = OpenThread(PROCESS_ALL_ACCESS, false, (IntPtr)process.Threads[0].Id);
ResumeThread(p);
CloseHandle(p);
}
}
}
const int PROCESS_ALL_ACCESS = 0x001F03FF;
const string SE_DEBUG_NAME = "SeDebugPrivilege";
const uint SE_PRIVILEGE_ENABLED = 0x00000002;
const uint STANDARD_RIGHTS_REQUIRED = 0x000F0000;
const uint STANDARD_RIGHTS_READ = 0x00020000;
const uint TOKEN_ASSIGN_PRIMARY = 0x0001;
const uint TOKEN_DUPLICATE = 0x0002;
const uint TOKEN_IMPERSONATE = 0x0004;
const uint TOKEN_QUERY = 0x0008;
const uint TOKEN_QUERY_SOURCE = 0x0010;
const uint TOKEN_ADJUST_PRIVILEGES = 0x0020;
const uint TOKEN_ADJUST_GROUPS = 0x0040;
const uint TOKEN_ADJUST_DEFAULT = 0x0080;
const uint TOKEN_ADJUST_SESSIONID = 0x0100;
const uint TOKEN_READ = STANDARD_RIGHTS_READ | TOKEN_QUERY;
const uint TOKEN_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED | TOKEN_ASSIGN_PRIMARY |
TOKEN_DUPLICATE | TOKEN_IMPERSONATE | TOKEN_QUERY | TOKEN_QUERY_SOURCE |
TOKEN_ADJUST_PRIVILEGES | TOKEN_ADJUST_GROUPS | TOKEN_ADJUST_DEFAULT |
TOKEN_ADJUST_SESSIONID);
[DllImport("kernel32.dll")]
private static extern IntPtr OpenThread(int dwDesiredAccess, bool bInheritHandle, IntPtr dwThreadId);
[DllImport("kernel32.dll")]
private static extern bool CloseHandle(IntPtr hObject);
[DllImport("kernel32")]
private static extern int SuspendThread(IntPtr hThread);
[DllImport("kernel32")]
private static extern int ResumeThread(IntPtr hThread);
[DllImport("advapi32.dll", SetLastError = true)]
private static extern bool OpenProcessToken(IntPtr processHandle, uint desiredAccess, out IntPtr tokenHandle);
[DllImport("advapi32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool LookupPrivilegeValue(string lpSystemName, string lpName,
[MarshalAs(UnmanagedType.Struct)] ref LUID lpLuid);
[DllImport("advapi32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool AdjustTokenPrivileges(IntPtr TokenHandle,
[MarshalAs(UnmanagedType.Bool)] bool DisableAllPrivileges,
[MarshalAs(UnmanagedType.Struct)] ref TOKEN_PRIVILEGES NewState,
uint BufferLength, IntPtr PreviousState, uint ReturnLength);
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
private struct LUID
{
internal int LowPart;
internal uint HighPart;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
private struct TOKEN_PRIVILEGES
{
internal int PrivilegeCount;
internal LUID_AND_ATTRIBUTES Privilege;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
private struct LUID_AND_ATTRIBUTES
{
internal LUID Luid;
internal uint Attributes;
}
}
}

View File

@ -1,6 +1,6 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* CopyRight (C) 2012-2025 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse

View File

@ -1,6 +1,6 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* CopyRight (C) 2012-2025 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse

View File

@ -1,6 +1,6 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* CopyRight (C) 2012-2025 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse
@ -22,9 +22,9 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Runtime.InteropServices;
using System.Windows.Forms;
#pragma warning disable 1591
@ -32,7 +32,7 @@ namespace Sunny.UI
{
public class Thunder : IDisposable
{
private readonly Timer timer;
private readonly System.Windows.Forms.Timer timer;
private bool Exit;
public delegate void OnTaskInfoChange(object sender, ThunderTask task);
@ -52,7 +52,7 @@ namespace Sunny.UI
public Thunder()
{
InitSuccess = ThunderDll.Init();
timer = new Timer();
timer = new System.Windows.Forms.Timer();
timer.Interval = 1000;
timer.Tick += Timer_Tick;
timer.Start();
@ -512,7 +512,7 @@ namespace Sunny.UI
public override string ToString()
{
return Status.DisplayText() + ",已完成:" + (Percent * 100.0f).ToString("F2") + "%,速度:" + Speed + "KB/s";
return Status.Description() + ",已完成:" + (Percent * 100.0f).ToString("F2") + "%,速度:" + Speed + "KB/s";
}
}
@ -524,43 +524,43 @@ namespace Sunny.UI
/// <summary>
/// 无
/// </summary>
[DisplayText("无")]
[Description("无")]
NOITEM = 0,
/// <summary>
/// 错误
/// </summary>
[DisplayText("错误")]
[Description("错误")]
TSC_ERROR,
/// <summary>
/// 暂停
/// </summary>
[DisplayText("暂停")]
[Description("暂停")]
TSC_PAUSE,
/// <summary>
/// 下载
/// </summary>
[DisplayText("下载中")]
[Description("下载中")]
TSC_DOWNLOAD,
/// <summary>
/// 完成
/// </summary>
[DisplayText("完成")]
[Description("完成")]
TSC_COMPLETE,
/// <summary>
/// 停止开始
/// </summary>
[DisplayText("已开始")]
[Description("已开始")]
TSC_STARTENDING,
/// <summary>
/// 停止完成
/// </summary>
[DisplayText("已停止")]
[Description("已停止")]
TSC_STOPENDING
}

View File

@ -1,34 +0,0 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse
* Gitee: https://gitee.com/yhuse/SunnyUI
* GitHub: https://github.com/yhuse/SunnyUI
*
* SunnyUI.Common.dll can be used for free under the MIT license.
* If you use this code, please keep this note.
* 使
******************************************************************************
* : UTranslate.cs
* :
* : V3.1
* : 2021-07-23
*
* 2021-07-23: V3.0.5
******************************************************************************/
namespace Sunny.UI
{
/// <summary>
/// 多语翻译接口
/// </summary>
public interface ITranslate
{
/// <summary>
/// 多语翻译接口
/// </summary>
void Translate();
}
}

View File

@ -0,0 +1,163 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2023 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse
* Gitee: https://gitee.com/yhuse/SunnyUI
* GitHub: https://github.com/yhuse/SunnyUI
*
* SunnyUI.Common.dll can be used for free under the MIT license.
* If you use this code, please keep this note.
* 使
******************************************************************************
* : UXmlConfig.cs
* : XML
* : V3.1
* : 2020-01-01
*
* 2020-01-01: V2.2.0
******************************************************************************/
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Xml;
namespace Sunny.UI
{
/// <summary>
/// XML 配置文件类
/// </summary>
/// <typeparam name="TConfig">类型</typeparam>
public class XmlConfig<TConfig> : BaseConfig<TConfig> where TConfig : XmlConfig<TConfig>, new()
{
#region
/// <summary>
/// 当前可执行文件路径,末尾包括\
/// </summary>
/// <returns>结果</returns>
private static string CurrentDir()
{
return Environment.CurrentDirectory.DealPath();
}
/// <summary>加载指定配置文件</summary>
/// <param name="filename">文件名</param>
/// <returns>结果</returns>
public override bool Load(string filename)
{
if (filename.IsNullOrWhiteSpace())
{
filename = CurrentDir() + ConfigFile;
}
if (filename.IsNullOrWhiteSpace())
{
throw new ApplicationException($"未指定{typeof(TConfig).Name}的配置文件路径!");
}
if (!File.Exists(filename))
{
return false;
}
try
{
ConcurrentDictionary<string, Ident> idents = ConfigHelper.InitIdents(current);
XmlDocument doc = new XmlDocument();
doc.Load(filename);
XmlElement root = doc.DocumentElement; //获取根节点
foreach (Ident ident in idents.Values)
{
if (root != null)
{
var elements = root.GetElementsByTagName(ident.Key);
if (elements.Count == 1)
{
if (ident.IsList)
{
ident.Values.Clear();
foreach (XmlNode node in elements[0].ChildNodes)
{
ident.Values.Add(node.InnerText);
}
}
else
{
ident.Value = elements[0].InnerText;
}
}
}
}
ConfigHelper.LoadConfigValue(current, idents);
return true;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return false;
}
}
/// <summary>保存到配置文件中去</summary>
/// <param name="filename">文件名</param>
public override void Save(string filename)
{
if (filename.IsNullOrWhiteSpace())
{
filename = CurrentDir() + ConfigFile;
}
if (filename.IsNullOrWhiteSpace())
{
throw new ApplicationException($"未指定{typeof(TConfig).Name}的配置文件路径!");
}
ConcurrentDictionary<string, Ident> idents = ConfigHelper.InitIdents(current);
ConfigHelper.SaveConfigValue(Current, idents);
List<string> strs = new List<string> { "<?xml version=" + "\"" + "1.0" + "\"" + " encoding=" + "\"" + "utf-8" + "\"" + "?> ", "<!--" + Description + "--> " };
strs.Add("<" + GetType().Name + ">");
SortedList<int, Ident> slist = new SortedList<int, Ident>();
foreach (var ident in idents.Values)
{
slist.Add(ident.Index, ident);
}
foreach (var ident in slist.Values)
{
if (!ident.Description.IsNullOrEmpty())
{
strs.Add(" <!--" + ident.Description + "-->");
}
if (!ident.IsList)
{
strs.Add(" <" + ident.Key + ">" + ident.Value + "</" + ident.Key + ">");
}
else
{
strs.Add(" <" + ident.Key + ">");
foreach (string value in ident.Values)
{
strs.Add(" <Value>" + value + "</Value>");
}
strs.Add(" </" + ident.Key + ">");
}
}
strs.Add("</" + GetType().Name + ">");
File.WriteAllLines(filename, strs.ToArray(), Encoding.UTF8);
}
#endregion
}
}

View File

@ -27,8 +27,8 @@ namespace Sunny.UI
public void Translate()
{
btnOK.Text = UILocalize.OK;
btnCancel.Text = UILocalize.Cancel;
btnOK.Text = UIStyles.CurrentResources.OK;
btnCancel.Text = UIStyles.CurrentResources.Cancel;
}
private LabelRotate m_colorSample;
@ -49,441 +49,459 @@ namespace Sunny.UI
private void InitializeComponent()
{
this.m_colorTable = new Sunny.UI.UIColorTable();
this.m_colorSample = new Sunny.UI.LabelRotate();
this.edtA = new Sunny.UI.UITextBox();
this.edtR = new Sunny.UI.UITextBox();
this.edtG = new Sunny.UI.UITextBox();
this.edtB = new Sunny.UI.UITextBox();
this.lblA = new Sunny.UI.UILabel();
this.lblR = new Sunny.UI.UILabel();
this.lblG = new Sunny.UI.UILabel();
this.lblB = new Sunny.UI.UILabel();
this.m_colorWheel = new Sunny.UI.UIColorWheel();
this.m_colorBar = new Sunny.UI.HSLColorSlider();
this.m_opacitySlider = new Sunny.UI.ColorSlider();
this.btnOK = new Sunny.UI.UISymbolButton();
this.btnCancel = new Sunny.UI.UISymbolButton();
this.SuspendLayout();
m_colorTable = new UIColorTable();
m_colorSample = new LabelRotate();
edtA = new UITextBox();
edtR = new UITextBox();
edtG = new UITextBox();
edtB = new UITextBox();
lblA = new UILabel();
lblR = new UILabel();
lblG = new UILabel();
lblB = new UILabel();
m_colorWheel = new UIColorWheel();
m_colorBar = new HSLColorSlider();
m_opacitySlider = new ColorSlider();
btnOK = new UISymbolButton();
btnCancel = new UISymbolButton();
SuspendLayout();
//
// m_colorTable
//
this.m_colorTable.BackColor = System.Drawing.Color.Transparent;
this.m_colorTable.Colors = new System.Drawing.Color[] {
System.Drawing.Color.Black,
System.Drawing.Color.DarkGreen,
System.Drawing.Color.DarkSlateGray,
System.Drawing.Color.Purple,
System.Drawing.Color.Maroon,
System.Drawing.Color.Teal,
System.Drawing.Color.Green,
System.Drawing.Color.Olive,
System.Drawing.Color.Navy,
System.Drawing.Color.Indigo,
System.Drawing.Color.MidnightBlue,
System.Drawing.Color.DarkRed,
System.Drawing.Color.DarkMagenta,
System.Drawing.Color.DarkBlue,
System.Drawing.Color.DarkCyan,
System.Drawing.Color.DarkOliveGreen,
System.Drawing.Color.SaddleBrown,
System.Drawing.Color.ForestGreen,
System.Drawing.Color.OliveDrab,
System.Drawing.Color.SeaGreen,
System.Drawing.Color.DarkGoldenrod,
System.Drawing.Color.DarkSlateBlue,
System.Drawing.Color.MediumBlue,
System.Drawing.Color.Sienna,
System.Drawing.Color.Brown,
System.Drawing.Color.DarkTurquoise,
System.Drawing.Color.DimGray,
System.Drawing.Color.LightSeaGreen,
System.Drawing.Color.DarkViolet,
System.Drawing.Color.Firebrick,
System.Drawing.Color.MediumVioletRed,
System.Drawing.Color.MediumSeaGreen,
System.Drawing.Color.Crimson,
System.Drawing.Color.Chocolate,
System.Drawing.Color.MediumSpringGreen,
System.Drawing.Color.Goldenrod,
System.Drawing.Color.SteelBlue,
System.Drawing.Color.LawnGreen,
System.Drawing.Color.DarkOrchid,
System.Drawing.Color.Orange,
System.Drawing.Color.LimeGreen,
System.Drawing.Color.Yellow,
System.Drawing.Color.Gold,
System.Drawing.Color.Red,
System.Drawing.Color.Magenta,
System.Drawing.Color.Lime,
System.Drawing.Color.SpringGreen,
System.Drawing.Color.YellowGreen,
System.Drawing.Color.Chartreuse,
System.Drawing.Color.DeepSkyBlue,
System.Drawing.Color.Aqua,
System.Drawing.Color.OrangeRed,
System.Drawing.Color.Blue,
System.Drawing.Color.DarkOrange,
System.Drawing.Color.CadetBlue,
System.Drawing.Color.Cyan,
System.Drawing.Color.Fuchsia,
System.Drawing.Color.Gray,
System.Drawing.Color.SlateGray,
System.Drawing.Color.Peru,
System.Drawing.Color.BlueViolet,
System.Drawing.Color.LightSlateGray,
System.Drawing.Color.DeepPink,
System.Drawing.Color.MediumTurquoise,
System.Drawing.Color.DodgerBlue,
System.Drawing.Color.Turquoise,
System.Drawing.Color.RoyalBlue,
System.Drawing.Color.SlateBlue,
System.Drawing.Color.MediumOrchid,
System.Drawing.Color.DarkKhaki,
System.Drawing.Color.IndianRed,
System.Drawing.Color.GreenYellow,
System.Drawing.Color.MediumAquamarine,
System.Drawing.Color.Tomato,
System.Drawing.Color.DarkSeaGreen,
System.Drawing.Color.Orchid,
System.Drawing.Color.RosyBrown,
System.Drawing.Color.PaleVioletRed,
System.Drawing.Color.MediumPurple,
System.Drawing.Color.Coral,
System.Drawing.Color.CornflowerBlue,
System.Drawing.Color.DarkGray,
System.Drawing.Color.SandyBrown,
System.Drawing.Color.MediumSlateBlue,
System.Drawing.Color.Tan,
System.Drawing.Color.DarkSalmon,
System.Drawing.Color.BurlyWood,
System.Drawing.Color.HotPink,
System.Drawing.Color.Salmon,
System.Drawing.Color.Violet,
System.Drawing.Color.LightCoral,
System.Drawing.Color.SkyBlue,
System.Drawing.Color.LightSalmon,
System.Drawing.Color.Khaki,
System.Drawing.Color.Plum,
System.Drawing.Color.LightGreen,
System.Drawing.Color.Aquamarine,
System.Drawing.Color.Silver,
System.Drawing.Color.LightSkyBlue,
System.Drawing.Color.LightSteelBlue,
System.Drawing.Color.LightBlue,
System.Drawing.Color.PaleGreen,
System.Drawing.Color.PowderBlue,
System.Drawing.Color.Thistle,
System.Drawing.Color.PaleGoldenrod,
System.Drawing.Color.PaleTurquoise,
System.Drawing.Color.LightGray,
System.Drawing.Color.Wheat,
System.Drawing.Color.NavajoWhite,
System.Drawing.Color.Moccasin,
System.Drawing.Color.LightPink,
System.Drawing.Color.PeachPuff,
System.Drawing.Color.Gainsboro,
System.Drawing.Color.Pink,
System.Drawing.Color.Bisque,
System.Drawing.Color.LightGoldenrodYellow,
System.Drawing.Color.LemonChiffon,
System.Drawing.Color.BlanchedAlmond,
System.Drawing.Color.Beige,
System.Drawing.Color.AntiqueWhite,
System.Drawing.Color.PapayaWhip,
System.Drawing.Color.Cornsilk,
System.Drawing.Color.LightYellow,
System.Drawing.Color.LightCyan,
System.Drawing.Color.Lavender,
System.Drawing.Color.Linen,
System.Drawing.Color.MistyRose,
System.Drawing.Color.OldLace,
System.Drawing.Color.WhiteSmoke,
System.Drawing.Color.SeaShell,
System.Drawing.Color.Azure,
System.Drawing.Color.Honeydew,
System.Drawing.Color.Ivory,
System.Drawing.Color.LavenderBlush,
System.Drawing.Color.FloralWhite,
System.Drawing.Color.AliceBlue,
System.Drawing.Color.MintCream,
System.Drawing.Color.GhostWhite,
System.Drawing.Color.Snow,
System.Drawing.Color.White};
this.m_colorTable.Cols = 16;
this.m_colorTable.FieldSize = new System.Drawing.Size(12, 12);
this.m_colorTable.FrameColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255)))));
this.m_colorTable.Location = new System.Drawing.Point(10, 8);
this.m_colorTable.Name = "m_colorTable";
this.m_colorTable.Padding = new System.Windows.Forms.Padding(8);
this.m_colorTable.RotatePointAlignment = System.Drawing.ContentAlignment.MiddleCenter;
this.m_colorTable.SelectedItem = System.Drawing.Color.Black;
this.m_colorTable.Size = new System.Drawing.Size(253, 148);
this.m_colorTable.Style = Sunny.UI.UIStyle.Custom;
this.m_colorTable.StyleCustomMode = false;
this.m_colorTable.TabIndex = 0;
this.m_colorTable.TagString = null;
this.m_colorTable.Text = "colorTable1";
this.m_colorTable.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.m_colorTable.TextAngle = 0F;
this.m_colorTable.SelectedIndexChanged += new System.EventHandler(this.m_colorTable_SelectedIndexChanged);
m_colorTable.BackColor = Color.Transparent;
m_colorTable.Colors = new Color[]
{
Color.Black,
Color.DarkGreen,
Color.DarkSlateGray,
Color.Purple,
Color.Maroon,
Color.Teal,
Color.Green,
Color.Olive,
Color.Navy,
Color.Indigo,
Color.MidnightBlue,
Color.DarkRed,
Color.DarkMagenta,
Color.DarkBlue,
Color.DarkCyan,
Color.DarkOliveGreen,
Color.SaddleBrown,
Color.ForestGreen,
Color.OliveDrab,
Color.SeaGreen,
Color.DarkGoldenrod,
Color.DarkSlateBlue,
Color.MediumBlue,
Color.Sienna,
Color.Brown,
Color.DarkTurquoise,
Color.DimGray,
Color.LightSeaGreen,
Color.DarkViolet,
Color.Firebrick,
Color.MediumVioletRed,
Color.MediumSeaGreen,
Color.Crimson,
Color.Chocolate,
Color.MediumSpringGreen,
Color.Goldenrod,
Color.SteelBlue,
Color.LawnGreen,
Color.DarkOrchid,
Color.Orange,
Color.LimeGreen,
Color.Yellow,
Color.Gold,
Color.Red,
Color.Magenta,
Color.Lime,
Color.SpringGreen,
Color.YellowGreen,
Color.Chartreuse,
Color.DeepSkyBlue,
Color.Aqua,
Color.OrangeRed,
Color.Blue,
Color.DarkOrange,
Color.CadetBlue,
Color.Cyan,
Color.Fuchsia,
Color.Gray,
Color.SlateGray,
Color.Peru,
Color.BlueViolet,
Color.LightSlateGray,
Color.DeepPink,
Color.MediumTurquoise,
Color.DodgerBlue,
Color.Turquoise,
Color.RoyalBlue,
Color.SlateBlue,
Color.MediumOrchid,
Color.DarkKhaki,
Color.IndianRed,
Color.GreenYellow,
Color.MediumAquamarine,
Color.Tomato,
Color.DarkSeaGreen,
Color.Orchid,
Color.RosyBrown,
Color.PaleVioletRed,
Color.MediumPurple,
Color.Coral,
Color.CornflowerBlue,
Color.DarkGray,
Color.SandyBrown,
Color.MediumSlateBlue,
Color.Tan,
Color.DarkSalmon,
Color.BurlyWood,
Color.HotPink,
Color.Salmon,
Color.Violet,
Color.LightCoral,
Color.SkyBlue,
Color.LightSalmon,
Color.Khaki,
Color.Plum,
Color.LightGreen,
Color.Aquamarine,
Color.Silver,
Color.LightSkyBlue,
Color.LightSteelBlue,
Color.LightBlue,
Color.PaleGreen,
Color.PowderBlue,
Color.Thistle,
Color.PaleGoldenrod,
Color.PaleTurquoise,
Color.LightGray,
Color.Wheat,
Color.NavajoWhite,
Color.Moccasin,
Color.LightPink,
Color.PeachPuff,
Color.Gainsboro,
Color.Pink,
Color.Bisque,
Color.LightGoldenrodYellow,
Color.LemonChiffon,
Color.BlanchedAlmond,
Color.Beige,
Color.AntiqueWhite,
Color.PapayaWhip,
Color.Cornsilk,
Color.LightYellow,
Color.LightCyan,
Color.Lavender,
Color.Linen,
Color.MistyRose,
Color.OldLace,
Color.WhiteSmoke,
Color.SeaShell,
Color.Azure,
Color.Honeydew,
Color.Ivory,
Color.LavenderBlush,
Color.FloralWhite,
Color.AliceBlue,
Color.MintCream,
Color.GhostWhite,
Color.Snow,
Color.White
};
m_colorTable.Cols = 16;
m_colorTable.FieldSize = new Size(12, 12);
m_colorTable.FrameColor = Color.FromArgb(80, 160, 255);
m_colorTable.Location = new Point(10, 8);
m_colorTable.Name = "m_colorTable";
m_colorTable.Padding = new System.Windows.Forms.Padding(8);
m_colorTable.RotatePointAlignment = ContentAlignment.MiddleCenter;
m_colorTable.SelectedItem = Color.Black;
m_colorTable.Size = new Size(253, 148);
m_colorTable.Style = UIStyle.Custom;
m_colorTable.TabIndex = 0;
m_colorTable.Text = "colorTable1";
m_colorTable.TextAlign = ContentAlignment.MiddleLeft;
m_colorTable.TextAngle = 0F;
m_colorTable.SelectedIndexChanged += m_colorTable_SelectedIndexChanged;
//
// m_colorSample
//
this.m_colorSample.FrameColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255)))));
this.m_colorSample.Location = new System.Drawing.Point(10, 163);
this.m_colorSample.Name = "m_colorSample";
this.m_colorSample.RotatePointAlignment = System.Drawing.ContentAlignment.MiddleCenter;
this.m_colorSample.Size = new System.Drawing.Size(253, 26);
this.m_colorSample.Style = Sunny.UI.UIStyle.Custom;
this.m_colorSample.StyleCustomMode = false;
this.m_colorSample.TabIndex = 1;
this.m_colorSample.TabStop = false;
this.m_colorSample.TagString = null;
this.m_colorSample.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.m_colorSample.TextAngle = 0F;
this.m_colorSample.Paint += new System.Windows.Forms.PaintEventHandler(this.m_colorSample_Paint);
m_colorSample.FrameColor = Color.FromArgb(80, 160, 255);
m_colorSample.Location = new Point(10, 163);
m_colorSample.Name = "m_colorSample";
m_colorSample.RotatePointAlignment = ContentAlignment.MiddleCenter;
m_colorSample.Size = new Size(253, 26);
m_colorSample.Style = UIStyle.Custom;
m_colorSample.TabIndex = 1;
m_colorSample.TabStop = false;
m_colorSample.TextAlign = ContentAlignment.MiddleLeft;
m_colorSample.TextAngle = 0F;
m_colorSample.Paint += m_colorSample_Paint;
//
// edtA
//
this.edtA.Cursor = System.Windows.Forms.Cursors.IBeam;
this.edtA.FillColor = System.Drawing.Color.White;
this.edtA.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.edtA.Location = new System.Drawing.Point(29, 197);
this.edtA.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.edtA.Maximum = 255D;
this.edtA.Minimum = 0D;
this.edtA.Name = "edtA";
this.edtA.Padding = new System.Windows.Forms.Padding(5);
this.edtA.Size = new System.Drawing.Size(41, 26);
this.edtA.Style = Sunny.UI.UIStyle.Custom;
this.edtA.TabIndex = 2;
this.edtA.Text = "0";
this.edtA.Type = Sunny.UI.UITextBox.UIEditType.Integer;
edtA.Cursor = System.Windows.Forms.Cursors.IBeam;
edtA.Font = new Font("宋体", 10.5F, FontStyle.Regular, GraphicsUnit.Point, 134);
edtA.Location = new Point(29, 197);
edtA.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
edtA.Maximum = 255D;
edtA.Minimum = 0D;
edtA.MinimumSize = new Size(1, 16);
edtA.Name = "edtA";
edtA.Padding = new System.Windows.Forms.Padding(5);
edtA.ShowText = false;
edtA.Size = new Size(41, 26);
edtA.Style = UIStyle.Custom;
edtA.TabIndex = 2;
edtA.Text = "0";
edtA.TextAlignment = ContentAlignment.MiddleLeft;
edtA.Type = UITextBox.UIEditType.Integer;
edtA.Watermark = "";
edtA.LostFocus += edtA_TextChanged;
//
// edtR
//
this.edtR.Cursor = System.Windows.Forms.Cursors.IBeam;
this.edtR.FillColor = System.Drawing.Color.White;
this.edtR.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.edtR.Location = new System.Drawing.Point(93, 197);
this.edtR.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.edtR.Maximum = 255D;
this.edtR.Minimum = 0D;
this.edtR.Name = "edtR";
this.edtR.Padding = new System.Windows.Forms.Padding(5);
this.edtR.Size = new System.Drawing.Size(41, 26);
this.edtR.Style = Sunny.UI.UIStyle.Custom;
this.edtR.TabIndex = 3;
this.edtR.Text = "0";
this.edtR.Type = Sunny.UI.UITextBox.UIEditType.Integer;
edtR.Cursor = System.Windows.Forms.Cursors.IBeam;
edtR.Font = new Font("宋体", 10.5F, FontStyle.Regular, GraphicsUnit.Point, 134);
edtR.Location = new Point(93, 197);
edtR.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
edtR.Maximum = 255D;
edtR.Minimum = 0D;
edtR.MinimumSize = new Size(1, 16);
edtR.Name = "edtR";
edtR.Padding = new System.Windows.Forms.Padding(5);
edtR.ShowText = false;
edtR.Size = new Size(41, 26);
edtR.Style = UIStyle.Custom;
edtR.TabIndex = 3;
edtR.Text = "0";
edtR.TextAlignment = ContentAlignment.MiddleLeft;
edtR.Type = UITextBox.UIEditType.Integer;
edtR.Watermark = "";
edtR.LostFocus += edtR_TextChanged;
//
// edtG
//
this.edtG.Cursor = System.Windows.Forms.Cursors.IBeam;
this.edtG.FillColor = System.Drawing.Color.White;
this.edtG.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.edtG.Location = new System.Drawing.Point(158, 197);
this.edtG.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.edtG.Maximum = 255D;
this.edtG.Minimum = 0D;
this.edtG.Name = "edtG";
this.edtG.Padding = new System.Windows.Forms.Padding(5);
this.edtG.Size = new System.Drawing.Size(41, 26);
this.edtG.Style = Sunny.UI.UIStyle.Custom;
this.edtG.TabIndex = 4;
this.edtG.Text = "0";
this.edtG.Type = Sunny.UI.UITextBox.UIEditType.Integer;
edtG.Cursor = System.Windows.Forms.Cursors.IBeam;
edtG.Font = new Font("宋体", 10.5F, FontStyle.Regular, GraphicsUnit.Point, 134);
edtG.Location = new Point(158, 197);
edtG.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
edtG.Maximum = 255D;
edtG.Minimum = 0D;
edtG.MinimumSize = new Size(1, 16);
edtG.Name = "edtG";
edtG.Padding = new System.Windows.Forms.Padding(5);
edtG.ShowText = false;
edtG.Size = new Size(41, 26);
edtG.Style = UIStyle.Custom;
edtG.TabIndex = 4;
edtG.Text = "0";
edtG.TextAlignment = ContentAlignment.MiddleLeft;
edtG.Type = UITextBox.UIEditType.Integer;
edtG.Watermark = "";
edtG.LostFocus += edtG_TextChanged;
//
// edtB
//
this.edtB.Cursor = System.Windows.Forms.Cursors.IBeam;
this.edtB.FillColor = System.Drawing.Color.White;
this.edtB.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.edtB.Location = new System.Drawing.Point(222, 197);
this.edtB.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.edtB.Maximum = 255D;
this.edtB.Minimum = 0D;
this.edtB.Name = "edtB";
this.edtB.Padding = new System.Windows.Forms.Padding(5);
this.edtB.Size = new System.Drawing.Size(41, 26);
this.edtB.Style = Sunny.UI.UIStyle.Custom;
this.edtB.TabIndex = 5;
this.edtB.Text = "0";
this.edtB.Type = Sunny.UI.UITextBox.UIEditType.Integer;
edtB.Cursor = System.Windows.Forms.Cursors.IBeam;
edtB.Font = new Font("宋体", 10.5F, FontStyle.Regular, GraphicsUnit.Point, 134);
edtB.Location = new Point(222, 197);
edtB.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
edtB.Maximum = 255D;
edtB.Minimum = 0D;
edtB.MinimumSize = new Size(1, 16);
edtB.Name = "edtB";
edtB.Padding = new System.Windows.Forms.Padding(5);
edtB.ShowText = false;
edtB.Size = new Size(41, 26);
edtB.Style = UIStyle.Custom;
edtB.TabIndex = 5;
edtB.Text = "0";
edtB.TextAlignment = ContentAlignment.MiddleLeft;
edtB.Type = UITextBox.UIEditType.Integer;
edtB.Watermark = "";
edtB.LostFocus += edtB_TextChanged;
//
// lblA
//
this.lblA.AutoSize = true;
this.lblA.BackColor = System.Drawing.Color.Transparent;
this.lblA.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblA.Location = new System.Drawing.Point(9, 200);
this.lblA.Name = "lblA";
this.lblA.Size = new System.Drawing.Size(19, 20);
this.lblA.Style = Sunny.UI.UIStyle.Custom;
this.lblA.TabIndex = 6;
this.lblA.Text = "A";
this.lblA.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
lblA.AutoSize = true;
lblA.BackColor = Color.Transparent;
lblA.Font = new Font("宋体", 10.5F, FontStyle.Regular, GraphicsUnit.Point, 134);
lblA.ForeColor = Color.FromArgb(48, 48, 48);
lblA.Location = new Point(9, 200);
lblA.Name = "lblA";
lblA.Size = new Size(14, 14);
lblA.Style = UIStyle.Custom;
lblA.TabIndex = 6;
lblA.Text = "A";
lblA.TextAlign = ContentAlignment.MiddleLeft;
//
// lblR
//
this.lblR.AutoSize = true;
this.lblR.BackColor = System.Drawing.Color.Transparent;
this.lblR.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblR.Location = new System.Drawing.Point(74, 200);
this.lblR.Name = "lblR";
this.lblR.Size = new System.Drawing.Size(18, 20);
this.lblR.Style = Sunny.UI.UIStyle.Custom;
this.lblR.TabIndex = 7;
this.lblR.Text = "R";
this.lblR.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
lblR.AutoSize = true;
lblR.BackColor = Color.Transparent;
lblR.Font = new Font("宋体", 10.5F, FontStyle.Regular, GraphicsUnit.Point, 134);
lblR.ForeColor = Color.FromArgb(48, 48, 48);
lblR.Location = new Point(74, 200);
lblR.Name = "lblR";
lblR.Size = new Size(14, 14);
lblR.Style = UIStyle.Custom;
lblR.TabIndex = 7;
lblR.Text = "R";
lblR.TextAlign = ContentAlignment.MiddleLeft;
//
// lblG
//
this.lblG.AutoSize = true;
this.lblG.BackColor = System.Drawing.Color.Transparent;
this.lblG.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblG.Location = new System.Drawing.Point(138, 200);
this.lblG.Name = "lblG";
this.lblG.Size = new System.Drawing.Size(19, 20);
this.lblG.Style = Sunny.UI.UIStyle.Custom;
this.lblG.TabIndex = 8;
this.lblG.Text = "G";
this.lblG.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
lblG.AutoSize = true;
lblG.BackColor = Color.Transparent;
lblG.Font = new Font("宋体", 10.5F, FontStyle.Regular, GraphicsUnit.Point, 134);
lblG.ForeColor = Color.FromArgb(48, 48, 48);
lblG.Location = new Point(138, 200);
lblG.Name = "lblG";
lblG.Size = new Size(14, 14);
lblG.Style = UIStyle.Custom;
lblG.TabIndex = 8;
lblG.Text = "G";
lblG.TextAlign = ContentAlignment.MiddleLeft;
//
// lblB
//
this.lblB.AutoSize = true;
this.lblB.BackColor = System.Drawing.Color.Transparent;
this.lblB.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblB.Location = new System.Drawing.Point(203, 200);
this.lblB.Name = "lblB";
this.lblB.Size = new System.Drawing.Size(18, 20);
this.lblB.Style = Sunny.UI.UIStyle.Custom;
this.lblB.TabIndex = 9;
this.lblB.Text = "B";
this.lblB.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
lblB.AutoSize = true;
lblB.BackColor = Color.Transparent;
lblB.Font = new Font("宋体", 10.5F, FontStyle.Regular, GraphicsUnit.Point, 134);
lblB.ForeColor = Color.FromArgb(48, 48, 48);
lblB.Location = new Point(203, 200);
lblB.Name = "lblB";
lblB.Size = new Size(14, 14);
lblB.Style = UIStyle.Custom;
lblB.TabIndex = 9;
lblB.Text = "B";
lblB.TextAlign = ContentAlignment.MiddleLeft;
//
// m_colorWheel
//
this.m_colorWheel.BackColor = System.Drawing.Color.Transparent;
this.m_colorWheel.FrameColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255)))));
this.m_colorWheel.Location = new System.Drawing.Point(269, 8);
this.m_colorWheel.Name = "m_colorWheel";
this.m_colorWheel.SelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(254)))), ((int)(((byte)(235)))), ((int)(((byte)(205)))));
this.m_colorWheel.Size = new System.Drawing.Size(148, 148);
this.m_colorWheel.Style = Sunny.UI.UIStyle.Custom;
this.m_colorWheel.StyleCustomMode = false;
this.m_colorWheel.TabIndex = 10;
this.m_colorWheel.TagString = null;
this.m_colorWheel.Text = "colorWheel1";
this.m_colorWheel.SelectedColorChanged += new System.EventHandler(this.m_colorWheel_SelectedColorChanged);
m_colorWheel.BackColor = Color.Transparent;
m_colorWheel.FrameColor = Color.FromArgb(80, 160, 255);
m_colorWheel.Location = new Point(269, 8);
m_colorWheel.Name = "m_colorWheel";
m_colorWheel.SelectedColor = Color.FromArgb(254, 235, 205);
m_colorWheel.Size = new Size(148, 148);
m_colorWheel.Style = UIStyle.Custom;
m_colorWheel.TabIndex = 10;
m_colorWheel.Text = "colorWheel1";
m_colorWheel.SelectedColorChanged += m_colorWheel_SelectedColorChanged;
//
// m_colorBar
//
this.m_colorBar.BackColor = System.Drawing.Color.Transparent;
this.m_colorBar.BarPadding = new System.Windows.Forms.Padding(12, 5, 32, 10);
this.m_colorBar.Color1 = System.Drawing.Color.Black;
this.m_colorBar.Color2 = System.Drawing.Color.FromArgb(((int)(((byte)(127)))), ((int)(((byte)(127)))), ((int)(((byte)(127)))));
this.m_colorBar.Color3 = System.Drawing.Color.White;
this.m_colorBar.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.m_colorBar.FrameColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255)))));
this.m_colorBar.Location = new System.Drawing.Point(422, 8);
this.m_colorBar.Name = "m_colorBar";
this.m_colorBar.NumberOfColors = Sunny.UI.ColorSlider.eNumberOfColors.Use3Colors;
this.m_colorBar.Orientation = System.Windows.Forms.Orientation.Vertical;
this.m_colorBar.Padding = new System.Windows.Forms.Padding(0, 0, 1, 0);
this.m_colorBar.Percent = 0F;
this.m_colorBar.RotatePointAlignment = System.Drawing.ContentAlignment.MiddleRight;
this.m_colorBar.Size = new System.Drawing.Size(45, 148);
this.m_colorBar.Style = Sunny.UI.UIStyle.Custom;
this.m_colorBar.StyleCustomMode = false;
this.m_colorBar.TabIndex = 11;
this.m_colorBar.TagString = null;
this.m_colorBar.Text = "Lightness";
this.m_colorBar.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.m_colorBar.TextAngle = 270F;
this.m_colorBar.ValueOrientation = Sunny.UI.ColorSlider.eValueOrientation.MaxToMin;
this.m_colorBar.SelectedValueChanged += new System.EventHandler(this.m_colorBar_SelectedValueChanged);
m_colorBar.BackColor = Color.Transparent;
m_colorBar.BarPadding = new System.Windows.Forms.Padding(12, 5, 32, 10);
m_colorBar.Color1 = Color.Black;
m_colorBar.Color2 = Color.FromArgb(127, 127, 127);
m_colorBar.Color3 = Color.White;
m_colorBar.Font = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
m_colorBar.FrameColor = Color.FromArgb(80, 160, 255);
m_colorBar.Location = new Point(422, 8);
m_colorBar.Name = "m_colorBar";
m_colorBar.NumberOfColors = ColorSlider.eNumberOfColors.Use3Colors;
m_colorBar.Orientation = System.Windows.Forms.Orientation.Vertical;
m_colorBar.Padding = new System.Windows.Forms.Padding(0, 0, 1, 0);
m_colorBar.Percent = 0F;
m_colorBar.RotatePointAlignment = ContentAlignment.MiddleRight;
m_colorBar.Size = new Size(45, 148);
m_colorBar.Style = UIStyle.Custom;
m_colorBar.TabIndex = 11;
m_colorBar.Text = "Lightness";
m_colorBar.TextAlign = ContentAlignment.BottomCenter;
m_colorBar.TextAngle = 270F;
m_colorBar.ValueOrientation = ColorSlider.eValueOrientation.MaxToMin;
m_colorBar.SelectedValueChanged += m_colorBar_SelectedValueChanged;
//
// m_opacitySlider
//
this.m_opacitySlider.BackColor = System.Drawing.Color.Transparent;
this.m_opacitySlider.BarPadding = new System.Windows.Forms.Padding(60, 12, 80, 25);
this.m_opacitySlider.Color1 = System.Drawing.Color.White;
this.m_opacitySlider.Color2 = System.Drawing.Color.Black;
this.m_opacitySlider.Color3 = System.Drawing.Color.Black;
this.m_opacitySlider.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.m_opacitySlider.ForeColor = System.Drawing.Color.Black;
this.m_opacitySlider.FrameColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255)))));
this.m_opacitySlider.Location = new System.Drawing.Point(269, 163);
this.m_opacitySlider.Name = "m_opacitySlider";
this.m_opacitySlider.NumberOfColors = Sunny.UI.ColorSlider.eNumberOfColors.Use2Colors;
this.m_opacitySlider.Orientation = System.Windows.Forms.Orientation.Horizontal;
this.m_opacitySlider.Padding = new System.Windows.Forms.Padding(5, 0, 0, 0);
this.m_opacitySlider.Percent = 1F;
this.m_opacitySlider.RotatePointAlignment = System.Drawing.ContentAlignment.MiddleCenter;
this.m_opacitySlider.Size = new System.Drawing.Size(198, 26);
this.m_opacitySlider.Style = Sunny.UI.UIStyle.Custom;
this.m_opacitySlider.StyleCustomMode = false;
this.m_opacitySlider.TabIndex = 1;
this.m_opacitySlider.TagString = null;
this.m_opacitySlider.Text = "Opacity";
this.m_opacitySlider.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.m_opacitySlider.TextAngle = 0F;
this.m_opacitySlider.ValueOrientation = Sunny.UI.ColorSlider.eValueOrientation.MinToMax;
this.m_opacitySlider.SelectedValueChanged += new System.EventHandler(this.m_opacitySlider_SelectedValueChanged);
m_opacitySlider.BackColor = Color.Transparent;
m_opacitySlider.BarPadding = new System.Windows.Forms.Padding(60, 12, 80, 25);
m_opacitySlider.Color1 = Color.White;
m_opacitySlider.Color2 = Color.Black;
m_opacitySlider.Color3 = Color.Black;
m_opacitySlider.Font = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point, 0);
m_opacitySlider.ForeColor = Color.Black;
m_opacitySlider.FrameColor = Color.FromArgb(80, 160, 255);
m_opacitySlider.Location = new Point(269, 163);
m_opacitySlider.Name = "m_opacitySlider";
m_opacitySlider.NumberOfColors = ColorSlider.eNumberOfColors.Use2Colors;
m_opacitySlider.Orientation = System.Windows.Forms.Orientation.Horizontal;
m_opacitySlider.Padding = new System.Windows.Forms.Padding(5, 0, 0, 0);
m_opacitySlider.Percent = 1F;
m_opacitySlider.RotatePointAlignment = ContentAlignment.MiddleCenter;
m_opacitySlider.Size = new Size(198, 26);
m_opacitySlider.Style = UIStyle.Custom;
m_opacitySlider.TabIndex = 1;
m_opacitySlider.Text = "Opacity";
m_opacitySlider.TextAlign = ContentAlignment.MiddleLeft;
m_opacitySlider.TextAngle = 0F;
m_opacitySlider.ValueOrientation = ColorSlider.eValueOrientation.MinToMax;
m_opacitySlider.SelectedValueChanged += m_opacitySlider_SelectedValueChanged;
//
// btnOK
//
this.btnOK.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnOK.Font = new System.Drawing.Font("宋体", 12F);
this.btnOK.Location = new System.Drawing.Point(269, 197);
this.btnOK.Name = "btnOK";
this.btnOK.Padding = new System.Windows.Forms.Padding(28, 0, 0, 0);
this.btnOK.Size = new System.Drawing.Size(95, 26);
this.btnOK.Style = Sunny.UI.UIStyle.Custom;
this.btnOK.TabIndex = 12;
this.btnOK.Text = "确定";
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
btnOK.Cursor = System.Windows.Forms.Cursors.Hand;
btnOK.Font = new Font("宋体", 12F);
btnOK.Location = new Point(269, 197);
btnOK.MinimumSize = new Size(1, 1);
btnOK.Name = "btnOK";
btnOK.Padding = new System.Windows.Forms.Padding(28, 0, 0, 0);
btnOK.Size = new Size(95, 26);
btnOK.Style = UIStyle.Custom;
btnOK.SymbolOffset = new Point(0, 1);
btnOK.TabIndex = 12;
btnOK.Text = "确定";
btnOK.TipsFont = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
btnOK.Click += btnOK_Click;
//
// btnCancel
//
this.btnCancel.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnCancel.Font = new System.Drawing.Font("宋体", 12F);
this.btnCancel.Location = new System.Drawing.Point(372, 197);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Padding = new System.Windows.Forms.Padding(28, 0, 0, 0);
this.btnCancel.Size = new System.Drawing.Size(95, 26);
this.btnCancel.Style = Sunny.UI.UIStyle.Custom;
this.btnCancel.Symbol = 61453;
this.btnCancel.TabIndex = 13;
this.btnCancel.Text = "取消";
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
btnCancel.Cursor = System.Windows.Forms.Cursors.Hand;
btnCancel.Font = new Font("宋体", 12F);
btnCancel.Location = new Point(372, 197);
btnCancel.MinimumSize = new Size(1, 1);
btnCancel.Name = "btnCancel";
btnCancel.Padding = new System.Windows.Forms.Padding(28, 0, 0, 0);
btnCancel.Size = new Size(95, 26);
btnCancel.Style = UIStyle.Custom;
btnCancel.Symbol = 361453;
btnCancel.SymbolOffset = new Point(0, 1);
btnCancel.TabIndex = 13;
btnCancel.Text = "取消";
btnCancel.TipsFont = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
btnCancel.Click += btnCancel_Click;
//
// UIColorItem
//
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnOK);
this.Controls.Add(this.m_opacitySlider);
this.Controls.Add(this.m_colorBar);
this.Controls.Add(this.m_colorWheel);
this.Controls.Add(this.lblB);
this.Controls.Add(this.lblG);
this.Controls.Add(this.lblR);
this.Controls.Add(this.lblA);
this.Controls.Add(this.edtB);
this.Controls.Add(this.edtG);
this.Controls.Add(this.edtR);
this.Controls.Add(this.edtA);
this.Controls.Add(this.m_colorSample);
this.Controls.Add(this.m_colorTable);
this.FillColor = System.Drawing.Color.White;
this.Name = "UIColorItem";
this.Size = new System.Drawing.Size(476, 233);
this.Style = Sunny.UI.UIStyle.Custom;
this.ResumeLayout(false);
this.PerformLayout();
Controls.Add(btnCancel);
Controls.Add(btnOK);
Controls.Add(m_opacitySlider);
Controls.Add(m_colorBar);
Controls.Add(m_colorWheel);
Controls.Add(lblB);
Controls.Add(lblG);
Controls.Add(lblR);
Controls.Add(lblA);
Controls.Add(edtB);
Controls.Add(edtG);
Controls.Add(edtR);
Controls.Add(edtA);
Controls.Add(m_colorSample);
Controls.Add(m_colorTable);
FillColor = Color.White;
Name = "UIColorItem";
Size = new Size(476, 233);
Style = UIStyle.Custom;
ResumeLayout(false);
PerformLayout();
}
private void m_colorTable_SelectedIndexChanged(object sender, EventArgs e)
@ -524,6 +542,19 @@ namespace Sunny.UI
m_colorWheel.SetLightness(m_colorBar.SelectedHSLColor.Lightness);
}
private void UpdateInfo()
{
Color c = Color.FromArgb((int)Math.Floor(255f * m_opacity), m_selectedColor);
string info = string.Format("{0} aRGB({1}, {2}, {3}, {4})", m_colorWheel.SelectedHSLColor.ToString(), c.A, c.R, c.G, c.B);
updateBox = true;
edtA.IntValue = c.A;
edtR.IntValue = c.R;
edtG.IntValue = c.G;
edtB.IntValue = c.B;
//m_infoLabel.Text = info;
updateBox = false;
}
private void m_opacitySlider_SelectedValueChanged(object sender, EventArgs e)
{
m_opacity = Math.Max(0, m_opacitySlider.Percent);
@ -532,17 +563,6 @@ namespace Sunny.UI
UpdateInfo();
}
private void UpdateInfo()
{
Color c = Color.FromArgb((int)Math.Floor(255f * m_opacity), m_selectedColor);
string info = string.Format("{0} aRGB({1}, {2}, {3}, {4})", m_colorWheel.SelectedHSLColor.ToString(), c.A, c.R, c.G, c.B);
edtA.IntValue = c.A;
edtR.IntValue = c.R;
edtG.IntValue = c.G;
edtB.IntValue = c.B;
//m_infoLabel.Text = info;
}
private void m_colorWheel_SelectedColorChanged(object sender, EventArgs e)
{
Color selcol = m_colorWheel.SelectedColor;
@ -558,6 +578,8 @@ namespace Sunny.UI
UpdateInfo();
}
private bool updateBox = false;
private void btnCancel_Click(object sender, EventArgs e)
{
Close();
@ -609,5 +631,30 @@ namespace Sunny.UI
edtB.SetStyleColor(uiColor);
lblA.ForeColor = lblR.ForeColor = lblG.ForeColor = lblB.ForeColor = uiColor.PanelForeColor;
}
private void edtR_TextChanged(object sender, EventArgs e)
{
if (updateBox) return;
SelectedColor = Color.FromArgb(SelectedColor.A, edtR.IntValue, SelectedColor.G, SelectedColor.B);
}
private void edtG_TextChanged(object sender, EventArgs e)
{
if (updateBox) return;
SelectedColor = Color.FromArgb(SelectedColor.A, SelectedColor.R, edtG.IntValue, SelectedColor.B);
}
private void edtB_TextChanged(object sender, EventArgs e)
{
if (updateBox) return;
SelectedColor = Color.FromArgb(SelectedColor.A, SelectedColor.R, SelectedColor.G, edtB.IntValue);
}
private void edtA_TextChanged(object sender, EventArgs e)
{
if (updateBox) return;
SelectedColor = Color.FromArgb(edtA.IntValue, SelectedColor);
UpdateInfo();
}
}
}

View File

@ -28,38 +28,38 @@
/// </summary>
private void InitializeComponent()
{
this.listBox = new Sunny.UI.UIListBox();
this.SuspendLayout();
listBox = new UIListBox();
SuspendLayout();
//
// listBox
//
this.listBox.BackColor = System.Drawing.Color.Transparent;
this.listBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.listBox.FillColor = System.Drawing.Color.White;
this.listBox.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.listBox.FormatString = "";
this.listBox.ItemSelectForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255)))));
this.listBox.Location = new System.Drawing.Point(0, 0);
this.listBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.listBox.MinimumSize = new System.Drawing.Size(1, 1);
this.listBox.Name = "listBox";
this.listBox.Padding = new System.Windows.Forms.Padding(2);
this.listBox.Radius = 0;
this.listBox.Size = new System.Drawing.Size(184, 210);
this.listBox.TabIndex = 3;
this.listBox.Text = null;
this.listBox.Click += new System.EventHandler(this.ListBox_Click);
this.listBox.SelectedIndexChanged += new System.EventHandler(this.listBox_SelectedIndexChanged);
this.listBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.listBox_KeyDown);
listBox.BackColor = System.Drawing.Color.Transparent;
listBox.Dock = System.Windows.Forms.DockStyle.Fill;
listBox.FillColor = System.Drawing.Color.White;
listBox.Font = new System.Drawing.Font("宋体", 12F);
listBox.HoverColor = System.Drawing.Color.FromArgb(155, 200, 255);
listBox.ItemSelectForeColor = System.Drawing.Color.FromArgb(235, 243, 255);
listBox.Location = new System.Drawing.Point(0, 0);
listBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
listBox.MinimumSize = new System.Drawing.Size(1, 1);
listBox.Name = "listBox";
listBox.Padding = new System.Windows.Forms.Padding(2);
listBox.Radius = 0;
listBox.ShowText = false;
listBox.Size = new System.Drawing.Size(184, 210);
listBox.TabIndex = 3;
listBox.Text = null;
listBox.KeyDown += listBox_KeyDown;
listBox.Click += ListBox_Click;
listBox.SelectedIndexChanged += listBox_SelectedIndexChanged;
//
// UIComboBoxItem
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.Controls.Add(this.listBox);
this.Name = "UIComboBoxItem";
this.Size = new System.Drawing.Size(184, 210);
this.ResumeLayout(false);
AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
Controls.Add(listBox);
Name = "UIComboBoxItem";
Size = new System.Drawing.Size(184, 210);
ResumeLayout(false);
}
#endregion

View File

@ -1,6 +1,6 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* CopyRight (C) 2012-2025 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse
@ -20,7 +20,6 @@
******************************************************************************/
using System;
using System.Drawing;
namespace Sunny.UI
{
@ -53,24 +52,6 @@ namespace Sunny.UI
public event EventHandler BeforeListClick;
/// <summary>
/// 设置边框颜色
/// </summary>
/// <param name="color">颜色</param>
public override void SetRectColor(Color color)
{
//listBox.ItemSelectBackColor = color;
}
/// <summary>
/// 设置填充颜色
/// </summary>
/// <param name="color">颜色</param>
public override void SetFillColor(Color color)
{
//ListBox.ItemSelectForeColor = color;
}
private void listBox_SelectedIndexChanged(object sender, EventArgs e)
{
DoValueChanged(this, ListBox.SelectedValue);
@ -83,5 +64,11 @@ namespace Sunny.UI
Close();
}
}
public override void SetStyleColor(UIBaseStyle uiColor)
{
base.SetStyleColor(uiColor);
listBox.SetStyleColor(uiColor);
}
}
}

View File

@ -1,4 +1,64 @@
<root>
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">

View File

@ -1,6 +1,6 @@
/******************************************************************************
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* CopyRight (C) 2012-2025 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse
@ -19,6 +19,7 @@
* 2023-03-29: V3.3.3
* 2024-05-28: V3.6.6
* 2024-05-28: V3.6.6 FilterColumnName增加;
* 2024-07-23: V3.6.8 '*','[',']','%'
******************************************************************************/
using System;
@ -29,7 +30,7 @@ using System.Windows.Forms;
namespace Sunny.UI
{
public class UIComboDataGridViewItem : UIDropDownItem, ITranslate
internal class UIComboDataGridViewItem : UIDropDownItem, ITranslate
{
private UIPanel panel;
private UISymbolButton btnCancel;
@ -83,10 +84,10 @@ namespace Sunny.UI
public void Translate()
{
btnOK.Text = UILocalize.OK;
btnCancel.Text = UILocalize.Cancel;
btnClear.Text = UILocalize.Clear;
btnSearch.Text = UILocalize.Search;
btnOK.Text = UIStyles.CurrentResources.OK;
btnCancel.Text = UIStyles.CurrentResources.Cancel;
btnClear.Text = UIStyles.CurrentResources.Clear;
btnSearch.Text = UIStyles.CurrentResources.Search;
}
public bool ShowButtons
@ -101,11 +102,11 @@ namespace Sunny.UI
private void InitializeComponent()
{
DataGridViewCellStyle dataGridViewCellStyle1 = new DataGridViewCellStyle();
DataGridViewCellStyle dataGridViewCellStyle2 = new DataGridViewCellStyle();
DataGridViewCellStyle dataGridViewCellStyle3 = new DataGridViewCellStyle();
DataGridViewCellStyle dataGridViewCellStyle4 = new DataGridViewCellStyle();
DataGridViewCellStyle dataGridViewCellStyle5 = new DataGridViewCellStyle();
DataGridViewCellStyle dataGridViewCellStyle11 = new DataGridViewCellStyle();
DataGridViewCellStyle dataGridViewCellStyle12 = new DataGridViewCellStyle();
DataGridViewCellStyle dataGridViewCellStyle13 = new DataGridViewCellStyle();
DataGridViewCellStyle dataGridViewCellStyle14 = new DataGridViewCellStyle();
DataGridViewCellStyle dataGridViewCellStyle15 = new DataGridViewCellStyle();
panel = new UIPanel();
btnCancel = new UISymbolButton();
btnOK = new UISymbolButton();
@ -124,7 +125,7 @@ namespace Sunny.UI
panel.Controls.Add(btnCancel);
panel.Controls.Add(btnOK);
panel.Dock = DockStyle.Bottom;
panel.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
panel.Font = new System.Drawing.Font("宋体", 12F);
panel.Location = new System.Drawing.Point(0, 289);
panel.Margin = new Padding(4, 5, 4, 5);
panel.MinimumSize = new System.Drawing.Size(1, 1);
@ -146,7 +147,8 @@ namespace Sunny.UI
btnCancel.FillHoverColor = System.Drawing.Color.FromArgb(235, 115, 115);
btnCancel.FillPressColor = System.Drawing.Color.FromArgb(184, 64, 64);
btnCancel.FillSelectedColor = System.Drawing.Color.FromArgb(184, 64, 64);
btnCancel.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
btnCancel.Font = new System.Drawing.Font("宋体", 10.5F);
btnCancel.LightColor = System.Drawing.Color.FromArgb(253, 243, 243);
btnCancel.Location = new System.Drawing.Point(478, 8);
btnCancel.MinimumSize = new System.Drawing.Size(1, 1);
btnCancel.Name = "btnCancel";
@ -155,73 +157,73 @@ namespace Sunny.UI
btnCancel.RectPressColor = System.Drawing.Color.FromArgb(184, 64, 64);
btnCancel.RectSelectedColor = System.Drawing.Color.FromArgb(184, 64, 64);
btnCancel.Size = new System.Drawing.Size(80, 29);
btnCancel.Style = UIStyle.Red;
btnCancel.Style = UIStyle.Custom;
btnCancel.StyleCustomMode = true;
btnCancel.Symbol = 61453;
btnCancel.Symbol = 361453;
btnCancel.SymbolOffset = new System.Drawing.Point(0, 1);
btnCancel.TabIndex = 1;
btnCancel.Text = "取消";
btnCancel.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
btnCancel.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
btnCancel.Click += btnCancel_Click;
//
// btnOK
//
btnOK.Anchor = AnchorStyles.Top | AnchorStyles.Right;
btnOK.Cursor = Cursors.Hand;
btnOK.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
btnOK.Font = new System.Drawing.Font("宋体", 10.5F);
btnOK.Location = new System.Drawing.Point(389, 8);
btnOK.MinimumSize = new System.Drawing.Size(1, 1);
btnOK.Name = "btnOK";
btnOK.Size = new System.Drawing.Size(80, 29);
btnOK.SymbolOffset = new System.Drawing.Point(0, 1);
btnOK.TabIndex = 0;
btnOK.Text = "确定";
btnOK.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
btnOK.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
btnOK.Click += btnOK_Click;
//
// dataGridView
//
dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(243, 249, 255);
dataGridView.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1;
dataGridViewCellStyle11.BackColor = System.Drawing.Color.FromArgb(243, 249, 255);
dataGridView.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle11;
dataGridView.BackgroundColor = System.Drawing.Color.FromArgb(243, 249, 255);
dataGridView.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single;
dataGridViewCellStyle2.Alignment = DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle2.BackColor = System.Drawing.Color.FromArgb(80, 160, 255);
dataGridViewCellStyle2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
dataGridViewCellStyle2.ForeColor = System.Drawing.Color.White;
dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.FromArgb(80, 160, 255);
dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle2.WrapMode = DataGridViewTriState.True;
dataGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2;
dataGridViewCellStyle12.Alignment = DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle12.BackColor = System.Drawing.Color.FromArgb(80, 160, 255);
dataGridViewCellStyle12.Font = new System.Drawing.Font("宋体", 12F);
dataGridViewCellStyle12.ForeColor = System.Drawing.Color.White;
dataGridViewCellStyle12.SelectionBackColor = System.Drawing.Color.FromArgb(80, 160, 255);
dataGridViewCellStyle12.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle12.WrapMode = DataGridViewTriState.True;
dataGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle12;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewCellStyle3.Alignment = DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle3.BackColor = System.Drawing.Color.White;
dataGridViewCellStyle3.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
dataGridViewCellStyle3.ForeColor = System.Drawing.Color.FromArgb(48, 48, 48);
dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.FromArgb(220, 236, 255);
dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.FromArgb(48, 48, 48);
dataGridViewCellStyle3.WrapMode = DataGridViewTriState.False;
dataGridView.DefaultCellStyle = dataGridViewCellStyle3;
dataGridViewCellStyle13.Alignment = DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle13.BackColor = System.Drawing.Color.White;
dataGridViewCellStyle13.Font = new System.Drawing.Font("宋体", 12F);
dataGridViewCellStyle13.ForeColor = System.Drawing.Color.FromArgb(48, 48, 48);
dataGridViewCellStyle13.SelectionBackColor = System.Drawing.Color.FromArgb(220, 236, 255);
dataGridViewCellStyle13.SelectionForeColor = System.Drawing.Color.FromArgb(48, 48, 48);
dataGridViewCellStyle13.WrapMode = DataGridViewTriState.False;
dataGridView.DefaultCellStyle = dataGridViewCellStyle13;
dataGridView.Dock = DockStyle.Fill;
dataGridView.EnableHeadersVisualStyles = false;
dataGridView.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
dataGridView.Font = new System.Drawing.Font("宋体", 12F);
dataGridView.GridColor = System.Drawing.Color.FromArgb(104, 173, 255);
dataGridView.Location = new System.Drawing.Point(0, 44);
dataGridView.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridViewCellStyle4.Alignment = DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle4.BackColor = System.Drawing.Color.FromArgb(243, 249, 255);
dataGridViewCellStyle4.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
dataGridViewCellStyle4.ForeColor = System.Drawing.Color.FromArgb(48, 48, 48);
dataGridViewCellStyle4.SelectionBackColor = System.Drawing.Color.FromArgb(80, 160, 255);
dataGridViewCellStyle4.SelectionForeColor = System.Drawing.Color.FromArgb(48, 48, 48);
dataGridViewCellStyle4.WrapMode = DataGridViewTriState.True;
dataGridView.RowHeadersDefaultCellStyle = dataGridViewCellStyle4;
dataGridViewCellStyle5.BackColor = System.Drawing.Color.White;
dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(48, 48, 48);
dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.FromArgb(220, 236, 255);
dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.FromArgb(48, 48, 48);
dataGridView.RowsDefaultCellStyle = dataGridViewCellStyle5;
dataGridView.RowTemplate.Height = 25;
dataGridView.ScrollBarRectColor = System.Drawing.Color.FromArgb(80, 160, 255);
dataGridViewCellStyle14.Alignment = DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle14.BackColor = System.Drawing.Color.FromArgb(243, 249, 255);
dataGridViewCellStyle14.Font = new System.Drawing.Font("宋体", 12F);
dataGridViewCellStyle14.ForeColor = System.Drawing.Color.FromArgb(48, 48, 48);
dataGridViewCellStyle14.SelectionBackColor = System.Drawing.Color.FromArgb(80, 160, 255);
dataGridViewCellStyle14.SelectionForeColor = System.Drawing.Color.FromArgb(48, 48, 48);
dataGridViewCellStyle14.WrapMode = DataGridViewTriState.True;
dataGridView.RowHeadersDefaultCellStyle = dataGridViewCellStyle14;
dataGridViewCellStyle15.BackColor = System.Drawing.Color.White;
dataGridViewCellStyle15.ForeColor = System.Drawing.Color.FromArgb(48, 48, 48);
dataGridViewCellStyle15.SelectionBackColor = System.Drawing.Color.FromArgb(220, 236, 255);
dataGridViewCellStyle15.SelectionForeColor = System.Drawing.Color.FromArgb(48, 48, 48);
dataGridView.RowsDefaultCellStyle = dataGridViewCellStyle15;
dataGridView.SelectedIndex = -1;
dataGridView.Size = new System.Drawing.Size(569, 245);
dataGridView.TabIndex = 3;
@ -233,7 +235,7 @@ namespace Sunny.UI
pFilter.Controls.Add(btnSearch);
pFilter.Controls.Add(edtFilter);
pFilter.Dock = DockStyle.Top;
pFilter.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
pFilter.Font = new System.Drawing.Font("宋体", 12F);
pFilter.Location = new System.Drawing.Point(0, 0);
pFilter.Margin = new Padding(4, 5, 4, 5);
pFilter.MinimumSize = new System.Drawing.Size(1, 1);
@ -249,31 +251,33 @@ namespace Sunny.UI
//
btnClear.Anchor = AnchorStyles.Top | AnchorStyles.Right;
btnClear.Cursor = Cursors.Hand;
btnClear.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
btnClear.Font = new System.Drawing.Font("宋体", 10.5F);
btnClear.Location = new System.Drawing.Point(478, 8);
btnClear.MinimumSize = new System.Drawing.Size(1, 1);
btnClear.Name = "btnClear";
btnClear.Size = new System.Drawing.Size(80, 29);
btnClear.Symbol = 61666;
btnClear.Symbol = 361666;
btnClear.SymbolOffset = new System.Drawing.Point(0, 1);
btnClear.SymbolSize = 22;
btnClear.TabIndex = 2;
btnClear.Text = "清除";
btnClear.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
btnClear.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
btnClear.Click += btnClear_Click;
//
// btnSearch
//
btnSearch.Anchor = AnchorStyles.Top | AnchorStyles.Right;
btnSearch.Cursor = Cursors.Hand;
btnSearch.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
btnSearch.Font = new System.Drawing.Font("宋体", 10.5F);
btnSearch.Location = new System.Drawing.Point(389, 8);
btnSearch.MinimumSize = new System.Drawing.Size(1, 1);
btnSearch.Name = "btnSearch";
btnSearch.Size = new System.Drawing.Size(80, 29);
btnSearch.Symbol = 61442;
btnSearch.Symbol = 361442;
btnSearch.SymbolOffset = new System.Drawing.Point(0, 1);
btnSearch.TabIndex = 1;
btnSearch.Text = "搜索";
btnSearch.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
btnSearch.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
btnSearch.Click += btnSearch_Click;
//
// edtFilter
@ -281,7 +285,7 @@ namespace Sunny.UI
edtFilter.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
edtFilter.ButtonSymbolOffset = new System.Drawing.Point(0, 0);
edtFilter.Cursor = Cursors.IBeam;
edtFilter.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
edtFilter.Font = new System.Drawing.Font("宋体", 10.5F);
edtFilter.Location = new System.Drawing.Point(17, 10);
edtFilter.Margin = new Padding(4, 5, 4, 5);
edtFilter.MinimumSize = new System.Drawing.Size(1, 16);
@ -381,6 +385,24 @@ namespace Sunny.UI
}
else
{
char[] chars = filterText.ToCharArray();
List<char> chars2 = new List<char>();
foreach (char c in chars)
{
if (c.Equals('*') || c.Equals('[') || c.Equals(']') || c.Equals('%'))
{
chars2.Add('[');
chars2.Add(c);
chars2.Add(']');
}
else
{
chars2.Add(c);
}
}
filterText = new string(chars2.ToArray());
if (FilterColumnName.IsValid())
{
if (FilterColumnName.Contains(";"))
@ -418,7 +440,6 @@ namespace Sunny.UI
}
}
filter = filter.Replace("*", "[*]");
if (dataGridView.DataSource is DataTable table)
{
try

View File

@ -18,7 +18,7 @@
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>

View File

@ -2,7 +2,7 @@
namespace Sunny.UI
{
public class UIComboTreeViewItem : UIDropDownItem, ITranslate
internal class UIComboTreeViewItem : UIDropDownItem, ITranslate
{
private UIPanel panel;
private UISymbolButton btnCancel;
@ -52,123 +52,115 @@ namespace Sunny.UI
public void Translate()
{
btnOK.Text = UILocalize.OK;
btnCancel.Text = UILocalize.Cancel;
btnOK.Text = UIStyles.CurrentResources.OK;
btnCancel.Text = UIStyles.CurrentResources.Cancel;
uiCheckBox1.Text = UIStyles.CurrentResources.All;
}
private void InitializeComponent()
{
this.treeView = new Sunny.UI.UITreeView();
this.panel = new Sunny.UI.UIPanel();
this.btnCancel = new Sunny.UI.UISymbolButton();
this.btnOK = new Sunny.UI.UISymbolButton();
this.uiCheckBox1 = new Sunny.UI.UICheckBox();
this.panel.SuspendLayout();
this.SuspendLayout();
treeView = new UITreeView();
panel = new UIPanel();
uiCheckBox1 = new UICheckBox();
btnCancel = new UISymbolButton();
btnOK = new UISymbolButton();
panel.SuspendLayout();
SuspendLayout();
//
// treeView
//
this.treeView.Dock = System.Windows.Forms.DockStyle.Fill;
this.treeView.FillColor = System.Drawing.Color.White;
this.treeView.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.treeView.LineColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
this.treeView.Location = new System.Drawing.Point(0, 0);
this.treeView.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.treeView.MinimumSize = new System.Drawing.Size(1, 1);
this.treeView.Name = "treeView";
this.treeView.RadiusSides = Sunny.UI.UICornerRadiusSides.None;
this.treeView.ShowText = false;
this.treeView.Size = new System.Drawing.Size(250, 176);
this.treeView.TabIndex = 0;
this.treeView.Text = "uiTreeView1";
this.treeView.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
this.treeView.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
this.treeView.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.TreeView_NodeMouseClick);
treeView.Dock = System.Windows.Forms.DockStyle.Fill;
treeView.FillColor = System.Drawing.Color.White;
treeView.Font = new System.Drawing.Font("宋体", 12F);
treeView.LineColor = System.Drawing.Color.FromArgb(48, 48, 48);
treeView.Location = new System.Drawing.Point(0, 0);
treeView.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
treeView.MinimumSize = new System.Drawing.Size(1, 1);
treeView.Name = "treeView";
treeView.RadiusSides = UICornerRadiusSides.None;
treeView.ScrollBarStyleInherited = false;
treeView.ShowText = false;
treeView.Size = new System.Drawing.Size(250, 176);
treeView.TabIndex = 0;
treeView.Text = "uiTreeView1";
treeView.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
treeView.NodeMouseClick += TreeView_NodeMouseClick;
//
// panel
//
this.panel.Controls.Add(this.uiCheckBox1);
this.panel.Controls.Add(this.btnCancel);
this.panel.Controls.Add(this.btnOK);
this.panel.Dock = System.Windows.Forms.DockStyle.Bottom;
this.panel.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.panel.Location = new System.Drawing.Point(0, 176);
this.panel.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.panel.MinimumSize = new System.Drawing.Size(1, 1);
this.panel.Name = "panel";
this.panel.RadiusSides = Sunny.UI.UICornerRadiusSides.None;
this.panel.RectSides = ((System.Windows.Forms.ToolStripStatusLabelBorderSides)(((System.Windows.Forms.ToolStripStatusLabelBorderSides.Left | System.Windows.Forms.ToolStripStatusLabelBorderSides.Right)
| System.Windows.Forms.ToolStripStatusLabelBorderSides.Bottom)));
this.panel.Size = new System.Drawing.Size(250, 44);
this.panel.TabIndex = 1;
this.panel.Text = null;
this.panel.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
this.panel.Visible = false;
this.panel.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
//
// btnCancel
//
this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnCancel.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnCancel.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80)))));
this.btnCancel.FillColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80)))));
this.btnCancel.FillHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(115)))), ((int)(((byte)(115)))));
this.btnCancel.FillPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(184)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.btnCancel.FillSelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(184)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.btnCancel.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.btnCancel.Location = new System.Drawing.Point(159, 8);
this.btnCancel.MinimumSize = new System.Drawing.Size(1, 1);
this.btnCancel.Name = "btnCancel";
this.btnCancel.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80)))));
this.btnCancel.RectHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(115)))), ((int)(((byte)(115)))));
this.btnCancel.RectPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(184)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.btnCancel.RectSelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(184)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.btnCancel.Size = new System.Drawing.Size(80, 29);
this.btnCancel.Style = Sunny.UI.UIStyle.Red;
this.btnCancel.StyleCustomMode = true;
this.btnCancel.Symbol = 61453;
this.btnCancel.TabIndex = 1;
this.btnCancel.Text = "取消";
this.btnCancel.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// btnOK
//
this.btnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnOK.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnOK.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.btnOK.Location = new System.Drawing.Point(70, 8);
this.btnOK.MinimumSize = new System.Drawing.Size(1, 1);
this.btnOK.Name = "btnOK";
this.btnOK.Size = new System.Drawing.Size(80, 29);
this.btnOK.TabIndex = 0;
this.btnOK.Text = "确定";
this.btnOK.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
panel.Controls.Add(uiCheckBox1);
panel.Controls.Add(btnCancel);
panel.Controls.Add(btnOK);
panel.Dock = System.Windows.Forms.DockStyle.Bottom;
panel.Font = new System.Drawing.Font("宋体", 12F);
panel.Location = new System.Drawing.Point(0, 176);
panel.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
panel.MinimumSize = new System.Drawing.Size(1, 1);
panel.Name = "panel";
panel.RadiusSides = UICornerRadiusSides.None;
panel.RectSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.Left | System.Windows.Forms.ToolStripStatusLabelBorderSides.Right | System.Windows.Forms.ToolStripStatusLabelBorderSides.Bottom;
panel.Size = new System.Drawing.Size(250, 44);
panel.TabIndex = 1;
panel.Text = null;
panel.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
panel.Visible = false;
//
// uiCheckBox1
//
this.uiCheckBox1.BackColor = System.Drawing.Color.Transparent;
this.uiCheckBox1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.uiCheckBox1.Location = new System.Drawing.Point(3, 8);
this.uiCheckBox1.MinimumSize = new System.Drawing.Size(1, 1);
this.uiCheckBox1.Name = "uiCheckBox1";
this.uiCheckBox1.Padding = new System.Windows.Forms.Padding(22, 0, 0, 0);
this.uiCheckBox1.Size = new System.Drawing.Size(64, 29);
this.uiCheckBox1.TabIndex = 2;
this.uiCheckBox1.Text = "全选";
this.uiCheckBox1.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
this.uiCheckBox1.CheckedChanged += new System.EventHandler(this.uiCheckBox1_CheckedChanged);
uiCheckBox1.BackColor = System.Drawing.Color.Transparent;
uiCheckBox1.Font = new System.Drawing.Font("宋体", 12F);
uiCheckBox1.ForeColor = System.Drawing.Color.FromArgb(48, 48, 48);
uiCheckBox1.Location = new System.Drawing.Point(3, 8);
uiCheckBox1.MinimumSize = new System.Drawing.Size(1, 1);
uiCheckBox1.Name = "uiCheckBox1";
uiCheckBox1.Padding = new System.Windows.Forms.Padding(22, 0, 0, 0);
uiCheckBox1.Size = new System.Drawing.Size(64, 29);
uiCheckBox1.TabIndex = 2;
uiCheckBox1.Text = "全选";
uiCheckBox1.CheckedChanged += uiCheckBox1_CheckedChanged;
//
// btnCancel
//
btnCancel.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right;
btnCancel.Cursor = System.Windows.Forms.Cursors.Hand;
btnCancel.Font = new System.Drawing.Font("宋体", 10.5F);
btnCancel.Location = new System.Drawing.Point(159, 8);
btnCancel.MinimumSize = new System.Drawing.Size(1, 1);
btnCancel.Name = "btnCancel";
btnCancel.Size = new System.Drawing.Size(80, 29);
btnCancel.StyleCustomMode = true;
btnCancel.Symbol = 361453;
btnCancel.SymbolOffset = new System.Drawing.Point(0, 1);
btnCancel.SymbolSize = 22;
btnCancel.TabIndex = 1;
btnCancel.Text = "取消";
btnCancel.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
btnCancel.Click += btnCancel_Click;
//
// btnOK
//
btnOK.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right;
btnOK.Cursor = System.Windows.Forms.Cursors.Hand;
btnOK.Font = new System.Drawing.Font("宋体", 10.5F);
btnOK.Location = new System.Drawing.Point(70, 8);
btnOK.MinimumSize = new System.Drawing.Size(1, 1);
btnOK.Name = "btnOK";
btnOK.Size = new System.Drawing.Size(80, 29);
btnOK.SymbolOffset = new System.Drawing.Point(0, 1);
btnOK.SymbolSize = 22;
btnOK.TabIndex = 0;
btnOK.Text = "确定";
btnOK.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
btnOK.Click += btnOK_Click;
//
// UIComboTreeViewItem
//
this.Controls.Add(this.treeView);
this.Controls.Add(this.panel);
this.Name = "UIComboTreeViewItem";
this.Size = new System.Drawing.Size(250, 220);
this.panel.ResumeLayout(false);
this.ResumeLayout(false);
Controls.Add(treeView);
Controls.Add(panel);
Name = "UIComboTreeViewItem";
Size = new System.Drawing.Size(250, 220);
panel.ResumeLayout(false);
ResumeLayout(false);
}
private void TreeView_NodeMouseClick(object sender, System.Windows.Forms.TreeNodeMouseClickEventArgs e)
@ -192,6 +184,8 @@ namespace Sunny.UI
treeView.Style = style.Name;
panel.Style = style.Name;
btnOK.Style = style.Name;
btnCancel.Style = style.Name;
uiCheckBox1.Style = style.Name;
}
private void btnCancel_Click(object sender, System.EventArgs e)

View File

@ -1,4 +1,64 @@
<root>
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">

View File

@ -1,6 +1,6 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2024 ShenYongHua().
* CopyRight (C) 2012-2025 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse
@ -270,7 +270,7 @@ namespace Sunny.UI
tabPage3.Controls.Add(p3);
tabPage3.Location = new Point(0, 40);
tabPage3.Name = "tabPage3";
tabPage3.Size = new Size(461, 277);
tabPage3.Size = new Size(200, 60);
tabPage3.TabIndex = 2;
tabPage3.Text = "tabPage3";
tabPage3.UseVisualStyleBackColor = true;
@ -285,7 +285,7 @@ namespace Sunny.UI
p3.MinimumSize = new Size(1, 1);
p3.Name = "p3";
p3.RadiusSides = UICornerRadiusSides.None;
p3.Size = new Size(461, 277);
p3.Size = new Size(200, 60);
p3.Style = UIStyle.Custom;
p3.TabIndex = 2;
p3.Text = null;
@ -382,18 +382,18 @@ namespace Sunny.UI
public void Translate()
{
months.Clear();
months.Add(UILocalize.January);
months.Add(UILocalize.February);
months.Add(UILocalize.March);
months.Add(UILocalize.April);
months.Add(UILocalize.May);
months.Add(UILocalize.June);
months.Add(UILocalize.July);
months.Add(UILocalize.August);
months.Add(UILocalize.September);
months.Add(UILocalize.October);
months.Add(UILocalize.November);
months.Add(UILocalize.December);
months.Add(UIStyles.CurrentResources.January);
months.Add(UIStyles.CurrentResources.February);
months.Add(UIStyles.CurrentResources.March);
months.Add(UIStyles.CurrentResources.April);
months.Add(UIStyles.CurrentResources.May);
months.Add(UIStyles.CurrentResources.June);
months.Add(UIStyles.CurrentResources.July);
months.Add(UIStyles.CurrentResources.August);
months.Add(UIStyles.CurrentResources.September);
months.Add(UIStyles.CurrentResources.October);
months.Add(UIStyles.CurrentResources.November);
months.Add(UIStyles.CurrentResources.December);
}
private void TopPanel_Click(object sender, EventArgs e)
@ -788,7 +788,7 @@ namespace Sunny.UI
int width = p3.Width / 7;
int height = (p3.Height - 30 * SizeMultiple) / 6;
using Font font = SizeMultiple == 1 ? this.Font : new Font(this.Font.FontFamily, this.Font.Size * 1.5f);
string[] weeks = { UILocalize.Sunday, UILocalize.Monday, UILocalize.Tuesday, UILocalize.Wednesday, UILocalize.Thursday, UILocalize.Friday, UILocalize.Saturday };
string[] weeks = { UIStyles.CurrentResources.Sunday, UIStyles.CurrentResources.Monday, UIStyles.CurrentResources.Tuesday, UIStyles.CurrentResources.Wednesday, UIStyles.CurrentResources.Thursday, UIStyles.CurrentResources.Friday, UIStyles.CurrentResources.Saturday };
for (int i = 0; i < weeks.Length; i++)
{
e.Graphics.DrawString(weeks[i], font, ForeColor, new Rectangle(width * i, 4 * SizeMultiple, width, 19 * SizeMultiple), ContentAlignment.MiddleCenter);
@ -802,10 +802,15 @@ namespace Sunny.UI
int left = width * (i % 7);
int top = height * (i / 7);
Color color = (days[i].Month == Month) ? ForeColor : Color.DarkGray;
color = (days[i].DateString() == date.DateString()) ? PrimaryColor : color;
color = (days[i].DateString() == date.DateString()) ? b3.SymbolColor : color;
if (days[i] < min) color = Color.DarkGray;
if (days[i] > max) color = Color.DarkGray;
if (days[i].DateString() == date.DateString())
{
e.Graphics.DrawRectangle(b3.SymbolColor, new Rectangle(left + 1, top + 30 * SizeMultiple + 1, width - 2, height - 2));
}
if (!maxDrawer)
{
e.Graphics.DrawString(days[i].Day.ToString(), font, i == activeDay ? PrimaryColor : color, new Rectangle(left, top + 30 * SizeMultiple, width, height), ContentAlignment.MiddleCenter);
@ -821,8 +826,9 @@ namespace Sunny.UI
{
using Font SubFont = this.Font.DPIScaleFont(SizeMultiple == 1 ? 10.5f : 15.75f);
e.Graphics.FillRectangle(p3.FillColor, p3.Width - width * 4 + 1, p3.Height - height + 1, width * 4 - 2, height - 2);
e.Graphics.FillRoundRectangle(PrimaryColor, new Rectangle(p3.Width - width * 4 + 6, p3.Height - height + 3, 8, height - 10), 3);
e.Graphics.DrawString(UILocalize.Today + ": " + DateTime.Now.DateString(), SubFont, isToday ? PrimaryColor : Color.DarkGray, new Rectangle(p3.Width - width * 4 + 17, p3.Height - height - 1, Width, height), ContentAlignment.MiddleLeft);
e.Graphics.DrawString(UIStyles.CurrentResources.Today + " " + DateTime.Now.DateString(), SubFont, isToday ? b3.SymbolColor : Color.DarkGray, new Rectangle(p3.Width - width * 4, p3.Height - height - 1, Width, height), ContentAlignment.MiddleLeft);
SizeF sf = TextRenderer.MeasureText(UIStyles.CurrentResources.Today, SubFont);
e.Graphics.DrawRectangle(b3.SymbolColor, new Rectangle(p3.Width - width * 4 + 1, p3.Height - height + 1, (int)sf.Width - 2, height - 4));
}
}

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More