Fill() public method

Sets the WorldLocation and ConsoleLocation properties based on the cell size of the provided console. If absolute positioning is used on the console, then the properties will represent pixels.
This method alters the data of the mouse information based on the provided console. It
public Fill ( IConsole data ) : void
data IConsole The console to get the data from.
return void
        public bool HandlerMouse(IConsole console, MouseInfo info)
        {
            if (console.IsVisible && console.CanUseMouse)
            {
                info.Fill(console);

                bool doDrag = (info.LeftButtonDown && CanMoveWithLeftButton) || (info.RightButtonDown && CanMoveWithRightButton);

                if (info.Console == console && doDrag)
                {
                    // Mouse just went down on us.
                    if (!_mouseDown)
                    {
                        _mouseDown             = true;
                        _mouseLastLocation     = new Point(info.ConsoleLocation.X, info.ConsoleLocation.Y);
                        console.ExclusiveFocus = true;
                    }
                    else
                    {
                        // Mouse has been down, still is
                        Point currentLocation = new Point(info.ConsoleLocation.X, info.ConsoleLocation.Y);

                        if (currentLocation != _mouseLastLocation)
                        {
                            Rectangle viewport = console.TextSurface.RenderArea;

#if SFML
                            viewport.Left += _mouseLastLocation.X - currentLocation.X;
                            viewport.Top  += _mouseLastLocation.Y - currentLocation.Y;
#elif MONOGAME
                            viewport.X += _mouseLastLocation.X - currentLocation.X;
                            viewport.Y += _mouseLastLocation.Y - currentLocation.Y;
#endif
                            _mouseLastLocation = currentLocation;

                            console.TextSurface.RenderArea = viewport;
                        }
                    }

                    return(true);
                }

                if (!doDrag && _mouseDown)
                {
                    console.ExclusiveFocus = false;
                    _mouseDown             = false;
                }
            }

            return(false);
        }
        public bool HandlerMouse(IConsole console, MouseInfo info)
        {
            if (console.IsVisible && console.CanUseMouse)
            {
                info.Fill(console);

                bool doDrag = (info.LeftButtonDown && CanMoveWithLeftButton) || (info.RightButtonDown && CanMoveWithRightButton);

                if (info.Console == console && doDrag)
                {
                    // Mouse just went down on us.
                    if (!_mouseDown)
                    {
                        _mouseDown = true;
                        _mouseLastLocation = new Point(info.ConsoleLocation.X, info.ConsoleLocation.Y);
                        console.ExclusiveFocus = true;
                    }
                    else
                    {
                        // Mouse has been down, still is
                        Point currentLocation = new Point(info.ConsoleLocation.X, info.ConsoleLocation.Y);

                        if (currentLocation != _mouseLastLocation)
                        {
                            Rectangle viewport = console.ViewArea;

                            viewport.X += _mouseLastLocation.X - currentLocation.X;
                            viewport.Y += _mouseLastLocation.Y - currentLocation.Y;
                            _mouseLastLocation = currentLocation;

                            console.ViewArea = viewport;
                        }
                    }

                    return true;
                }

                if (!doDrag && _mouseDown)
                {
                    console.ExclusiveFocus = false;
                    _mouseDown = false;
                }
            }

            return false;
        }
Example #3
0
        /// <summary>
        /// Processes the mouse.
        /// </summary>
        /// <param name="info"></param>
        /// <returns>True when the mouse is over this console.</returns>
        public virtual bool ProcessMouse(MouseInfo info)
        {
            var handlerResult = MouseHandler == null ? false : MouseHandler(this, info);

            if (!handlerResult)
            {
                if (this.IsVisible && this.CanUseMouse)
                {
                    info.Fill(this);

                    if (info.Console == this)
                    {
                        if (this.CanFocus && this.MouseCanFocus && info.LeftClicked)
                        {
                            IsFocused = true;

                            if (IsFocused && this.MoveToFrontOnMouseFocus && this.Parent != null && this.Parent.IndexOf(this) != this.Parent.Count - 1)
                                this.Parent.MoveToTop(this);
                        }

                        if (_isMouseOver != true)
                        {
                            _isMouseOver = true;
                            OnMouseEnter(info);
                        }

                        OnMouseIn(info);

                        if (info.LeftClicked)
                            OnMouseLeftClicked(info);

                        if (info.RightClicked)
                            OnRightMouseClicked(info);

                        return true;
                    }
                    else
                    {
                        if (_isMouseOver)
                        {
                            _isMouseOver = false;
                            OnMouseExit(info);
                        }
                    }
                }
            }

            return handlerResult;
        }
Example #4
0
        public override bool ProcessMouse(MouseInfo info)
        {
            var worldLocation = info.ScreenLocation.WorldLocationToConsole(textSurface.Font.Size.X, textSurface.Font.Size.Y);
            var consoleLocation = new Point(worldLocation.X - _position.X, worldLocation.Y - _position.Y);

            // Check if mouse is within the upper/lower bounds of the console
            if (info.ConsoleLocation.Y >= 0 && info.ConsoleLocation.Y <= textSurface.RenderArea.Height - 1)
            {
                bool isHexRow = info.ConsoleLocation.Y % 2 == 1;
                // Check if mouse is on an alternating row
                if (isHexRow)
                    info.ScreenLocation.X -= textSurface.Font.Size.X / 2;

                info.Fill(this);

                if (info.Console == this)
                {
                    FillHexes(lastCell, 176, lastCellHexRow);
                    lastCell = info.ConsoleLocation.ToIndex(textSurface.Width);
                    lastCellHexRow = isHexRow;
                    FillHexes(lastCell, 45, isHexRow);

                    return true;
                }
            }

            //base.ProcessMouse(info);

            FillHexes(lastCell, 176, lastCellHexRow);

            return true;
        }