コード例 #1
0
ファイル: TestUITestGame.cs プロジェクト: GhostTap/MonoGame
		protected override void LoadContent()
		{
			base.LoadContent();

			_font = Content.Load<SpriteFont> (@"Fonts\Default");

			_universe = new Universe(Content) {
				AutoHandleInput = true
			};
			Components.Add (new UniverseComponent(this, _universe));

			var exitButton = new Button
			{
				BackgroundColor = Color.Black,
				Content = new Label {
					Font = _font,
					Text = "Exit",
					TextColor = Color.White
				},
				Location = PointF.Empty
			};

			exitButton.Content.SizeToFit ();
			exitButton.SizeToFit ();
			exitButton.Tapped += (sender, e) => {
				Exit ();
			};

			var label = new Label {
				BackgroundColor = Color.Indigo,
				Font = _font,
				Location = new PointF(20, 200),
				Text = "fantastic",
				TextColor = Color.White
			};

			label.SizeToFit ();

			var button1 = new Button
			{
				BackgroundColor = Color.OrangeRed,
				Content = new Label {
					Font = _font,
					Text = "Button 1",
					TextColor = Color.White
				},
				Location = new PointF(label.Frame.Left, 60)
			};

			button1.Content.SizeToFit ();
			button1.SizeToFit ();

			button1.Tapped += (sender, e) => {
				label.Text = ("button 1!");
			};

			var button2 = new Button
			{
				BackgroundColor = Color.Goldenrod,
				Content = new Label {
					Font = _font,
					Text = "Button 2",
					TextColor = Color.White
				},
				Location = new PointF(button1.Frame.Left, button1.Frame.Bottom)
			};

			button2.Content.SizeToFit ();
			button2.SizeToFit ();

			button2.Tapped += (sender, e) => {
				label.Text = ("button 2!");
			};

			_universe.Add (exitButton);
			_universe.Add (button1);
			_universe.Add (button2);
			_universe.Add (label);
		}
コード例 #2
0
ファイル: GuideTestGame.cs プロジェクト: Boerlam001/MonoGame
		private void InitializeGui()
		{
			_universe = new Universe (Content)
			{
				AutoHandleInput = true
			};
			Components.Add (new UniverseComponent (this, _universe));

			var exitButton = new Button
			{
				BackgroundColor = Color.Black,
				Content = new Label {
					Font = _font,
					Text = "Exit",
					TextColor = Color.White
				},
				Location = PointF.Empty
			};

			exitButton.Content.SizeToFit ();
			exitButton.SizeToFit ();
			exitButton.Tapped += (sender, e) => {
				Exit ();
			};

			_labelEndShowKeyboardInput = new Label
			{
				Frame = new RectangleF (20, 60, 320, 20),
				Font = _font,
				TextColor = Color.White
			};

			_labelShowKeyboardInputCallback = new Label
			{
				Frame = new RectangleF (
					_labelEndShowKeyboardInput.Frame.Left,
					_labelEndShowKeyboardInput.Frame.Bottom + 10,
					_labelEndShowKeyboardInput.Frame.Width,
					_labelEndShowKeyboardInput.Frame.Height),
				Font = _font,
				TextColor = Color.White
			};

			var buttonShowKeyboardInput = new Button
			{
				BackgroundColor = Color.Lavender,
				Content = new Label
				{
					Font = _font,
					Text = "Show Keyboard Input",
					TextColor = Color.Black
				},
				Location = new PointF(20, 200)
			};

			buttonShowKeyboardInput.Content.SizeToFit ();
			buttonShowKeyboardInput.SizeToFit ();
			buttonShowKeyboardInput.Tapped += (sender, e) => {
				TestShowKeyboardInput (
					"Some normal title",
					"And a perfectly ordinary description",
					"the default");
			};

			var buttonShowKeyboardInputLong = new Button
			{
				BackgroundColor = Color.Lavender,
				Content = new Label
				{
					Font = _font,
					Text = "Show Keyboard Input (long)",
					TextColor = Color.Black
				},
				Location = new PointF(
					buttonShowKeyboardInput.Frame.Left,
					buttonShowKeyboardInput.Frame.Bottom + 10)
			};

			buttonShowKeyboardInputLong.Content.SizeToFit ();
			buttonShowKeyboardInputLong.SizeToFit ();
			buttonShowKeyboardInputLong.Tapped += (sender, e) => {
				TestShowKeyboardInput (
					"This is the title that never ends, yes it goes on and on my friends.  One " +
					"day some people started writing it, etc",
					"And here is a super-duper description that rambles on a bit about, you " +
					"know, whatever.  And then finally ends over here at about this point.",
					"surprisingly terse default");
			};

			_universe.Add (exitButton);
			_universe.Add (_labelEndShowKeyboardInput);
			_universe.Add (_labelShowKeyboardInputCallback);
			_universe.Add (buttonShowKeyboardInput);
			_universe.Add (buttonShowKeyboardInputLong);
		}