コード例 #1
0
        protected override void OnMouseIn(SadConsole.Input.MouseInfo data)
        {
            if (data.Cell != null && TrackedRegion.Contains(data.ConsoleLocation.X, data.ConsoleLocation.Y))
            {
                // Draw the character index and value in the status area
                string[] items = new string[] { "Index: ", data.Cell.CharacterIndex.ToString() + " ", ((char)data.Cell.CharacterIndex).ToString() };

                items[2] = items[2].PadRight(this.CellData.Width - 2 - (items[0].Length + items[1].Length));

                var text = items[0].CreateColored(Color.LightBlue, Theme.BorderStyle.Background, null) +
                           items[1].CreateColored(Color.LightCoral, Color.Black, null) +
                           items[2].CreateColored(Color.LightCyan, Color.Black, null);

                text.IgnoreBackground = true;
                text.IgnoreEffect     = true;

                CellData.Print(1, this.CellData.Height - 2, text);

                // Set the special effect on the current known character and clear it on the last known
                if (_lastInfo == null)
                {
                }
                else if (_lastInfo.ConsoleLocation != data.ConsoleLocation)
                {
                    this.CellData.SetEffect(_lastInfo.Cell,
                                            new SadConsole.Effects.Fade()
                    {
                        FadeBackground        = true,
                        FadeForeground        = true,
                        DestinationForeground = new ColorGradient(_highlightedCellEffect.Foreground, _lastInfo.Cell.Foreground),
                        DestinationBackground = new ColorGradient(_highlightedCellEffect.Background, _lastInfo.Cell.Background),
                        FadeDuration          = 0.3d,
                        RemoveOnFinished      = true,
                        UseCellBackground     = false,
                        UseCellForeground     = false,
                        CloneOnApply          = true
                    }
                                            );
                }

                this.CellData.SetEffect(data.Cell, _highlightedCellEffect);
                _lastInfo = data.Clone();
            }
            else
            {
                DrawSelectedItemString();

                // Clear the special effect on the last known character
                if (_lastInfo != null)
                {
                    this.CellData.SetEffect(_lastInfo.Cell, null);
                    _lastInfo = null;
                }
            }

            base.OnMouseIn(data);
        }