System.Windows.Forms.ListBox.ShiftSelection C# (CSharp) Method

ShiftSelection() private method

private ShiftSelection ( int index ) : void
index int
return void
		private void ShiftSelection (int index)
		{
			int shorter_item = -1, dist = Items.Count + 1, cur_dist;
			
			foreach (int idx in selected_indices) {
				if (idx > index) {
					cur_dist = idx - index;
				} else {
					cur_dist = index - idx;
				}

				if (cur_dist < dist) {
					dist = cur_dist;
					shorter_item = idx;
				}
			}
			
			if (shorter_item != -1) {
				int start, end;
				
				if (shorter_item > index) {
					start = index;
					end = shorter_item;
				} else {
					start = shorter_item;
					end = index;
				}
				
				selected_indices.Clear ();
				for (int idx = start; idx <= end; idx++) {
					selected_indices.AddCore (idx);
				}
			}
		}