Beispiel #1
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);
        }
Beispiel #2
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)
                {
                    if (!SkipMouseDataFill)
                    {
                        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);
        }