@@ -53,9 +53,9 @@ private void RenderFieldsCheckboxes(IEnumerable<Field> availableFields, IEnumera
53
53
int locationX = 0 ;
54
54
int locationY = 5 ;
55
55
bool isFirst = true ;
56
- HashSet < string > fieldNames = new HashSet < string > ( ) ;
57
56
bool isClearingSelectAllCheckbox = false ;
58
57
58
+ var checkboxControls = new List < CheckBox > ( ) ;
59
59
foreach ( Field field in availableFields )
60
60
{
61
61
if ( isFirst ) //Add toggle all checkbox and some other setting changes
@@ -97,7 +97,6 @@ private void RenderFieldsCheckboxes(IEnumerable<Field> availableFields, IEnumera
97
97
if ( checkbox . Enabled )
98
98
{
99
99
checkbox . Checked = selectAllCheckBox . Checked ;
100
- //this.PreSelectedFields.Remove((string)checkbox.Tag);
101
100
}
102
101
}
103
102
}
@@ -108,57 +107,62 @@ private void RenderFieldsCheckboxes(IEnumerable<Field> availableFields, IEnumera
108
107
locationY += DynamicFieldCheckboxYIncrement ;
109
108
}
110
109
111
- if ( ! fieldNames . Contains ( field . Name . ToLowerInvariant ( ) ) ) //Normally two fields with the same name shouldn't exist but lets make sure
110
+ bool isUnsupportedFieldType = UnsupportedSchemaTypes . Contains ( field . SchemaType ) ;
111
+ var fieldCheckbox = new CheckBox ( )
112
112
{
113
- bool isUnsupportedFieldType = UnsupportedSchemaTypes . Contains ( field . SchemaType ) ;
114
- var fieldCheckbox = new CheckBox ( )
113
+ Name = string . Concat ( "checkbox_" , field . Name ) ,
114
+ Text = string . Concat ( field . Name , isUnsupportedFieldType ? "(Unsupported)" : string . Empty ) ,
115
+ Tag = field . Name ,
116
+ Checked = preSelectedFields . Contains ( field . Name ) ,
117
+ Location = new Point ( locationX , locationY ) ,
118
+ AutoSize = true ,
119
+ Enabled = ! isUnsupportedFieldType
120
+ } ;
121
+ fieldCheckbox . CheckedChanged += ( object checkboxSender , EventArgs checkboxEventArgs ) =>
122
+ {
123
+ var fieldCheckBox = ( CheckBox ) checkboxSender ;
124
+
125
+ if ( fieldCheckBox . Checked )
115
126
{
116
- Name = string . Concat ( "checkbox_" , field . Name ) ,
117
- Text = string . Concat ( field . Name , isUnsupportedFieldType ? "(Unsupported)" : string . Empty ) ,
118
- Tag = field . Name ,
119
- Checked = preSelectedFields . Contains ( field . Name ) ,
120
- Location = new Point ( locationX , locationY ) ,
121
- AutoSize = true ,
122
- Enabled = ! isUnsupportedFieldType
123
- } ;
124
- fieldCheckbox . CheckedChanged += ( object checkboxSender , EventArgs checkboxEventArgs ) =>
127
+ this . PreSelectedFields . Add ( ( string ) fieldCheckBox . Tag ) ;
128
+ }
129
+ else
125
130
{
126
- var fieldCheckBox = ( CheckBox ) checkboxSender ;
127
-
128
- if ( fieldCheckBox . Checked )
129
- {
130
- this . PreSelectedFields . Add ( ( string ) fieldCheckBox . Tag ) ;
131
- }
132
- else
133
- {
134
- this . PreSelectedFields . Remove ( ( string ) fieldCheckBox . Tag ) ;
135
- }
131
+ this . PreSelectedFields . Remove ( ( string ) fieldCheckBox . Tag ) ;
132
+ }
136
133
137
134
138
- if ( ! fieldCheckBox . Checked )
135
+ if ( ! fieldCheckBox . Checked )
136
+ {
137
+ foreach ( Control control in this . fieldsPanel . Controls )
139
138
{
140
- foreach ( Control control in this . fieldsPanel . Controls )
139
+ if ( control . Tag . Equals ( SelectAllCheckboxName ) && control is CheckBox checkbox )
141
140
{
142
- if ( control . Tag . Equals ( SelectAllCheckboxName ) && control is CheckBox checkbox )
141
+ if ( checkbox . Enabled && checkbox . Checked )
143
142
{
144
- if ( checkbox . Enabled && checkbox . Checked )
145
- {
146
- isClearingSelectAllCheckbox = true ;
147
- checkbox . Checked = false ;
148
- this . PreSelectedFields . Remove ( ( string ) fieldCheckBox . Tag ) ;
149
- isClearingSelectAllCheckbox = false ;
150
- break ;
151
- }
143
+ isClearingSelectAllCheckbox = true ;
144
+ checkbox . Checked = false ;
145
+ this . PreSelectedFields . Remove ( ( string ) fieldCheckBox . Tag ) ;
146
+ isClearingSelectAllCheckbox = false ;
147
+ break ;
152
148
}
153
149
}
154
150
}
155
- } ;
156
- this . fieldsPanel . Controls . Add ( fieldCheckbox ) ;
151
+ }
152
+ } ;
153
+ checkboxControls . Add ( fieldCheckbox ) ;
157
154
158
- locationY += DynamicFieldCheckboxYIncrement ;
159
- fieldNames . Add ( field . Name . ToLowerInvariant ( ) ) ;
160
- }
155
+ locationY += DynamicFieldCheckboxYIncrement ;
161
156
}
157
+
158
+ //Disable fields with dupe names because we don't support case sensitive fields right now
159
+ var duplicateFields = checkboxControls ? . GroupBy ( f => f . Text . ToUpperInvariant ( ) ) . Where ( g => g . Count ( ) > 1 ) . SelectMany ( g => g ) . ToList ( ) ;
160
+ foreach ( var duplicateField in duplicateFields )
161
+ {
162
+ duplicateField . Enabled = false ;
163
+ }
164
+
165
+ this . fieldsPanel . Controls . AddRange ( checkboxControls . ToArray < Control > ( ) ) ;
162
166
}
163
167
}
164
168
catch ( Exception ex )
0 commit comments