Advertisement
Guest User

Untitled

a guest
Apr 8th, 2011
468
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. using System.Drawing;
  2. namespace DealerCenter
  3. {
  4. using MonoMobile.MVVM;
  5. using MonoTouch.Foundation;
  6. using MonoTouch.UIKit;
  7. using System.Threading;
  8.  
  9. [Register("AppDelegate")]
  10. public class AppDelegate : UIApplicationDelegate
  11. {
  12. private static UIImage _DefaultImage = UIImage.FromFile("Default.png");
  13.  
  14. private UIWindow _Window;
  15. private UINavigationController _Navigation;
  16.  
  17. // This method is invoked when the application has loaded its UI and its ready to run
  18. public override bool FinishedLaunching(UIApplication app, NSDictionary options)
  19. {
  20. _Navigation = new UINavigationController();
  21. _Navigation.View.BackgroundColor = UIColor.FromPatternImage(_DefaultImage);
  22.  
  23. // Create the main window and add the navigation controller as a subview
  24. _Window = new UIWindow(UIScreen.MainScreen.Bounds);
  25.  
  26. _Window.Alpha = 0.5f;
  27.  
  28. _Window.AddSubview(_Navigation.View);
  29. _Window.MakeKeyAndVisible();
  30.  
  31. Application.Window = _Window;
  32. Application.Navigation = _Navigation;
  33.  
  34. // this method initializes the main menu Dialog
  35. var startupThread = new Thread(Startup as ThreadStart);
  36. startupThread.Start();
  37.  
  38. return true;
  39. }
  40.  
  41. [Export("Startup")]
  42. private void Startup()
  43. {
  44. using (var pool = new NSAutoreleasePool())
  45. {
  46. InvokeOnMainThread(delegate
  47. {
  48. var binding = new BindingContext(new LoginView(), "DealerCenter");
  49. _Navigation.ViewControllers = new UIViewController[] { new DialogViewController(UITableViewStyle.Grouped, binding, true) };//{Autorotate = true } };
  50.  
  51.  
  52. UIView.BeginAnimations("fadeIn");
  53. UIView.SetAnimationDuration(0.3f);
  54. _Window.Alpha = 1.0f;
  55. UIView.CommitAnimations();
  56. });
  57. }
  58. }
  59.  
  60. // This method is allegedly required in iPhoneOS 3.0
  61. public override void OnActivated(UIApplication application)
  62. {
  63. }
  64.  
  65. public override void WillTerminate (UIApplication application)
  66. {
  67. SaveScreen();
  68. }
  69.  
  70. public override void DidEnterBackground (UIApplication application)
  71. {
  72. SaveScreen();
  73. }
  74.  
  75. private void SaveScreen()
  76. {
  77. // Save screenshot as splashscreen
  78. UIGraphics.BeginImageContext(_Window.Bounds.Size);
  79.  
  80. _Window.Layer.RenderInContext(UIGraphics.GetCurrentContext());
  81. var image = UIGraphics.GetImageFromCurrentImageContext();
  82.  
  83. UIGraphics.EndImageContext();
  84.  
  85. NSError err = new NSError();
  86. image.AsPNG().Save("Default.png", true, out err);
  87. }
  88. }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement