//======================================================== // Constructors //======================================================== public ImageBlockControl() { InitializeComponent(); _list = new ImagePairControl[10]; for (int i = 0; i < 10; i++) { var control = new ImagePairControl(); control.Index = i + 1; control.Location = new Point(0, 0 + (i * control.Height)); this.Controls.Add(control); _list[i] = control; } }
/// <summary> /// Gives ImagePairControl by its index. /// </summary> /// <param name="index">Values 1..10</param> /// <returns></returns> public ImagePairControl getImagePairControl(int index) { if (index < 1 || index > 10) { throw new ArgumentOutOfRangeException("Index interval should be [1,10]. Value: " + index); } ImagePairControl control = _list[index - 1]; if (control.Index != index) { foreach (var item in _list) { if (item.Index == index) { control = item; break; } } } return(control); }