public VertScrollBar(Vector2 topLeft, float height) { this.topLeft = topLeft; this.bottomRight = new Vector2(topLeft.X + width, topLeft.Y + height); base.UIC_Initialize(); InputManager.BindMouse(() => { if (active) { Point m = InputManager.GetMousePos(); if ((BoundBox.Contains(m) || selected) && !selectedOutside) { float dist = ((m.Y - (BoundBoxPart.Bottom - BoundBoxPart.Top) / 2) - BoundBox.Top); dist = height - dist; float percent = dist / height; curValue = maxValue * percent; if (curValue < minValue) { curValue = minValue; } if (curValue > maxValue) { curValue = maxValue; } selected = true; } else { selectedOutside = true; } } }, MouseButton.Left, true, true); InputManager.BindMouse(() => { selectedOutside = false; selected = false; }, MouseButton.Left, false, false); }
public void computeSelected() { Point mousePos = InputManager.GetMousePos(); if (BoundBox.Contains(mousePos)) { if (mousePos.X - Position.X <= width) { float off = mousePos.Y - Position.Y; float which = off / 15; which = (float)Math.Floor(which); int oldSel = selectedIndex; selectedIndex = (int)(which + vertOffset); if (selectedIndex >= dataSource.Count) { selectedIndex = -1; } } } else { selectedIndex = -1; } }