private void AddFont(string logicalName, string fileName) { var font = _game.Content.Load<SpriteFont>("Fonts\\" + fileName); var fontAdapter = new SpriteFontAdapter(font); _fonts.Add(logicalName, fontAdapter); }
public void GameOver() { RemoveChild(timer); matrix.GameOver(); Sprite messageBackground = new Sprite(TextureProvider.Common.MessageBoxBackground); messageBackground.Scale = 0.5f; messageBackground.DisplayOnCenterScreen(); SpriteFontAdapter messageSprite = new SpriteFontAdapter(FontProvider.DefaultFont, Vector2.Zero, "Game Over!"); messageSprite.DisplayOnCenterSprite(messageBackground, 5, -30); Button buttonOk = new Button(TextureProvider.Common.ButtonBackground, FontProvider.DefaultFont, "OK"); buttonOk.Scale = 0.5f; buttonOk.DisplayOnCenterSprite(messageBackground, 5, 20); buttonOk.Click += ButtonClickOK; AddChild(messageBackground); AddChild(messageSprite); AddChild(buttonOk); }
protected override void LoadContent() { var spriteBatchAdapter = new SpriteBatchAdapter(new SpriteBatch(this.GraphicsDevice)); var spriteFontAdapter = new SpriteFontAdapter(this.Game.Content.Load <SpriteFont>("SpriteFont")); var primitivesService = new PrimitivesService(this.GraphicsDevice); var renderer = new Renderer(spriteBatchAdapter, primitivesService); this.rootElement = new RootElement(this.GraphicsDevice.Viewport.ToRect(), renderer, new InputManager()); var bindingClass = new BindingClass(); var bindingClass2 = new BindingClass2(); var border = new Border { Background = new SolidColorBrush(Colors.LightGray), Child = new TextBlock(spriteFontAdapter) { Text = "Click" } }; var toggleButton = new ToggleButton { Content = border }; border.Bind(Border.BackgroundProperty, bindingClass2.BackgroundColor); toggleButton.Bind(ToggleButton.IsCheckedProperty, bindingClass2.IsChecked, bindingClass2.IsChecked); this.rootElement.Content = toggleButton; }
protected override void LoadContent() { var spriteBatchAdapter = new SpriteBatchAdapter(new SpriteBatch(this.GraphicsDevice)); var primitivesService = new PrimitivesService(this.GraphicsDevice); var renderer = new Renderer(spriteBatchAdapter, primitivesService); this.rootElement = new RootElement(this.GraphicsDevice.Viewport.ToRect(), renderer, new InputManager()); var scrollView = new ScrollViewer(); this.rootElement.Content = scrollView; var stackPanel = new StackPanel(); scrollView.Content = stackPanel; scrollView.CanHorizontallyScroll = true; var headerFont = new SpriteFontAdapter(this.Game.Content.Load <SpriteFont>("SpriteFont")); var descFont = new SpriteFontAdapter(this.Game.Content.Load <SpriteFont>("SpriteFont")); foreach (int app in Enumerable.Range(0, 2)) { var grid = new Grid { ColumnDefinitions = { new ColumnDefinition { Width = GridLength.Auto }, new ColumnDefinition() } }; grid.Children.Add( new Image { Source = new TextureImage( new Texture2DAdapter(this.Game.Content.Load <Texture2D>("Textures/badger2"))) }); var textStack = new StackPanel { Margin = new Thickness(12, 0, 0, 0) }; Grid.SetColumn(textStack, 1); grid.Children.Add(textStack); textStack.Children.Add(new TextBlock(headerFont) { Text = "Title" }); textStack.Children.Add( new TextBlock(descFont) { Text = "Description - some text that should wrap when it runs of the screen.", Wrapping = TextWrapping.Wrap, }); stackPanel.Children.Add(grid); } }
protected override void LoadContent() { this.spriteFontAdapter = new SpriteFontAdapter(this.Game.Content.Load <SpriteFont>("SpriteFont")); this.spriteBatchAdapter = new SpriteBatchAdapter(new SpriteBatch(this.GraphicsDevice)); var renderer = new Renderer(this.spriteBatchAdapter, new PrimitivesService(this.GraphicsDevice)); this.rootElement = new RootElement(this.GraphicsDevice.Viewport.ToRect(), renderer, new InputManager()); var itemsControl = new ItemsControl(); // this.rootElement.Content = itemsControl; }
protected override void LoadContent() { base.LoadContent(); _spriteBatchAdapter = new SpriteBatchAdapter(new SpriteBatch(GraphicsDevice)); var primitivesService = new PrimitivesService(GraphicsDevice); var renderer = new Renderer(_spriteBatchAdapter, primitivesService); _rootElement = new RootElement(GraphicsDevice.Viewport.ToRect(), renderer, new RedBadger.Xpf.Adapters.Xna.Input.InputManager()); var spriteFont = Game.Content.Load <SpriteFont>("Fonts\\Kootenay"); var spriteFontAdapter = new SpriteFontAdapter(spriteFont); var grid = new Grid() { Background = new SolidColorBrush(Colors.White), RowDefinitions = { new RowDefinition(), new RowDefinition() }, ColumnDefinitions = { new ColumnDefinition() }, }; _rootElement.Content = grid; var button = new Button() { Content = new TextBlock(spriteFontAdapter) { Text = "Hello World", Foreground = new SolidColorBrush(Colors.Black), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, }, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, }; var textBox = new TextBox(spriteFontAdapter); button.Click += delegate { (button.Content as TextBlock).Text += "1"; }; button.Gestures.Subscribe(obj => Console.WriteLine("Hi")); Grid.SetRow(button, 0); Grid.SetColumn(button, 0); Grid.SetRow(textBox, 1); grid.Children.Add(button); grid.Children.Add(textBox); }
public NinePatch(ContentManager content, Canvas canvas, string name, SpriteFontAdapter font) { this.RowDefinitions.Add(new RowDefinition { Height = new GridLength(16) }); this.RowDefinitions.Add(new RowDefinition()); this.RowDefinitions.Add(new RowDefinition { Height = new GridLength(16) }); this.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(16) }); this.ColumnDefinitions.Add(new ColumnDefinition()); this.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(6) }); this.content = content; this.canvas = canvas; this.font = font; BuildNinePatch(name); }
protected override void LoadContent() { this.spriteBatchAdapter = new SpriteBatchAdapter(new SpriteBatch(this.GraphicsDevice)); var primitivesService = new PrimitivesService(this.GraphicsDevice); var renderer = new Renderer(this.spriteBatchAdapter, primitivesService); var spriteFontAdapter = new SpriteFontAdapter(this.Game.Content.Load <SpriteFont>("Segoe18")); var largeFont = new SpriteFontAdapter(this.Game.Content.Load <SpriteFont>("Segoe30")); var addButtonImageTexture = new TextureImage(new Texture2DAdapter(this.Game.Content.Load <Texture2D>("AddButton"))); var trashButtonImageTexture = new TextureImage(new Texture2DAdapter(this.Game.Content.Load <Texture2D>("TrashButton"))); this.rootElement = new RootElement(this.GraphicsDevice.Viewport.ToRect(), renderer, new InputManager()); var buttonClickResults = new ObservableCollection <string>(); var header1 = new TextBlock(spriteFontAdapter) { Text = "MY APPLICATION", Foreground = new SolidColorBrush(Colors.White), Margin = new Thickness(10) }; var header2 = new TextBlock(largeFont) { Text = "XNA Application Bar", Foreground = new SolidColorBrush(Colors.White), Margin = new Thickness(10) }; var itemsControl = new ItemsControl { ItemsSource = buttonClickResults, ItemTemplate = _ => { var textBlock = new TextBlock(spriteFontAdapter) { Foreground = new SolidColorBrush(Colors.White) }; textBlock.Bind( TextBlock.TextProperty, BindingFactory.CreateOneWay <string>()); return(textBlock); } }; var scrollViewer = new ScrollViewer { Content = itemsControl }; var applicationBar = new ApplicationBar { Buttons = { new ApplicationBarIconButton("Add", addButtonImageTexture), new ApplicationBarIconButton("Delete", trashButtonImageTexture) } }; var grid = new Grid { Background = new SolidColorBrush(Colors.Black), RowDefinitions = { new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, new RowDefinition(), new RowDefinition { Height = new GridLength(70) } }, Children = { header1, header2, scrollViewer, applicationBar } }; applicationBar.Clicks.Subscribe( Observer.Create <ApplicationBarIconButton>(s => buttonClickResults.Add(s.Text))); Grid.SetRow(header1, 0); Grid.SetRow(header2, 1); Grid.SetRow(scrollViewer, 2); Grid.SetRow(applicationBar, 3); this.rootElement.Content = grid; }
protected override void LoadContent() { this.spriteFont = this.Game.Content.Load <SpriteFont>("SpriteFont"); this.spriteBatchAdapter = new SpriteBatchAdapter(new SpriteBatch(this.GraphicsDevice)); var spriteFontAdapter = new SpriteFontAdapter(this.spriteFont); var items = new ObservableCollection <string>(); var itemsControl = new ItemsControl { ItemTemplate = _ => { var textBlock = new TextBlock(spriteFontAdapter) { Margin = new Thickness(0, 0, 0, 50), Background = new SolidColorBrush(GetRandomColor(this.random)) }; textBlock.Bind(TextBlock.TextProperty, BindingFactory.CreateOneWay <string>()); return(textBlock); }, ItemsSource = items }; var renderer = new Renderer(this.spriteBatchAdapter, new PrimitivesService(this.GraphicsDevice)); this.rootElement = new RootElement(this.GraphicsDevice.Viewport.ToRect(), renderer, new InputManager()) { Content = new ScrollViewer { Content = itemsControl } }; Observable.Timer(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1)).ObserveOnDispatcher().Subscribe( l => items.Add(DateTime.Now.ToString())); /*var renderer = new Renderer(this.spriteBatchAdapter, new PrimitivesService(this.GraphicsDevice)); * * this.rootElement = new RootElement(this.GraphicsDevice.Viewport.ToRect(), renderer, new InputManager()); * * var textBlock = new TextBlock(spriteFontAdapter) * { * Text = * "Red Badger is a product and service consultancy, specialising in bespoke software projects, developer tools and platforms on the Microsoft technology stack.", * Background = new SolidColorBrush(Colors.Red), * HorizontalAlignment = HorizontalAlignment.Left, * VerticalAlignment = VerticalAlignment.Top, * Wrapping = TextWrapping.Wrap, * Margin = new Thickness(10), * Padding = new Thickness(10) * }; * * this.rootElement.Content = textBlock; * * var grid = new Grid { RowDefinitions = { new RowDefinition(), new RowDefinition() } }; * * var button = new Button * { * Content = * new TextBlock(spriteFontAdapter) * { * Text = "Click", Background = new SolidColorBrush(Colors.Blue) * } * }; * grid.Children.Add(button); * Grid.SetRow(button, 1); * * this.textBlock = new TextBlock(spriteFontAdapter) { Text = "Item 1", Margin = new Thickness(15) }; * this.stackPanel = new StackPanel * { * Children = * { * this.textBlock, * new TextBlock(spriteFontAdapter) { Text = "Item 2", Margin = new Thickness(15) }, * new TextBlock(spriteFontAdapter) { Text = "Item 3", Margin = new Thickness(15) } * } * }; * grid.Children.Add(this.stackPanel); * this.rootElement.Content = grid; * * button.Click += (sender, args) => this.stackPanel.Children.RemoveAt(0);*/ }
public Button(Texture2D texture, SpriteFont spriteFont, string text) : base(texture) { MouseClickDetector.LeftButtonDown += Notify; spriteFontAdapter = new SpriteFontAdapter(spriteFont, Vector2.Zero, text); }
protected override void LoadContent() { var spriteBatchAdapter = new SpriteBatchAdapter(new SpriteBatch(this.GraphicsDevice)); var renderer = new Renderer(spriteBatchAdapter, new PrimitivesService(this.GraphicsDevice)); this.rootElement = new RootElement(this.GraphicsDevice.Viewport.ToRect(), renderer); this.lcd = new SpriteFontAdapter(this.Game.Content.Load <SpriteFont>("Lcd")); this.led = new SpriteFontAdapter(this.Game.Content.Load <SpriteFont>("Led")); Observable.FromEvent <EventArgs>( handler => this.Game.Window.OrientationChanged += handler, handler => this.Game.Window.OrientationChanged -= handler).Subscribe( _ => this.rootElement.Viewport = this.Game.GraphicsDevice.Viewport.ToRect()); IElement homeTeamPanel = this.CreateTeamDisplay(); var clockPanel = new StackPanel { Children = { new Border { HorizontalAlignment = HorizontalAlignment.Center, BorderBrush = new SolidColorBrush(Colors.White), BorderThickness = new Thickness(4), Padding = new Thickness(10), Margin = new Thickness(10), Child = new TextBlock(this.led) { Text = "00:00", Foreground = new SolidColorBrush(Colors.Red), HorizontalAlignment = HorizontalAlignment.Center } }, new StackPanel { HorizontalAlignment = HorizontalAlignment.Center, Orientation = Orientation.Horizontal, Children = { new TextBlock(this.lcd) { Text = "PERIOD", Foreground = new SolidColorBrush(Colors.LightGray), Padding = new Thickness(10), VerticalAlignment = VerticalAlignment.Center }, new TextBlock(this.led) { Text = "0", Foreground = new SolidColorBrush(Colors.Yellow), Padding = new Thickness(10), VerticalAlignment = VerticalAlignment.Center } } } } }; IElement guestTeamPanel = this.CreateTeamDisplay(); var grid = new Grid { Background = new SolidColorBrush(Colors.Black), ColumnDefinitions = { new ColumnDefinition { Width = GridLength.Auto }, new ColumnDefinition(), new ColumnDefinition { Width = GridLength.Auto } }, Children = { homeTeamPanel, clockPanel, guestTeamPanel } }; Grid.SetColumn(homeTeamPanel, 0); Grid.SetColumn(clockPanel, 1); Grid.SetColumn(guestTeamPanel, 2); var border = new Border { VerticalAlignment = VerticalAlignment.Top, BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(5), Child = grid, }; this.rootElement.Content = border; }
protected override void LoadContent() { var spriteBatchAdapter = new SpriteBatchAdapter(new SpriteBatch(this.GraphicsDevice)); var renderer = new Renderer(spriteBatchAdapter, new PrimitivesService(this.GraphicsDevice)); this.rootElement = new RootElement(this.GraphicsDevice.Viewport.ToRect(), renderer, new InputManager()); this.lcd = new SpriteFontAdapter(this.Game.Content.Load <SpriteFont>("Lcd")); this.led = new SpriteFontAdapter(this.Game.Content.Load <SpriteFont>("Led")); // TODO: Some changes in ReactiveEx v2.0, using alternative for now, fill fix up later //Observable.FromEvent<EventArgs>( // handler => this.Game.Window.OrientationChanged += handler, // handler => this.Game.Window.OrientationChanged -= handler).Subscribe( // _ => this.rootElement.Viewport = this.Game.GraphicsDevice.Viewport.ToRect()); // Alternative mechanism to hook up to the event. Ensure you manage unhooking the event yourself. this.Game.Window.OrientationChanged += (sender, args) => this.rootElement.Viewport = this.Game.GraphicsDevice.Viewport.ToRect(); var timeTextBlock = new TextBlock(this.led) { Foreground = new SolidColorBrush(Colors.Red), HorizontalAlignment = HorizontalAlignment.Center }; timeTextBlock.Bind(TextBlock.TextProperty, this.clock.TimeDisplay); var periodTextBlock = new TextBlock(this.led) { Foreground = new SolidColorBrush(Colors.Yellow), Padding = new Thickness(10), VerticalAlignment = VerticalAlignment.Center }; periodTextBlock.Bind( TextBlock.TextProperty, BindingFactory.CreateOneWay <Clock, int, string>(this.clock, c => c.Period)); IElement homeTeamPanel = this.CreateTeamDisplay(this.homeTeam); var clockPanel = new StackPanel { Children = { new Border { HorizontalAlignment = HorizontalAlignment.Center, BorderBrush = new SolidColorBrush(Colors.White), BorderThickness = new Thickness(4), Padding = new Thickness(10), Margin = new Thickness(10), Width = 280, Child = timeTextBlock }, new StackPanel { HorizontalAlignment = HorizontalAlignment.Center, Orientation = Orientation.Horizontal, Children = { new TextBlock(this.lcd) { Text = "PERIOD", Foreground = new SolidColorBrush(Colors.LightGray), Padding = new Thickness(10), VerticalAlignment = VerticalAlignment.Center }, periodTextBlock } } } }; IElement guestTeamPanel = this.CreateTeamDisplay(this.guestTeam); var grid = new Grid { Background = new SolidColorBrush(Colors.Black), ColumnDefinitions = { new ColumnDefinition { Width = GridLength.Auto }, new ColumnDefinition(), new ColumnDefinition { Width = GridLength.Auto } }, Children = { homeTeamPanel, clockPanel, guestTeamPanel } }; Grid.SetColumn(homeTeamPanel, 0); Grid.SetColumn(clockPanel, 1); Grid.SetColumn(guestTeamPanel, 2); var border = new Border { Height = 280, VerticalAlignment = VerticalAlignment.Top, BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(5), Child = grid, }; this.rootElement.Content = border; }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. this.spriteBatch = new SpriteBatchAdapter(new SpriteBatch(this.GraphicsDevice)); var primitiveService = new PrimitivesService(this.GraphicsDevice); var renderer = new Renderer(this.spriteBatch, primitiveService); var input = new InputManager(); this.root = new RootElement(this.GraphicsDevice.Viewport.ToRect(), renderer, input); this.font = new SpriteFontAdapter(this.Content.Load <SpriteFont>(@"SpriteFont")); this.chunks = new ObservableCollection <Chunk>(); string[] files = Directory.GetFiles(Environment.CurrentDirectory + @"\Content\Textures"); foreach (string file in files) { var chunk = new Chunk { Name = Path.GetFileNameWithoutExtension(file), Texture = this.Content.Load <Texture2D>(@"Textures/" + Path.GetFileNameWithoutExtension(file)) }; this.chunks.Add(chunk); } var items = new ItemsControl { ItemTemplate = _ => { var textBlock = new TextBlock(this.font) { Foreground = new SolidColorBrush(Colors.White), HorizontalAlignment = HorizontalAlignment.Center }; textBlock.Bind( TextBlock.TextProperty, BindingFactory.CreateOneWay <Chunk, string>(o => o.Name)); var image = new Image { Stretch = Stretch.Fill, Width = 100, }; image.Bind( Image.SourceProperty, BindingFactory.CreateOneWay <Chunk, ImageSource>(o => o.XnaImage)); var panel = new StackPanel { Orientation = Orientation.Vertical, Background = new SolidColorBrush(new Media.Color(0, 0, 0, 100)), }; panel.Children.Add(image); panel.Children.Add(textBlock); var border = new Border { BorderBrush = new SolidColorBrush(Colors.Black), BorderThickness = new Thickness(2, 2, 2, 2), Margin = new Thickness(5, 5, 5, 5), Child = panel, }; var button = new Button { Content = border, Margin = new Thickness(5, 5, 5, 5), }; return(button); }, ItemsSource = this.chunks, }; items.ItemsPanel.Margin = new Thickness(0, 0, 25, 0); var scrollViewer = new ScrollViewer { Content = items }; var canvas = new Canvas { }; var chunkPallet = new NinePatch(this.Content, canvas, "Chunk Pallet", this.font) { Width = 280, Height = 550, }; this.ninePatches.Add(chunkPallet); chunkPallet.Children.Add(scrollViewer); canvas.Children.Add(chunkPallet); Grid.SetColumn(scrollViewer, 1); Grid.SetRow(scrollViewer, 1); Canvas.SetLeft(chunkPallet, 740); Canvas.SetTop(chunkPallet, 20); this.root.Content = canvas; }
protected override void LoadContent() { this.spriteFont = this.Game.Content.Load <SpriteFont>("SpriteFont"); this.spriteBatchAdapter = new SpriteBatchAdapter(new SpriteBatch(this.GraphicsDevice)); var spriteFontAdapter = new SpriteFontAdapter(this.spriteFont); var renderer = new Renderer(this.spriteBatchAdapter, new PrimitivesService(this.GraphicsDevice)); this.rootElement = new RootElement(this.GraphicsDevice.Viewport.ToRect(), renderer, new InputManager()); var border = new Border { Width = 300, Height = 300, Background = new SolidColorBrush(Colors.DarkGray), BorderBrush = new SolidColorBrush(Colors.Black), BorderThickness = new Thickness(2) }; var outerBorder = new Border { Background = new SolidColorBrush(Colors.Yellow), BorderBrush = new SolidColorBrush(Colors.Red), BorderThickness = new Thickness(2), Child = border }; var button = new Button { Content = new Border { Background = new SolidColorBrush(Colors.Brown), Width = 100, Height = 50 } }; button.Click += (sender, args) => { if (border.Width == 300) { border.Width = 100; border.Height = 150; } else { border.Width = 300; border.Height = 300; } }; var stackPanel = new StackPanel { HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Children = { outerBorder, button } }; this.rootElement.Content = stackPanel; /*var child_10_StackPanel = new StackPanel { Background = new SolidColorBrush(Colors.Red) }; * * var child_20_Border = new Border { Width = 200, Height = 300, Background = new SolidColorBrush(Colors.Yellow) }; * var child_21_Border = new Border { Width = 100, Height = 100, Background = new SolidColorBrush(Colors.Blue) }; * * var child_30_StackPanel = new StackPanel { Width = 300, Height = 400, Background = new SolidColorBrush(Colors.Green) }; * * var child_40_Border = new Border { Width = 400, Height = 500, Background = new SolidColorBrush(Colors.Orange) }; * var child_41_Border = new Border { Width = 600, Height = 700, Background = new SolidColorBrush(Colors.Gray) }; * * var child_50_Border = new Border { Width = 500, Height = 600, Background = new SolidColorBrush(Colors.Purple) }; * * this.rootElement.Content = child_10_StackPanel; * * child_10_StackPanel.Children.Add(child_20_Border); * child_10_StackPanel.Children.Add(child_21_Border); * * child_20_Border.Child = child_30_StackPanel; * * child_30_StackPanel.Children.Add(child_40_Border); * child_30_StackPanel.Children.Add(child_41_Border); * * child_40_Border.Child = child_50_Border;*/ }
protected override void LoadContent() { var spriteBatchAdapter = new SpriteBatchAdapter(new SpriteBatch(this.GraphicsDevice)); var spriteFontAdapter = new SpriteFontAdapter(this.Game.Content.Load <SpriteFont>("SpriteFont")); var renderer = new Renderer(spriteBatchAdapter, new PrimitivesService(this.GraphicsDevice)); this.rootElement = new RootElement(this.GraphicsDevice.Viewport.ToRect(), renderer, new InputManager()); // Setup Layout var cardImage = new Image { Stretch = Stretch.None }; var cardToggleButton = new ToggleButton { Content = cardImage, Margin = new Thickness(10) }; var resetButton = new Button { Content = new Border { Background = new SolidColorBrush(Colors.LightGray), Child = new TextBlock(spriteFontAdapter) { Text = "Reset", Margin = new Thickness(10) } }, Margin = new Thickness(10), HorizontalAlignment = HorizontalAlignment.Center }; var stackPanel = new StackPanel { Children = { cardToggleButton, resetButton } }; this.rootElement.Content = stackPanel; // Setup Data Binding var faceDownImage = new TextureImage(new Texture2DAdapter(this.Game.Content.Load <Texture2D>("FaceDown"))); var faceUpImage = new TextureImage(new Texture2DAdapter(this.Game.Content.Load <Texture2D>("FaceUp"))); var card = new Card(faceDownImage, faceUpImage); cardImage.Bind( Image.SourceProperty, BindingFactory.CreateOneWay <Card, ImageSource>(card, d => d.CardImage)); cardToggleButton.Bind( ToggleButton.IsCheckedProperty, BindingFactory.CreateTwoWay(card, d => d.IsCardFaceUp)); resetButton.Click += (sender, args) => card.Reset(); }
protected override void LoadContent() { this.spriteBatchAdapter = new SpriteBatchAdapter(new SpriteBatch(this.GraphicsDevice)); var primitivesService = new PrimitivesService(this.GraphicsDevice); var renderer = new Renderer(this.spriteBatchAdapter, primitivesService); this.rootElement = new RootElement(this.GraphicsDevice.Viewport.ToRect(), renderer); var spriteFont = this.Game.Content.Load <SpriteFont>("MySpriteFont"); var spriteFontAdapter = new SpriteFontAdapter(spriteFont); var grid = new Grid { Background = new SolidColorBrush(Colors.White), RowDefinitions = { new RowDefinition(), new RowDefinition { Height = new GridLength(320) }, new RowDefinition() }, ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(200) }, new ColumnDefinition { Width = new GridLength(200) } } }; this.rootElement.Content = grid; var topLeftBorder = new Border { BorderBrush = new SolidColorBrush(Colors.Black), BorderThickness = new Thickness(0, 0, 0, 2), Child = new TextBlock(spriteFontAdapter) { Text = "Score: 5483", Margin = new Thickness(10) } }; Grid.SetRow(topLeftBorder, 0); Grid.SetColumn(topLeftBorder, 0); grid.Children.Add(topLeftBorder); var topRightBorder = new Border { BorderBrush = new SolidColorBrush(Colors.Black), BorderThickness = new Thickness(0, 0, 0, 2), Child = new TextBlock(spriteFontAdapter) { Text = "High: 9999", Margin = new Thickness(10), HorizontalAlignment = HorizontalAlignment.Right } }; Grid.SetRow(topRightBorder, 0); Grid.SetColumn(topRightBorder, 1); grid.Children.Add(topRightBorder); var bottomLeftBorder = new Border { BorderBrush = new SolidColorBrush(Colors.Black), BorderThickness = new Thickness(0, 2, 0, 0), Background = new SolidColorBrush(new Color(106, 168, 79, 255)), Child = new TextBlock(spriteFontAdapter) { Text = "Lives: 3", Margin = new Thickness(10), VerticalAlignment = VerticalAlignment.Bottom } }; Grid.SetRow(bottomLeftBorder, 2); Grid.SetColumn(bottomLeftBorder, 0); grid.Children.Add(bottomLeftBorder); var bottomRightBorder = new Border { BorderBrush = new SolidColorBrush(Colors.Black), BorderThickness = new Thickness(0, 2, 0, 0), Background = new SolidColorBrush(new Color(106, 168, 79, 255)) }; Grid.SetRow(bottomRightBorder, 2); Grid.SetColumn(bottomRightBorder, 1); grid.Children.Add(bottomRightBorder); }
protected override void LoadContent() { this.spriteBatchAdapter = new SpriteBatchAdapter(new SpriteBatch(this.GraphicsDevice)); var primitivesService = new PrimitivesService(this.GraphicsDevice); var renderer = new Renderer(this.spriteBatchAdapter, primitivesService); this.rootElement = new RootElement(this.GraphicsDevice.Viewport.ToRect(), renderer); // TODO: Some changes in ReactiveEx v2.0, using alternative for now, fill fix up later //Observable.FromEvent<EventArgs>( // handler => this.Game.Window.OrientationChanged += handler, // handler => this.Game.Window.OrientationChanged -= handler).Subscribe( // _ => this.rootElement.Viewport = this.Game.GraphicsDevice.Viewport.ToRect()); // Alternative mechanism to hook up to the event. Ensure you manage unhooking the event yourself. this.Game.Window.OrientationChanged += (sender, args) => this.rootElement.Viewport = this.Game.GraphicsDevice.Viewport.ToRect(); var spriteFont = this.Game.Content.Load <SpriteFont>("MySpriteFont"); var spriteFontAdapter = new SpriteFontAdapter(spriteFont); var grid = new Grid { Background = new SolidColorBrush(Colors.White), RowDefinitions = { new RowDefinition { Height = new GridLength(50) }, new RowDefinition(), new RowDefinition { Height = new GridLength(50) } }, ColumnDefinitions = { new ColumnDefinition(), new ColumnDefinition() } }; this.rootElement.Content = grid; var topLeftBorder = new Border { BorderBrush = new SolidColorBrush(Colors.Black), BorderThickness = new Thickness(0, 0, 0, 2), Child = new TextBlock(spriteFontAdapter) { Text = "Score: 5483", Margin = new Thickness(10) } }; Grid.SetRow(topLeftBorder, 0); Grid.SetColumn(topLeftBorder, 0); grid.Children.Add(topLeftBorder); var topRightBorder = new Border { BorderBrush = new SolidColorBrush(Colors.Black), BorderThickness = new Thickness(0, 0, 0, 2), Child = new TextBlock(spriteFontAdapter) { Text = "High: 9999", Margin = new Thickness(10), HorizontalAlignment = HorizontalAlignment.Right } }; Grid.SetRow(topRightBorder, 0); Grid.SetColumn(topRightBorder, 1); grid.Children.Add(topRightBorder); var bottomLeftBorder = new Border { BorderBrush = new SolidColorBrush(Colors.Black), BorderThickness = new Thickness(0, 2, 0, 0), Background = new SolidColorBrush(new Color(106, 168, 79, 255)), Child = new TextBlock(spriteFontAdapter) { Text = "Lives: 3", Margin = new Thickness(10), VerticalAlignment = VerticalAlignment.Bottom } }; Grid.SetRow(bottomLeftBorder, 2); Grid.SetColumn(bottomLeftBorder, 0); grid.Children.Add(bottomLeftBorder); var bottomRightBorder = new Border { BorderBrush = new SolidColorBrush(Colors.Black), BorderThickness = new Thickness(0, 2, 0, 0), Background = new SolidColorBrush(new Color(106, 168, 79, 255)) }; Grid.SetRow(bottomRightBorder, 2); Grid.SetColumn(bottomRightBorder, 1); grid.Children.Add(bottomRightBorder); }