示例#1
0
        private void CardCanvas_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            double cardCanvasWidth  = e.NewSize.Width;
            double cardCanvasHeight = e.NewSize.Height;
            double frameWidth       = 0.95 * e.NewSize.Width;
            double frameHeight      = 0.9 * e.NewSize.Width;

            AdjustSize(cardCanvasWidth, cardCanvasHeight, frameWidth, frameHeight);

            const double FontScalePower   = 0.12;
            double       fontSizeCardType = Math.Max(MinimumFontSize, cardCanvasHeight * FontScalePower);

            TextBoxPower.FontSize = fontSizeCardType;

            AdjustCardNameSize(frameWidth, frameHeight, fontScale: 0.07, yPositionScale: 0.07);

            Artwork.Width  = (1 - 2 * FrameOffset) * frameWidth;
            Artwork.Height = 0.8 * frameHeight;
            SetLeft(Artwork, (frameWidth - Artwork.Width) / 2);
            SetTop(Artwork, 0.115 * frameWidth);

            TextBoxPower.Measure(new Size(frameWidth, 0.2 * frameHeight));
            TextBoxPower.Arrange(new Rect(TextBoxPower.DesiredSize));
            SetLeft(TextBoxPower, (frameWidth - TextBoxPower.ActualWidth) / 2);
            SetTop(TextBoxPower, (1 - FrameOffset) * frameHeight * 0.98 - TextBoxPower.ActualHeight / 2);

            _imageSummoningSickness.Width  = (1 - 2 * FrameOffset) * frameWidth;
            _imageSummoningSickness.Height = 0.8 * frameHeight;
            SetLeft(_imageSummoningSickness, (frameWidth - _imageSummoningSickness.Width) / 2);
            SetTop(_imageSummoningSickness, 0.115 * frameWidth);

            _rectanglePowerFrame.Width  = 1.1 * TextBoxPower.ActualWidth;
            _rectanglePowerFrame.Height = 1.1 * TextBoxPower.ActualHeight;
            SetLeft(_rectanglePowerFrame, (frameWidth - _rectanglePowerFrame.Width) / 2);
            SetTop(_rectanglePowerFrame, (1 - FrameOffset) * frameHeight * 0.98 - _rectanglePowerFrame.Height / 2);

            _abilitiesItemsControl.Width  = 0.2 * frameWidth;
            _abilitiesItemsControl.Height = frameHeight + _abilitiesItemsControl.Width / 2;

            while (_abilitiesItemsControl.Items.Count > 0)
            {
                AbilityIconCanvas item        = _abilitiesItemsControl.Items[0] as AbilityIconCanvas;
                double            totalHeight = _abilitiesItemsControl.Items.Count * _abilitiesItemsControl.Width;
                if (totalHeight > _abilitiesItemsControl.Height)
                {
                    _abilitiesItemsControl.Width = 0.99 * _abilitiesItemsControl.Width;
                }
                else
                {
                    break;
                }
            }

            SetLeft(_abilitiesItemsControl, GetLeft(this) - _abilitiesItemsControl.Width / 2);
            SetBottom(_abilitiesItemsControl, GetBottom(this));

            RectangleColorFrame.Width  = frameWidth - frameWidth * FrameOffset;
            RectangleColorFrame.Height = frameHeight - frameHeight * FrameOffset;
            SetLeft(RectangleColorFrame, (frameWidth - RectangleColorFrame.Width) / 2);
            SetTop(RectangleColorFrame, (frameHeight - RectangleColorFrame.Height) / 2);
        }
示例#2
0
        private void CardCanvas_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            double frameWidth  = e.NewSize.Width;
            double frameHeight = e.NewSize.Height;

            AdjustSize(frameWidth, frameHeight, frameWidth, frameHeight);

            const double FontScaleCardType = 0.04;
            double       fontSizeCardType  = Math.Max(MinimumFontSize, frameHeight * FontScaleCardType);

            _textBoxCardType.FontSize = fontSizeCardType;
            _textBoxRace.FontSize     = 0.7 * fontSizeCardType;

            RectangleColorFrame.Width  = CanvasFrame.Width * (1 - FrameOffset);
            RectangleColorFrame.Height = CanvasFrame.Height * (1 - FrameOffset);
            SetLeft(RectangleColorFrame, (frameWidth - RectangleColorFrame.Width) / 2);
            SetTop(RectangleColorFrame, (frameHeight - RectangleColorFrame.Height) / 2);

            _textBoxCost.FontSize = frameHeight * 0.07;

            double costLength = CanvasFrame.Width * 0.115;

            _textBoxCost.Width  = costLength;
            _textBoxCost.Height = costLength;

            double leftAndTop = (frameWidth - RectangleColorFrame.Width) / 2;

            SetLeft(_textBoxCost, leftAndTop);
            SetTop(_textBoxCost, leftAndTop);

            AdjustCardNameSize(frameWidth, frameHeight);

            Artwork.Width  = RectangleColorFrame.Width;
            Artwork.Height = 0.48 * frameHeight;
            SetLeft(Artwork, (CanvasFrame.Width - RectangleColorFrame.Width) / 2);
            SetTop(Artwork, 0.14 * frameHeight);

            const double FontScale = 0.029;
            double       fontSize  = frameHeight * FontScale;

            _textBoxCardText.FontSize = fontSize;

            _textBoxCardText.Width  = CanvasFrame.Width * (1 - 2 * FrameOffset);
            _textBoxCardText.Height = 0.27 * frameHeight;
            SetLeft(_textBoxCardText, 0.07 * frameWidth);
            SetTop(_textBoxCardText, 0.63 * frameHeight);

            double typeRowHeight = TypeRowHeightScale * frameHeight;

            const double FontScalePower = 0.06;
            double       fontSizePower  = Math.Max(MinimumFontSize, Height * FontScalePower);

            TextBoxPower.FontSize = fontSizePower;

            TextBoxPower.Measure(new Size(frameWidth, 0.2 * frameHeight));
            TextBoxPower.Arrange(new Rect(TextBoxPower.DesiredSize));
            SetLeft(TextBoxPower, 0.05 * frameWidth);
            SetTop(TextBoxPower, typeRowHeight - TextBoxPower.ActualHeight / 2);

            _textBoxCardType.Width  = 0.3 * frameWidth;
            _textBoxCardType.Height = TextBoxPower.ActualHeight;
            SetLeft(_textBoxCardType, (CanvasFrame.Width - _textBoxCardType.Width) / 2);
            SetTop(_textBoxCardType, typeRowHeight - _textBoxCardType.Height / 2);

            AdjustRaceSize(frameWidth, frameHeight);

            _imageCardBack.Width  = CanvasFrame.Width * (1 - FrameOffset);
            _imageCardBack.Height = CanvasFrame.Height * (1 - FrameOffset);
            SetLeft(_imageCardBack, (frameWidth - _imageCardBack.Width) / 2);
            SetTop(_imageCardBack, (frameHeight - _imageCardBack.Height) / 2);

            _imageKnownToPlayerWithoutPriority.Width  = 0.7 * CanvasFrame.Width;
            _imageKnownToPlayerWithoutPriority.Height = 0.3 * CanvasFrame.Height;
            SetLeft(_imageKnownToPlayerWithoutPriority, (frameWidth - _imageKnownToPlayerWithoutPriority.Width) / 2);
            SetTop(_imageKnownToPlayerWithoutPriority, (frameHeight - _imageKnownToPlayerWithoutPriority.Height) / 2);
        }