private void FileStatusListBox_KeyDown(object sender, KeyEventArgs e) { switch (e.KeyCode) { case Keys.A: { if (e.Control) { try { FileStatusListBox.SuspendLayout(); FileStatusListBox.ClearSelected(); for (int n = FileStatusListBox.Items.Count - 1; n >= 0; n--) { FileStatusListBox.SetSelected(n, true); } e.Handled = true; } finally { FileStatusListBox.ResumeLayout(); } } break; } default: if (this.KeyDown != null) { this.KeyDown(sender, e); } break; } }
private void FileStatusListBox_KeyDown(object sender, KeyEventArgs e) { switch (e.KeyCode) { case Keys.A: { if (e.Control) { FileStatusListBox.BeginUpdate(); try { for (var i = 0; i < FileStatusListBox.Items.Count; i++) { FileStatusListBox.SetSelected(i, true); } e.Handled = true; } finally { FileStatusListBox.EndUpdate(); } } break; } default: if (KeyDown != null) { KeyDown(sender, e); } break; } }
public new void Focus() { if (FileStatusListBox.Items.Count > 0) { if (FileStatusListBox.SelectedItem == null) { FileStatusListBox.SelectedIndex = 0; } FileStatusListBox.Focus(); } }
void FileStatusListBox_MouseDown(object sender, MouseEventArgs e) { //SELECT if (e.Button == MouseButtons.Right) { Point point = new Point(e.X, e.Y); int hoverIndex = FileStatusListBox.IndexFromPoint(point); if (hoverIndex >= 0) { if (!FileStatusListBox.GetSelected(hoverIndex)) { while (FileStatusListBox.SelectedIndices.Count > 0) { FileStatusListBox.SetSelected(FileStatusListBox.SelectedIndices[0], false); } FileStatusListBox.SetSelected(hoverIndex, true); } } } //DRAG if (e.Button == MouseButtons.Left) { if (SelectedItems.Count > 0) { // Remember the point where the mouse down occurred. // The DragSize indicates the size that the mouse can move // before a drag event should be started. Size dragSize = SystemInformation.DragSize; // Create a rectangle using the DragSize, with the mouse position being // at the center of the rectangle. dragBoxFromMouseDown = new Rectangle(new Point(e.X - (dragSize.Width / 2), e.Y - (dragSize.Height / 2)), dragSize); } else { // Reset the rectangle if the mouse is not over an item in the ListBox. dragBoxFromMouseDown = Rectangle.Empty; } } }
private int FilterFiles(Regex filter) { try { SuspendLayout(); var items = FileStatusListBox.Items.Cast <GitItemStatus>().ToList(); for (var i = 0; i < items.Count; i++) { FileStatusListBox.SetSelected(i, filter.IsMatch(items[i].Name)); } return(FileStatusListBox.SelectedIndices.Count); } finally { ResumeLayout(true); } }