-
Notifications
You must be signed in to change notification settings - Fork 1
/
ComboBox.razor.cs
2976 lines (2643 loc) · 101 KB
/
ComboBox.razor.cs
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
#region using statements
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using Microsoft.AspNetCore.Components;
using DataJuggler.UltimateHelper;
using DataJuggler.Blazor.Components.Enumerations;
using DataJuggler.Blazor.Components.Interfaces;
using System.Drawing;
using DataJuggler.Blazor.Components.Delegates;
using DataJuggler.Blazor.Components.Util;
#endregion
namespace DataJuggler.Blazor.Components
{
#region class ComboBox
/// <summary>
/// This class is designed to make a DropDownList easier to work with.
/// </summary>
public partial class ComboBox : ComponentBase, IBlazorComponent, IBlazorComponentParent, ILabelFont, ITextBoxFont
{
#region Private Variables
private double buttonLeft;
private string buttonPosition;
private double buttonTop;
private string selectedText;
private string buttonUrl;
private CheckedListBox checkedListComponent;
private bool checkListMode;
private List<IBlazorComponent> children;
private string className;
private ImageButton button;
private string displayStyle;
private bool expanded;
private double expandedButtonLeft;
private double height;
private string heightStyle;
private string heightUnit;
private string imagePath;
private List<Item> items;
private List<Item> storedSelectedItems;
private string labelBackColor;
private string labelClassName;
private Color labelColor;
private double labelLeft;
private double labelMarginRight;
private double labelMarginRightList;
private string labelMarginRightListStyle;
private string labelMarginRightStyle;
private string labelPosition;
private string labelText;
private double labelTop;
private double labelWidth;
private double left;
private string leftStyle;
private Color listBackgroundColor;
private double listItemHeight;
private string listItemClassName;
private double listItemLeft;
private string listItemPosition;
private Color listItemTextColor;
private Color listItemBackgroundColor;
private double listItemTop;
private double listItemWidth;
private string listItemWidthStyle;
private string name;
private string noPadding;
private IBlazorComponentParent parent;
private string position;
private Item selectedItem;
private string textAlign;
private ThemeEnum theme;
private double top;
private string topStyle;
private string unit;
private bool visible;
private int visibleCount;
private double width;
private int zIndex;
private string listItemHeightStyle;
private double checkedListheight;
private double checkedListWidth;
private double labelFontSize;
private string labelFontSizeUnit;
private string labelFontName;
private double textBoxWidth;
private double column1Width;
private double column2Width;
private double buttonWidth;
private double buttonHeight;
private TextBoxComponent textBox;
private double textBoxLeft;
private int listZIndex;
private string filterText;
private int filterIndex;
private double fontSize;
private string fontUnit;
private double checkedListLeft;
private double checkedListTop;
private string checkedListClassName;
private double checkBoxTextXPosition;
private double checkBoxTextYPosition;
private int checkedListZIndex;
private string checkedListPosition;
private string checkedListUnit;
private string checkedListHeightUnit;
private double textBoxHeight;
private string labelUnit;
private double checkBoxXPosition;
private double checkBoxYPosition;
private string containerStyle;
private double controlWidth;
private double controlHeight;
private string dropdownClassName;
private double textBoxFontSize;
private string textBoxFontName;
private string fontName;
// Had to bring back BlazorStyled
private string listItemContainer;
private string listItemStyle;
private string buttonStyle;
private string checkedListBoxStyle;
private double checkedListItemLeft;
private double checkedListItemTop;
#endregion
#region Constructor
/// <summary>
/// Create a new instance of a ComboBox object
/// </summary>
public ComboBox()
{
// Perform initializations for this object
Init();
}
#endregion
#region Events
#region ButtonClicked(int buttonNumber, string buttonText)
/// <summary>
/// Button Clicked
/// </summary>
public void ButtonClicked(int buttonNumber, string buttonText)
{
// if the TextSize button was clicked
if ((buttonNumber == 1) && (HasButton))
{
// Store the selections (checked boxes) before hiding
StoreSelections();
// Set the value for expanded or not
Expanded = !Expanded;
}
// Update the UI
Refresh();
}
#endregion
#region SelectionChanged(ChangeEventArgs selectedItem)
/// <summary>
/// event is fired when On Change
/// </summary>
public void SelectionChanged(ChangeEventArgs selectedItem)
{
// Set the selectedItem
SelectedText = selectedItem.Value.ToString();
// Set the SelectedItem
SetSelectedItem(SelectedText, false);
// if the Parent exists
if (HasParent)
{
// Create a new instance of a 'Message' object.
Message message = new Message();
// Notify the parent
message.Text = SelectedText;
// Set who the message is from
message.Sender = this;
// Send the parent a message the selection changed
Parent.ReceiveData(message);
}
// No longer expanded
Expanded = false;
// Update everything
Refresh();
}
#endregion
#endregion
#region Methods
#region DisplaySelections()
/// <summary>
/// Display Selections
/// </summary>
public void DisplaySelections()
{
// If the CheckedListComponent exists and the TextBox exists
if ((HasCheckedListComponent) && (HasTextBox))
{
// Get the Selected Items
List<Item> selectedItems = this.CheckedListComponent.SelectedItems;
// Dislay the selected items
DisplaySelections(selectedItems);
}
else if ((HasTextBox) && (HasStoredSelectedItems))
{
// Dislay the selected items
DisplaySelections(StoredSelectedItems);
}
}
#endregion
#region DisplaySelections(List<Item> selectedItems)
/// <summary>
/// This method displays the SelectedItems
/// </summary>
/// <param name="selectedItems"></param>
public void DisplaySelections(List<Item> selectedItems)
{
// Initial value
string selectedText = "";
// if the TextBox exists and there are one or more selectedItems
if ((HasTextBox) && (ListHelper.HasOneOrMoreItems(selectedItems)))
{
// Set Loading to true
TextBox.Loading = true;
// Create a new instance of a 'StringBuilder' object.
StringBuilder sb = new StringBuilder();
// Iterate the collection of Item objects
foreach(Item item in selectedItems)
{
// if checked
if (item.ItemChecked)
{
// Append the Item and a semicolon separator
sb.Append(item.Text);
sb.Append(";");
}
}
// Set the selected Text
selectedText = sb.ToString();
// Set the SelecctedText
TextBox.SetTextValue(selectedText);
// Update
TextBox.Refresh();
// Set Loading to false
TextBox.Loading = false;
}
}
#endregion
#region FindChildByName(string name)
/// <summary>
/// method returns the Child By Name
/// </summary>
public IBlazorComponent FindChildByName(string name)
{
// initial value
IBlazorComponent child = null;
// if the value for HasChildren is true
if (HasChildren)
{
foreach (IBlazorComponent tempChild in Children)
{
// if this is the item being sought
if (TextHelper.IsEqual(tempChild.Name, name))
{
// set the return value
child = tempChild;
// break out of loop
break;
}
}
}
// return value
return child;
}
#endregion
#region GetCountItemsWithFilter()
/// <summary>
/// returns the Count Items With Filter
/// </summary>
public int GetCountItemsWithFilter()
{
// initial value
int count = 0;
if ((HasItems) && (HasFilterText))
{
// Get the items
List<Item> items = Items.Where(x => x.Text.StartsWith(FilterText)).ToList();
// If the items collection exists and has one or more items
if (ListHelper.HasOneOrMoreItems(items))
{
// Get the count
count = items.Count;
}
}
// return value
return count;
}
#endregion
#region Init()
/// <summary>
/// This method performs initializations for this object.
/// </summary>
public void Init()
{
// Default to 30% for the label, the rest goes to the ComboBox
Theme = ThemeEnum.Black;
// Button
ButtonPosition = "relative";
ButtonUrl = "_content/DataJuggler.Blazor.Components/Images/Buttons/ComboBoxBlack.png";
ButtonWidth = 24;
ButtonTop = -1;
ButtonLeft = -1;
SelectedText = "";
Children = new List<IBlazorComponent>();
Visible = true;
Left = -3;
Top = 0;
Height = 32;
Unit = "px";
HeightUnit = "px";
Width = 224; // Updated from 120
checkedListheight = 64;
CheckedListWidth = 120;
Position = "relative";
VisibleCount = 5;
ZIndex = 80; // Updated from 40
ListZIndex = 80;
LabelMarginRight = 0;
LabelMarginRightList = 0;
listItemLeft = -150; // Updated from 108
ListItemWidth = 108; // Updated from 120
TextAlign = "center";
Items = new List<Item>();
LabelBackColor = "transparent";
LabelUnit = "px";
ListItemPosition = "relative";
ListItemHeight = 16;
listItemTop = 32; // Updated from -12
LabelPosition = "relative";
ListItemBackgroundColor = Color.White;
ListBackgroundColor = Color.White;
ListItemClassName = "zindex200"; // Updated from "height16"
Column1Width = 100;
Column2Width = 128; // Already matching value
// CheckBox
CheckBoxTextXPosition = -1;
checkBoxTextYPosition = -1;
CheckedListZIndex = 40;
CheckedListPosition = "absolute";
// TextBox
TextBoxWidth = 124; // Updated from 12
TextBoxLeft = 0; // Updated from -3.2
TextBoxHeight = 22; // Updated from 24
// Set the Fonts
LabelFontSize = 18; // Updated from GlobalDefaults.LabelFontSize
LabelFontName = "Calibri"; // Updated from GlobalDefaults.LabelFontName
TextBoxFontSize = GlobalDefaults.TextBoxFontSize;
TextBoxFontName = GlobalDefaults.TextBoxFontName;
FontSize = GlobalDefaults.TextBoxFontSize;
FontUnit = "px";
// Set so the image is set
Expanded = false;
// Additional Properties
LabelClassName = "down4 right2";
}
#endregion
#region LoadItems(List<T> items, bool addEmptyRowAtTop = false)
/// <summary>
/// This method loads a list of any type
/// </summary>
public void LoadItems<T>(List<T> items, bool addEmptyRowAtTop = false)
{
// clear the list
this.Items = new List<Item>();
// if the list exists
if ((items != null) && (items.Count > 0))
{
// if addEmptyRowAtTop is true
if (addEmptyRowAtTop)
{
// Add the empty item
Item item = new Item();
item.Text = "";
item.Id = 0;
// Add this item
Items.Add(item);
}
// iterate the list
foreach (object tempItem in items)
{
Item item = new Item();
item.Text = tempItem.ToString();
item.Id = Items.Count + 1;
Items.Add(item);
}
// if not checkListMode
if (!CheckListMode)
{
// Select the first item
SelectedItem = Items[0];
}
// Update Async
Refresh();
}
}
#endregion
#region LoadItems(Type enumType)
/// <summary>
/// This method loads a combobox with the enum values
/// </summary>
public void LoadItems(Type enumType)
{
// locals
string[] names = null;
Array values = null;
int index = -1;
string formattedName = "";
// clear the list
this.Items = new List<Item>();
// verifyh the object is an emum
if (enumType.IsEnum)
{
// get the names from the enum
names = Enum.GetNames(enumType);
values = Enum.GetValues(enumType);
// if there are one or more names
if ((names != null) && (names.Length > 0) && (values != null) && (values.Length == names.Length))
{
// iterate the names
foreach (string name in names)
{
// increment index
index++;
// Get the int value of the enum
int id = (int) values.GetValue(index);
// replace out any underscores with spaces
formattedName = name.Replace("_", " ");
// Create the item
Item item = new Item();
// Get the value
item.Id = id;
// Set the name with any underscores out
item.Text = formattedName;
// add this item
this.Items.Add(item);
}
// Update Async
Refresh();
}
}
}
#endregion
#region OnTextChanged(string text)
/// <summary>
/// On Text Changed
/// </summary>
public void OnTextChanged(string text)
{
// This method is here so I can figure out why the selections are erased
// When the combo box button is clicked to close.
if (!TextHelper.Exists(text))
{
// the text was set to blank
DisplaySelections();
}
}
#endregion
#region ReceiveData(Message message)
/// <summary>
/// method returns the Data
/// </summary>
public void ReceiveData(Message message)
{
// If the 'message' object
if (NullHelper.Exists(message))
{
// if it is the CheckedListBox
if ((message.Text == "SendItems") && (HasCheckedListComponent))
{
// set the items
CheckedListComponent.SetItems(Items);
}
// if a checkbox was checked
else if ((message.Text == "ItemSelected") && (CheckListMode))
{
// Display Selections
DisplaySelections();
}
else if (message.Text.Contains("text"))
{
// get the key pressed
string keyPressed = message.Text.Replace("text: Key", "");
// Filter the list of items
if (TextHelper.Exists(FilterText))
{
// if the FilterText matches
if (FilterText == keyPressed)
{
// Check if in range for this filter group
FilterIndex++;
// Check if in range for this filter group
int itemsWithThisFilter = GetCountItemsWithFilter();
// if the FilterIndex
if (FilterIndex >= itemsWithThisFilter)
{
// Reset
FilterIndex = 0;
}
}
else
{
// Set the FilterText
FilterText = keyPressed;
// Select the first item
FilterIndex = 0;
}
}
else
{
// Use this as the Filter
FilterText = keyPressed;
// Select the first item
FilterIndex = 0;
}
// if there are enough items
if (ListHelper.HasXOrMoreItems(FilteredItems, FilterIndex + 1))
{
// Set the Selected Item
SelectedItem = FilteredItems[FilterIndex];
// if the SelectedItem exists
if (HasSelectedItem)
{
// Set the Selected Text
SetSelectedText(SelectedItem.Text);
// if the SelectedText exists
if ((HasSelectedText) && (HasItems))
{
// find the index
int index = ItemHelper.FindItemIndexByText(Items, SelectedText);
// if found
if (index >= 0)
{
// Set the selected index
SelectedItem = Items[index];
}
}
}
}
// Update the UI
Refresh();
}
else
{
// Refresh
Refresh();
}
}
}
#endregion
#region Refresh()
/// <summary>
/// method Refresh
/// </summary>
public void Refresh()
{
// Update the UI
InvokeAsync(() =>
{
StateHasChanged();
});
}
#endregion
#region Register(IBlazorComponent component)
/// <summary>
/// method registers the ComboBoxButton
/// </summary>
public void Register(IBlazorComponent component)
{
// Add this item
this.Children.Add(component);
// if this is the Button registering
if (component is ImageButton)
{
// Store the ComboBoxButton
Button = component as ImageButton;
// if the value for HasComboBoxButton is true
if (HasButton)
{
// Setup the click handler
Button.SetClickHandler(ButtonClicked);
}
}
else if (component is TextBoxComponent)
{
// Store the TextBox
TextBox = component as TextBoxComponent;
// if the value for HasStoredSelectedItems is true
if (HasStoredSelectedItems)
{
// Display the Selections
DisplaySelections(StoredSelectedItems);
}
}
else if (component is CheckedListBox)
{
// store
CheckedListComponent = component as CheckedListBox;
// if the value for HasCheckedListComponent is true
if (HasCheckedListComponent)
{
// Set the Items
CheckedListComponent.SetItems(Items);
// if the value for HasStoredSelectedItems is true
if (HasStoredSelectedItems)
{
// Now set the SelectedItems
SetSelectedItems(StoredSelectedItems);
// erase
StoredSelectedItems = null;
}
}
}
}
#endregion
#region SetSelectedItems(List<Item> selectedItems)
/// <summary>
/// Set Selected Items for the ComboBox in CheckedListMode
/// </summary>
public void SetSelectedItems(List<Item> selectedItems)
{
// if the value for HasCheckedListComponent is true
if ((HasCheckedListComponent) && (ListHelper.HasOneOrMoreItems(selectedItems)))
{
// iterate the items
foreach (Item item in selectedItems)
{
// if this item is checked
if (item.ItemChecked)
{
// Find the item by Id
int index = ItemHelper.FindItemIndexByText(CheckedListComponent.Items, item.Text);
// if the index was found
if (index >= 0)
{
// Check this item
CheckedListComponent.Items[index].ItemChecked = true;
}
}
}
// Update the selections
CheckedListComponent.Refresh();
// display the selections
DisplaySelections();
}
else
{
// Store this for once the ocmponent is registered
StoredSelectedItems = selectedItems;
}
}
#endregion
#region SetSelectedText(string buttonText)
/// <summary>
/// Set the selected value for the combo box Text
/// </summary>
public void SetSelectedText(string buttonText)
{
// Store the buttonText
SelectedText = buttonText;
}
#endregion
#region SetLeft(int left)
/// <summary>
/// Set Left
/// </summary>
public void SetLeft(int left)
{
// store
Left = left;
}
#endregion
#region SetPosition(string position)
/// <summary>
/// Set Position
/// </summary>
public void SetPosition(string position)
{
// store
Position = position;
}
#endregion
#region SetSelectedItem(string text, bool refresh = true)
/// <summary>
/// returns the Selected Item
/// </summary>
public Item SetSelectedItem(string text, bool refresh = true)
{
// initial value
Item selectedItem = null;
// If the text string exists
if ((TextHelper.Exists(text)) && (HasItems))
{
// Iterate the collection of Item objects
foreach (Item item in Items)
{
// if a direct match
if (TextHelper.IsEqual(item.Text, text))
{
// set the selecteted item
selectedItem = item;
// Set the property
SelectedItem = item;
// Set the ButtonText
SelectedText = selectedItem.Text.Replace("_", " ");
// if the value for refresh is true
if (refresh)
{
// Update this object
Refresh();
}
// break out of the loop
break;
}
else if (TextHelper.Exists(item.Text))
{
// if a match with the underscores replaced as a space
if (TextHelper.IsEqual(item.Text.Replace("_", " "), text))
{
// set the selecteted item
selectedItem = item;
// Set the property
SelectedItem = item;
// Set the ButtonText
SelectedText = selectedItem.Text.Replace("_", " ");
// if the value for refresh is true
if (refresh)
{
// Update this object
Refresh();
}
// break out of the loop
break;
}
}
}
}
// return value
return selectedItem;
}
#endregion
#region SetupComponent()
/// <summary>
/// Set Button Image
/// </summary>
public void SetupComponent()
{
// if Blue Mode
if (theme == ThemeEnum.Blue)
{
if (Expanded)
{
ButtonUrl = "_content/DataJuggler.Blazor.Components/Images/Buttons/TriangleButtonOpen.png";
}
else
{
ButtonUrl = "_content/DataJuggler.Blazor.Components/Images/Buttons/TriangleButtonClosed.png";
}
}
else if ((theme == ThemeEnum.Dark) || (theme == ThemeEnum.Black))
{
if (Expanded)
{
ButtonUrl = "_content/DataJuggler.Blazor.Components/Images/Buttons/BlackTriangleOpen.png";
}
else
{
ButtonUrl = "_content/DataJuggler.Blazor.Components/Images/Buttons/BlackTriangleClosed.png";
}
}
else if (theme == ThemeEnum.Brown)
{
if (Expanded)
{
ButtonUrl = "_content/DataJuggler.Blazor.Components/Images/Buttons/BrownTriangleOpen.png";
}
else
{
ButtonUrl = "_content/DataJuggler.Blazor.Components/Images/Buttons/BrownTriangleClosed.png";
}
}
else if (theme == ThemeEnum.BlueGold)
{
if (Expanded)
{
ButtonUrl = "_content/DataJuggler.Blazor.Components/Images/Buttons/BlueGoldArrowOpen.png";
}
else
{
ButtonUrl = "_content/DataJuggler.Blazor.Components/Images/Buttons/BlueGoldArrowClosed.png";
}
}
// if the Button exists
if (HasButton)
{
// Update the Button
Button.Refresh();
}
// Display the Selections (if in CheckListMode)
DisplaySelections();
}
#endregion
#region SetVisible(bool visible)
/// <summary>
/// Set Visible
/// </summary>
public void SetVisible(bool visible)
{
// store
Visible = visible;
}
#endregion
#region StoreSelections()
/// <summary>
/// Store Selections
/// </summary>
public void StoreSelections()
{
// If the CheckedListComponent and the Items collections both exist
if ((HasCheckedListComponent) && (HasItems))
{
// Get the selected items
List<Item> selectedItems = CheckedListComponent.SelectedItems;
// first unselect everything
foreach (Item item in Items)
{
// unselect
item.ItemChecked = false;
}
// If the selectedItems collection exists and has one or more items
if (ListHelper.HasOneOrMoreItems(selectedItems))
{
foreach (Item item in selectedItems)
{
// attempt to find this item
Item temp = CheckedListComponent.FindItemById(item.Id);
// If the temp object exists
if (NullHelper.Exists(temp))
{
// set to true
temp.ItemChecked = true;
}
}
}
}
}
#endregion
#endregion
#region Properties
#region Button
/// <summary>
/// This property gets or sets the value for 'Button'.
/// </summary>
public ImageButton Button
{
get { return button; }
set { button = value; }
}
#endregion
#region ButtonHeight
/// <summary>
/// This property gets or sets the value for 'ButtonHeight'.
/// </summary>
[Parameter]
public double ButtonHeight
{
get { return buttonHeight; }
set { buttonHeight = value; }
}
#endregion
#region ButtonLeft
/// <summary>
/// This property gets or sets the value for 'ButtonLeft'.
/// </summary>
[Parameter]
public double ButtonLeft
{
get