Exemplo n.º 1
0
        public void PaintOverlays_PaintsAllOverlaysAndRestoresGraphicsContextForEachOne()
        {
            var overlayManager = new OverlayManager();
            var overlay1       = new OverlayThatChangesInterpolationMode();
            var overlay2       = new OverlayThatChangesInterpolationMode();

            overlayManager.AddOverlay(overlay1);
            overlayManager.AddOverlay(overlay2);

            using (Bitmap bitmap = new Bitmap(32, 32))
            {
                using (Graphics graphics = Graphics.FromImage(bitmap))
                {
                    graphics.InterpolationMode = InterpolationMode.HighQualityBilinear;
                    var request = new OverlayPaintRequest(graphics, new Rectangle(0, 0, 32, 32), 0, 0);

                    overlayManager.PaintOverlays(request);

                    Assert.Multiple(() =>
                    {
                        Assert.AreEqual(InterpolationMode.HighQualityBilinear, graphics.InterpolationMode);

                        Assert.IsTrue(overlay1.WasPainted);
                        Assert.AreEqual(InterpolationMode.HighQualityBilinear, overlay1.OldInterpolationMode);

                        Assert.IsTrue(overlay2.WasPainted);
                        Assert.AreEqual(InterpolationMode.HighQualityBilinear, overlay2.OldInterpolationMode);
                    });
                }
            }
        }
Exemplo n.º 2
0
    public void LoadOverlays()
    {
        OverlayManager overlayManager = new OverlayManager();

        RootList.Add(overlayManager);

        overlayManager.AddOverlay("hud", new Hud(this));
        overlayManager.AddOverlay("inventory", new Inventory(this));

        overlayManager.SwitchTo("hud");
    }
Exemplo n.º 3
0
    public void LoadOverlays()
    {
        OverlayManager overlayManager = new OverlayManager();

        RootList.Add(overlayManager);

        overlayManager.AddOverlay("hud", new Hud(this));
        overlayManager.AddOverlay("menu", new InGameMenu(this));
        overlayManager.AddOverlay("die", new Die(this, "Sprites/Overlay/spr_die"));
        overlayManager.AddOverlay("finish", new Die(this, "Sprites/Overlay/spr_finish"));
        overlayManager.SwitchTo("hud");
    }
Exemplo n.º 4
0
        public void AddOverlay_WhenOverlayIsNotNull_AddsTheOverlay()
        {
            var overlayManager = new OverlayManager();
            var overlay        = new StubOverlay();

            overlayManager.AddOverlay(overlay);

            Assert.AreElementsEqual(new[] { overlay }, overlayManager.Overlays);
        }
Exemplo n.º 5
0
        public void AddOverlay_WhenOverlayIsNotNullAndIsPresent_RemovesTheOverlay()
        {
            var overlayManager = new OverlayManager();
            var overlay        = new StubOverlay();

            overlayManager.AddOverlay(overlay);

            overlayManager.RemoveOverlay(overlay);

            Assert.Count(0, overlayManager.Overlays);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Gets the caption overlay to display over of screenshots images and videos.
        /// </summary>
        /// <returns>The caption overlay.</returns>
        public static CaptionOverlay GetCaptionOverlay()
        {
            OverlayManager overlayManager = GetOverlayManager();

            DefaultCaptionOverlay defaultCaptionOverlay = (DefaultCaptionOverlay)
                                                          GenericCollectionUtils.Find(overlayManager.Overlays, x => x is DefaultCaptionOverlay);

            if (defaultCaptionOverlay == null)
            {
                defaultCaptionOverlay = new DefaultCaptionOverlay();
                overlayManager.AddOverlay(defaultCaptionOverlay);
            }

            return(defaultCaptionOverlay);
        }
Exemplo n.º 7
0
        public void ToOverlay_ReturnsACompositeOverlay()
        {
            var overlayManager = new OverlayManager();
            var overlay        = new OverlayThatChangesInterpolationMode();

            overlayManager.AddOverlay(overlay);

            Overlay compositeOverlay = overlayManager.ToOverlay();

            var compositeOverlayManager = new OverlayManager();

            compositeOverlayManager.AddOverlay(compositeOverlay);
            using (Bitmap bitmap = new Bitmap(32, 32))
                compositeOverlayManager.PaintOverlaysOnImage(bitmap, 0, 0);
            Assert.IsTrue(overlay.WasPainted);
        }
Exemplo n.º 8
0
        public void Paint()
        {
            var overlayManager = new OverlayManager();
            var overlay        = new CaptionOverlay()
            {
                Text = "This is some text.",
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Bottom
            };

            overlayManager.AddOverlay(overlay);

            using (Bitmap bitmap = CreateBitmapWithBackground())
            {
                overlayManager.PaintOverlaysOnImage(bitmap, 0, 0);

                TestLog.WriteLine("Image should contain 'This is some text.' centered at the bottom.");
                TestLog.EmbedImage("Image", bitmap);
            }
        }
Exemplo n.º 9
0
        public void AddOverlay_WhenOverlayIsNull_Throws()
        {
            var overlayManager = new OverlayManager();

            Assert.Throws <ArgumentNullException>(() => overlayManager.AddOverlay(null));
        }