@@ -40,6 +40,7 @@ public class CloneFieldDefinitionsControl : MultipleConnectionsPluginControlBase
4040 private Button button2 ;
4141 private readonly List < EntityMetadata > _entitiesDetailedSource = new List < EntityMetadata > ( ) ;
4242 private Button button3 ;
43+ private ColumnHeader columnHeader6 ;
4344 private List < EntityMetadata > _entitiesDetailedTarget = new List < EntityMetadata > ( ) ;
4445
4546 public string RepositoryName => "XrmToolBox.CloneFieldDefinitions" ;
@@ -171,6 +172,7 @@ private void InitializeComponent()
171172 this . prefixOverride = new System . Windows . Forms . CheckBox ( ) ;
172173 this . button2 = new System . Windows . Forms . Button ( ) ;
173174 this . listView1 = new System . Windows . Forms . ListView ( ) ;
175+ this . columnHeader6 = ( ( System . Windows . Forms . ColumnHeader ) ( new System . Windows . Forms . ColumnHeader ( ) ) ) ;
174176 this . columnHeader1 = ( ( System . Windows . Forms . ColumnHeader ) ( new System . Windows . Forms . ColumnHeader ( ) ) ) ;
175177 this . columnHeader3 = ( ( System . Windows . Forms . ColumnHeader ) ( new System . Windows . Forms . ColumnHeader ( ) ) ) ;
176178 this . columnHeader2 = ( ( System . Windows . Forms . ColumnHeader ) ( new System . Windows . Forms . ColumnHeader ( ) ) ) ;
@@ -206,6 +208,7 @@ private void InitializeComponent()
206208 this . label1 . Location = new System . Drawing . Point ( 3 , 0 ) ;
207209 this . label1 . Name = "label1" ;
208210 this . label1 . Size = new System . Drawing . Size ( 70 , 13 ) ;
211+ this . label1 . Margin = new Padding ( 8 , 7 , 8 , 7 ) ;
209212 this . label1 . TabIndex = 0 ;
210213 this . label1 . Text = "Source Entity" ;
211214 //
@@ -218,14 +221,15 @@ private void InitializeComponent()
218221 this . comboBox1 . Size = new System . Drawing . Size ( 121 , 21 ) ;
219222 this . comboBox1 . TabIndex = 1 ;
220223 this . comboBox1 . SelectedValueChanged += new System . EventHandler ( this . OnSelectSourceEntity ) ;
221- this . comboBox1 . DropDown += new System . EventHandler ( this . AdjustWidthComboBox_DropDown ) ;
224+ this . comboBox1 . DropDown += new System . EventHandler ( this . AdjustWidthComboBox_DropDown ) ;
222225 //
223226 // label2
224227 //
225228 this . label2 . AutoSize = true ;
226229 this . label2 . Location = new System . Drawing . Point ( 206 , 0 ) ;
227230 this . label2 . Name = "label2" ;
228231 this . label2 . Size = new System . Drawing . Size ( 67 , 13 ) ;
232+ this . label2 . Margin = new Padding ( 8 , 7 , 8 , 7 ) ;
229233 this . label2 . TabIndex = 2 ;
230234 this . label2 . Text = "Target Entity" ;
231235 //
@@ -243,7 +247,7 @@ private void InitializeComponent()
243247 // button1
244248 //
245249 this . button1 . Dock = System . Windows . Forms . DockStyle . Right ;
246- this . button1 . Location = new System . Drawing . Point ( 406 , 3 ) ;
250+ this . button1 . Location = new System . Drawing . Point ( 406 , 0 ) ;
247251 this . button1 . Name = "button1" ;
248252 this . button1 . Size = new System . Drawing . Size ( 136 , 24 ) ;
249253 this . button1 . TabIndex = 4 ;
@@ -257,6 +261,7 @@ private void InitializeComponent()
257261 this . label3 . Location = new System . Drawing . Point ( 548 , 0 ) ;
258262 this . label3 . Name = "label3" ;
259263 this . label3 . Size = new System . Drawing . Size ( 58 , 13 ) ;
264+ this . label3 . Margin = new Padding ( 8 , 7 , 8 , 7 ) ;
260265 this . label3 . TabIndex = 6 ;
261266 this . label3 . Text = "Field Prefix" ;
262267 this . label3 . Click += new System . EventHandler ( this . label3_Click ) ;
@@ -274,6 +279,7 @@ private void InitializeComponent()
274279 this . prefixOverrideLabel . Location = new System . Drawing . Point ( 718 , 0 ) ;
275280 this . prefixOverrideLabel . Name = "prefixOverrideLabel" ;
276281 this . prefixOverrideLabel . Size = new System . Drawing . Size ( 76 , 13 ) ;
282+ this . prefixOverrideLabel . Margin = new Padding ( 8 , 7 , 8 , 7 ) ;
277283 this . prefixOverrideLabel . TabIndex = 7 ;
278284 this . prefixOverrideLabel . Text = "Override Prefix" ;
279285 //
@@ -286,9 +292,9 @@ private void InitializeComponent()
286292 //
287293 // button2
288294 //
289- this . button2 . Location = new System . Drawing . Point ( 824 , 3 ) ;
295+ this . button2 . Location = new System . Drawing . Point ( 824 , 0 ) ;
290296 this . button2 . Name = "button2" ;
291- this . button2 . Size = new System . Drawing . Size ( 191 , 23 ) ;
297+ this . button2 . Size = new System . Drawing . Size ( 191 , 24 ) ;
292298 this . button2 . TabIndex = 9 ;
293299 this . button2 . Text = "Target Org: Source" ;
294300 this . button2 . UseVisualStyleBackColor = true ;
@@ -304,6 +310,7 @@ private void InitializeComponent()
304310 this . listView1 . BackColor = System . Drawing . Color . WhiteSmoke ;
305311 this . listView1 . CheckBoxes = true ;
306312 this . listView1 . Columns . AddRange ( new System . Windows . Forms . ColumnHeader [ ] {
313+ this . columnHeader6 ,
307314 this . columnHeader1 ,
308315 this . columnHeader3 ,
309316 this . columnHeader2 ,
@@ -313,11 +320,20 @@ private void InitializeComponent()
313320 this . listView1 . ImeMode = System . Windows . Forms . ImeMode . On ;
314321 this . listView1 . Location = new System . Drawing . Point ( 3 , 48 ) ;
315322 this . listView1 . Name = "listView1" ;
323+ this . listView1 . OwnerDraw = true ;
316324 this . listView1 . Size = new System . Drawing . Size ( 1129 , 443 ) ;
317325 this . listView1 . Sorting = System . Windows . Forms . SortOrder . Ascending ;
318326 this . listView1 . TabIndex = 1 ;
319327 this . listView1 . UseCompatibleStateImageBehavior = false ;
320328 this . listView1 . View = System . Windows . Forms . View . Details ;
329+ this . listView1 . ColumnClick += new System . Windows . Forms . ColumnClickEventHandler ( this . ListView1_ColumnClick ) ;
330+ this . listView1 . DrawColumnHeader += new System . Windows . Forms . DrawListViewColumnHeaderEventHandler ( this . ListView1_DrawColumnHeader ) ;
331+ this . listView1 . DrawItem += new System . Windows . Forms . DrawListViewItemEventHandler ( this . ListView1_DrawItem ) ;
332+ this . listView1 . DrawSubItem += new System . Windows . Forms . DrawListViewSubItemEventHandler ( this . ListView1_DrawSubItem ) ;
333+ //
334+ // columnHeader6
335+ //
336+ this . columnHeader6 . Width = 30 ;
321337 //
322338 // columnHeader1
323339 //
@@ -346,9 +362,9 @@ private void InitializeComponent()
346362 //
347363 // button3
348364 //
349- this . button3 . Location = new System . Drawing . Point ( 1021 , 3 ) ;
365+ this . button3 . Location = new System . Drawing . Point ( 1021 , 0 ) ;
350366 this . button3 . Name = "button3" ;
351- this . button3 . Size = new System . Drawing . Size ( 97 , 23 ) ;
367+ this . button3 . Size = new System . Drawing . Size ( 97 , 24 ) ;
352368 this . button3 . TabIndex = 10 ;
353369 this . button3 . Text = "Reset Target Org" ;
354370 this . button3 . UseVisualStyleBackColor = true ;
@@ -369,6 +385,61 @@ private void InitializeComponent()
369385
370386 }
371387
388+ private void ListView1_DrawColumnHeader ( object sender ,
389+ DrawListViewColumnHeaderEventArgs e )
390+ {
391+ if ( e . ColumnIndex == 0 )
392+ {
393+ e . DrawBackground ( ) ;
394+ bool value = false ;
395+ try
396+ {
397+ value = Convert . ToBoolean ( e . Header . Tag ) ;
398+ }
399+ catch ( Exception )
400+ {
401+ }
402+ CheckBoxRenderer . DrawCheckBox ( e . Graphics ,
403+ new Point ( e . Bounds . Left + 4 , e . Bounds . Top + 4 ) ,
404+ value ? System . Windows . Forms . VisualStyles . CheckBoxState . CheckedNormal :
405+ System . Windows . Forms . VisualStyles . CheckBoxState . UncheckedNormal ) ;
406+ }
407+ else
408+ {
409+ e . DrawDefault = true ;
410+ }
411+ }
412+
413+ private void ListView1_DrawItem ( object sender , DrawListViewItemEventArgs e )
414+ {
415+ e . DrawDefault = true ;
416+ }
417+
418+ private void ListView1_DrawSubItem ( object sender , DrawListViewSubItemEventArgs e )
419+ {
420+ e . DrawDefault = true ;
421+ }
422+
423+ private void ListView1_ColumnClick ( object sender , ColumnClickEventArgs e )
424+ {
425+ if ( e . Column == 0 )
426+ {
427+ bool value = false ;
428+ try
429+ {
430+ value = Convert . ToBoolean ( listView1 . Columns [ e . Column ] . Tag ) ;
431+ }
432+ catch ( Exception )
433+ {
434+ }
435+ listView1 . Columns [ e . Column ] . Tag = ! value ;
436+ foreach ( ListViewItem item in listView1 . Items )
437+ item . Checked = ! value ;
438+
439+ listView1 . Invalidate ( ) ;
440+ }
441+ }
442+
372443 private string GetDisplayLabel ( Microsoft . Xrm . Sdk . Label label )
373444 {
374445 return label ? . UserLocalizedLabel ? . Label ?? label ? . LocalizedLabels ? . FirstOrDefault ( ) ? . Label ;
@@ -385,7 +456,7 @@ private void OnCloneButtonClick(object sender, EventArgs e)
385456 {
386457 var checkedItems = listView1 . CheckedItems ;
387458
388- var fieldsToClone = ( from object checkedItem in checkedItems select ( ( ListViewItem ) checkedItem ) . Text )
459+ var fieldsToClone = ( from object checkedItem in checkedItems select ( ( ListViewItem ) checkedItem ) . SubItems [ 1 ] . Text )
389460 . ToList ( ) ;
390461
391462 var sourceEntity = ( string ) comboBox1 . SelectedItem ;
@@ -710,8 +781,8 @@ private void PopulateAttributeList()
710781
711782 foreach ( var attributeMetadata in attributes )
712783 {
713- var item = new ListViewItem ( attributeMetadata . LogicalName ) ;
714-
784+ var item = new ListViewItem ( ) ;
785+ item . SubItems . Add ( attributeMetadata . LogicalName ) ;
715786 item . SubItems . Add ( GetDisplayLabel ( attributeMetadata . DisplayName ) ) ;
716787 item . SubItems . Add ( attributeMetadata . AttributeType . ToString ( ) ) ;
717788 item . SubItems . Add ( GetDisplayLabel ( attributeMetadata . Description ) ) ;
0 commit comments