// METHOD:: Remove persisted items no longer needed private void RemoveItems(int item) { if (SelectedIndexes.ContainsKey(item)) { SelectedIndexes.Remove(item); } }
// METHOD:: Add checked items and persist them to memory private void PersistItems(int item) { if (!SelectedIndexes.Exists(i => i == item)) { SelectedIndexes.Add(item); } }
// METHOD:: Add checked items and persist them to memory private void PersistItems(int item, object idValue) { if (!SelectedIndexes.Keys.Contains(item)) { SelectedIndexes.Add(item, idValue); } }
public void AddSelection(int tileId) { if (!SelectedIndexes.Contains(tileId)) { SelectedIndexes.Add(tileId); } }
private void This_PropertyChanged(object sender, PropertyChangedEventArgs e) { switch (e.PropertyName) { case nameof(Viewer.Items): SelectedIndexes.Clear(); break; default: break; } }
private SolidBrush ReturnForeFromSubItem(int I, ListViewItem.ListViewSubItem Item) { if (SelectedIndexes.Contains(I)) { return(new SolidBrush(Color.FromArgb(10, 10, 10))); } if (HandleItemsForeColor) { return(new SolidBrush(Item.ForeColor)); } else { return(new SolidBrush(ForeColor)); } }
protected override void OnPropertyChanged(string name) { switch (name) { case nameof(CurrentTileSetRef): UpdateModel(); SelectedIndexes.Clear(); break; default: break; } base.OnPropertyChanged(name); }
internal void AddSelectedIndex(int index, bool single) { if (single) { SelectedIndexes.Clear(); } focused_index = Math.Max(index, 0); if (index != -1) { SelectedIndexes.Add(index); } owner.Invalidate(); }
// METHOD:: Repopulate checked items and store in gridview. private void RepopulateCheckedItems() { foreach (GridViewRow row in this.Rows) { // Retrieve the reference to the checkbox CheckBox checkBox = (CheckBox)row.FindControl(InputCheckBoxField.CheckBoxID); if (SelectedIndexes != null) { if (SelectedIndexes.Exists(i => i == row.DataItemIndex)) { checkBox.Checked = true; } } } }
protected override void OnMouseUp(MouseEventArgs e) { int Selection = GetSelectedFromLocation(e.Location); if (Selection == -1 || !(e.Button == MouseButtons.Left)) { return; } if (Multiselect && IsControlDown()) { if (!SelectedIndexes.Contains(Selection)) { SelectedIndexes.Add(Selection); } else { SelectedIndexes.Remove(Selection); } } else if (Multiselect && !IsControlDown()) { SelectedIndexes = new List <int>() { Selection } } ; else { SelectedIndexes = new List <int>() { Selection }; SelectedIndex = Selection; } if (Selection == -1) { SelectedIndexes = new List <int>(); } Invalidate(); SelectedIndexChanged?.Invoke(this, Selection); base.OnMouseUp(e); }
public void RemoveSelected() { if (ItemCount > 0 && SelectedCount > 0) { // Sort by index in the QueueData list to prevent positions shifting due to removes var sortedByValue = SelectedIndexes.OrderByDescending(rowItem => rowItem); // Once sorted, remove each selected item foreach (var index in sortedByValue) { RemoveAt(index); } selectedIndices.Clear(); OnSelectedIndexChanged(null); } }
// METHOD:: Remove persisted items no longer needed private void RemoveItems(int item) { SelectedIndexes.Remove(item); }
protected override void OnPaint(PaintEventArgs e) { e.Graphics.Clear(Color.FromArgb(50, 50, 53)); using (SolidBrush Background = new SolidBrush(Color.FromArgb(55, 55, 58))) { e.Graphics.FillRectangle(Background, new Rectangle(1, 1, Width - 2, 26)); } using (Pen Border = new Pen(Color.FromArgb(42, 42, 45))) using (Pen Shadow = new Pen(Color.FromArgb(65, 65, 68)) ) { e.Graphics.DrawRectangle(Border, new Rectangle(0, 0, Width - 1, Height - 1)); e.Graphics.DrawRectangle(Border, new Rectangle(0, 0, Width - 1, 26)); e.Graphics.DrawLine(Shadow, 1, 1, Width - 2, 1); } if (Columns != null) { for (var I = 0; I <= Columns.Count() - 1; I++) { if (!(I == 0)) { using (SolidBrush Separator = new SolidBrush(Color.FromArgb(42, 42, 45))) using (SolidBrush Shadow = new SolidBrush(Color.FromArgb(65, 65, 68)) ) { e.Graphics.FillRectangle(Separator, new Rectangle(ColumnWidth * I, 1, 1, 26)); e.Graphics.FillRectangle(Shadow, new Rectangle(ColumnWidth * I - 1, 1, 1, 25)); if (Grid && Items != null) { e.Graphics.FillRectangle(Separator, new Rectangle(ColumnWidth * I, 1, 1, 26 + (Items.Count() * ItemSize))); e.Graphics.FillRectangle(Shadow, new Rectangle(ColumnWidth * I - 1, 1, 1, 25 + (Items.Count() * ItemSize))); } } } using (SolidBrush Fore = new SolidBrush(ForeColor)) { e.Graphics.DrawString(Columns[I], Font, Fore, new Point((ColumnWidth * I) + 6, 4)); } } } if (Items != null) { if (!(Highlight == -1)) { using (SolidBrush Background = new SolidBrush(Color.FromArgb(66, 66, 69))) using (Pen Line = new Pen(Color.FromArgb(45, 45, 48)) ) { e.Graphics.FillRectangle(Background, new Rectangle(1, 26 + Highlight * ItemSize, Width - 2, ItemSize)); e.Graphics.DrawRectangle(Line, new Rectangle(1, 26 + Highlight * ItemSize, Width - 2, ItemSize)); } } using (SolidBrush Selection = new SolidBrush(Color.FromArgb(41, 130, 232))) using (Pen Line = new Pen(Color.FromArgb(40, 40, 40)) ) { if (Multiselect && !(SelectedIndexes.Count == 0)) { foreach (int Selected in SelectedIndexes) { e.Graphics.FillRectangle(Selection, new Rectangle(1, 26 + Selected * ItemSize, Width - 2, ItemSize)); if (Selected == 0 && SelectedIndexes.Count == 1) { e.Graphics.DrawLine(Line, 1, 26 + ItemSize, Width - 2, 26 + ItemSize); } else if (SelectedIndexes.Count == 1) { e.Graphics.DrawLine(Line, 1, 26 + ItemSize + Selected * ItemSize, Width - 2, 26 + ItemSize + Selected * ItemSize); } } } else if (!(SelectedIndexes.Count == 0)) { e.Graphics.FillRectangle(Selection, new Rectangle(1, 26 + SelectedIndex * ItemSize, Width - 2, ItemSize)); } } if (SelectedIndexes.Count > 0) { BorderIndex = SelectedIndexes.Max(); } for (var I = 0; I <= Items.Count() - 1; I++) { e.Graphics.DrawString(Items[I].Text, Font, ReturnForeFromItem(I, Items[I]), new Point(6, 26 + I * ItemSize + 2)); if (Items[I].SubItems != null) { for (var X = 0; X <= Items[I].SubItems.Count - 1; X++) { if (!(Items[I].SubItems[X].Text == Items[I].Text)) { e.Graphics.DrawString(Items[I].SubItems[X].Text, Font, ReturnForeFromSubItem(I, Items[I].SubItems[X]), new Rectangle((ColumnWidth * X) + 6, 26 + I * ItemSize + 2, ColumnWidth - 8, 16)); } } } } if (SelectedIndexes.Contains(BorderIndex)) { using (Pen Line = new Pen(Color.FromArgb(40, 40, 40))) { e.Graphics.DrawLine(Line, 1, 26 + ItemSize + BorderIndex * ItemSize, Width - 2, 26 + ItemSize + BorderIndex * ItemSize); } } } base.OnPaint(e); }
public void ClearSelection() { SelectedIndexes.Clear(); UpdateInfo(); }
public void ClearAllCheckedItems() { SelectedIndexes.Clear(); }
public void RemoveSelection(int tileId) { SelectedIndexes.Remove(tileId); }
public override bool OnMouseDown(DxWindow window, DxControl ctl, MouseEventArgs args, SharpDX.Point pt) { if (!IntersectTest(pt.X, pt.Y) || !IsMouseOver) { if (Active) { TopMost = false; window.DrawOnTopList.Remove(this); } Active = false; return(false); } var oldActive = Active; if (pt.X >= Rect.X && pt.X <= Rect.X + Rect.Width && pt.Y >= Rect.Y && pt.Y <= Rect.Y + 21) { Active = !Active; } if (Active) { if (oldActive == false) { _currentPosition = 0; } if (_currentHighlightItem != -1) { if (MultiSelect) { if (SelectedIndexes.Contains(_currentHighlightItem + _currentPosition)) { SelectedIndexes.Remove(_currentHighlightItem + _currentPosition); } else { SelectedIndexes.Add(_currentHighlightItem + _currentPosition); } } else { SelectedIndexes.Clear(); SelectedIndexes.Add(_currentHighlightItem + _currentPosition); } } if (!MultiSelect) { if (oldActive) { Active = false; } } } TopMost = Active; if (Active && !oldActive) { window.DrawOnTopList.Add(this); } else if (!Active && oldActive) { window.DrawOnTopList.Remove(this); } return(true); }
public override void Draw(Graphics graphics, Action action = null) { action = () => { if (Active) { if (Items.Count < _maxItemsVisible) { Rect.Height = (Items.Count + 1) * 21 + 5; } else { Rect.Height = (_maxItemsVisible + 1) * 21 + 5; } graphics.OutlineFillRectangle(ActiveBorder, ActiveFill, Rect.X, Rect.Y, Rect.Width, Rect.Height, 1, 0); graphics.DrawText(new TextHelper(SelectedItems.Cast <string>().Aggregate("", (current, item) => current + $"{item},").TrimEnd(',')) { ParagraphAlignment = ParagraphAlignment.Center, TextAntialiasMode = TextAntialiasMode.Grayscale, FontWeight = FontWeight.SemiBold }, Font, ActiveFontBrush, null, Rect.X + 4, Rect.Y - 1, Rect.Width - 17, 21); graphics.DrawLine(ActiveFontBrush, new Point(Rect.X + Rect.Width - 5, Rect.Y + 8), new Point(Rect.X + Rect.Width - 9, Rect.Y + 12), 2); //arrow graphics.DrawLine(ActiveFontBrush, new Point(Rect.X + Rect.Width - 12, Rect.Y + 8), new Point(Rect.X + Rect.Width - 8, Rect.Y + 12), 2); //arrow graphics.FillRectangle(Separator, Rect.X, Rect.Y + 21, Rect.Width, 1); //separator for (var i = 0; i < (Items.Count > _maxItemsVisible ? _maxItemsVisible : Items.Count); i++) { if (_currentHighlightItem == i) { graphics.FillRectangle(ItemOverHighlight, Rect.X + 4, Rect.Y + 21 + i * 21, Rect.Width - 8 - (Items.Count <= _maxItemsVisible ? 0 : 9), 21); } graphics.DrawText(new TextHelper(Items[i + _currentPosition].ToString()) { ParagraphAlignment = ParagraphAlignment.Center, TextAntialiasMode = TextAntialiasMode.Grayscale, FontWeight = FontWeight.SemiBold }, Font, SelectedIndexes.Contains(i + _currentPosition) ? ActiveFontBrush : FontBrush, null, Rect.X + 8, Rect.Y + 21 + i * 21, Rect.Width - 17, 21); } if (Items.Count > _maxItemsVisible) { graphics.FillRectangle(ScrollBarFill, Rect.X + Rect.Width - 10, Rect.Y + 25, 3, Rect.Height - 29); var scrollHeight = Rect.Height - 29; var scrollOnePieceHeight = scrollHeight / (float)Items.Count; var scrollActiveHeight = scrollOnePieceHeight * 7; graphics.FillRectangle(ScrollBarActive, Rect.X + Rect.Width - 10, Rect.Y + 25 + scrollOnePieceHeight * _currentPosition, 3, scrollActiveHeight); } } else { Rect.Height = Height; graphics.OutlineFillRectangle(Border, Fill, Rect.X, Rect.Y, Rect.Width, Rect.Height, 1, 0); graphics.DrawText(new TextHelper(SelectedItems.Cast <string>().Aggregate("", (current, item) => current + $"{item},").TrimEnd(',')) { ParagraphAlignment = ParagraphAlignment.Center, TextAntialiasMode = TextAntialiasMode.Grayscale, FontWeight = FontWeight.SemiBold }, Font, ActiveFontBrush, null, Rect.X + 4, Rect.Y - 1, Rect.Width, 21); graphics.DrawLine(ActiveFontBrush, new Point(Rect.X + Rect.Width - 5, Rect.Y + 8), new Point(Rect.X + Rect.Width - 9, Rect.Y + 12), 2); //arrow graphics.DrawLine(ActiveFontBrush, new Point(Rect.X + Rect.Width - 12, Rect.Y + 8), new Point(Rect.X + Rect.Width - 8, Rect.Y + 12), 2); //arrow } }; base.Draw(graphics, action); }
public void ClearSelection() { SelectedIndexes.Clear(); }