/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

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