Exemplo n.º 1
0
        public void CanHandleDotsInPath()
        {
            var files = new List<string>
            {
                @"c:\Sprite.Net\a.gif",
                @"c:\Sprite.Net\b.gif",
            };

            var hoverGenerator = new HoverGenerator();
            var result = hoverGenerator.Generate(files);
            Assert.That(result, Has.Count.EqualTo(2));
            Assert.That(result.Keys, Has.Member(@"c:\Sprite.Net\a.gif"));
            Assert.That(result.Keys, Has.Member(@"c:\Sprite.Net\b.gif"));
        }
Exemplo n.º 2
0
        public void CanHandleDotsInPath()
        {
            var files = new List <string>
            {
                @"c:\Sprite.Net\a.gif",
                @"c:\Sprite.Net\b.gif",
            };

            var hoverGenerator = new HoverGenerator();
            var result         = hoverGenerator.Generate(files);

            Assert.That(result, Has.Count.EqualTo(2));
            Assert.That(result.Keys, Has.Member(@"c:\Sprite.Net\a.gif"));
            Assert.That(result.Keys, Has.Member(@"c:\Sprite.Net\b.gif"));
        }
Exemplo n.º 3
0
        public void ShouldPaitHoverIconWithOrdinaryIcon()
        {
            var files = new List<string>
            {
                @"c:\Sprite\a.gif",
                @"c:\Sprite\b.gif",
                @"c:\Sprite\a-hover.gif",
            };

            var hoverGenerator = new HoverGenerator();
            var result = hoverGenerator.Generate(files);
            Assert.That(result, Has.Count.EqualTo(2));
            Assert.That(result.Keys, Has.Member(@"c:\Sprite\a.gif"));
            Assert.That(result.Keys, Has.Member(@"c:\Sprite\b.gif"));
            Assert.That(result[@"c:\Sprite\a.gif"], Is.EqualTo(@"c:\Sprite\a-hover.gif"));
        }
Exemplo n.º 4
0
        public SpriteInfo Build(ImageSettings settings, List<string> imageLocations)
        {
            _spriteInfo = new SpriteInfo();
            _settings = settings;
            var imagePairs = new HoverGenerator().Generate(imageLocations);

            int totalImages = 0;
            foreach (var imagePath in imagePairs)
            {
                var imageInfo = new ImageInfo
                {
                    FileName = imagePath.Key,
                    Bitmap = new Bitmap(imagePath.Key),
                };
                UpdateSizes(imageInfo);
                totalImages++;

                var hoverPath = imagePath.Value;
                if (hoverPath != null)
                {
                    var hoverInfo = new ImageInfo
                    {
                        FileName = hoverPath,
                        Bitmap = new Bitmap(hoverPath)
                    };

                    UpdateSizes(hoverInfo);
                    totalImages++;
                    imageInfo.HoverImage = hoverInfo;
                }

                _spriteInfo.Images.Add(imageInfo);
            }

            // Create a drawing surface and add the images to it
            // Since we'll be padding each image by 1px later on, we need to increase the sprites's size correspondingly.
            if (settings.TileInXAxis)
            {
                _spriteInfo.Width += totalImages;
            }
            else
            {
                _spriteInfo.Height += totalImages;
            }

            return _spriteInfo;
        }
Exemplo n.º 5
0
        public void ShouldPaitHoverIconWithOrdinaryIcon()
        {
            var files = new List <string>
            {
                @"c:\Sprite\a.gif",
                @"c:\Sprite\b.gif",
                @"c:\Sprite\a-hover.gif",
            };

            var hoverGenerator = new HoverGenerator();
            var result         = hoverGenerator.Generate(files);

            Assert.That(result, Has.Count.EqualTo(2));
            Assert.That(result.Keys, Has.Member(@"c:\Sprite\a.gif"));
            Assert.That(result.Keys, Has.Member(@"c:\Sprite\b.gif"));
            Assert.That(result[@"c:\Sprite\a.gif"], Is.EqualTo(@"c:\Sprite\a-hover.gif"));
        }