Ejemplo n.º 1
0
        private void ParseDescriptionFile(string deckDirectory, string[] descriptionLines)
        {
            var imageDescription = new RectangularDeckImageDescription();

            var lineIndex = 0;

            _cardsImage = new BitmapImage(new Uri(Path.Combine(deckDirectory, descriptionLines[lineIndex++])));

            _imageSize = new CardSize(_cardsImage.PixelWidth, _cardsImage.PixelHeight);

            var offsetParts = descriptionLines[lineIndex++].Split(' ');

            imageDescription.HorizontalOffsetOfFirstCard = double.Parse(offsetParts[0], CultureInfo.InvariantCulture);
            imageDescription.VerticalOffsetOfFirstCard   = double.Parse(offsetParts[1], CultureInfo.InvariantCulture);

            var cardSizeParts = descriptionLines[lineIndex++].Split(' ');

            imageDescription.CardWidth  = double.Parse(cardSizeParts[0], CultureInfo.InvariantCulture);
            imageDescription.CardHeight = double.Parse(cardSizeParts[1], CultureInfo.InvariantCulture);

            _ratio = imageDescription.CardWidth / imageDescription.CardHeight;

            var spacingParts = descriptionLines[lineIndex++].Split(' ');

            imageDescription.HorizontalSpacingBetweenCards = double.Parse(spacingParts[0], CultureInfo.InvariantCulture);
            imageDescription.VerticalSpacingBetweenCards   = double.Parse(spacingParts[1], CultureInfo.InvariantCulture);

            imageDescription.Ranks = GetRanks(descriptionLines[lineIndex++]);
            imageDescription.Suits = GetSuits(descriptionLines[lineIndex]);

            _cardImagePositionProvider = new RectangularCardImagePositionProvider(imageDescription);
        }
Ejemplo n.º 2
0
 public Rect(double left, double top, Size size)
     : this()
 {
     Left = left;
     Top = top;
     Width = size.Width;
     Height = size.Height;
 }
        public OneCardImagePositionProviderTest()
        {
            _fixture = new Fixture();

            _cardSize = _fixture.Create<Size>();

            _description = new OneCardImageDescription
            {
                CardWidth = _cardSize.Width,
                CardHeight = _cardSize.Height
            };

            _fixture.Inject<IOneCardImageDescription>(_description);
        }
        public RectangularCardImagePositionProviderTest()
        {
            _fixture = new Fixture();

            _cardSize = _fixture.Create<Size>();

            _description = new RectangularDeckImageDescription
            {
                CardWidth = _cardSize.Width,
                CardHeight = _cardSize.Height,
                Ranks = new[]
                {
                    Ace, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King
                },
                Suits = new[] { Clubs, Diamonds, Hearts, Spades }
            };

            _fixture.Inject<IRectangularDeckImageDescription>(_description);
        }
Ejemplo n.º 5
0
        private void ParseDescriptionFile(string deckDirectory, string[] descriptionLines)
        {
            var imageDescription = new RectangularDeckImageDescription();

            var lineIndex = 0;

            _cardsImage = new BitmapImage(new Uri(Path.Combine(deckDirectory, descriptionLines[lineIndex++])));

            _imageSize = new CardSize(_cardsImage.PixelWidth, _cardsImage.PixelHeight);

            var offsetParts = descriptionLines[lineIndex++].Split(' ');
            imageDescription.HorizontalOffsetOfFirstCard = double.Parse(offsetParts[0], CultureInfo.InvariantCulture);
            imageDescription.VerticalOffsetOfFirstCard = double.Parse(offsetParts[1], CultureInfo.InvariantCulture);

            var cardSizeParts = descriptionLines[lineIndex++].Split(' ');
            imageDescription.CardWidth = double.Parse(cardSizeParts[0], CultureInfo.InvariantCulture);
            imageDescription.CardHeight = double.Parse(cardSizeParts[1], CultureInfo.InvariantCulture);

            _ratio = imageDescription.CardWidth / imageDescription.CardHeight;

            var spacingParts = descriptionLines[lineIndex++].Split(' ');
            imageDescription.HorizontalSpacingBetweenCards = double.Parse(spacingParts[0], CultureInfo.InvariantCulture);
            imageDescription.VerticalSpacingBetweenCards = double.Parse(spacingParts[1], CultureInfo.InvariantCulture);

            imageDescription.Ranks = GetRanks(descriptionLines[lineIndex++]);
            imageDescription.Suits = GetSuits(descriptionLines[lineIndex]);

            _cardImagePositionProvider = new RectangularCardImagePositionProvider(imageDescription);
        }
Ejemplo n.º 6
0
 public bool Equals(Size other)
 {
     return Width.Equals(other.Width) && Height.Equals(other.Height);
 }