コード例 #1
0
        protected override void OnMouseLeftClicked(SadConsole.Input.MouseInfo data)
        {
            if (data.Cell != null && TrackedRegion.Contains(data.ConsoleLocation.X, data.ConsoleLocation.Y))
            {
                SelectedCharacterIndex = data.Cell.GlyphIndex;
            }
            else if (data.ConsoleLocation.X == textSurface.Width - 1 && data.ConsoleLocation.Y == 0)
            {
                Hide();
            }

            base.OnMouseLeftClicked(data);
        }
コード例 #2
0
        /// <summary>
        /// Fills the specified area.
        /// </summary>
        /// <param name="area">The area to fill.</param>
        /// <param name="foreground">Foregorund of every cell. If null, skips.</param>
        /// <param name="background">Foregorund of every cell. If null, skips.</param>
        /// <param name="glyph">Glyph of every cell. If null, skips.</param>
        /// <param name="spriteEffect">Sprite effect of every cell. If null, skips.</param>
        public Cell[] Fill(Rectangle area, Color?foreground, Color?background, int?glyph, SpriteEffects?spriteEffect = null)
        {
            // Check for valid rect
            Rectangle consoleArea = new Rectangle(0, 0, textSurface.Width, textSurface.Height);

            if (consoleArea.Contains(area))
            {
                var cells     = new Cell[consoleArea.Width * consoleArea.Height];
                int cellIndex = 0;

                for (int x = area.Left; x < area.Left + area.Width; x++)
                {
                    for (int y = area.Top; y < area.Top + area.Height; y++)
                    {
                        Cell cell = textSurface[y * textSurface.Width + x];

                        if (glyph.HasValue)
                        {
                            cell.GlyphIndex = glyph.Value;
                        }
                        if (background.HasValue)
                        {
                            cell.Background = background.Value;
                        }
                        if (foreground.HasValue)
                        {
                            cell.Foreground = foreground.Value;
                        }
                        if (spriteEffect.HasValue)
                        {
                            cell.SpriteEffect = spriteEffect.Value;
                        }

                        cells[cellIndex] = cell;
                        cellIndex++;
                    }
                }

                return(cells);
            }

            return(new Cell[] { });
        }