yangyin
2025-03-27 b0de14c2670b9ff0079dacfb4b7457b438368f11
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
// COPYRIGHT (C) Tom. ALL RIGHTS RESERVED.
// THE AntdUI PROJECT IS AN WINFORM LIBRARY LICENSED UNDER THE Apache-2.0 License.
// LICENSED UNDER THE Apache License, VERSION 2.0 (THE "License")
// YOU MAY NOT USE THIS FILE EXCEPT IN COMPLIANCE WITH THE License.
// YOU MAY OBTAIN A COPY OF THE LICENSE AT
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING, SOFTWARE
// DISTRIBUTED UNDER THE LICENSE IS DISTRIBUTED ON AN "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
// SEE THE LICENSE FOR THE SPECIFIC LANGUAGE GOVERNING PERMISSIONS AND
// LIMITATIONS UNDER THE License.
// GITEE: https://gitee.com/antdui/AntdUI
// GITHUB: https://github.com/AntdUI/AntdUI
// CSDN: https://blog.csdn.net/v_132
// QQ: 17379620
 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Design;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
 
namespace AntdUI
{
    /// <summary>
    /// Button 按钮
    /// </summary>
    /// <remarks>按钮用于开始一个即时操作。</remarks>
    [Description("Button 按钮")]
    [ToolboxItem(true)]
    [DefaultProperty("Text")]
    public class Button : IControl, IButtonControl
    {
        IButton button;
 
        public Button()
        {
            SetStyle(ControlStyles.StandardClick | ControlStyles.StandardDoubleClick, false);
            base.BackColor = Color.Transparent;
            button = new IButton(this, () => BeforeAutoSize());
        }
 
        #region 属性
 
        /// <summary>
        /// 文字颜色
        /// </summary>
        [Description("文字颜色"), Category("外观"), DefaultValue(null)]
        [Editor(typeof(Design.ColorEditor), typeof(UITypeEditor))]
        public new Color? ForeColor
        {
            get => button.Fore;
            set => button.Fore = value;
        }
 
        #region 背景
 
        /// <summary>
        /// 背景颜色
        /// </summary>
        [Description("背景颜色"), Category("外观"), DefaultValue(null)]
        [Editor(typeof(Design.ColorEditor), typeof(UITypeEditor))]
        public new Color? BackColor
        {
            get => button.Back;
            set => button.Back = value;
        }
 
        /// <summary>
        /// 背景渐变色
        /// </summary>
        [Description("背景渐变色"), Category("外观"), DefaultValue(null)]
        public string? BackExtend
        {
            get => button.BackExtend;
            set => button.BackExtend = value;
        }
 
        /// <summary>
        /// 悬停背景颜色
        /// </summary>
        [Description("悬停背景颜色"), Category("外观"), DefaultValue(null)]
        [Editor(typeof(Design.ColorEditor), typeof(UITypeEditor))]
        public Color? BackHover
        {
            get => button.BackHover;
            set => button.BackHover = value;
        }
 
        /// <summary>
        /// 激活背景颜色
        /// </summary>
        [Description("激活背景颜色"), Category("外观"), DefaultValue(null)]
        [Editor(typeof(Design.ColorEditor), typeof(UITypeEditor))]
        public Color? BackActive
        {
            get => button.BackActive;
            set => button.BackActive = value;
        }
 
        /// <summary>
        /// 背景图片
        /// </summary>
        [Description("背景图片"), Category("外观"), DefaultValue(null)]
        public new Image? BackgroundImage
        {
            get => button.BackgroundImage;
            set => button.BackgroundImage = value;
        }
 
        /// <summary>
        /// 背景图片布局
        /// </summary>
        [Description("背景图片布局"), Category("外观"), DefaultValue(TFit.Fill)]
        public new TFit BackgroundImageLayout
        {
            get => button.BackgroundImageLayout;
            set => button.BackgroundImageLayout = value;
        }
 
        #endregion
 
        #region 默认样式
 
        /// <summary>
        /// Default模式背景颜色
        /// </summary>
        [Description("Default模式背景颜色"), Category("外观"), DefaultValue(null)]
        [Editor(typeof(Design.ColorEditor), typeof(UITypeEditor))]
        public Color? DefaultBack
        {
            get => button.DefaultBack;
            set => button.DefaultBack = value;
        }
 
        /// <summary>
        /// Default模式边框颜色
        /// </summary>
        [Description("Default模式边框颜色"), Category("外观"), DefaultValue(null)]
        [Editor(typeof(Design.ColorEditor), typeof(UITypeEditor))]
        public Color? DefaultBorderColor
        {
            get => button.DefaultBorderColor;
            set => button.DefaultBorderColor = value;
        }
 
        #endregion
 
        #region 边框
 
        /// <summary>
        /// 边框宽度
        /// </summary>
        [Description("边框宽度"), Category("边框"), DefaultValue(0F)]
        public float BorderWidth
        {
            get => button.BorderWidth;
            set => button.BorderWidth = value;
        }
 
        #endregion
 
        /// <summary>
        /// 波浪大小
        /// </summary>
        [Description("波浪大小"), Category("外观"), DefaultValue(4)]
        public int WaveSize
        {
            get => button.WaveSize;
            set => button.WaveSize = value;
        }
 
        /// <summary>
        /// 圆角
        /// </summary>
        [Description("圆角"), Category("外观"), DefaultValue(6)]
        public int Radius
        {
            get => button.Radius;
            set => button.Radius = value;
        }
 
        /// <summary>
        /// 形状
        /// </summary>
        [Description("形状"), Category("外观"), DefaultValue(TShape.Default)]
        public TShape Shape
        {
            get => button.Shape;
            set => button.Shape = value;
        }
 
        /// <summary>
        /// 类型
        /// </summary>
        [Description("类型"), Category("外观"), DefaultValue(TTypeMini.Default)]
        public TTypeMini Type
        {
            get => button.Type;
            set => button.Type = value;
        }
 
        /// <summary>
        /// 幽灵属性,使按钮背景透明
        /// </summary>
        [Description("幽灵属性,使按钮背景透明"), Category("外观"), DefaultValue(false)]
        public bool Ghost
        {
            get => button.Ghost;
            set => button.Ghost = value;
        }
 
        /// <summary>
        /// 响应真实区域
        /// </summary>
        [Description("响应真实区域"), Category("行为"), DefaultValue(false)]
        public bool RespondRealAreas { get; set; }
 
        /// <summary>
        /// 显示箭头
        /// </summary>
        [Description("显示箭头"), Category("行为"), DefaultValue(false)]
        public bool ShowArrow
        {
            get => button.ShowArrow;
            set => button.ShowArrow = value;
        }
 
        /// <summary>
        /// 箭头链接样式
        /// </summary>
        [Description("箭头链接样式"), Category("行为"), DefaultValue(false)]
        public bool IsLink
        {
            get => button.IsLink;
            set => button.IsLink = value;
        }
 
        /// <summary>
        /// 箭头角度
        /// </summary>
        [Browsable(false), Description("箭头角度"), Category("外观"), DefaultValue(-1F)]
        public float ArrowProg
        {
            get => button.ArrowProg;
            set => button.ArrowProg = value;
        }
 
        #region 文本
 
        /// <summary>
        /// 文本
        /// </summary>
        [Editor(typeof(System.ComponentModel.Design.MultilineStringEditor), typeof(UITypeEditor))]
        [Description("文本"), Category("外观"), DefaultValue(null)]
        public override string? Text
        {
            get => button.Text;
            set
            {
                var old = button.Text;
                button.Text = value;
                if (old != value) OnTextChanged(EventArgs.Empty);
            }
        }
 
        /// <summary>
        /// 文本位置
        /// </summary>
        [Description("文本位置"), Category("外观"), DefaultValue(ContentAlignment.MiddleCenter)]
        public ContentAlignment TextAlign
        {
            get => button.TextAlign;
            set => button.TextAlign = value;
        }
 
        /// <summary>
        /// 文本超出自动处理
        /// </summary>
        [Description("文本超出自动处理"), Category("行为"), DefaultValue(false)]
        public bool AutoEllipsis
        {
            get => button.AutoEllipsis;
            set => button.AutoEllipsis = value;
        }
 
        /// <summary>
        /// 是否多行
        /// </summary>
        [Description("是否多行"), Category("行为"), DefaultValue(false)]
        public bool TextMultiLine
        {
            get => button.TextMultiLine;
            set => button.TextMultiLine = value;
        }
 
        #endregion
 
        #region 图标
 
        /// <summary>
        /// 图标比例
        /// </summary>
        [Description("图标比例"), Category("外观"), DefaultValue(.7F)]
        public float IconRatio
        {
            get => button.IconRatio;
            set => button.IconRatio = value;
        }
 
        /// <summary>
        /// 图标
        /// </summary>
        [Description("图标"), Category("外观"), DefaultValue(null)]
        public Image? Icon
        {
            get => button.Icon;
            set => button.Icon = value;
        }
 
        /// <summary>
        /// 图标SVG
        /// </summary>
        [Description("图标SVG"), Category("外观"), DefaultValue(null)]
        public string? IconSvg
        {
            get => button.IconSvg;
            set => button.IconSvg = value;
        }
 
        /// <summary>
        /// 是否包含图标
        /// </summary>
        public bool HasIcon => button.HasIcon;
 
        /// <summary>
        /// 图标大小
        /// </summary>
        [Description("图标大小"), Category("外观"), DefaultValue(typeof(Size), "0, 0")]
        public Size IconSize
        {
            get => button.IconSize;
            set => button.IconSize = value;
        }
 
        /// <summary>
        /// 悬停图标
        /// </summary>
        [Description("悬停图标"), Category("外观"), DefaultValue(null)]
        public Image? IconHover
        {
            get => button.IconHover;
            set => button.IconHover = value;
        }
 
        /// <summary>
        /// 悬停图标SVG
        /// </summary>
        [Description("悬停图标SVG"), Category("外观"), DefaultValue(null)]
        public string? IconHoverSvg
        {
            get => button.IconHoverSvg;
            set => button.IconHoverSvg = value;
        }
 
        /// <summary>
        /// 悬停图标动画时长
        /// </summary>
        [Description("悬停图标动画时长"), Category("外观"), DefaultValue(200)]
        public int IconHoverAnimation
        {
            get => button.IconHoverAnimation;
            set => button.IconHoverAnimation = value;
        }
 
        /// <summary>
        /// 按钮图标组件的位置
        /// </summary>
        [Description("按钮图标组件的位置"), Category("外观"), DefaultValue(TAlignMini.Left)]
        public TAlignMini IconPosition
        {
            get => button.IconPosition;
            set => button.IconPosition = value;
        }
 
        #endregion
 
        #region 切换
 
        /// <summary>
        /// 选中状态
        /// </summary>
        [Description("选中状态"), Category("切换"), DefaultValue(false)]
        public bool Toggle
        {
            get => button.Toggle;
            set => button.Toggle = value;
        }
 
        /// <summary>
        /// 切换图标
        /// </summary>
        [Description("切换图标"), Category("切换"), DefaultValue(null)]
        public Image? ToggleIcon
        {
            get => button.ToggleIcon;
            set => button.ToggleIcon = value;
        }
 
        /// <summary>
        /// 切换图标SVG
        /// </summary>
        [Description("切换图标SVG"), Category("切换"), DefaultValue(null)]
        public string? ToggleIconSvg
        {
            get => button.ToggleIconSvg;
            set => button.ToggleIconSvg = value;
        }
 
        /// <summary>
        /// 是否包含切换图标
        /// </summary>
        public bool HasToggleIcon => button.HasToggleIcon;
 
        /// <summary>
        /// 切换悬停图标
        /// </summary>
        [Description("切换悬停图标"), Category("切换"), DefaultValue(null)]
        public Image? ToggleIconHover
        {
            get => button.ToggleIconHover;
            set => button.ToggleIconHover = value;
        }
 
        /// <summary>
        /// 切换悬停图标SVG
        /// </summary>
        [Description("切换悬停图标SVG"), Category("切换"), DefaultValue(null)]
        public string? ToggleIconHoverSvg
        {
            get => button.ToggleIconHoverSvg;
            set => button.ToggleIconHoverSvg = value;
        }
 
        /// <summary>
        /// 图标切换动画时长
        /// </summary>
        [Description("图标切换动画时长"), Category("切换"), DefaultValue(200)]
        public int IconToggleAnimation
        {
            get => button.IconToggleAnimation;
            set => button.IconToggleAnimation = value;
        }
 
        /// <summary>
        /// 文字颜色
        /// </summary>
        [Description("切换文字颜色"), Category("切换"), DefaultValue(null)]
        [Editor(typeof(Design.ColorEditor), typeof(UITypeEditor))]
        public Color? ToggleFore
        {
            get => button.ToggleFore;
            set => button.ToggleFore = value;
        }
 
        /// <summary>
        /// 切换类型
        /// </summary>
        [Description("切换类型"), Category("切换"), DefaultValue(null)]
        public TTypeMini? ToggleType
        {
            get => button.ToggleType;
            set => button.ToggleType = value;
        }
 
        #region 背景
 
        /// <summary>
        /// 切换背景颜色
        /// </summary>
        [Description("切换背景颜色"), Category("切换"), DefaultValue(null)]
        [Editor(typeof(Design.ColorEditor), typeof(UITypeEditor))]
        public Color? ToggleBack
        {
            get => button.ToggleBack;
            set => button.ToggleBack = value;
        }
 
        /// <summary>
        /// 切换背景渐变色
        /// </summary>
        [Description("切换背景渐变色"), Category("切换"), DefaultValue(null)]
        public string? ToggleBackExtend
        {
            get => button.ToggleBackExtend;
            set => button.ToggleBackExtend = value;
        }
 
        /// <summary>
        /// 切换悬停背景颜色
        /// </summary>
        [Description("切换悬停背景颜色"), Category("切换"), DefaultValue(null)]
        [Editor(typeof(Design.ColorEditor), typeof(UITypeEditor))]
        public Color? ToggleBackHover
        {
            get => button.ToggleBackHover;
            set => button.ToggleBackHover = value;
        }
 
        /// <summary>
        /// 切换激活背景颜色
        /// </summary>
        [Description("切换激活背景颜色"), Category("切换"), DefaultValue(null)]
        [Editor(typeof(Design.ColorEditor), typeof(UITypeEditor))]
        public Color? ToggleBackActive
        {
            get => button.ToggleBackActive;
            set => button.ToggleBackActive = value;
        }
 
        #endregion
 
        #endregion
 
        #region 加载动画
 
        /// <summary>
        /// 加载状态
        /// </summary>
        [Description("加载状态"), Category("外观"), DefaultValue(false)]
        public bool Loading
        {
            get => button.Loading;
            set => button.Loading = value;
        }
 
        /// <summary>
        /// 加载进度
        /// </summary>
        [Description("加载进度"), Category("加载"), DefaultValue(0.3F)]
        public float LoadingValue
        {
            get => button.LoadingValue;
            set => button.LoadingValue = value;
        }
 
        #region 水波进度
 
        /// <summary>
        /// 水波进度
        /// </summary>
        [Description("水波进度"), Category("加载"), DefaultValue(0F)]
        public float LoadingWaveValue
        {
            get => button.LoadingWaveValue;
            set => button.LoadingWaveValue = value;
        }
 
        /// <summary>
        /// 水波颜色
        /// </summary>
        [Description("水波颜色"), Category("加载"), DefaultValue(null)]
        [Editor(typeof(Design.ColorEditor), typeof(UITypeEditor))]
        public Color? LoadingWaveColor
        {
            get => button.LoadingWaveColor;
            set => button.LoadingWaveColor = value;
        }
 
        /// <summary>
        /// 水波是否垂直
        /// </summary>
        [Description("水波是否垂直"), Category("加载"), DefaultValue(false)]
        public bool LoadingWaveVertical
        {
            get => button.LoadingWaveVertical;
            set => button.LoadingWaveVertical = value;
        }
 
        /// <summary>
        /// 水波大小
        /// </summary>
        [Description("水波大小"), Category("加载"), DefaultValue(2)]
        public int LoadingWaveSize
        {
            get => button.LoadingWaveSize;
            set => button.LoadingWaveSize = value;
        }
 
        /// <summary>
        /// 水波数量
        /// </summary>
        [Description("水波数量"), Category("加载"), DefaultValue(1)]
        public int LoadingWaveCount
        {
            get => button.LoadingWaveCount;
            set => button.LoadingWaveCount = value;
        }
 
        #endregion
 
        #endregion
 
        /// <summary>
        /// 连接左边
        /// </summary>
        [Description("连接左边"), Category("外观"), DefaultValue(false)]
        public bool JoinLeft
        {
            get => button.JoinLeft;
            set => button.JoinLeft = value;
        }
 
        /// <summary>
        /// 连接右边
        /// </summary>
        [Description("连接右边"), Category("外观"), DefaultValue(false)]
        public bool JoinRight
        {
            get => button.JoinRight;
            set => button.JoinRight = value;
        }
 
        #endregion
 
        #region 渲染
 
        protected override void OnPaint(PaintEventArgs e)
        {
            var g = e.Graphics.High();
            button.Paint(g, ClientRectangle.PaddingRect(Padding), ReadRectangle);
            this.PaintBadge(g);
            base.OnPaint(e);
        }
 
        public override Rectangle ReadRectangle
        {
            get => ClientRectangle.PaddingRect(Padding).ReadRect((WaveSize + button.BorderWidth / 2F) * Config.Dpi, button.Shape, button.JoinLeft, button.JoinRight);
        }
 
        public override GraphicsPath RenderRegion
        {
            get
            {
                var rect_read = ReadRectangle;
                float _radius = (button.Shape == TShape.Round || button.Shape == TShape.Circle) ? rect_read.Height : button.Radius * Config.Dpi;
                return button.Path(rect_read, _radius);
            }
        }
 
        #endregion
 
        #region 鼠标
 
        protected override void OnMouseMove(MouseEventArgs e)
        {
            if (RespondRealAreas)
            {
                var rect_read = ReadRectangle;
                using (var path = button.Path(rect_read, button.Radius * Config.Dpi))
                {
                    button.MouseHover = path.IsVisible(e.Location);
                }
            }
            base.OnMouseMove(e);
        }
 
        protected override void OnMouseEnter(EventArgs e)
        {
            base.OnMouseEnter(e);
            if (RespondRealAreas) return;
            button.MouseHover = true;
        }
 
        protected override void OnMouseLeave(EventArgs e)
        {
            base.OnMouseLeave(e);
            button.MouseHover = false;
        }
 
        protected override void OnLeave(EventArgs e)
        {
            base.OnLeave(e);
            button.MouseHover = false;
        }
 
        protected override void OnMouseDown(MouseEventArgs e)
        {
            if (CanClick(e.Location))
            {
                Focus();
                base.OnMouseDown(e);
                button.MouseDown = true;
            }
        }
 
        protected override void OnMouseUp(MouseEventArgs e)
        {
            if (button.MouseDown)
            {
                if (CanClick(e.Location))
                {
                    base.OnMouseUp(e);
                    if (e.Button == MouseButtons.Left)
                    {
                        button.OnClick();
                        OnClick(e);
                    }
                    OnMouseClick(e);
                }
                button.MouseDown = false;
            }
            else base.OnMouseUp(e);
        }
 
        #endregion
 
        #region 自动大小
 
        /// <summary>
        /// 自动大小
        /// </summary>
        [Browsable(true)]
        [Description("自动大小"), Category("外观"), DefaultValue(false)]
        public override bool AutoSize
        {
            get => base.AutoSize;
            set
            {
                if (base.AutoSize == value) return;
                base.AutoSize = value;
                if (value)
                {
                    if (autoSize == TAutoSize.None) autoSize = TAutoSize.Auto;
                }
                else autoSize = TAutoSize.None;
                BeforeAutoSize();
            }
        }
 
        TAutoSize autoSize = TAutoSize.None;
        /// <summary>
        /// 自动大小模式
        /// </summary>
        [Description("自动大小模式"), Category("外观"), DefaultValue(TAutoSize.None)]
        public TAutoSize AutoSizeMode
        {
            get => autoSize;
            set
            {
                if (autoSize == value) return;
                autoSize = value;
                base.AutoSize = autoSize != TAutoSize.None;
                BeforeAutoSize();
            }
        }
 
        protected override void OnFontChanged(EventArgs e)
        {
            BeforeAutoSize();
            base.OnFontChanged(e);
        }
 
        public override Size GetPreferredSize(Size proposedSize)
        {
            if (autoSize == TAutoSize.None) return base.GetPreferredSize(proposedSize);
            else if (autoSize == TAutoSize.Width) return new Size(PSize.Width, base.GetPreferredSize(proposedSize).Height);
            else if (autoSize == TAutoSize.Height) return new Size(base.GetPreferredSize(proposedSize).Width, PSize.Height);
            return PSize;
        }
 
        internal Size PSize
        {
            get
            {
                return Helper.GDI(g =>
                {
                    var font_size = g.MeasureString(button.Text ?? Config.NullText, Font).Size();
                    int gap = (int)(20 * Config.Dpi), wave = (int)(WaveSize * Config.Dpi);
                    if (button.Shape == TShape.Circle || string.IsNullOrEmpty(button.Text))
                    {
                        int s = font_size.Height + wave + gap;
                        return new Size(s, s);
                    }
                    else
                    {
                        int m = wave * 2;
                        if (button.JoinLeft || button.JoinRight) m = 0;
                        bool has_icon = button.Loading || HasIcon;
                        if (has_icon || button.ShowArrow)
                        {
                            if (has_icon && (IconPosition == TAlignMini.Top || IconPosition == TAlignMini.Bottom))
                            {
                                int size = (int)Math.Ceiling(font_size.Height * 1.2F);
                                return new Size(font_size.Width + m + gap + size, font_size.Height + wave + gap + size);
                            }
                            int height = font_size.Height + wave + gap;
                            if (has_icon && button.ShowArrow) return new Size(font_size.Width + m + gap + font_size.Height * 2, height);
                            else if (has_icon) return new Size(font_size.Width + m + gap + (int)Math.Ceiling(font_size.Height * 1.2F), height);
                            else return new Size(font_size.Width + m + gap + (int)Math.Ceiling(font_size.Height * .8F), height);
                        }
                        else return new Size(font_size.Width + m + gap, font_size.Height + wave + gap);
                    }
                });
            }
        }
 
        protected override void OnResize(EventArgs e)
        {
            BeforeAutoSize();
            base.OnResize(e);
        }
 
        internal bool BeforeAutoSize()
        {
            if (autoSize == TAutoSize.None) return true;
            if (InvokeRequired)
            {
                bool flag = false;
                Invoke(new Action(() =>
                {
                    flag = BeforeAutoSize();
                }));
                return flag;
            }
            var PS = PSize;
            switch (autoSize)
            {
                case TAutoSize.Width:
                    if (Width == PS.Width) return true;
                    Width = PS.Width;
                    break;
                case TAutoSize.Height:
                    if (Height == PS.Height) return true;
                    Height = PS.Height;
                    break;
                case TAutoSize.Auto:
                default:
                    if (Width == PS.Width && Height == PS.Height) return true;
                    Size = PS;
                    break;
            }
            return false;
        }
 
        #endregion
 
        #region 按钮点击
 
        protected override void OnKeyUp(KeyEventArgs e)
        {
            if (e.KeyCode is Keys.Enter or Keys.Space)
            {
                button.OnClick();
                OnClick(EventArgs.Empty);
                e.Handled = true;
            }
            base.OnKeyUp(e);
        }
 
        [DefaultValue(DialogResult.None)]
        public DialogResult DialogResult { get; set; } = DialogResult.None;
 
        /// <summary>
        /// 是否默认按钮
        /// </summary>
        public void NotifyDefault(bool value)
        {
 
        }
 
        public void PerformClick()
        {
            button.OnClick();
            OnClick(EventArgs.Empty);
        }
 
        bool CanClick()
        {
            if (button.Loading) return false;
            else
            {
                if (RespondRealAreas)
                {
                    var e = PointToClient(MousePosition);
                    var rect_read = ReadRectangle;
                    using (var path = button.Path(rect_read, button.Radius * Config.Dpi))
                    {
                        return path.IsVisible(e);
                    }
                }
                else return true;
            }
        }
        bool CanClick(Point e)
        {
            if (button.Loading) return false;
            else
            {
                if (RespondRealAreas)
                {
                    var rect_read = ReadRectangle;
                    using (var path = button.Path(rect_read, button.Radius * Config.Dpi))
                    {
                        return path.IsVisible(e);
                    }
                }
                else return true;
            }
        }
 
        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Advanced)]
        public new event EventHandler? DoubleClick
        {
            add => base.DoubleClick += value;
            remove => base.DoubleClick -= value;
        }
 
        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Advanced)]
        public new event MouseEventHandler? MouseDoubleClick
        {
            add => base.MouseDoubleClick += value;
            remove => base.MouseDoubleClick -= value;
        }
 
        #endregion
 
        protected override void OnEnabledChanged(EventArgs e)
        {
            button.Enabled = Enabled;
            base.OnEnabledChanged(e);
        }
 
        protected override void Dispose(bool disposing)
        {
            button.Dispose();
            base.Dispose(disposing);
        }
    }
 
    class IButton : IDisposable
    {
        Func<Font> Font;
        Func<bool> BAutoSize;
        Action Invalidate;
        IControl control;
 
        public IButton(IControl _control, Func<bool> autoSize)
        {
            control = _control;
            Invalidate = () => control.Invalidate();
            Font = () => control.Font;
            BAutoSize = autoSize;
        }
 
        #region 属性
 
        bool enabled = true;
        public bool Enabled
        {
            get => enabled;
            set
            {
                if (enabled == value) return;
                enabled = value;
                Invalidate();
            }
        }
 
        Color? fore;
        /// <summary>
        /// 文字颜色
        /// </summary>
        public Color? Fore
        {
            get => fore;
            set
            {
                if (fore == value) fore = value;
                fore = value;
                Invalidate();
            }
        }
 
        #region 背景
 
        Color? back;
        /// <summary>
        /// 背景颜色
        /// </summary>
        public Color? Back
        {
            get => back;
            set
            {
                if (back == value) return;
                back = value;
                Invalidate();
            }
        }
 
        string? backExtend = null;
        /// <summary>
        /// 背景渐变色
        /// </summary>
        public string? BackExtend
        {
            get => backExtend;
            set
            {
                if (backExtend == value) return;
                backExtend = value;
                Invalidate();
            }
        }
 
        /// <summary>
        /// 悬停背景颜色
        /// </summary>
        public Color? BackHover { get; set; }
 
        /// <summary>
        /// 激活背景颜色
        /// </summary>
        public Color? BackActive { get; set; }
 
        Image? backImage = null;
        /// <summary>
        /// 背景图片
        /// </summary>
        public Image? BackgroundImage
        {
            get => backImage;
            set
            {
                if (backImage == value) return;
                backImage = value;
                Invalidate();
            }
        }
 
        TFit backFit = TFit.Fill;
        /// <summary>
        /// 背景图片布局
        /// </summary>
        public TFit BackgroundImageLayout
        {
            get => backFit;
            set
            {
                if (backFit == value) return;
                backFit = value;
                Invalidate();
            }
        }
 
        #endregion
 
        #region 默认样式
 
        Color? defaultback;
        /// <summary>
        /// Default模式背景颜色
        /// </summary>
        public Color? DefaultBack
        {
            get => defaultback;
            set
            {
                if (defaultback == value) return;
                defaultback = value;
                if (type == TTypeMini.Default) Invalidate();
            }
        }
 
        Color? defaultbordercolor;
        /// <summary>
        /// Default模式边框颜色
        /// </summary>
        public Color? DefaultBorderColor
        {
            get => defaultbordercolor;
            set
            {
                if (defaultbordercolor == value) return;
                defaultbordercolor = value;
                if (type == TTypeMini.Default) Invalidate();
            }
        }
 
        #endregion
 
        #region 边框
 
        float borderWidth = 0;
        /// <summary>
        /// 边框宽度
        /// </summary>
        public float BorderWidth
        {
            get => borderWidth;
            set
            {
                if (borderWidth == value) return;
                borderWidth = value;
                Invalidate();
            }
        }
 
        #endregion
 
        /// <summary>
        /// 波浪大小
        /// </summary>
        public int WaveSize { get; set; } = 4;
 
        int radius = 6;
        /// <summary>
        /// 圆角
        /// </summary>
        public int Radius
        {
            get => radius;
            set
            {
                if (radius == value) return;
                radius = value;
                if (BAutoSize()) Invalidate();
            }
        }
 
        TShape shape = TShape.Default;
        /// <summary>
        /// 形状
        /// </summary>
        public TShape Shape
        {
            get => shape;
            set
            {
                if (shape == value) return;
                shape = value;
                if (BAutoSize()) Invalidate();
            }
        }
 
        TTypeMini type = TTypeMini.Default;
        /// <summary>
        /// 类型
        /// </summary>
        public TTypeMini Type
        {
            get => type;
            set
            {
                if (type == value) return;
                type = value;
                Invalidate();
            }
        }
 
        bool ghost = false;
        /// <summary>
        /// 幽灵属性,使按钮背景透明
        /// </summary>
        public bool Ghost
        {
            get => ghost;
            set
            {
                if (ghost == value) return;
                ghost = value;
                Invalidate();
            }
        }
 
        public float ArrowProg = -1F;
 
        bool showArrow = false;
        /// <summary>
        /// 显示箭头
        /// </summary>
        public bool ShowArrow
        {
            get => showArrow;
            set
            {
                if (showArrow == value) return;
                showArrow = value;
                if (BAutoSize()) Invalidate();
            }
        }
 
        bool isLink = false;
        /// <summary>
        /// 箭头链接样式
        /// </summary>
        public bool IsLink
        {
            get => isLink;
            set
            {
                if (isLink == value) return;
                isLink = value;
                Invalidate();
            }
        }
 
        #region 文本
 
        bool textLine = false;
        string? text = null;
        /// <summary>
        /// 文本
        /// </summary>
        public string? Text
        {
            get => text;
            set
            {
                if (string.IsNullOrEmpty(value)) value = null;
                if (text == value) return;
                text = value;
                if (text == null) textLine = false;
                else textLine = text.Contains(Environment.NewLine);
                if (BAutoSize()) Invalidate();
            }
        }
 
        StringFormat stringFormat = Helper.SF_NoWrap();
        ContentAlignment textAlign = ContentAlignment.MiddleCenter;
        /// <summary>
        /// 文本位置
        /// </summary>
        [Description("文本位置"), Category("外观"), DefaultValue(ContentAlignment.MiddleCenter)]
        public ContentAlignment TextAlign
        {
            get => textAlign;
            set
            {
                if (textAlign == value) return;
                if (loading || HasIcon || showArrow)
                {
                    value = ContentAlignment.MiddleCenter;
                    if (textAlign == value) return;
                }
                textAlign = value;
                textAlign.SetAlignment(ref stringFormat);
                Invalidate();
            }
        }
 
        bool autoEllipsis = false;
        /// <summary>
        /// 文本超出自动处理
        /// </summary>
        public bool AutoEllipsis
        {
            get => autoEllipsis;
            set
            {
                if (autoEllipsis == value) return;
                autoEllipsis = value;
                stringFormat.Trimming = value ? StringTrimming.EllipsisCharacter : StringTrimming.None;
            }
        }
 
        bool textMultiLine = false;
        /// <summary>
        /// 是否多行
        /// </summary>
        public bool TextMultiLine
        {
            get => textMultiLine;
            set
            {
                if (textMultiLine == value) return;
                textMultiLine = value;
                stringFormat.FormatFlags = value ? 0 : StringFormatFlags.NoWrap;
                Invalidate();
            }
        }
 
        #endregion
 
        #region 图标
 
        float iconratio = .7F;
        /// <summary>
        /// 图标比例
        /// </summary>
        [Description("图标比例"), Category("外观"), DefaultValue(.7F)]
        public float IconRatio
        {
            get => iconratio;
            set
            {
                if (iconratio == value) return;
                iconratio = value;
                if (BAutoSize()) Invalidate();
            }
        }
 
        Image? icon = null;
        /// <summary>
        /// 图标
        /// </summary>
        [Description("图标"), Category("外观"), DefaultValue(null)]
        public Image? Icon
        {
            get => icon;
            set
            {
                if (icon == value) return;
                icon = value;
                if (BAutoSize()) Invalidate();
            }
        }
 
        string? iconSvg = null;
        /// <summary>
        /// 图标SVG
        /// </summary>
        [Description("图标SVG"), Category("外观"), DefaultValue(null)]
        public string? IconSvg
        {
            get => iconSvg;
            set
            {
                if (iconSvg == value) return;
                iconSvg = value;
                if (BAutoSize()) Invalidate();
            }
        }
 
        /// <summary>
        /// 是否包含图标
        /// </summary>
        public bool HasIcon
        {
            get => iconSvg != null || icon != null;
        }
 
        /// <summary>
        /// 图标大小
        /// </summary>
        [Description("图标大小"), Category("外观"), DefaultValue(typeof(Size), "0, 0")]
        public Size IconSize { get; set; } = new Size(0, 0);
 
        /// <summary>
        /// 悬停图标
        /// </summary>
        [Description("悬停图标"), Category("外观"), DefaultValue(null)]
        public Image? IconHover { get; set; } = null;
 
        /// <summary>
        /// 悬停图标SVG
        /// </summary>
        [Description("悬停图标SVG"), Category("外观"), DefaultValue(null)]
        public string? IconHoverSvg { get; set; } = null;
 
        /// <summary>
        /// 悬停图标动画时长
        /// </summary>
        [Description("悬停图标动画时长"), Category("外观"), DefaultValue(200)]
        public int IconHoverAnimation { get; set; } = 200;
 
        TAlignMini iconPosition = TAlignMini.Left;
        /// <summary>
        /// 按钮图标组件的位置
        /// </summary>
        [Description("按钮图标组件的位置"), Category("外观"), DefaultValue(TAlignMini.Left)]
        public TAlignMini IconPosition
        {
            get => iconPosition;
            set
            {
                if (iconPosition == value) return;
                iconPosition = value;
                if (BAutoSize()) Invalidate();
            }
        }
 
        #endregion
 
        #region 切换
 
        #region 动画
 
        bool AnimationIconToggle = false;
        float AnimationIconToggleValue = 0F;
 
        #endregion
 
        bool toggle = false;
        /// <summary>
        /// 选中状态
        /// </summary>
        [Description("选中状态"), Category("切换"), DefaultValue(false)]
        public bool Toggle
        {
            get => toggle;
            set
            {
                if (value == toggle) return;
                toggle = value;
                if (Config.Animation)
                {
                    if (IconToggleAnimation > 0 && HasIcon && HasToggleIcon)
                    {
                        ThreadIconHover?.Dispose();
                        ThreadIconHover = null;
                        AnimationIconHover = false;
 
                        ThreadIconToggle?.Dispose();
                        AnimationIconToggle = true;
                        var t = Animation.TotalFrames(10, IconToggleAnimation);
                        if (value)
                        {
                            ThreadIconToggle = new ITask((i) =>
                            {
                                AnimationIconToggleValue = Animation.Animate(i, t, 1F, AnimationType.Ball);
                                Invalidate();
                                return true;
                            }, 10, t, () =>
                            {
                                AnimationIconToggleValue = 1F;
                                AnimationIconToggle = false;
                                Invalidate();
                            });
                        }
                        else
                        {
                            ThreadIconToggle = new ITask((i) =>
                            {
                                AnimationIconToggleValue = 1F - Animation.Animate(i, t, 1F, AnimationType.Ball);
                                Invalidate();
                                return true;
                            }, 10, t, () =>
                            {
                                AnimationIconToggleValue = 0F;
                                AnimationIconToggle = false;
                                Invalidate();
                            });
                        }
                    }
                    else Invalidate();
                }
                else Invalidate();
            }
        }
 
        Image? iconToggle = null;
        /// <summary>
        /// 切换图标
        /// </summary>
        [Description("切换图标"), Category("切换"), DefaultValue(null)]
        public Image? ToggleIcon
        {
            get => iconToggle;
            set
            {
                if (iconToggle == value) return;
                iconToggle = value;
                if (toggle) Invalidate();
            }
        }
 
        string? iconSvgToggle = null;
        /// <summary>
        /// 切换图标SVG
        /// </summary>
        [Description("切换图标SVG"), Category("切换"), DefaultValue(null)]
        public string? ToggleIconSvg
        {
            get => iconSvgToggle;
            set
            {
                if (iconSvgToggle == value) return;
                iconSvgToggle = value;
                if (toggle) Invalidate();
            }
        }
 
        /// <summary>
        /// 是否包含切换图标
        /// </summary>
        public bool HasToggleIcon
        {
            get => iconSvgToggle != null || iconToggle != null;
        }
 
        /// <summary>
        /// 切换悬停图标
        /// </summary>
        [Description("切换悬停图标"), Category("切换"), DefaultValue(null)]
        public Image? ToggleIconHover { get; set; } = null;
 
        /// <summary>
        /// 切换悬停图标SVG
        /// </summary>
        [Description("切换悬停图标SVG"), Category("切换"), DefaultValue(null)]
        public string? ToggleIconHoverSvg { get; set; } = null;
 
        /// <summary>
        /// 图标切换动画时长
        /// </summary>
        [Description("图标切换动画时长"), Category("切换"), DefaultValue(200)]
        public int IconToggleAnimation { get; set; } = 200;
 
        Color? foreToggle;
        /// <summary>
        /// 文字颜色
        /// </summary>
        public Color? ToggleFore
        {
            get => foreToggle;
            set
            {
                if (foreToggle == value) foreToggle = value;
                foreToggle = value;
                if (toggle) Invalidate();
            }
        }
 
        TTypeMini? typeToggle = null;
        /// <summary>
        /// 切换类型
        /// </summary>
        public TTypeMini? ToggleType
        {
            get => typeToggle;
            set
            {
                if (typeToggle == value) return;
                typeToggle = value;
                if (toggle) Invalidate();
            }
        }
 
        #region 背景
 
        Color? backToggle;
        /// <summary>
        /// 切换背景颜色
        /// </summary>
        public Color? ToggleBack
        {
            get => backToggle;
            set
            {
                if (backToggle == value) return;
                backToggle = value;
                if (toggle) Invalidate();
            }
        }
 
        string? backExtendToggle = null;
        /// <summary>
        /// 切换背景渐变色
        /// </summary>
        public string? ToggleBackExtend
        {
            get => backExtendToggle;
            set
            {
                if (backExtendToggle == value) return;
                backExtendToggle = value;
                if (toggle) Invalidate();
            }
        }
 
        /// <summary>
        /// 切换悬停背景颜色
        /// </summary>
        public Color? ToggleBackHover { get; set; }
 
        /// <summary>
        /// 切换激活背景颜色
        /// </summary>
        public Color? ToggleBackActive { get; set; }
 
        #endregion
 
        #endregion
 
        #region 加载动画
 
        bool loading = false;
        int AnimationLoadingValue = 0;
        int AnimationLoadingWaveValue = 0;
        /// <summary>
        /// 加载状态
        /// </summary>
        [Description("加载状态"), Category("外观"), DefaultValue(false)]
        public bool Loading
        {
            get => loading;
            set
            {
                if (loading == value) return;
                loading = value;
                control.SetCursor(_mouseHover && enabled && !value);
                BAutoSize();
                ThreadLoading?.Dispose();
                if (loading)
                {
                    AnimationClickValue = 0;
                    ThreadLoading = new ITask(control, i =>
                    {
                        AnimationLoadingWaveValue += 1;
                        if (AnimationLoadingWaveValue > 100) AnimationLoadingWaveValue = 0;
                        AnimationLoadingValue = i;
                        Invalidate();
                        return loading;
                    }, 10, 360, 6, () =>
                    {
                        Invalidate();
                    });
                }
                else Invalidate();
            }
        }
 
        /// <summary>
        /// 加载进度
        /// </summary>
        public float LoadingValue { get; set; } = 0.3F;
 
        #region 水波进度
 
        /// <summary>
        /// 水波进度
        /// </summary>
        public float LoadingWaveValue { get; set; } = 0;
 
        /// <summary>
        /// 水波颜色
        /// </summary>
        public Color? LoadingWaveColor { get; set; }
 
        /// <summary>
        /// 水波是否垂直
        /// </summary>
        public bool LoadingWaveVertical { get; set; }
 
        /// <summary>
        /// 水波大小
        /// </summary>
        public int LoadingWaveSize { get; set; } = 2;
 
        /// <summary>
        /// 水波数量
        /// </summary>
        public int LoadingWaveCount { get; set; } = 1;
 
        #endregion
 
        #endregion
 
        bool joinLeft = false;
        /// <summary>
        /// 连接左边
        /// </summary>
        [Description("连接左边"), Category("外观"), DefaultValue(false)]
        public bool JoinLeft
        {
            get => joinLeft;
            set
            {
                if (joinLeft == value) return;
                joinLeft = value;
                if (BAutoSize()) Invalidate();
            }
        }
 
        bool joinRight = false;
        /// <summary>
        /// 连接右边
        /// </summary>
        [Description("连接右边"), Category("外观"), DefaultValue(false)]
        public bool JoinRight
        {
            get => joinRight;
            set
            {
                if (joinRight == value) return;
                joinRight = value;
                if (BAutoSize()) Invalidate();
            }
        }
 
        public void Dispose()
        {
            ThreadClick?.Dispose();
            ThreadHover?.Dispose();
            ThreadIconHover?.Dispose();
            ThreadIconToggle?.Dispose();
            ThreadLoading?.Dispose();
        }
 
        ITask? ThreadHover = null;
        ITask? ThreadIconHover = null;
        ITask? ThreadIconToggle = null;
        ITask? ThreadClick = null;
        ITask? ThreadLoading = null;
 
        #region 点击动画
 
        bool AnimationClick = false;
        float AnimationClickValue = 0;
 
        public void OnClick()
        {
            if (WaveSize > 0 && Config.Animation)
            {
                ThreadClick?.Dispose();
                AnimationClickValue = 0;
                AnimationClick = true;
                ThreadClick = new ITask(control, () =>
                {
                    if (AnimationClickValue > 0.6) AnimationClickValue = AnimationClickValue.Calculate(0.04F);
                    else AnimationClickValue += AnimationClickValue = AnimationClickValue.Calculate(0.1F);
                    if (AnimationClickValue > 1) { AnimationClickValue = 0F; return false; }
                    Invalidate();
                    return true;
                }, 50, () =>
                {
                    AnimationClick = false;
                    Invalidate();
                });
            }
        }
 
        #endregion
 
        #region 悬停动画
 
        bool _mouseDown = false;
        public bool MouseDown
        {
            get => _mouseDown;
            set
            {
                if (_mouseDown == value) return;
                _mouseDown = value;
                Invalidate();
            }
        }
 
        int AnimationHoverValue = 0;
        bool AnimationHover = false;
        bool AnimationIconHover = false;
        float AnimationIconHoverValue = 0F;
        bool _mouseHover = false;
        public bool MouseHover
        {
            get => _mouseHover;
            set
            {
                if (_mouseHover == value) return;
                _mouseHover = value;
                control.SetCursor(value && enabled && !loading);
                if (enabled)
                {
                    var backHover = GetColorO();
                    int alpha = backHover.A;
                    if (Config.Animation)
                    {
                        if (IconHoverAnimation > 0 && ((toggle && HasToggleIcon && (ToggleIconHoverSvg != null || ToggleIconHover != null)) || (HasIcon && (IconHoverSvg != null || IconHover != null))))
                        {
                            ThreadIconHover?.Dispose();
                            AnimationIconHover = true;
                            var t = Animation.TotalFrames(10, IconHoverAnimation);
                            if (value)
                            {
                                ThreadIconHover = new ITask((i) =>
                                {
                                    AnimationIconHoverValue = Animation.Animate(i, t, 1F, AnimationType.Ball);
                                    Invalidate();
                                    return true;
                                }, 10, t, () =>
                                {
                                    AnimationIconHoverValue = 1F;
                                    AnimationIconHover = false;
                                    Invalidate();
                                });
                            }
                            else
                            {
                                ThreadIconHover = new ITask((i) =>
                                {
                                    AnimationIconHoverValue = 1F - Animation.Animate(i, t, 1F, AnimationType.Ball);
                                    Invalidate();
                                    return true;
                                }, 10, t, () =>
                                {
                                    AnimationIconHoverValue = 0F;
                                    AnimationIconHover = false;
                                    Invalidate();
                                });
                            }
                        }
                        if (alpha > 0)
                        {
                            int addvalue = alpha / 12;
                            ThreadHover?.Dispose();
                            AnimationHover = true;
                            if (value)
                            {
                                ThreadHover = new ITask(control, () =>
                                {
                                    AnimationHoverValue += addvalue;
                                    if (AnimationHoverValue > alpha) { AnimationHoverValue = alpha; return false; }
                                    Invalidate();
                                    return true;
                                }, 10, () =>
                                {
                                    AnimationHover = false;
                                    Invalidate();
                                });
                            }
                            else
                            {
                                ThreadHover = new ITask(control, () =>
                                {
                                    if (AnimationHoverValue > alpha) AnimationHoverValue = alpha;
                                    else AnimationHoverValue -= addvalue;
                                    if (AnimationHoverValue < 1) { AnimationHoverValue = 0; return false; }
                                    Invalidate();
                                    return true;
                                }, 10, () =>
                                {
                                    AnimationHover = false;
                                    Invalidate();
                                });
                            }
                        }
                        else
                        {
                            AnimationHoverValue = alpha;
                            Invalidate();
                        }
                    }
                    else AnimationHoverValue = alpha;
                    Invalidate();
                }
            }
        }
 
        #endregion
 
        #endregion
 
        #region 渲染
 
        public void Paint(Graphics g, Rectangle rect, Rectangle rect_read)
        {
            float _radius = (shape == TShape.Round || shape == TShape.Circle) ? rect_read.Height : radius * Config.Dpi;
 
            if (backImage != null) g.PaintImg(rect_read, backImage, backFit, _radius, shape);
 
            bool is_default = type == TTypeMini.Default;
            if (toggle && typeToggle.HasValue) is_default = typeToggle.Value == TTypeMini.Default;
            if (is_default)
            {
                GetDefaultColorConfig(out var _fore, out var _color, out var _back_hover, out var _back_active);
                using (var path = Path(rect_read, _radius))
                {
                    #region 动画
 
                    if (AnimationClick)
                    {
                        float maxw = rect_read.Width + ((rect.Width - rect_read.Width) * AnimationClickValue), maxh = rect_read.Height + ((rect.Height - rect_read.Height) * AnimationClickValue);
                        if (shape == TShape.Circle)
                        {
                            if (maxw > maxh) maxw = maxh;
                            else maxh = maxw;
                        }
                        float alpha = 100 * (1F - AnimationClickValue);
                        using (var brush = new SolidBrush(Helper.ToColor(alpha, _color)))
                        {
                            using (var path_click = new RectangleF(rect.X + (rect.Width - maxw) / 2F, rect.Y + (rect.Height - maxh) / 2F, maxw, maxh).RoundPath(_radius, shape))
                            {
                                path_click.AddPath(path, false);
                                g.FillPath(brush, path_click);
                            }
                        }
                    }
 
                    #endregion
 
                    if (enabled)
                    {
                        if (!ghost)
                        {
                            #region 绘制阴影
 
                            if (WaveSize > 0)
                            {
                                using (var path_shadow = new RectangleF(rect_read.X, rect_read.Y + 3, rect_read.Width, rect_read.Height).RoundPath(_radius))
                                {
                                    path_shadow.AddPath(path, false);
                                    using (var brush = new SolidBrush(Style.Db.FillQuaternary))
                                    {
                                        g.FillPath(brush, path_shadow);
                                    }
                                }
                            }
 
                            #endregion
 
                            using (var brush = new SolidBrush(defaultback ?? Style.Db.DefaultBg))
                            {
                                g.FillPath(brush, path);
                            }
                        }
                        if (borderWidth > 0)
                        {
                            PaintLoadingWave(g, path, rect_read);
                            float border = borderWidth * Config.Dpi;
                            if (MouseDown)
                            {
                                using (var brush = new Pen(_back_active, border))
                                {
                                    g.DrawPath(brush, path);
                                }
                                PaintTextLoading(g, text, _back_active, rect_read, enabled);
                            }
                            else if (AnimationHover)
                            {
                                var colorHover = Helper.ToColor(AnimationHoverValue, _back_hover);
                                using (var brush = new Pen(Style.Db.DefaultBorder, border))
                                {
                                    g.DrawPath(brush, path);
                                }
                                using (var brush = new Pen(colorHover, border))
                                {
                                    g.DrawPath(brush, path);
                                }
                                PaintTextLoading(g, text, _fore, colorHover, rect_read);
                            }
                            else if (MouseHover)
                            {
                                using (var brush = new Pen(_back_hover, border))
                                {
                                    g.DrawPath(brush, path);
                                }
                                PaintTextLoading(g, text, _back_hover, rect_read, enabled);
                            }
                            else
                            {
                                using (var brush = new Pen(defaultbordercolor ?? Style.Db.DefaultBorder, border))
                                {
                                    g.DrawPath(brush, path);
                                }
                                PaintTextLoading(g, text, _fore, rect_read, enabled);
                            }
                        }
                        else
                        {
                            if (MouseDown)
                            {
                                using (var brush = new SolidBrush(_back_active))
                                {
                                    g.FillPath(brush, path);
                                }
                            }
                            else if (AnimationHover)
                            {
                                using (var brush = new SolidBrush(Helper.ToColor(AnimationHoverValue, _back_hover)))
                                {
                                    g.FillPath(brush, path);
                                }
                            }
                            else if (MouseHover)
                            {
                                using (var brush = new SolidBrush(_back_hover))
                                {
                                    g.FillPath(brush, path);
                                }
                            }
                            PaintLoadingWave(g, path, rect_read);
                            PaintTextLoading(g, text, _fore, rect_read, enabled);
                        }
                    }
                    else
                    {
                        PaintLoadingWave(g, path, rect_read);
                        if (borderWidth > 0)
                        {
                            using (var brush = new SolidBrush(Style.Db.FillTertiary))
                            {
                                g.FillPath(brush, path);
                            }
                        }
                        PaintTextLoading(g, text, Style.Db.TextQuaternary, rect_read, enabled);
                    }
                }
            }
            else
            {
                GetColorConfig(out var _fore, out var _back, out var _back_hover, out var _back_active);
                using (var path = Path(rect_read, _radius))
                {
                    #region 动画
 
                    if (AnimationClick)
                    {
                        float maxw = rect_read.Width + ((rect.Width - rect_read.Width) * AnimationClickValue), maxh = rect_read.Height + ((rect.Height - rect_read.Height) * AnimationClickValue);
                        if (shape == TShape.Circle)
                        {
                            if (maxw > maxh) maxw = maxh;
                            else maxh = maxw;
                        }
                        float alpha = 100 * (1F - AnimationClickValue);
                        using (var brush = new SolidBrush(Helper.ToColor(alpha, _back)))
                        {
                            using (var path_click = new RectangleF(rect.X + (rect.Width - maxw) / 2F, rect.Y + (rect.Height - maxh) / 2F, maxw, maxh).RoundPath(_radius, shape))
                            {
                                path_click.AddPath(path, false);
                                g.FillPath(brush, path_click);
                            }
                        }
                    }
 
                    #endregion
 
                    if (ghost)
                    {
                        PaintLoadingWave(g, path, rect_read);
 
                        #region 绘制背景
 
                        if (borderWidth > 0)
                        {
                            float border = borderWidth * Config.Dpi;
                            if (MouseDown)
                            {
                                using (var brush = new Pen(_back_active, border))
                                {
                                    g.DrawPath(brush, path);
                                }
                                PaintTextLoading(g, text, _back_active, rect_read, enabled);
                            }
                            else if (AnimationHover)
                            {
                                var colorHover = Helper.ToColor(AnimationHoverValue, _back_hover);
                                using (var brush = new Pen(enabled ? _back : Style.Db.FillTertiary, border))
                                {
                                    g.DrawPath(brush, path);
                                }
                                using (var brush = new Pen(colorHover, border))
                                {
                                    g.DrawPath(brush, path);
                                }
                                PaintTextLoading(g, text, _back, colorHover, rect_read);
                            }
                            else if (MouseHover)
                            {
                                using (var brush = new Pen(_back_hover, border))
                                {
                                    g.DrawPath(brush, path);
                                }
                                PaintTextLoading(g, text, _back_hover, rect_read, enabled);
                            }
                            else
                            {
                                if (enabled)
                                {
                                    if (toggle)
                                    {
                                        using (var brushback = backExtendToggle.BrushEx(rect_read, _back))
                                        {
                                            using (var brush = new Pen(brushback, border))
                                            {
                                                g.DrawPath(brush, path);
                                            }
                                        }
                                    }
                                    else
                                    {
                                        using (var brushback = backExtend.BrushEx(rect_read, _back))
                                        {
                                            using (var brush = new Pen(brushback, border))
                                            {
                                                g.DrawPath(brush, path);
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    using (var brush = new Pen(Style.Db.FillTertiary, border))
                                    {
                                        g.DrawPath(brush, path);
                                    }
                                }
                                PaintTextLoading(g, text, enabled ? _back : Style.Db.TextQuaternary, rect_read, enabled);
                            }
                        }
                        else PaintTextLoading(g, text, enabled ? _back : Style.Db.TextQuaternary, rect_read, enabled);
 
                        #endregion
                    }
                    else
                    {
                        #region 绘制阴影
 
                        if (enabled && WaveSize > 0)
                        {
                            using (var path_shadow = new RectangleF(rect_read.X, rect_read.Y + 3, rect_read.Width, rect_read.Height).RoundPath(_radius))
                            {
                                path_shadow.AddPath(path, false);
                                using (var brush = new SolidBrush(_back.rgba(Config.Mode == TMode.Dark ? 0.15F : 0.1F)))
                                {
                                    g.FillPath(brush, path_shadow);
                                }
                            }
                        }
 
                        #endregion
 
                        #region 绘制背景
 
                        if (enabled)
                        {
                            if (toggle)
                            {
                                using (var brush = backExtendToggle.BrushEx(rect_read, _back))
                                {
                                    g.FillPath(brush, path);
                                }
                            }
                            else
                            {
                                using (var brush = backExtend.BrushEx(rect_read, _back))
                                {
                                    g.FillPath(brush, path);
                                }
                            }
                        }
                        else
                        {
                            using (var brush = new SolidBrush(Style.Db.FillTertiary))
                            {
                                g.FillPath(brush, path);
                            }
                        }
 
                        if (MouseDown)
                        {
                            using (var brush = new SolidBrush(_back_active))
                            {
                                g.FillPath(brush, path);
                            }
                        }
                        else if (AnimationHover)
                        {
                            var colorHover = Helper.ToColor(AnimationHoverValue, _back_hover);
                            using (var brush = new SolidBrush(colorHover))
                            {
                                g.FillPath(brush, path);
                            }
                        }
                        else if (MouseHover)
                        {
                            using (var brush = new SolidBrush(_back_hover))
                            {
                                g.FillPath(brush, path);
                            }
                        }
 
                        #endregion
 
                        PaintLoadingWave(g, path, rect_read);
                        PaintTextLoading(g, text, enabled ? _fore : Style.Db.TextQuaternary, rect_read, enabled);
                    }
                }
            }
        }
 
        #region 渲染帮助
 
        void PaintLoadingWave(Graphics g, GraphicsPath path, Rectangle rect)
        {
            if (loading && LoadingWaveValue > 0)
            {
                using (var brush = new SolidBrush(LoadingWaveColor ?? Style.Db.Fill))
                {
                    if (LoadingWaveValue >= 1) g.FillPath(brush, path);
                    else if (LoadingWaveCount > 0)
                    {
                        var state = g.Save();
                        g.SetClip(path);
                        g.ResetTransform();
                        int len = (int)(LoadingWaveSize * Config.Dpi), count = LoadingWaveCount * 2 + 2;
                        if (count < 6) count = 6;
                        if (LoadingWaveVertical)
                        {
                            int pvalue = (int)(rect.Height * LoadingWaveValue);
                            if (pvalue > 0)
                            {
                                pvalue = rect.Height - pvalue + rect.Y;
                                int wd = rect.Width / LoadingWaveCount, wd2 = wd * 2, pvalue2 = pvalue - len, rr = rect.X + wd * count;
                                using (var path_line = new GraphicsPath())
                                {
                                    g.TranslateTransform(-(wd + wd2 * (AnimationLoadingWaveValue / 100F)), 0);
                                    path_line.AddLine(rr, pvalue, rr, rect.Bottom);
                                    path_line.AddLine(rr, rect.Bottom, rect.X, rect.Bottom);
                                    path_line.AddLine(rect.X, rect.Bottom, rect.X, pvalue);
                                    bool to = true;
                                    var line = new List<PointF>(count);
                                    for (int i = 0; i < count + 1; i++)
                                    {
                                        line.Add(new PointF(rect.X + wd * i, to ? pvalue : pvalue2));
                                        to = !to;
                                    }
                                    path_line.AddCurve(line.ToArray());
                                    g.FillPath(brush, path_line);
                                }
                            }
                        }
                        else
                        {
                            int pvalue = (int)(rect.Width * LoadingWaveValue);
                            if (pvalue > 0)
                            {
                                pvalue += rect.X;
                                int wd = rect.Height / LoadingWaveCount, wd2 = wd * 2, pvalue2 = pvalue + len, rb = rect.Y + wd * count;
 
                                using (var path_line = new GraphicsPath())
                                {
                                    g.TranslateTransform(0, -(wd + wd2 * (AnimationLoadingWaveValue / 100F)));
                                    path_line.AddLine(pvalue, rb, rect.X, rb);
                                    path_line.AddLine(rect.X, rb, rect.X, rect.Y);
                                    path_line.AddLine(rect.X, rect.Y, pvalue, rect.Y);
                                    bool to = true;
                                    var line = new List<PointF>(count);
                                    for (int i = 0; i < count + 1; i++)
                                    {
                                        line.Add(new PointF(to ? pvalue : pvalue2, rect.Y + wd * i));
                                        to = !to;
                                    }
                                    path_line.AddCurve(line.ToArray());
                                    g.FillPath(brush, path_line);
                                }
                            }
                        }
                        g.Restore(state);
                    }
                    else
                    {
                        if (LoadingWaveVertical)
                        {
                            int pvalue = (int)(rect.Height * LoadingWaveValue);
                            if (pvalue > 0)
                            {
                                var state = g.Save();
                                g.SetClip(new Rectangle(rect.X, rect.Y + rect.Height - pvalue, rect.Width, pvalue));
                                g.FillPath(brush, path);
                                g.Restore(state);
                            }
                        }
                        else
                        {
                            int pvalue = (int)(rect.Width * LoadingWaveValue);
                            if (pvalue > 0)
                            {
                                var state = g.Save();
                                g.SetClip(new Rectangle(rect.X, rect.Y, pvalue, rect.Height));
                                g.FillPath(brush, path);
                                g.Restore(state);
                            }
                        }
                    }
                }
            }
        }
        void PaintTextLoading(Graphics g, string? text, Color color, Rectangle rect_read, bool enabled)
        {
            var font_size = g.MeasureString(text ?? Config.NullText, Font()).Size();
            if (text == null)
            {
                //没有文字
                var rect = GetIconRectCenter(font_size, rect_read);
                if (loading)
                {
                    float loading_size = rect_read.Height * 0.06F;
                    using (var brush = new Pen(color, loading_size))
                    {
                        brush.StartCap = brush.EndCap = LineCap.Round;
                        g.DrawArc(brush, rect, AnimationLoadingValue, LoadingValue * 360F);
                    }
                }
                else
                {
                    if (PaintIcon(g, color, rect, false, enabled) && showArrow)
                    {
                        int size = (int)(font_size.Height * IconRatio);
                        var rect_arrow = new Rectangle(rect_read.X + (rect_read.Width - size) / 2, rect_read.Y + (rect_read.Height - size) / 2, size, size);
                        using (var pen = new Pen(color, 2F * Config.Dpi))
                        {
                            pen.StartCap = pen.EndCap = LineCap.Round;
                            if (isLink)
                            {
                                int size_arrow = rect_arrow.Width / 2;
                                g.TranslateTransform(rect_arrow.X + size_arrow, rect_arrow.Y + size_arrow);
                                g.RotateTransform(-90F);
                                g.DrawLines(pen, new Rectangle(-size_arrow, -size_arrow, rect_arrow.Width, rect_arrow.Height).TriangleLines(ArrowProg));
                                g.ResetTransform();
                            }
                            else g.DrawLines(pen, rect_arrow.TriangleLines(ArrowProg));
                        }
                    }
                }
            }
            else
            {
                bool has_left = loading || HasIcon, has_right = showArrow;
                Rectangle rect_text;
                if (has_left || has_right)
                {
                    if (has_left && has_right)
                    {
                        rect_text = RectAlignLR(g, textLine, Font(), iconPosition, iconratio, font_size, rect_read, out var rect_l, out var rect_r);
 
                        if (loading)
                        {
                            float loading_size = rect_l.Height * .14F;
                            using (var brush = new Pen(color, loading_size))
                            {
                                brush.StartCap = brush.EndCap = LineCap.Round;
                                g.DrawArc(brush, rect_l, AnimationLoadingValue, LoadingValue * 360F);
                            }
                        }
                        else PaintIcon(g, color, rect_l, true, enabled);
 
                        #region ARROW
 
                        using (var pen = new Pen(color, 2F * Config.Dpi))
                        {
                            pen.StartCap = pen.EndCap = LineCap.Round;
                            if (isLink)
                            {
                                int size_arrow = rect_r.Width / 2;
                                g.TranslateTransform(rect_r.X + size_arrow, rect_r.Y + size_arrow);
                                g.RotateTransform(-90F);
                                g.DrawLines(pen, new Rectangle(-size_arrow, -size_arrow, rect_r.Width, rect_r.Height).TriangleLines(ArrowProg));
                                g.ResetTransform();
                            }
                            else g.DrawLines(pen, rect_r.TriangleLines(ArrowProg));
                        }
 
                        #endregion
                    }
                    else if (has_left)
                    {
                        rect_text = RectAlignL(g, textLine, Font(), iconPosition, iconratio, font_size, rect_read, out var rect_l);
                        if (loading)
                        {
                            float loading_size = rect_l.Height * .14F;
                            using (var brush = new Pen(color, loading_size))
                            {
                                brush.StartCap = brush.EndCap = LineCap.Round;
                                g.DrawArc(brush, rect_l, AnimationLoadingValue, LoadingValue * 360F);
                            }
                        }
                        else PaintIcon(g, color, rect_l, true, enabled);
                    }
                    else
                    {
                        rect_text = RectAlignR(g, textLine, Font(), iconPosition, iconratio, font_size, rect_read, out var rect_r);
 
                        #region ARROW
 
                        using (var pen = new Pen(color, 2F * Config.Dpi))
                        {
                            pen.StartCap = pen.EndCap = LineCap.Round;
                            if (isLink)
                            {
                                int size_arrow = rect_r.Width / 2;
                                g.TranslateTransform(rect_r.X + size_arrow, rect_r.Y + size_arrow);
                                g.RotateTransform(-90F);
                                g.DrawLines(pen, new Rectangle(-size_arrow, -size_arrow, rect_r.Width, rect_r.Height).TriangleLines(ArrowProg));
                                g.ResetTransform();
                            }
                            else g.DrawLines(pen, rect_r.TriangleLines(ArrowProg));
                        }
 
                        #endregion
                    }
                }
                else
                {
                    int sps = (int)(font_size.Height * .4F), sps2 = sps * 2;
                    rect_text = new Rectangle(rect_read.X + sps, rect_read.Y + sps, rect_read.Width - sps2, rect_read.Height - sps2);
                    PaintTextAlign(rect_read, ref rect_text);
                }
                using (var brush = new SolidBrush(color))
                {
                    g.DrawStr(text, Font(), brush, rect_text, stringFormat);
                }
            }
        }
        void PaintTextLoading(Graphics g, string? text, Color color, Color colorHover, Rectangle rect_read)
        {
            var font_size = g.MeasureString(text ?? Config.NullText, Font()).Size();
            if (text == null)
            {
                var rect = GetIconRectCenter(font_size, rect_read);
                if (loading)
                {
                    float loading_size = rect_read.Height * 0.06F;
                    using (var brush = new Pen(color, loading_size))
                    {
                        brush.StartCap = brush.EndCap = LineCap.Round;
                        g.DrawArc(brush, rect, AnimationLoadingValue, LoadingValue * 360F);
                    }
                }
                else
                {
                    if (PaintIcon(g, color, rect, false, true))
                    {
                        if (showArrow)
                        {
                            int size = (int)(font_size.Height * IconRatio);
                            var rect_arrow = new Rectangle(rect_read.X + (rect_read.Width - size) / 2, rect_read.Y + (rect_read.Height - size) / 2, size, size);
                            using (var pen = new Pen(color, 2F * Config.Dpi))
                            using (var penHover = new Pen(colorHover, pen.Width))
                            {
                                pen.StartCap = pen.EndCap = LineCap.Round;
                                if (isLink)
                                {
                                    int size_arrow = rect_arrow.Width / 2;
                                    g.TranslateTransform(rect_arrow.X + size_arrow, rect_arrow.Y + size_arrow);
                                    g.RotateTransform(-90F);
                                    var rect_arrow_lines = new Rectangle(-size_arrow, -size_arrow, rect_arrow.Width, rect_arrow.Height).TriangleLines(ArrowProg);
                                    g.DrawLines(pen, rect_arrow_lines);
                                    g.DrawLines(penHover, rect_arrow_lines);
                                    g.ResetTransform();
                                }
                                else
                                {
                                    var rect_arrow_lines = rect_arrow.TriangleLines(ArrowProg);
                                    g.DrawLines(pen, rect_arrow_lines);
                                    g.DrawLines(penHover, rect_arrow_lines);
                                }
                            }
                        }
                    }
                    else PaintIcon(g, colorHover, rect, false, true);
                }
            }
            else
            {
                bool has_left = loading || HasIcon, has_right = showArrow;
                Rectangle rect_text;
                if (has_left || has_right)
                {
                    if (has_left && has_right)
                    {
                        rect_text = RectAlignLR(g, textLine, Font(), iconPosition, iconratio, font_size, rect_read, out var rect_l, out var rect_r);
 
                        if (loading)
                        {
                            float loading_size = rect_l.Height * .14F;
                            using (var brush = new Pen(color, loading_size))
                            {
                                brush.StartCap = brush.EndCap = LineCap.Round;
                                g.DrawArc(brush, rect_l, AnimationLoadingValue, LoadingValue * 360F);
                            }
                        }
                        else
                        {
                            PaintIcon(g, color, rect_l, true, true);
                            PaintIcon(g, colorHover, rect_l, true, true);
                        }
 
                        #region ARROW
 
                        using (var pen = new Pen(color, 2F * Config.Dpi))
                        using (var penHover = new Pen(colorHover, pen.Width))
                        {
                            penHover.StartCap = penHover.EndCap = pen.StartCap = pen.EndCap = LineCap.Round;
                            if (isLink)
                            {
                                int size_arrow = rect_r.Width / 2;
                                g.TranslateTransform(rect_r.X + size_arrow, rect_r.Y + size_arrow);
                                g.RotateTransform(-90F);
                                var rect_arrow = new Rectangle(-size_arrow, -size_arrow, rect_r.Width, rect_r.Height).TriangleLines(ArrowProg);
                                g.DrawLines(pen, rect_arrow);
                                g.DrawLines(penHover, rect_arrow);
                                g.ResetTransform();
                            }
                            else
                            {
                                var rect_arrow = rect_r.TriangleLines(ArrowProg);
                                g.DrawLines(pen, rect_arrow);
                                g.DrawLines(penHover, rect_arrow);
                            }
                        }
 
                        #endregion
                    }
                    else if (has_left)
                    {
                        rect_text = RectAlignL(g, textLine, Font(), iconPosition, iconratio, font_size, rect_read, out var rect_l);
                        if (loading)
                        {
                            float loading_size = rect_l.Height * .14F;
                            using (var brush = new Pen(color, loading_size))
                            {
                                brush.StartCap = brush.EndCap = LineCap.Round;
                                g.DrawArc(brush, rect_l, AnimationLoadingValue, LoadingValue * 360F);
                            }
                        }
                        else
                        {
                            PaintIcon(g, color, rect_l, true, true);
                            PaintIcon(g, colorHover, rect_l, true, true);
                        }
                    }
                    else
                    {
                        rect_text = RectAlignR(g, textLine, Font(), iconPosition, iconratio, font_size, rect_read, out var rect_r);
 
                        #region ARROW
 
                        using (var pen = new Pen(color, 2F * Config.Dpi))
                        using (var penHover = new Pen(colorHover, pen.Width))
                        {
                            penHover.StartCap = penHover.EndCap = pen.StartCap = pen.EndCap = LineCap.Round;
                            if (isLink)
                            {
                                int size_arrow = rect_r.Width / 2;
                                g.TranslateTransform(rect_r.X + size_arrow, rect_r.Y + size_arrow);
                                g.RotateTransform(-90F);
                                var rect_arrow = new Rectangle(-size_arrow, -size_arrow, rect_r.Width, rect_r.Height).TriangleLines(ArrowProg);
                                g.DrawLines(pen, rect_arrow);
                                g.DrawLines(penHover, rect_arrow);
                                g.ResetTransform();
                            }
                            else
                            {
                                var rect_arrow = rect_r.TriangleLines(ArrowProg);
                                g.DrawLines(pen, rect_arrow);
                                g.DrawLines(penHover, rect_arrow);
                            }
                        }
 
                        #endregion
                    }
                }
                else
                {
                    int sps = (int)(font_size.Height * .4F), sps2 = sps * 2;
                    rect_text = new Rectangle(rect_read.X + sps, rect_read.Y + sps, rect_read.Width - sps2, rect_read.Height - sps2);
                    PaintTextAlign(rect_read, ref rect_text);
                }
                using (var brush = new SolidBrush(color))
                using (var brushHover = new SolidBrush(colorHover))
                {
                    g.DrawStr(text, Font(), brush, rect_text, stringFormat);
                    g.DrawStr(text, Font(), brushHover, rect_text, stringFormat);
                }
            }
        }
 
        internal static Rectangle RectAlignL(Graphics g, bool textLine, Font font, TAlignMini iconPosition, float iconratio, Size font_size, Rectangle rect_read, out Rectangle rect_l)
        {
            int font_Height = font_size.Height;
            if (textLine && (iconPosition == TAlignMini.Top || iconPosition == TAlignMini.Bottom)) font_Height = g.MeasureString(Config.NullText, font).Size().Height;
            int icon_size = (int)(font_Height * iconratio), sp = (int)(font_Height * .25F);
            Rectangle rect_text;
            switch (iconPosition)
            {
                case TAlignMini.Top:
                    int t_x = rect_read.Y + ((rect_read.Height - (font_size.Height + icon_size + sp)) / 2);
                    rect_text = new Rectangle(rect_read.X, t_x + icon_size + sp, rect_read.Width, font_size.Height);
                    rect_l = new Rectangle(rect_read.X + (rect_read.Width - icon_size) / 2, t_x, icon_size, icon_size);
                    break;
                case TAlignMini.Bottom:
                    int b_x = rect_read.Y + ((rect_read.Height - (font_size.Height + icon_size + sp)) / 2);
                    rect_text = new Rectangle(rect_read.X, b_x, rect_read.Width, font_size.Height);
                    rect_l = new Rectangle(rect_read.X + (rect_read.Width - icon_size) / 2, b_x + font_size.Height + sp, icon_size, icon_size);
                    break;
                case TAlignMini.Right:
                    int r_x = rect_read.X + ((rect_read.Width - (font_size.Width + icon_size + sp)) / 2);
                    rect_text = new Rectangle(r_x, rect_read.Y, font_size.Width, rect_read.Height);
                    rect_l = new Rectangle(r_x + font_size.Width + sp, rect_read.Y + (rect_read.Height - icon_size) / 2, icon_size, icon_size);
                    break;
                case TAlignMini.Left:
                default:
                    int l_x = rect_read.X + ((rect_read.Width - (font_size.Width + icon_size + sp)) / 2);
                    rect_text = new Rectangle(l_x + icon_size + sp, rect_read.Y, font_size.Width, rect_read.Height);
                    rect_l = new Rectangle(l_x, rect_read.Y + (rect_read.Height - icon_size) / 2, icon_size, icon_size);
                    break;
            }
            return rect_text;
        }
        internal static Rectangle RectAlignLR(Graphics g, bool textLine, Font font, TAlignMini iconPosition, float iconratio, Size font_size, Rectangle rect_read, out Rectangle rect_l, out Rectangle rect_r)
        {
            int font_Height = font_size.Height;
            if (textLine && (iconPosition == TAlignMini.Top || iconPosition == TAlignMini.Bottom)) font_Height = g.MeasureString(Config.NullText, font).Size().Height;
            int icon_size = (int)(font_Height * iconratio), sp = (int)(font_Height * .25F), sps = (int)(font_size.Height * .4F);
            Rectangle rect_text;
            switch (iconPosition)
            {
                case TAlignMini.Top:
                    int t_x = rect_read.Y + ((rect_read.Height - (font_size.Height + icon_size + sp)) / 2);
                    rect_text = new Rectangle(rect_read.X, t_x + icon_size + sp, rect_read.Width, font_size.Height);
                    rect_l = new Rectangle(rect_read.X + (rect_read.Width - icon_size) / 2, t_x, icon_size, icon_size);
                    rect_r = new Rectangle(rect_read.Right - icon_size - sps, rect_text.Y + (rect_text.Height - icon_size) / 2, icon_size, icon_size);
                    break;
                case TAlignMini.Bottom:
                    int b_x = rect_read.Y + ((rect_read.Height - (font_size.Height + icon_size + sp)) / 2);
                    rect_text = new Rectangle(rect_read.X, b_x, rect_read.Width, font_size.Height);
                    rect_l = new Rectangle(rect_read.X + (rect_read.Width - icon_size) / 2, b_x + font_size.Height + sp, icon_size, icon_size);
                    rect_r = new Rectangle(rect_read.Right - icon_size - sps, rect_text.Y + (rect_text.Height - icon_size) / 2, icon_size, icon_size);
                    break;
                case TAlignMini.Right:
                    int r_x = rect_read.X + ((rect_read.Width - (font_size.Width + icon_size + sp + sps)) / 2), r_y = rect_read.Y + (rect_read.Height - icon_size) / 2;
                    rect_text = new Rectangle(r_x, rect_read.Y, font_size.Width, rect_read.Height);
                    rect_l = new Rectangle(r_x + font_size.Width + sp, r_y, icon_size, icon_size);
                    rect_r = new Rectangle(rect_read.X + sps, r_y, icon_size, icon_size);
                    break;
                case TAlignMini.Left:
                default:
                    int l_x = rect_read.X + ((rect_read.Width - (font_size.Width + icon_size + sp + sps)) / 2), l_y = rect_read.Y + (rect_read.Height - icon_size) / 2;
                    rect_text = new Rectangle(l_x + icon_size + sp, rect_read.Y, font_size.Width, rect_read.Height);
                    rect_l = new Rectangle(l_x, l_y, icon_size, icon_size);
                    rect_r = new Rectangle(rect_read.Right - icon_size - sps, l_y, icon_size, icon_size);
                    break;
            }
            return rect_text;
        }
        internal static Rectangle RectAlignR(Graphics g, bool textLine, Font font, TAlignMini iconPosition, float iconratio, Size font_size, Rectangle rect_read, out Rectangle rect_r)
        {
            int font_Height = font_size.Height;
            if (textLine && (iconPosition == TAlignMini.Top || iconPosition == TAlignMini.Bottom)) font_Height = g.MeasureString(Config.NullText, font).Size().Height;
            int icon_size = (int)(font_Height * iconratio), sp = (int)(font_Height * .25F), sps = (int)(font_size.Height * .4F), rsps = icon_size + sp;
            Rectangle rect_text;
            switch (iconPosition)
            {
                case TAlignMini.Bottom:
                case TAlignMini.Right:
                    rect_text = new Rectangle(rect_read.X + rsps, rect_read.Y, rect_read.Width - rsps, rect_read.Height);
                    rect_r = new Rectangle(rect_read.X + sps, rect_read.Y + (rect_read.Height - icon_size) / 2, icon_size, icon_size);
                    break;
                case TAlignMini.Top:
                case TAlignMini.Left:
                default:
                    rect_text = new Rectangle(rect_read.X, rect_read.Y, rect_read.Width - rsps, rect_read.Height);
                    rect_r = new Rectangle(rect_read.Right - icon_size - sps, rect_read.Y + (rect_read.Height - icon_size) / 2, icon_size, icon_size);
                    break;
            }
            return rect_text;
        }
 
        void PaintTextAlign(Rectangle rect_read, ref Rectangle rect_text)
        {
            switch (textAlign)
            {
                case ContentAlignment.MiddleCenter:
                case ContentAlignment.MiddleLeft:
                case ContentAlignment.MiddleRight:
                    rect_text.Y = rect_read.Y;
                    rect_text.Height = rect_read.Height;
                    break;
                case ContentAlignment.TopLeft:
                case ContentAlignment.TopRight:
                case ContentAlignment.TopCenter:
                    rect_text.Height = rect_read.Height - rect_text.Y;
                    break;
            }
        }
 
        #region 渲染图标
 
        /// <summary>
        /// 居中的图标绘制区域
        /// </summary>
        /// <param name="font_size">字体大小</param>
        /// <param name="rect_read">客户区域</param>
        Rectangle GetIconRectCenter(Size font_size, Rectangle rect_read)
        {
            if (IconSize.Width > 0 && IconSize.Height > 0)
            {
                int w = (int)(IconSize.Width * Config.Dpi), h = (int)(IconSize.Height * Config.Dpi);
                return new Rectangle(rect_read.X + (rect_read.Width - w) / 2, rect_read.Y + (rect_read.Height - h) / 2, w, h);
            }
            else
            {
                int w = (int)(font_size.Height * IconRatio * 1.125F);
                return new Rectangle(rect_read.X + (rect_read.Width - w) / 2, rect_read.Y + (rect_read.Height - w) / 2, w, w);
            }
        }
 
 
        /// <summary>
        /// 渲染图标
        /// </summary>
        /// <param name="g">GDI</param>
        /// <param name="color">颜色</param>
        /// <param name="rect_o">区域</param>
        /// <param name="hastxt">包含文本</param>
        /// <param name="enabled">使能</param>
        bool PaintIcon(Graphics g, Color? color, Rectangle rect_o, bool hastxt, bool enabled)
        {
            var rect = hastxt ? GetIconRect(rect_o) : rect_o;
            if (AnimationIconHover)
            {
                PaintCoreIcon(g, rect, color, 1F - AnimationIconHoverValue);
                PaintCoreIconHover(g, rect, color, AnimationIconHoverValue);
                return false;
            }
            else if (AnimationIconToggle)
            {
                float d = 1F - AnimationIconToggleValue;
                if (MouseHover)
                {
                    if (!PaintCoreIcon(g, IconHover, IconHoverSvg, rect, color, d)) PaintCoreIcon(g, icon, iconSvg, rect, color, d);
                    if (!PaintCoreIcon(g, ToggleIconHover, ToggleIconHoverSvg, rect, color, AnimationIconToggleValue)) PaintCoreIcon(g, ToggleIcon, ToggleIconSvg, rect, color, AnimationIconToggleValue);
                }
                else
                {
                    PaintCoreIcon(g, icon, iconSvg, rect, color, d);
                    PaintCoreIcon(g, iconToggle, iconSvgToggle, rect, color, AnimationIconToggleValue);
                }
                return false;
            }
            else
            {
                if (enabled)
                {
                    if (MouseHover)
                    {
                        if (PaintCoreIconHover(g, rect, color)) return false;
                    }
                    if (PaintCoreIcon(g, rect, color)) return false;
                }
                else
                {
                    if (MouseHover)
                    {
                        if (PaintCoreIconHover(g, rect, color, .3F)) return false;
                    }
                    if (PaintCoreIcon(g, rect, color, .3F)) return false;
                }
            }
            return true;
        }
 
        /// <summary>
        /// 图标绘制区域
        /// </summary>
        /// <param name="rectl">图标区域</param>
        Rectangle GetIconRect(Rectangle rectl)
        {
            if (IconSize.Width > 0 && IconSize.Height > 0)
            {
                int w = (int)(IconSize.Width * Config.Dpi), h = (int)(IconSize.Height * Config.Dpi);
                return new Rectangle(rectl.X + (rectl.Width - w) / 2, rectl.Y + (rectl.Height - h) / 2, w, h);
            }
            else return rectl;
        }
 
        bool PaintCoreIcon(Graphics g, Rectangle rect, Color? color, float opacity = 1F) => toggle ? PaintCoreIcon(g, iconToggle, iconSvgToggle, rect, color, opacity) : PaintCoreIcon(g, icon, iconSvg, rect, color, opacity);
        bool PaintCoreIconHover(Graphics g, Rectangle rect, Color? color, float opacity = 1F) => toggle ? PaintCoreIcon(g, ToggleIconHover, ToggleIconHoverSvg, rect, color, opacity) : PaintCoreIcon(g, IconHover, IconHoverSvg, rect, color, opacity);
 
        bool PaintCoreIcon(Graphics g, Image? icon, string? iconSvg, Rectangle rect, Color? color, float opacity = 1F)
        {
            if (iconSvg != null)
            {
                using (var _bmp = SvgExtend.GetImgExtend(iconSvg, rect, color))
                {
                    if (_bmp != null)
                    {
                        g.DrawImage(_bmp, rect, opacity);
                        return true;
                    }
                }
            }
            else if (icon != null)
            {
                g.DrawImage(icon, rect, opacity);
                return true;
            }
            return false;
        }
 
        #endregion
 
        public GraphicsPath Path(RectangleF rect_read, float _radius)
        {
            if (shape == TShape.Circle)
            {
                var path = new GraphicsPath();
                path.AddEllipse(rect_read);
                return path;
            }
            if (joinLeft && joinRight) return rect_read.RoundPath(0);
            else if (joinRight) return rect_read.RoundPath(_radius, true, false, false, true);
            else if (joinLeft) return rect_read.RoundPath(_radius, false, true, true, false);
            return rect_read.RoundPath(_radius);
        }
 
        #endregion
 
        #region 帮助
 
        Color GetColorO()
        {
            if (toggle)
            {
                if (typeToggle.HasValue) return GetColorO(typeToggle.Value);
                else return GetColorO(type);
            }
            return GetColorO(type);
        }
        Color GetColorO(TTypeMini type)
        {
            Color color;
            switch (type)
            {
                case TTypeMini.Default:
                    if (borderWidth > 0) color = Style.Db.PrimaryHover;
                    else color = Style.Db.FillSecondary;
                    break;
                case TTypeMini.Success:
                    color = Style.Db.SuccessHover;
                    break;
                case TTypeMini.Error:
                    color = Style.Db.ErrorHover;
                    break;
                case TTypeMini.Info:
                    color = Style.Db.InfoHover;
                    break;
                case TTypeMini.Warn:
                    color = Style.Db.WarningHover;
                    break;
                case TTypeMini.Primary:
                default:
                    color = Style.Db.PrimaryHover;
                    break;
            }
            if (BackHover.HasValue) color = BackHover.Value;
            return color;
        }
 
        void GetDefaultColorConfig(out Color Fore, out Color Color, out Color backHover, out Color backActive)
        {
            Fore = Style.Db.DefaultColor;
            Color = Style.Db.Primary;
            if (borderWidth > 0)
            {
                backHover = Style.Db.PrimaryHover;
                backActive = Style.Db.PrimaryActive;
            }
            else
            {
                backHover = Style.Db.FillSecondary;
                backActive = Style.Db.Fill;
            }
            if (toggle)
            {
                if (foreToggle.HasValue) Fore = foreToggle.Value;
                if (ToggleBackHover.HasValue) backHover = ToggleBackHover.Value;
                if (ToggleBackActive.HasValue) backActive = ToggleBackActive.Value;
            }
            else
            {
                if (fore.HasValue) Fore = fore.Value;
                if (BackHover.HasValue) backHover = BackHover.Value;
                if (BackActive.HasValue) backActive = BackActive.Value;
            }
            if (loading)
            {
                Fore = Color.FromArgb(165, Fore);
                Color = Color.FromArgb(165, Color);
            }
        }
 
        void GetColorConfig(out Color Fore, out Color Back, out Color backHover, out Color backActive)
        {
            if (toggle)
            {
                if (typeToggle.HasValue) GetColorConfig(typeToggle.Value, out Fore, out Back, out backHover, out backActive);
                else GetColorConfig(type, out Fore, out Back, out backHover, out backActive);
 
                if (foreToggle.HasValue) Fore = foreToggle.Value;
                if (backToggle.HasValue) Back = backToggle.Value;
                if (ToggleBackHover.HasValue) backHover = ToggleBackHover.Value;
                if (ToggleBackActive.HasValue) backActive = ToggleBackActive.Value;
                if (loading) Back = Color.FromArgb(165, Back);
                return;
            }
            GetColorConfig(type, out Fore, out Back, out backHover, out backActive);
            if (fore.HasValue) Fore = fore.Value;
            if (back.HasValue) Back = back.Value;
            if (BackHover.HasValue) backHover = BackHover.Value;
            if (BackActive.HasValue) backActive = BackActive.Value;
            if (loading) Back = Color.FromArgb(165, Back);
        }
 
        void GetColorConfig(TTypeMini type, out Color Fore, out Color Back, out Color backHover, out Color backActive)
        {
            switch (type)
            {
                case TTypeMini.Error:
                    Back = Style.Db.Error;
                    Fore = Style.Db.ErrorColor;
                    backHover = Style.Db.ErrorHover;
                    backActive = Style.Db.ErrorActive;
                    break;
                case TTypeMini.Success:
                    Back = Style.Db.Success;
                    Fore = Style.Db.SuccessColor;
                    backHover = Style.Db.SuccessHover;
                    backActive = Style.Db.SuccessActive;
                    break;
                case TTypeMini.Info:
                    Back = Style.Db.Info;
                    Fore = Style.Db.InfoColor;
                    backHover = Style.Db.InfoHover;
                    backActive = Style.Db.InfoActive;
                    break;
                case TTypeMini.Warn:
                    Back = Style.Db.Warning;
                    Fore = Style.Db.WarningColor;
                    backHover = Style.Db.WarningHover;
                    backActive = Style.Db.WarningActive;
                    break;
                case TTypeMini.Primary:
                default:
                    Back = Style.Db.Primary;
                    Fore = Style.Db.PrimaryColor;
                    backHover = Style.Db.PrimaryHover;
                    backActive = Style.Db.PrimaryActive;
                    break;
            }
        }
 
        #endregion
 
        #endregion
    }
}