Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Drawing;
- namespace DealerCenter
- {
- using MonoMobile.MVVM;
- using MonoTouch.Foundation;
- using MonoTouch.UIKit;
- using System.Threading;
- [Register("AppDelegate")]
- public class AppDelegate : UIApplicationDelegate
- {
- private static UIImage _DefaultImage = UIImage.FromFile("Default.png");
- private UIWindow _Window;
- private UINavigationController _Navigation;
- // This method is invoked when the application has loaded its UI and its ready to run
- public override bool FinishedLaunching(UIApplication app, NSDictionary options)
- {
- _Navigation = new UINavigationController();
- _Navigation.View.BackgroundColor = UIColor.FromPatternImage(_DefaultImage);
- // Create the main window and add the navigation controller as a subview
- _Window = new UIWindow(UIScreen.MainScreen.Bounds);
- _Window.Alpha = 0.5f;
- _Window.AddSubview(_Navigation.View);
- _Window.MakeKeyAndVisible();
- Application.Window = _Window;
- Application.Navigation = _Navigation;
- // this method initializes the main menu Dialog
- var startupThread = new Thread(Startup as ThreadStart);
- startupThread.Start();
- return true;
- }
- [Export("Startup")]
- private void Startup()
- {
- using (var pool = new NSAutoreleasePool())
- {
- InvokeOnMainThread(delegate
- {
- var binding = new BindingContext(new LoginView(), "DealerCenter");
- _Navigation.ViewControllers = new UIViewController[] { new DialogViewController(UITableViewStyle.Grouped, binding, true) };//{Autorotate = true } };
- UIView.BeginAnimations("fadeIn");
- UIView.SetAnimationDuration(0.3f);
- _Window.Alpha = 1.0f;
- UIView.CommitAnimations();
- });
- }
- }
- // This method is allegedly required in iPhoneOS 3.0
- public override void OnActivated(UIApplication application)
- {
- }
- public override void WillTerminate (UIApplication application)
- {
- SaveScreen();
- }
- public override void DidEnterBackground (UIApplication application)
- {
- SaveScreen();
- }
- private void SaveScreen()
- {
- // Save screenshot as splashscreen
- UIGraphics.BeginImageContext(_Window.Bounds.Size);
- _Window.Layer.RenderInContext(UIGraphics.GetCurrentContext());
- var image = UIGraphics.GetImageFromCurrentImageContext();
- UIGraphics.EndImageContext();
- NSError err = new NSError();
- image.AsPNG().Save("Default.png", true, out err);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement