1
+ using Util . Ui . Angular . Configs ;
2
+ using Util . Ui . NgZorro . Components . Base ;
3
+ using Util . Ui . NgZorro . Configs ;
4
+ using Util . Ui . NgZorro . Enums ;
5
+ using Util . Ui . NgZorro . Extensions ;
6
+
7
+ namespace Util . Ui . NgZorro . Components . ColorPickers . Builders ;
8
+
9
+ /// <summary>
10
+ /// 颜色选择标签生成器
11
+ /// </summary>
12
+ public class ColorPickerBuilder : FormControlBuilderBase < ColorPickerBuilder > {
13
+ /// <summary>
14
+ /// 配置
15
+ /// </summary>
16
+ private readonly Config _config ;
17
+
18
+ /// <summary>
19
+ /// 初始化颜色选择标签生成器
20
+ /// </summary>
21
+ /// <param name="config">配置</param>
22
+ public ColorPickerBuilder ( Config config ) : base ( config , "nz-color-picker" ) {
23
+ _config = config ;
24
+ }
25
+
26
+ /// <summary>
27
+ /// 配置标题
28
+ /// </summary>
29
+ public ColorPickerBuilder Title ( ) {
30
+ SetTitle ( _config . GetValue ( UiConst . Title ) ) ;
31
+ AttributeIfNotEmpty ( "[nzTitle]" , _config . GetValue ( AngularConst . BindTitle ) ) ;
32
+ return this ;
33
+ }
34
+
35
+ /// <summary>
36
+ /// 设置表单标签文本
37
+ /// </summary>
38
+ private void SetTitle ( string value ) {
39
+ var options = NgZorroOptionsService . GetOptions ( ) ;
40
+ if ( options . EnableI18n ) {
41
+ this . AttributeByI18n ( "[nzTitle]" , value ) ;
42
+ return ;
43
+ }
44
+ AttributeIfNotEmpty ( "nzTitle" , value ) ;
45
+ }
46
+
47
+ /// <summary>
48
+ /// 配置颜色默认值
49
+ /// </summary>
50
+ public ColorPickerBuilder DefaultValue ( ) {
51
+ AttributeIfNotEmpty ( "nzDefaultValue" , _config . GetValue ( UiConst . DefaultValue ) ) ;
52
+ AttributeIfNotEmpty ( "[nzDefaultValue]" , _config . GetValue ( AngularConst . BindDefaultValue ) ) ;
53
+ return this ;
54
+ }
55
+
56
+ /// <summary>
57
+ /// 配置颜色值
58
+ /// </summary>
59
+ public ColorPickerBuilder Value ( ) {
60
+ AttributeIfNotEmpty ( "nzValue" , _config . GetValue ( UiConst . Value ) ) ;
61
+ AttributeIfNotEmpty ( "[nzValue]" , _config . GetValue ( AngularConst . BindValue ) ) ;
62
+ return this ;
63
+ }
64
+
65
+ /// <summary>
66
+ /// 配置显示颜色文本
67
+ /// </summary>
68
+ public ColorPickerBuilder ShowText ( ) {
69
+ AttributeIfNotEmpty ( "[nzShowText]" , _config . GetBoolValue ( UiConst . ShowText ) ) ;
70
+ AttributeIfNotEmpty ( "[nzShowText]" , _config . GetValue ( AngularConst . BindShowText ) ) ;
71
+ return this ;
72
+ }
73
+
74
+ /// <summary>
75
+ /// 配置控件尺寸
76
+ /// </summary>
77
+ public ColorPickerBuilder Size ( ) {
78
+ AttributeIfNotEmpty ( "nzSize" , _config . GetValue < InputSize ? > ( UiConst . Size ) ? . Description ( ) ) ;
79
+ AttributeIfNotEmpty ( "[nzSize]" , _config . GetValue ( AngularConst . BindSize ) ) ;
80
+ return this ;
81
+ }
82
+
83
+ /// <summary>
84
+ /// 配置禁用
85
+ /// </summary>
86
+ public ColorPickerBuilder Disabled ( ) {
87
+ AttributeIfNotEmpty ( "[nzDisabled]" , _config . GetBoolValue ( UiConst . Disabled ) ) ;
88
+ AttributeIfNotEmpty ( "[nzDisabled]" , _config . GetValue ( AngularConst . BindDisabled ) ) ;
89
+ return this ;
90
+ }
91
+
92
+ /// <summary>
93
+ /// 配置禁用透明度
94
+ /// </summary>
95
+ public ColorPickerBuilder DisabledAlpha ( ) {
96
+ AttributeIfNotEmpty ( "[nzDisabledAlpha]" , _config . GetBoolValue ( UiConst . DisabledAlpha ) ) ;
97
+ AttributeIfNotEmpty ( "[nzDisabledAlpha]" , _config . GetValue ( AngularConst . BindDisabledAlpha ) ) ;
98
+ return this ;
99
+ }
100
+
101
+ /// <summary>
102
+ /// 配置触发模式
103
+ /// </summary>
104
+ public ColorPickerBuilder Trigger ( ) {
105
+ AttributeIfNotEmpty ( "nzTrigger" , _config . GetValue < ColorPickerTrigger ? > ( UiConst . Trigger ) ? . Description ( ) ) ;
106
+ AttributeIfNotEmpty ( "[nzTrigger]" , _config . GetValue ( AngularConst . BindTrigger ) ) ;
107
+ return this ;
108
+ }
109
+
110
+ /// <summary>
111
+ /// 配置允许清除
112
+ /// </summary>
113
+ public ColorPickerBuilder AllowClear ( ) {
114
+ AttributeIfNotEmpty ( "[nzAllowClear]" , _config . GetBoolValue ( UiConst . AllowClear ) ) ;
115
+ AttributeIfNotEmpty ( "[nzAllowClear]" , _config . GetValue ( AngularConst . BindAllowClear ) ) ;
116
+ return this ;
117
+ }
118
+
119
+ /// <summary>
120
+ /// 配置颜色格式
121
+ /// </summary>
122
+ public ColorPickerBuilder Format ( ) {
123
+ AttributeIfNotEmpty ( "nzFormat" , _config . GetValue < ColorPickerFormat ? > ( UiConst . Format ) ? . Description ( ) ) ;
124
+ AttributeIfNotEmpty ( "[nzFormat]" , _config . GetValue ( AngularConst . BindFormat ) ) ;
125
+ return this ;
126
+ }
127
+
128
+ /// <summary>
129
+ /// 配置显示弹出窗口
130
+ /// </summary>
131
+ public ColorPickerBuilder Open ( ) {
132
+ AttributeIfNotEmpty ( "[nzOpen]" , _config . GetValue ( UiConst . Open ) ) ;
133
+ return this ;
134
+ }
135
+
136
+ /// <summary>
137
+ /// 配置事件
138
+ /// </summary>
139
+ public ColorPickerBuilder Events ( ) {
140
+ AttributeIfNotEmpty ( "(nzOnChange)" , _config . GetValue ( UiConst . OnChange ) ) ;
141
+ AttributeIfNotEmpty ( "(nzOnClear)" , _config . GetValue ( UiConst . OnClear ) ) ;
142
+ AttributeIfNotEmpty ( "(nzOnFormatChange)" , _config . GetValue ( UiConst . OnFormatChange ) ) ;
143
+ AttributeIfNotEmpty ( "(nzOnOpenChange)" , _config . GetValue ( UiConst . OnOpenChange ) ) ;
144
+ return this ;
145
+ }
146
+
147
+ /// <summary>
148
+ /// 配置
149
+ /// </summary>
150
+ public override void Config ( ) {
151
+ base . ConfigBase ( _config ) ;
152
+ ConfigForm ( ) . Name ( ) . DefaultValue ( ) . Value ( )
153
+ . Title ( ) . ShowText ( ) . Size ( ) . Disabled ( ) . DisabledAlpha ( )
154
+ . Trigger ( ) . AllowClear ( ) . Format ( ) . Open ( )
155
+ . Events ( ) ;
156
+ }
157
+ }
0 commit comments