private void UpdateCardTooltip() { //todo: if distance to left or right of overlay < tooltip width -> switch side var pos = User32.GetMousePos(); var relativePlayerDeckPos = StackPanelPlayer.PointFromScreen(new Point(pos.X, pos.Y)); var relativeOpponentDeckPos = ListViewOpponent.PointFromScreen(new Point(pos.X, pos.Y)); var relativeSecretsPos = StackPanelSecrets.PointFromScreen(new Point(pos.X, pos.Y)); var visibility = Config.Instance.OverlayCardToolTips ? Visibility.Visible : Visibility.Hidden; //player card tooltips if (PointInsideControl(relativePlayerDeckPos, ListViewPlayer.ActualWidth, ListViewPlayer.ActualHeight)) { //card size = card list height / ammount of cards var cardSize = ListViewPlayer.ActualHeight / ListViewPlayer.Items.Count; var cardIndex = (int)(relativePlayerDeckPos.Y / cardSize); if (cardIndex < 0 || cardIndex >= ListViewPlayer.Items.Count) { return; } ToolTipCard.SetValue(DataContextProperty, ListViewPlayer.Items[cardIndex]); //offset is affected by scaling var topOffset = Canvas.GetTop(StackPanelPlayer) + cardIndex * cardSize * Config.Instance.OverlayPlayerScaling / 100; //prevent tooltip from going outside of the overlay if (topOffset + ToolTipCard.ActualHeight > Height) { topOffset = Height - ToolTipCard.ActualHeight; } SetTooltipPosition(topOffset, StackPanelPlayer); ToolTipCard.Visibility = visibility; } //opponent card tooltips else if (PointInsideControl(relativeOpponentDeckPos, ListViewOpponent.ActualWidth, ListViewOpponent.ActualHeight)) { //card size = card list height / ammount of cards var cardSize = ListViewOpponent.ActualHeight / ListViewOpponent.Items.Count; var cardIndex = (int)(relativeOpponentDeckPos.Y / cardSize); if (cardIndex < 0 || cardIndex >= ListViewOpponent.Items.Count) { return; } ToolTipCard.SetValue(DataContextProperty, ListViewOpponent.Items[cardIndex]); //offset is affected by scaling var topOffset = Canvas.GetTop(StackPanelOpponent) + cardIndex * cardSize * Config.Instance.OverlayOpponentScaling / 100; //prevent tooltip from going outside of the overlay if (topOffset + ToolTipCard.ActualHeight > Height) { topOffset = Height - ToolTipCard.ActualHeight; } SetTooltipPosition(topOffset, StackPanelOpponent); ToolTipCard.Visibility = visibility; } else if (PointInsideControl(relativeSecretsPos, StackPanelSecrets.ActualWidth, StackPanelSecrets.ActualHeight)) { //card size = card list height / ammount of cards var cardSize = StackPanelSecrets.ActualHeight / StackPanelSecrets.Children.Count; var cardIndex = (int)(relativeSecretsPos.Y / cardSize); if (cardIndex < 0 || cardIndex >= StackPanelSecrets.Children.Count) { return; } ToolTipCard.SetValue(DataContextProperty, StackPanelSecrets.Children[cardIndex].GetValue(DataContextProperty)); //offset is affected by scaling var topOffset = Canvas.GetTop(StackPanelSecrets) + cardIndex * cardSize * Config.Instance.OverlayOpponentScaling / 100; //prevent tooltip from going outside of the overlay if (topOffset + ToolTipCard.ActualHeight > Height) { topOffset = Height - ToolTipCard.ActualHeight; } SetTooltipPosition(topOffset, StackPanelSecrets); ToolTipCard.Visibility = visibility; } else { ToolTipCard.Visibility = Visibility.Hidden; HideAdditionalToolTips(); } if (ToolTipCard.Visibility == Visibility.Visible) { var card = ToolTipCard.GetValue(DataContextProperty) as Card; if (card != null) { if (_lastToolTipCardId != card.Id) { _lastToolTipCardId = card.Id; ShowAdditionalToolTips(); } } else { HideAdditionalToolTips(); } } else { HideAdditionalToolTips(); _lastToolTipCardId = string.Empty; } }
private void MouseInputOnMouseMoved(object sender, EventArgs eventArgs) { if (!_lmbDown || Visibility != Visibility.Visible) { return; } var pos = User32.GetMousePos(); var newPos = new Point(pos.X, pos.Y); var delta = new Point((newPos.X - _mousePos.X) * 100, (newPos.Y - _mousePos.Y) * 100); var panel = _selectedUIElement as StackPanel; if (panel != null) { if (panel.Name.Contains("Player")) { if (_resizeElement) { Config.Instance.PlayerDeckHeight += delta.Y / Height; _movableElements[panel].Height = Height * Config.Instance.PlayerDeckHeight / 100; } else { Config.Instance.PlayerDeckTop += delta.Y / Height; Config.Instance.PlayerDeckLeft += delta.X / Width; Canvas.SetTop(_movableElements[panel], Height * Config.Instance.PlayerDeckTop / 100); Canvas.SetLeft(_movableElements[panel], Width * Config.Instance.PlayerDeckLeft / 100 - StackPanelPlayer.ActualWidth * Config.Instance.OverlayPlayerScaling / 100); } } else if (panel.Name.Contains("Opponent")) { if (_resizeElement) { Config.Instance.OpponentDeckHeight += delta.Y / Height; _movableElements[panel].Height = Height * Config.Instance.OpponentDeckHeight / 100; } else { Config.Instance.OpponentDeckTop += delta.Y / Height; Config.Instance.OpponentDeckLeft += delta.X / Width; Canvas.SetTop(_movableElements[panel], Height * Config.Instance.OpponentDeckTop / 100); Canvas.SetLeft(_movableElements[panel], Width * Config.Instance.OpponentDeckLeft / 100); } } else if (panel.Name.Contains("Secret")) { Config.Instance.SecretsTop += delta.Y / Height; Config.Instance.SecretsLeft += delta.X / Width; Canvas.SetTop(_movableElements[panel], Height * Config.Instance.SecretsTop / 100); Canvas.SetLeft(_movableElements[panel], Width * Config.Instance.SecretsLeft / 100); } } var timer = _selectedUIElement as HearthstoneTextBlock; if (timer != null) { if (timer.Name.Contains("Turn")) { Config.Instance.TimersVerticalPosition += delta.Y / Height; Config.Instance.TimersHorizontalPosition += delta.X / Width; Canvas.SetTop(_movableElements[timer], Height * Config.Instance.TimersVerticalPosition / 100); Canvas.SetLeft(_movableElements[timer], Width * Config.Instance.TimersHorizontalPosition / 100); } } _mousePos = newPos; }