/// <summary> /// Processes the mouse. If allowed, will move the console around with the mouse. /// </summary> /// <param name="info">The mouse state.</param> /// <returns></returns> public override bool ProcessMouse(Input.MouseInfo info) { if (_titleWidth != 0 && _isVisible) { info.Fill(this); if (_isDragging && info.LeftButtonDown) { if (base.UseAbsolutePositioning) { Position = new Point(info.ScreenLocation.X - (_previousMouseInfo.ScreenLocation.X - _consoleAtDragAbsPos.X), info.ScreenLocation.Y - (_previousMouseInfo.ScreenLocation.Y - _consoleAtDragAbsPos.Y)); } else { Position = new Point(info.WorldLocation.X - _previousMouseInfo.ConsoleLocation.X, info.WorldLocation.Y - _previousMouseInfo.ConsoleLocation.Y); } return(true); } // Stopped dragging if (_isDragging && !info.LeftButtonDown) { _isDragging = false; ExclusiveFocus = _prevousMouseExclusiveDrag; return(true); } // Left button freshly down and we're not already dragging, check to see if in title if (!_isDragging && !_previousMouseInfo.LeftButtonDown && info.LeftButtonDown) { if (info.ConsoleLocation.Y == 0 && info.ConsoleLocation.X >= _titleLocationX && info.ConsoleLocation.X < _titleLocationX + _titleWidth) { _prevousMouseExclusiveDrag = ExclusiveFocus; // Mouse is in the title bar ExclusiveFocus = true; _isDragging = true; _consoleAtDragAbsPos = base.Position; if (this.MouseCanFocus) { if (Engine.ActiveConsole != this) { Engine.ActiveConsole = this; } if (this.Parent != null && this.Parent.IndexOf(this) != this.Parent.Count - 1) { this.Parent.MoveToTop(this); } } } } _previousMouseInfo = info.Clone(); } return(base.ProcessMouse(info)); }
protected override void OnMouseEnter(SadConsole.Input.MouseInfo info) { if (_lastInfo != null) { _lastInfo.Cell.Effect = null; } base.OnMouseEnter(info); }
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); }
protected override void OnMouseExit(SadConsole.Input.MouseInfo info) { if (_lastInfo != null) { _lastInfo.Cell.Effect = null; } DrawSelectedItemString(); base.OnMouseExit(info); }
protected override void OnMouseLeftClicked(SadConsole.Input.MouseInfo data) { if (data.Cell != null && TrackedRegion.Contains(data.ConsoleLocation.X, data.ConsoleLocation.Y)) { SelectedCharacterIndex = data.Cell.CharacterIndex; } else if (data.ConsoleLocation.X == this.CellData.Width - 1 && data.ConsoleLocation.Y == 0) { Hide(); } base.OnMouseLeftClicked(data); }
private void AfterDeserialized(StreamingContext context) { _previousMouseInfo = new Input.MouseInfo(); //Redraw(); }
/// <summary> /// Processes the mouse. If allowed, will move the console around with the mouse. /// </summary> /// <param name="info">The mouse state.</param> /// <returns></returns> public override bool ProcessMouse(Input.MouseInfo info) { if (_titleWidth != 0 && _isVisible) { info.Fill(this); if (_isDragging && info.LeftButtonDown) { if (base.UseAbsolutePositioning) Position = new Point(info.ScreenLocation.X - (_previousMouseInfo.ScreenLocation.X - _consoleAtDragAbsPos.X), info.ScreenLocation.Y - (_previousMouseInfo.ScreenLocation.Y - _consoleAtDragAbsPos.Y)); else Position = new Point(info.WorldLocation.X - _previousMouseInfo.ConsoleLocation.X, info.WorldLocation.Y - _previousMouseInfo.ConsoleLocation.Y); return true; } // Stopped dragging if (_isDragging && !info.LeftButtonDown) { _isDragging = false; ExclusiveFocus = _prevousMouseExclusiveDrag; return true; } // Left button freshly down and we're not already dragging, check to see if in title if (!_isDragging && !_previousMouseInfo.LeftButtonDown && info.LeftButtonDown) { if (info.ConsoleLocation.Y == 0 && info.ConsoleLocation.X >= _titleLocationX && info.ConsoleLocation.X < _titleLocationX + _titleWidth) { _prevousMouseExclusiveDrag = ExclusiveFocus; // Mouse is in the title bar ExclusiveFocus = true; _isDragging = true; _consoleAtDragAbsPos = base.Position; if (this.MouseCanFocus) { if (Engine.ActiveConsole != this) Engine.ActiveConsole = this; if (this.Parent != null && this.Parent.IndexOf(this) != this.Parent.Count - 1) this.Parent.MoveToTop(this); } } } _previousMouseInfo = info.Clone(); } return base.ProcessMouse(info); }
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.GlyphIndex.ToString() + " ", ((char)data.Cell.GlyphIndex).ToString() }; items[2] = items[2].PadRight(textSurface.Width - 2 - (items[0].Length + items[1].Length)); var text = items[0].CreateColored(ColorHelper.LightBlue, Theme.BorderStyle.Background, null) + items[1].CreateColored(ColorHelper.LightCoral, Color.Black, null) + items[2].CreateColored(ColorHelper.LightCyan, Color.Black, null); text.IgnoreBackground = true; text.IgnoreEffect = true; Print(1, textSurface.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) { effects.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 } ); } effects.SetEffect(data.Cell, _highlightedCellEffect); _lastInfo = data.Clone(); } else { DrawSelectedItemString(); // Clear the special effect on the last known character if (_lastInfo != null) { effects.SetEffect(_lastInfo.Cell, null); _lastInfo = null; } } base.OnMouseIn(data); }