Exemplo n.º 1
0
    protected override void OnUpdated()
    {
        var rows = items.Count / Columns;

        if (items.Count % Columns != 0)
        {
            rows++;
        }

        var y = camera.Src.Y - asd.Engine.Mouse.MiddleButton.WheelRotation * 30;

        y          = Math.Max(0.0f, y);
        y          = Math.Min(rows * ItemOffset.Y - 480 + 24 + 60, y);
        camera.Src = new asd.RectI(
            camera.Src.X,
            (int)y,
            camera.Src.Width,
            camera.Src.Height);

        var mouse = new asd.CircleShape();

        mouse.Position      = asd.Engine.Mouse.Position + new asd.Vector2DF(0, camera.Src.Y);
        mouse.OuterDiameter = 2;

        if (activeItem != null && !activeItem.Shape.GetIsCollidedWith(mouse))
        {
            activeItem.Disactivate();
            activeItem = null;
            browser.ShowInfo(null);
        }

        foreach (var item in items)
        {
            if (item.Shape.GetIsCollidedWith(mouse))
            {
                if (item != activeItem)
                {
                    item.Activate();
                    activeItem = item;
                    browser.ShowInfo(item.Sample);
                }
                if (asd.Engine.Mouse.LeftButton.ButtonState == asd.ButtonState.Push)
                {
                    browser.Selected = item.Sample;
                }
                break;
            }
        }
    }