예제 #1
0
 public override void Draw(SpriteBatch spriteBatch)
 {
     if (Visible)
     {
         render.Draw(spriteBatch);
         if (label != null)
         {
             label.Draw(spriteBatch);
         }
         if (Scrolls)
         {
             scroller.Draw(spriteBatch);
             // -- Draw in Scissor Rectangle -- //
             spriteBatch.End();
             _contentsRenderer.Draw(ContentManager);
             // -- Resume Master Sprite Batch
             spriteBatch.Begin();
         }
         else
         {
             // Draw my contents:
             ContentManager.Draw();
         }
     }
 }
예제 #2
0
        public void Scroller_DrawEmpty_Empty()
        {
            var scroller = new Scroller(new List <Response>(), 0, 0);
            var console  = Substitute.For <IConsole>();

            scroller.Draw(console);

            console.Received(0).WriteLine(Arg.Any <string>());
        }
예제 #3
0
        public void Scroller_DrawResponse_PadsWidth()
        {
            var scroller = new Scroller(new List <Response> {
                new Response("iTest Display\tSelector Text\tDomain Info\t71")
            }, 40, 1);
            var console = Substitute.For <IConsole>();

            scroller.Draw(console);

            console.Received(1).WriteLine(Arg.Is <string>(x => x.Length == 40));
        }
예제 #4
0
        public void Scroller_DrawResponse_HilightNormal()
        {
            var scroller = new Scroller(new List <Response> {
                new Response("iTest Display\tSelector Text\tDomain Info\t71"), new Response("iTest Display\tSelector Text\tDomain Info\t71")
            }, 40, 2);
            var console = Substitute.For <IConsole>();

            scroller.Draw(console);

            console.Received(1).SetHilight();
            console.Received(2).SetNormal();
        }
예제 #5
0
        public void Scroller_DrawResponse_LimitsLines()
        {
            var scroller = new Scroller(new List <Response> {
                new Response("iFirst Display\tSelector Text\tDomain Info\t71"), new Response("iSecond Display\tSelector Text\tDomain Info\t71")
            }, 40, 1);
            var console = Substitute.For <IConsole>();

            scroller.Draw(console);

            // Display first 1 line
            console.Received(1).WriteLine(Arg.Is <string>(x => x == "  First Display                         "));
            console.Received(0).WriteLine(Arg.Is <string>(x => x == "  Second Display                        "));

            // no blanking required
            console.Received(0).WriteLine();
        }
예제 #6
0
        public void Scroller_DrawResponse_FillsEmptyLines()
        {
            var scroller = new Scroller(new List <Response> {
                new Response("iFirst Display\tSelector Text\tDomain Info\t71"), new Response("iSecond Display\tSelector Text\tDomain Info\t71")
            }, 40, 5);
            var console = Substitute.For <IConsole>();

            scroller.Draw(console);

            // Display first 2 lines
            console.Received(1).WriteLine(Arg.Is <string>(x => x == "  First Display                         "));
            console.Received(1).WriteLine(Arg.Is <string>(x => x == "  Second Display                        "));

            // display blank lines to fill to desired length
            console.Received(3).WriteLine();
        }
예제 #7
0
        public void Scroller_DrawSingleResponse_ScrollsDisplay()
        {
            var scroller = new Scroller(new List <Response> {
                new Response("iFirst Display\tSelector Text\tDomain Info\t71"), new Response("iSecond Display\tSelector Text\tDomain Info\t71")
            }, 40, 1);
            var console = Substitute.For <IConsole>();

            scroller.ReadKey(new ConsoleKeyInfo('0', ConsoleKey.DownArrow, false, false, false));
            scroller.Draw(console);

            Assert.AreEqual(1, scroller.Line);

            // Display second 1 line
            console.Received(0).WriteLine(Arg.Is <string>(x => x == "  First Display                         "));
            console.Received(1).WriteLine(Arg.Is <string>(x => x == "  Second Display                        "));

            // no blanking required
            console.Received(0).WriteLine();
        }
예제 #8
0
        //-------------------------------------------------------
        //------------------------Drawing------------------------
        //-------------------------------------------------------



        public virtual void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(comboBoxTexture.currentItemTexture, Bounds, comboBoxTexture.currentItemColor);
            if (selectedIndex > -1)
            {
                spriteBatch.DrawString(spriteFont, " " + items[selectedIndex], new Vector2(Bounds.X, Bounds.Y), Color.Black);
            }
            else
            {
                spriteBatch.DrawString(spriteFont, InfoText, new Vector2(Bounds.X, Bounds.Y), Color.Black);
            }

            _dropDownButton.Draw(spriteBatch);

            if (!Collapsed)
            {
                if (_scroller != null)
                {
                    _scroller.Draw(spriteBatch);
                }

                for (int i = offset; i < showAmount + offset && i < items.Count; i++)
                {
                    Rectangle temp = new Rectangle(itemsBounds[i].X, itemsBounds[i].Y - offset * Bounds.Height, itemsBounds[i].Width, itemsBounds[i].Height);


                    if (selectedIndex == i)
                    {
                        spriteBatch.Draw(comboBoxTexture.selectedTexture, temp, comboBoxTexture.selectedColor);
                    }
                    else if (tempIndex == i)
                    {
                        spriteBatch.Draw(comboBoxTexture.selectionTexture, temp, comboBoxTexture.selectionColor);
                    }
                    else
                    {
                        spriteBatch.Draw(comboBoxTexture.itemBackgroundTexture, temp, comboBoxTexture.itemBackgroundColor);
                    }

                    spriteBatch.DrawString(spriteFont, " " + items[i], new Vector2(itemsBounds[i].X, itemsBounds[i].Y - offset * Bounds.Height), Color.Black);
                }
            }
        }