コード例 #1
0
        public void ShowAdditionalToolTips()
        {
            if (!Config.Instance.AdditionalOverlayTooltips)
            {
                return;
            }
            var card = ToolTipCard.DataContext as Card;

            if (card == null)
            {
                return;
            }
            if (!CardIds.SubCardIds.Keys.Contains(card.Id))
            {
                HideAdditionalToolTips();
                return;
            }

            StackPanelAdditionalTooltips.Children.Clear();
            foreach (var id in CardIds.SubCardIds[card.Id])
            {
                var tooltip = new CardToolTip();
                tooltip.SetValue(DataContextProperty, Game.GetCardFromId(id));
                StackPanelAdditionalTooltips.Children.Add(tooltip);
            }

            StackPanelAdditionalTooltips.UpdateLayout();

            //set position
            var tooltipLeft = Canvas.GetLeft(ToolTipCard);
            var left        = tooltipLeft < Width / 2
                                           ? tooltipLeft + ToolTipCard.ActualWidth
                                           : tooltipLeft - StackPanelAdditionalTooltips.ActualWidth;

            Canvas.SetLeft(StackPanelAdditionalTooltips, left);
            var top = Canvas.GetTop(ToolTipCard) - (StackPanelAdditionalTooltips.ActualHeight / 2 - ToolTipCard.ActualHeight / 2);

            if (top < 0)
            {
                top = 0;
            }
            else if (top + StackPanelAdditionalTooltips.ActualHeight > Height)
            {
                top = Height - StackPanelAdditionalTooltips.ActualHeight;
            }
            Canvas.SetTop(StackPanelAdditionalTooltips, top);

            StackPanelAdditionalTooltips.Visibility = Visibility.Visible;
        }
コード例 #2
0
        public void ShowAdditionalToolTips()
        {
            if (!Config.Instance.AdditionalOverlayTooltips)
                return;
            var card = ToolTipCard.DataContext as Card;
            if (card == null)
                return;
            if (!CardIds.SubCardIds.Keys.Contains(card.Id))
            {
                HideAdditionalToolTips();
                return;
            }

            StackPanelAdditionalTooltips.Children.Clear();
            foreach (var id in CardIds.SubCardIds[card.Id])
            {
                var tooltip = new CardToolTip();
                tooltip.SetValue(DataContextProperty, Database.GetCardFromId(id));
                StackPanelAdditionalTooltips.Children.Add(tooltip);
            }

            StackPanelAdditionalTooltips.UpdateLayout();

            //set position
            var tooltipLeft = Canvas.GetLeft(ToolTipCard);
            var left = tooltipLeft < Width / 2 ? tooltipLeft + ToolTipCard.ActualWidth : tooltipLeft - StackPanelAdditionalTooltips.ActualWidth;

            Canvas.SetLeft(StackPanelAdditionalTooltips, left);
            var top = Canvas.GetTop(ToolTipCard) - (StackPanelAdditionalTooltips.ActualHeight / 2 - ToolTipCard.ActualHeight / 2);
            if (top < 0)
                top = 0;
            else if (top + StackPanelAdditionalTooltips.ActualHeight > Height)
                top = Height - StackPanelAdditionalTooltips.ActualHeight;
            Canvas.SetTop(StackPanelAdditionalTooltips, top);

            StackPanelAdditionalTooltips.Visibility = Visibility.Visible;
        }