PageRenderTime 22ms CodeModel.GetById 16ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/Hnefatafl/Controllers/MenuController.cs

https://bitbucket.org/trisi/hnefatafl-monotouch
C# | 74 lines | 64 code | 10 blank | 0 comment | 3 complexity | 19b153894019b6b82afece324b6de055 MD5 | raw file
 1using System;
 2using System.Collections.Generic;
 3using System.Linq;
 4using MonoTouch.Foundation;
 5using MonoTouch.UIKit;
 6using MonoTouch.GameKit;
 7using MonoTouch.MessageUI;
 8using Core;
 9
10namespace Hnefatafl {
11	public class MenuController : UIViewController {
12		MenuView view;
13		SelectVariationController variationController;
14		UIViewController gameController;
15		
16		public MenuController ()
17		{
18		}
19
20		public void btnPassNPlay_Pushed ()
21		{
22			variationController = new SelectVariationController (GameType.PassNPlay);
23			NavigationController.PushViewController (variationController, true);
24		}
25
26		public void btnAsynchronous_Pushed ()
27		{
28			gameController = new OnlineMenuController ();
29			NavigationController.PushViewController (gameController, true);
30		}
31
32		public void btnRules_Pushed ()
33		{
34			UIViewController rulesView = new RulesController ();
35			NavigationController.PushViewController (rulesView, true);
36		}
37
38		public void btnFeedback_Pushed ()
39		{
40			MFMailComposeViewController mail = new MFMailComposeViewController ();
41			mail.Finished += (object sender, MFComposeResultEventArgs e) => {
42				DismissViewController (true, null);
43				if (e.Result == MFMailComposeResult.Failed)
44					new UIAlertView ("Message Failed!", 
45				                         "Your email failed to send", 
46				                         null, "Okay", null).Show ();
47			};
48			if (MFMailComposeViewController.CanSendMail) {
49				mail.SetToRecipients ( new string [] { "risiapps@gmail.com" });
50				mail.SetSubject ("Hnefatafl Feedback");
51				mail.SetMessageBody ("", false);
52				PresentViewController (mail, true, null);
53			}
54		}
55		
56		public override void LoadView ()
57		{
58			view = new MenuView ();
59			
60			view.btnPassNPlay_Pushed = btnPassNPlay_Pushed;
61			view.btnAsynchronous_Pushed = btnAsynchronous_Pushed;
62			view.btnRules_Pushed = btnRules_Pushed;
63			view.btnFeedback_Pushed = btnFeedback_Pushed;
64			
65			View = view;
66		}
67		
68		public override void ViewWillAppear (bool animated)
69		{
70			NavigationController.NavigationBar.Hidden = true;
71			base.ViewDidLoad ();
72		}
73	}
74}