private void SetToolTip(FrameworkElement element, DominionBase.ICard card) { ToolTip tt = new System.Windows.Controls.ToolTip(); ToolTipCard ttc = new ToolTipCard(); tt.Content = ttc; ToolTipService.SetShowOnDisabled(element, true); ToolTipService.SetHasDropShadow(element, true); if (wMain.Settings != null) { if (wMain.Settings.ToolTipShowDuration == ToolTipShowDuration.Off) { ToolTipService.SetIsEnabled(element, false); } else { ToolTipService.SetIsEnabled(element, true); ToolTipService.SetShowDuration(element, (int)wMain.Settings.ToolTipShowDuration); } } ToolTipService.SetInitialShowDelay(element, 2000); ToolTipService.SetBetweenShowDelay(element, 250); ttc.ICard = card; element.ToolTip = tt; }
private async Task UpdateCardTooltip() { var pos = User32.GetMousePos(); var relativePlayerDeckPos = ViewBoxPlayer.PointFromScreen(new Point(pos.X, pos.Y)); var relativeOpponentDeckPos = ViewBoxOpponent.PointFromScreen(new Point(pos.X, pos.Y)); var relativeSecretsPos = StackPanelSecrets.PointFromScreen(new Point(pos.X, pos.Y)); var relativeCardMark = _cardMarks.Select(x => new { Label = x, Pos = x.PointFromScreen(new Point(pos.X, pos.Y)) }); var visibility = (Config.Instance.OverlayCardToolTips && !Config.Instance.OverlaySecretToolTipsOnly) ? Visible : Hidden; var cardMark = relativeCardMark.FirstOrDefault( x => x.Label.IsVisible && PointInsideControl(x.Pos, x.Label.ActualWidth, x.Label.ActualHeight, new Thickness(3, 1, 7, 1))); if (!Config.Instance.HideOpponentCardMarks && cardMark != null) { var index = _cardMarks.IndexOf(cardMark.Label); var card = _game.Opponent.Hand.FirstOrDefault(x => x.GetTag(GameTag.ZONE_POSITION) == index + 1 && x.HasCardId && !x.Info.Hidden)?.Card; if (card != null) { ToolTipCard.SetValue(DataContextProperty, card); var topOffset = Canvas.GetTop(_cardMarks[index]) + _cardMarks[index].ActualHeight; var leftOffset = Canvas.GetLeft(_cardMarks[index]) + _cardMarks[index].ActualWidth * index; Canvas.SetTop(ToolTipCard, topOffset); Canvas.SetLeft(ToolTipCard, leftOffset); ToolTipCard.Visibility = Config.Instance.OverlayCardMarkToolTips ? Visible : Hidden; } } //player card tooltips else if (ListViewPlayer.Visibility == Visible && StackPanelPlayer.Visibility == Visible && PointInsideControl(relativePlayerDeckPos, ListViewPlayer.ActualWidth, ListViewPlayer.ActualHeight)) { //card size = card list height / ammount of cards var cardSize = ViewBoxPlayer.ActualHeight / ListViewPlayer.Items.Count; var cardIndex = (int)(relativePlayerDeckPos.Y / cardSize); if (cardIndex < 0 || cardIndex >= ListViewPlayer.Items.Count) { return; } ToolTipCard.SetValue(DataContextProperty, ListViewPlayer.Items.Cast <AnimatedCard>().ElementAt(cardIndex).Card); var centeredListOffset = Config.Instance.OverlayCenterPlayerStackPanel ? (BorderStackPanelPlayer.ActualHeight - StackPanelPlayer.ActualHeight) / 2 : 0; //offset is affected by scaling var topOffset = Canvas.GetTop(BorderStackPanelPlayer) + centeredListOffset + GetListViewOffset(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, BorderStackPanelPlayer); ToolTipCard.Visibility = visibility; } //opponent card tooltips else if (ListViewOpponent.Visibility == Visible && StackPanelOpponent.Visibility == Visible && PointInsideControl(relativeOpponentDeckPos, ListViewOpponent.ActualWidth, ListViewOpponent.ActualHeight)) { //card size = card list height / ammount of cards var cardSize = ViewBoxOpponent.ActualHeight / ListViewOpponent.Items.Count; var cardIndex = (int)(relativeOpponentDeckPos.Y / cardSize); if (cardIndex < 0 || cardIndex >= ListViewOpponent.Items.Count) { return; } ToolTipCard.SetValue(DataContextProperty, ListViewOpponent.Items.Cast <AnimatedCard>().ElementAt(cardIndex).Card); var centeredListOffset = Config.Instance.OverlayCenterOpponentStackPanel ? (BorderStackPanelOpponent.ActualHeight - StackPanelOpponent.ActualHeight) / 2 : 0; //offset is affected by scaling var topOffset = Canvas.GetTop(BorderStackPanelOpponent) + centeredListOffset + GetListViewOffset(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, BorderStackPanelOpponent); ToolTipCard.Visibility = visibility; } else if (StackPanelSecrets.Visibility == Visible && 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 = Config.Instance.OverlaySecretToolTipsOnly ? Visible : visibility; } else { ToolTipCard.Visibility = Hidden; HideAdditionalToolTips(); } if (ToolTipCard.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; } if (!Config.Instance.ForceMouseHook) { if (Config.Instance.ExtraFeatures) { var relativePos = PointFromScreen(new Point(pos.X, pos.Y)); if ((StackPanelSecrets.IsVisible && (PointInsideControl(StackPanelSecrets.PointFromScreen(new Point(pos.X, pos.Y)), StackPanelSecrets.ActualWidth, StackPanelSecrets.ActualHeight, new Thickness(20))) || relativePos.X < 170 && relativePos.Y > Height - 120)) { if (_mouseInput == null) { HookMouse(); } } else if (_mouseInput != null && !((_isFriendsListOpen.HasValue && _isFriendsListOpen.Value) || await Helper.FriendsListOpen())) { UnHookMouse(); } } else if (_mouseInput != null) { UnHookMouse(); } } if (!Config.Instance.AlwaysShowGoldProgress) { if (_game.IsInMenu && PointInsideControl(RectGoldDisplay.PointFromScreen(new Point(pos.X, pos.Y)), RectGoldDisplay.ActualWidth, RectGoldDisplay.ActualHeight)) { UpdateGoldProgress(); GoldProgressGrid.Visibility = Visible; } else { GoldProgressGrid.Visibility = Hidden; } } }
private void SetToolTip(FrameworkElement element, DominionBase.ICard card) { ToolTip tt = new System.Windows.Controls.ToolTip(); ToolTipCard ttc = new ToolTipCard(); tt.Content = ttc; ToolTipService.SetShowOnDisabled(element, true); ToolTipService.SetHasDropShadow(element, true); if (wMain.Settings != null) { if (wMain.Settings.ToolTipShowDuration == ToolTipShowDuration.Off) ToolTipService.SetIsEnabled(element, false); else { ToolTipService.SetIsEnabled(element, true); ToolTipService.SetShowDuration(element, (int)wMain.Settings.ToolTipShowDuration); } } ToolTipService.SetInitialShowDelay(element, 2000); ToolTipService.SetBetweenShowDelay(element, 250); ttc.ICard = card; element.ToolTip = tt; }
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 UpdateCardTooltip() { var pos = User32.GetMousePos(); var relativePlayerDeckPos = ViewBoxPlayer.PointFromScreen(new Point(pos.X, pos.Y)); var relativeOpponentDeckPos = ViewBoxOpponent.PointFromScreen(new Point(pos.X, pos.Y)); var relativeSecretsPos = StackPanelSecrets.PointFromScreen(new Point(pos.X, pos.Y)); var relativeCardMark = _cardMarks.Select(x => new { Label = x, Pos = x.PointFromScreen(new Point(pos.X, pos.Y)) }); var visibility = (Config.Instance.OverlayCardToolTips && !Config.Instance.OverlaySecretToolTipsOnly) ? Visible : Hidden; ToolTipCard.CardSetToolTip.Visibility = Config.Instance.OverlaySetToolTips ? Visible : Collapsed; ToolTipCard.CreatedByVisibility = Collapsed; var cardMark = relativeCardMark.FirstOrDefault( x => x.Label.IsVisible && PointInsideControl(x.Pos, x.Label.ActualWidth, x.Label.ActualHeight, new Thickness(3, 1, 7, 1))); if (!Config.Instance.HideOpponentCardMarks && cardMark != null) { var index = _cardMarks.IndexOf(cardMark.Label); var card = _game.Opponent.Hand.FirstOrDefault(x => x.GetTag(GameTag.ZONE_POSITION) == index + 1 && x.HasCardId && !x.Info.Hidden)?.Card; var creatorCard = _cardMarks[index].SourceCard; if (card != null || creatorCard != null) { ToolTipCard.SetValue(DataContextProperty, card ?? creatorCard); var offset = _cardMarks[index].ActualHeight * 1.25; var topOffset = Canvas.GetTop(_cardMarks[index]) + offset; var leftOffset = Canvas.GetLeft(_cardMarks[index]) + offset; Canvas.SetTop(ToolTipCard, topOffset); Canvas.SetLeft(ToolTipCard, leftOffset); ToolTipCard.Visibility = Config.Instance.OverlayCardMarkToolTips ? Visible : Hidden; ToolTipCard.CreatedByVisibility = card != null ? Collapsed : Visible; } else { ToolTipCard.Visibility = Hidden; ToolTipCard.CreatedByVisibility = Collapsed; } } //player card tooltips else if (ListViewPlayer.Visibility == Visible && StackPanelPlayer.Visibility == Visible && PointInsideControl(relativePlayerDeckPos, ListViewPlayer.ActualWidth, ListViewPlayer.ActualHeight)) { //card size = card list height / amount of cards var cardSize = ViewBoxPlayer.ActualHeight / ListViewPlayer.Items.Count; var cardIndex = (int)(relativePlayerDeckPos.Y / cardSize); if (cardIndex < 0 || cardIndex >= ListViewPlayer.Items.Count) { return; } ToolTipCard.SetValue(DataContextProperty, ListViewPlayer.Items.Cast <AnimatedCard>().ElementAt(cardIndex).Card); var centeredListOffset = Config.Instance.OverlayCenterPlayerStackPanel ? (BorderStackPanelPlayer.ActualHeight - StackPanelPlayer.ActualHeight) / 2 : 0; //offset is affected by scaling var topOffset = Canvas.GetTop(BorderStackPanelPlayer) + centeredListOffset + GetListViewOffset(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, BorderStackPanelPlayer); ToolTipCard.Visibility = visibility; } //opponent card tooltips else if (ListViewOpponent.Visibility == Visible && StackPanelOpponent.Visibility == Visible && PointInsideControl(relativeOpponentDeckPos, ListViewOpponent.ActualWidth, ListViewOpponent.ActualHeight)) { //card size = card list height / amount of cards var cardSize = ViewBoxOpponent.ActualHeight / ListViewOpponent.Items.Count; var cardIndex = (int)(relativeOpponentDeckPos.Y / cardSize); if (cardIndex < 0 || cardIndex >= ListViewOpponent.Items.Count) { return; } ToolTipCard.SetValue(DataContextProperty, ListViewOpponent.Items.Cast <AnimatedCard>().ElementAt(cardIndex).Card); var centeredListOffset = Config.Instance.OverlayCenterOpponentStackPanel ? (BorderStackPanelOpponent.ActualHeight - StackPanelOpponent.ActualHeight) / 2 : 0; //offset is affected by scaling var topOffset = Canvas.GetTop(BorderStackPanelOpponent) + centeredListOffset + GetListViewOffset(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, BorderStackPanelOpponent); ToolTipCard.Visibility = visibility; } else if (StackPanelSecrets.Visibility == Visible && PointInsideControl(relativeSecretsPos, StackPanelSecrets.ActualWidth, StackPanelSecrets.ActualHeight)) { //card size = card list height / amount 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 = Config.Instance.OverlaySecretToolTipsOnly ? Visible : visibility; } else if (BgsTopBar.Visibility == Visible && BattlegroundsMinionsPanel.Visibility == Visible && BattlegroundsMinionsPanel.ActiveTier > 0) { var found = false; foreach (var group in BattlegroundsMinionsPanel.Groups) { var cardList = group.Cards; if (!group.IsVisible || !cardList.IsVisible) { continue; } var relativePos = cardList.PointFromScreen(new Point(pos.X, pos.Y)); if (PointInsideControl(relativePos, cardList.ActualWidth, cardList.ActualHeight)) { var cards = cardList.ItemsControl.Items; var cardSize = cardList.ActualHeight / cards.Count; var cardIndex = (int)(relativePos.Y / cardSize); if (cardIndex < 0 || cardIndex >= cards.Count) { return; } var card = cards.GetItemAt(cardIndex) as AnimatedCard; if (card == null) { return; } ToolTipCard.SetValue(DataContextProperty, card.GetValue(DataContextProperty)); //offset is affected by scaling var cardListPos = cardList.TransformToAncestor(CanvasInfo).Transform(new Point(0, 0)); var topOffset = cardListPos.Y + cardIndex * cardSize * AutoScaling; //prevent tooltip from going outside of the overlay if (topOffset + ToolTipCard.ActualHeight > Height) { topOffset = Height - ToolTipCard.ActualHeight; } Canvas.SetTop(ToolTipCard, topOffset); Canvas.SetLeft(ToolTipCard, cardListPos.X - ToolTipCard.ActualWidth + 22); ToolTipCard.Visibility = visibility; found = true; } } if (!found) { ToolTipCard.Visibility = Hidden; HideAdditionalToolTips(); } } else { ToolTipCard.Visibility = Hidden; HideAdditionalToolTips(); } if (ToolTipCard.Visibility == Visible) { if (ToolTipCard.GetValue(DataContextProperty) is Card card) { if (_lastToolTipCardId != card.Id) { _lastToolTipCardId = card.Id; ShowAdditionalToolTips(); } } else { HideAdditionalToolTips(); } } else { HideAdditionalToolTips(); _lastToolTipCardId = string.Empty; } if (!Config.Instance.ForceMouseHook) { if (Config.Instance.ExtraFeatures) { var relativePos = PointFromScreen(new Point(pos.X, pos.Y)); if ((StackPanelSecrets.IsVisible && (PointInsideControl(StackPanelSecrets.PointFromScreen(new Point(pos.X, pos.Y)), StackPanelSecrets.ActualWidth, StackPanelSecrets.ActualHeight, new Thickness(20))) || relativePos.X < 170 && relativePos.Y > Height - 120)) { if (_mouseInput == null) { HookMouse(); } } else if (_mouseInput != null && !((_isFriendsListOpen.HasValue && _isFriendsListOpen.Value) || Reflection.IsFriendsListVisible())) { UnHookMouse(); } } else if (_mouseInput != null) { UnHookMouse(); } } }