public new void RemoveAt(int index) { StyleListBoxItem temp = (StyleListBoxItem)List[index]; List.RemoveAt(index); // Change index of other StyleListBoxItem for (int i = index; i < List.Count; i++) { ((StyleListBoxItem)List[i]).Index--; } if (OnItemRemoved != null) { OnItemRemoved(listbox, new EventItemArgs(temp)); } }
public void Add(StyleListBoxItem obj) { // Fill default style value to new item obj.SuspendUpdateChange(); obj.InheritedStyle = listbox.DefaultItemStyle; obj.ResumeUpdateChange(); // Fill index to new item obj.Control = listbox; obj.Index = List.Count; // Monitor the changes of item property obj.OnItemChanged += OnChanged; obj.OnItemSelectionChanged += OnSelectionChanged; List.Add(obj); // Raise AddItem event if (OnItemAdded != null) { OnItemAdded(listbox, new EventItemArgs(obj)); } }
public void Remove(StyleListBoxItem obj) { RemoveAt(obj.Index); }
internal void Add(StyleListBoxItem item) { List.Add(item); }
internal void Remove(StyleListBoxItem item) { List.Remove(item); }
/// <summary> /// Handles item selection when mouse is clicked on the item /// according to the SelectionMode rules. /// </summary> protected override void OnMouseClick(MouseEventArgs e) { if (!isCanUpdate) { return; } if (e.Button == MouseButtons.Left && SelectionMode != SelectionMode.None) { StyleListBoxItem item = GetItemFromPoint(e.Location); if (item != null) { SuspendUpdate(); if (SelectionMode == SelectionMode.One) { item.Selected = true; } else if (SelectionMode == SelectionMode.MultiSimple) { item.Selected = !item.Selected; } else if (SelectionMode == SelectionMode.MultiExtended) { if (Control.ModifierKeys.HasFlag(Keys.Control)) { item.Selected = !item.Selected; } else if (Control.ModifierKeys.HasFlag(Keys.Shift)) { // check if lastSelectedIndex is a valid index if (lastSelectedIndex < itemList.Count) { ClearSelected(); int startIndex = Math.Min(lastSelectedIndex, item.Index); int endIndex = Math.Max(lastSelectedIndex, item.Index); for (int i = startIndex; i <= endIndex; i++) { itemList[i].SetSelected(true); itemSelectedList.Add(itemList[i]); } _selectedIndex = item.Index; } } else { ClearSelected(); item.Selected = true; } } lastSelectedIndex = item.Index; ResumeUpdate(); Update(); if (e.Clicks == 1) { if (ItemClicked != null) { ItemClicked(this, new EventItemArgs(item)); } } else if (e.Clicks > 1) { if (ItemDoubleClicked != null) { ItemDoubleClicked(this, new EventItemArgs(item)); } } } } base.OnMouseClick(e); }
public EventItemChangedArgs(StyleListBoxItem item) { this.Item = item; }