Example #1
0
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            base.Draw(gameTime, spriteBatch);

            spriteBatch.Draw(background.Sheet.Texture, DestinationRect, background.SourceRect, Color.White);

            searchBar.Draw(gameTime, spriteBatch);

            List <TextBlock> toDraw = list.FindAll(x => x.Text.StartsWith(searchBar.Text));

            stack.Elements = toDraw.ToList <Control>();

            Rectangle itemRectangle = DestinationRect;

            itemRectangle.Height = 30;
            if (toDraw.Count > 0 && SelectedItem != null)
            {
                TextBlock textBlock = list[SelectedIndex];
                if (textBlock != null && toDraw.Contains(textBlock) && stack.IsElementDisplayed(stack.Elements.IndexOf(textBlock)))
                {
                    spriteBatch.Draw(background.Sheet.Texture, textBlock.DestinationRect, background.SourceRect, Color.White);
                }
                else
                {
                    SelectedItem = null;
                }
            }
            stack.Draw(gameTime, spriteBatch);
        }