private void itemLeave(BinListItem item) { if (overItem == item) { overItem = null; } }
private void itemClick(BinListItem item) { Main.SetFocus(this); if (lastSelectedBin != null && Main.KeyboardState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftShift)) { int start = Math.Min(lastSelectedBin.Offset, item.Bin.Offset); int end = Math.Max(lastSelectedBin.Offset, item.Bin.Offset); if (end - start > 0) { for (int i = start; i <= end; i++) { Bin rangeItem = bins[i]; if (!Selection.ContainsKey(rangeItem.Offset)) { Selection.Add(rangeItem.Offset, rangeItem); } } Layout(); } } if (lastSelectedBin != null) { lastSelectedBin.Selected = false; itemSelectedCallback(null); } if (item.Selected) { lastSelectedBin = item.Bin; lastSelectedBin.Selected = true; if (!Selection.ContainsKey(item.Bin.Offset)) { Selection.Add(item.Bin.Offset, item.Bin); } itemSelectedCallback(item); } else { if (Selection.ContainsKey(item.Bin.Offset)) { Selection.Remove(item.Bin.Offset); } lastSelectedBin = null; } }
private void itemEnter(BinListItem item) { overItem = item; }
public void Layout() { scrollbar.Visible = bins.Count > 0; if (bins.Count == 0) { while (items.Count > 0) { RemoveChild(items[0]); items.RemoveAt(0); } return; } dirty = false; int x = 100; int y = 2; int ctr = 0; BinListItem lineStartItem = null; BinListItem lineEndItem = null; for (int i = startIndex; i < bins.Count && y < Transform.Height - itemSize.Y - itemSpace.Y; i++) { Bin bin = bins[i]; BinListItem item; if (ctr >= items.Count) { item = new BinListItem(itemClick, itemEnter, itemLeave); item.CommentColumnWidth = commentColumnWidth; items.Add(item); AddChild(item); } else { item = items[ctr]; } if (lineStartItem == null) { lineStartItem = item; } item.Transform.Height = itemSize.Y; item.LineEnd = null; item.Bin = bin; item.ID = ctr; item.Selected = Selection.ContainsKey(item.Bin.Offset); if (x + item.Transform.Width + itemSpace.X > Transform.Width - commentColumnWidth || item.Bin.LineBreak) { lineStartItem.LineEnd = lineEndItem; x = 100; y += itemSize.Y + itemSpace.Y; lineStartItem = item; lineEndItem = item; } else { lineEndItem = item; } item.Transform.X = x; item.Transform.Y = y; x += item.Transform.Width + itemSpace.X; ctr++; } if (lineStartItem != null) { lineStartItem.LineEnd = lineEndItem; } if (ctr < bins.Count && ctr > 0) { ctr--; } while (items.Count > ctr) { RemoveChild(items[items.Count - 1]); items.RemoveAt(items.Count - 1); } scrollbar.Visible = items.Count != bins.Count; scrollbar.Layout(); }