コード例 #1
0
ファイル: AppDelegate.cs プロジェクト: xamarin/Sport
		public override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo)
		{
			NSObject aps, alert, payload;

			if(!userInfo.TryGetValue(new NSString("aps"), out aps))
				return;

			var apsHash = aps as NSDictionary;

			NotificationPayload payloadValue = null;
			if(apsHash.TryGetValue(new NSString("payload"), out payload))
			{
				payloadValue = JsonConvert.DeserializeObject<NotificationPayload>(payload.ToString());
				if(payloadValue != null)
				{
					MessagingCenter.Send(App.Instance, Shared.Messages.IncomingPayloadReceivedInternal, payloadValue);
				}
			}

			var badgeValue = apsHash.ObjectForKey(new NSString("badge"));

			if(badgeValue != null)
			{
				int count;
				if(int.TryParse(new NSString(badgeValue.ToString()), out count))
				{
					//UIApplication.SharedApplication.ApplicationIconBadgeNumber = count;
				}
			}

			if(apsHash.TryGetValue(new NSString("alert"), out alert))
			{
				alert.ToString().ToToast(ToastNotificationType.Info, "Incoming notification");
			}
		}
コード例 #2
0
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init();
            LoadApplication(new App());

            return base.FinishedLaunching(app, options);
        }
コード例 #3
0
ファイル: AppDelegate.cs プロジェクト: Coladela/signalr-chat
		public override bool FinishedLaunching(UIApplication app, NSDictionary options)
		{
			window = new UIWindow(UIScreen.MainScreen.Bounds);

			var controller = new UIViewController();
			var view = new UIView (UIScreen.MainScreen.Bounds);
			view.BackgroundColor = UIColor.White;
			controller.View = view;

			controller.NavigationItem.Title = "SignalR Client";

			var textView = new UITextView(new CGRect(0, 0, 320, view.Frame.Height - 0));
			view.AddSubview (textView);


			navController = new UINavigationController (controller);

			window.RootViewController = navController;
			window.MakeKeyAndVisible();

			if (SIGNALR_DEMO_SERVER == "http://YOUR-SERVER-INSTANCE-HERE") {
				textView.Text = "You need to configure the app to point to your own SignalR Demo service.  Please see the Getting Started Guide for more information!";
				return true;
			}
			
			var traceWriter = new TextViewWriter(SynchronizationContext.Current, textView);

			var client = new CommonClient(traceWriter);
			client.RunAsync(SIGNALR_DEMO_SERVER);

			return true;
		}
コード例 #4
0
		public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
		{
			ServiceLocator.Instance.Add<IDatabase, Database>();
			Globe.SharedInstance.Database.InitializeDatabase();

			int userid = (int)NSUserDefaults.StandardUserDefaults.IntForKey("iduser");
			string username = NSUserDefaults.StandardUserDefaults.StringForKey("username");
			string password = NSUserDefaults.StandardUserDefaults.StringForKey("password");


			if (!String.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password) && userid != 0)
			{
				Globe.SharedInstance.User.username = username;
				Globe.SharedInstance.User.password = password;
				Globe.SharedInstance.User.idUser = userid;

				createTabBarController();
				Window.RootViewController = TabBarController;
				Window.MakeKeyAndVisible();
			}

			SDImageCache.SharedImageCache.ClearMemory();
			SDImageCache.SharedImageCache.ClearDisk();

			StartTickNotification();



			if (launchOptions != null && launchOptions.ObjectForKey(UIApplication.LaunchOptionsRemoteNotificationKey) != null && TabBarController != null)
			{
				TabBarController.SelectedIndex = 1;
			}

			return true;
		}
コード例 #5
0
ファイル: AppDelegate.cs プロジェクト: drgizmo666/IosDemo
		public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
		{
			// Override point for customization after application launch.
			// If not required for your application you can safely delete this method

			return true;
		}
コード例 #6
0
ファイル: AppDelegate.cs プロジェクト: jbravobr/Mais-XamForms
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            //UserDialogs.Init();
            global::Xamarin.Forms.Forms.Init();
            Insights.Initialize("0d729b1f8027a9219421908d521e3af664ae52fc");
            PushNotificationManager pushmanager = PushNotificationManager.PushManager;
            pushmanager.Delegate = this;

            if (options != null)
            {
                if (options.ContainsKey(UIApplication.LaunchOptionsRemoteNotificationKey))
                { 
                    pushmanager.HandlePushReceived(options);
                }
            }

            pushmanager.RegisterForPushNotifications();

            try
            {
                var token = PushNotificationManager.PushManager.GetPushToken;
                
                if (!String.IsNullOrEmpty(token))
                    App.PushWooshToken = token;
            }
            catch (Exception ex)
            {
                Insights.Report(ex);
            }

            LoadApplication(new App());

            return base.FinishedLaunching(app, options);
        }
コード例 #7
0
		public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
		{
			Current = this;

			// SQL
//			var sqliteFilename = "TaskDB.db3";
//			string documentsPath = Environment.GetFolderPath (Environment.SpecialFolder.Personal); // Documents folder
//			string libraryPath = Path.Combine (documentsPath, "..", "Library"); // Library folder
//			var path = Path.Combine(libraryPath, sqliteFilename);
//			var conn = new Connection(path);
//			TaskMgr = new TodoItemManager(conn);

			// AZURE
			TaskMgr = new TodoItemManager(AzureStorageImplementation.DefaultService);


			// PUSH
			//var settings = UIUserNotificationSettings.GetSettingsForTypes (
			//	UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound
			//	, null);
			//UIApplication.SharedApplication.RegisterUserNotificationSettings (settings);

			//UIRemoteNotificationType notificationTypes = 
			//	 UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound;
			//UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes); 

			return true;
		}
コード例 #8
0
ファイル: AppDelegate.cs プロジェクト: ehill8624/ValkreRender
        //
        // This method is invoked when the application has loaded and is ready to run. In this 
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
			Current = this;

			var log = new LoggerConfiguration().CreateLogger();

			log.Information("Loading");

            UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.LightContent;

            // create a new window instance based on the screen size
            window = new UIWindow(UIScreen.MainScreen.Bounds);

            // If you have defined a view, add it here:
            // window.RootViewController  = navigationController;

			var rootNavigationController = Utilities.BuildNavigationController();
            rootNavigationController.PushViewController(new ViewControllers.Login(), false);
            window.RootViewController = rootNavigationController;

            // make the window visible
            window.MakeKeyAndVisible();

            Utilities.SetTintColor();

            autoSuspendHelper.FinishedLaunching(app, options);

            return true;
        }
コード例 #9
0
		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{
			// create our window
			window = new UIWindow (UIScreen.MainScreen.Bounds);
			window.MakeKeyAndVisible ();
			
			// are we running an iPhone or an iPad?
			DetermineCurrentDevice ();

			// instantiate our main navigatin controller and add it's view to the window
			mainNavController = new UINavigationController ();
			
			switch (CurrentDevice)
			{
				case DeviceType.iPhone:
					iPhoneHome = new HandlingRotation.Screens.iPhone.Home.HomeScreen ();
					mainNavController.PushViewController (iPhoneHome, false);
					break;
				
				case DeviceType.iPad:
					iPadHome = new HandlingRotation.Screens.iPad.Home.HomeScreenPad ();
					mainNavController.PushViewController (iPadHome, false);
					break;
			}

			window.RootViewController = mainNavController;

			return true;
		}
コード例 #10
0
		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{
			Forms.Init ();


			// http://forums.xamarin.com/discussion/21148/calabash-and-xamarin-forms-what-am-i-missing
			Forms.ViewInitialized += (object sender, ViewInitializedEventArgs e) => {

				// http://developer.xamarin.com/recipes/testcloud/set-accessibilityidentifier-ios/
				if (null != e.View.StyleId) {
					e.NativeView.AccessibilityIdentifier = e.View.StyleId;
					Console.WriteLine("Set AccessibilityIdentifier: " + e.View.StyleId);
				}
			};


			window = new UIWindow (UIScreen.MainScreen.Bounds);
			
			window.RootViewController = App.GetMainPage ().CreateViewController ();
			window.MakeKeyAndVisible ();


			#if DEBUG
			// requires Xamarin Test Cloud Agent component
			Xamarin.Calabash.Start();
			#endif


			return true;
		}
コード例 #11
0
ファイル: AppDelegate.cs プロジェクト: haunthy/sensus
        public override bool FinishedLaunching(UIApplication uiApplication, NSDictionary launchOptions)
        {
            SensusServiceHelper.Initialize(() => new iOSSensusServiceHelper());

            // facebook settings
            Settings.AppID = "873948892650954";
            Settings.DisplayName = "Sensus";

            Forms.Init();
            FormsMaps.Init();
            MapExtendRenderer.Init();

            // toasts for iOS
            DependencyService.Register<ToastNotificatorImplementation>();
            ToastNotificatorImplementation.Init();

            LoadApplication(new App());

            uiApplication.RegisterUserNotificationSettings(UIUserNotificationSettings.GetSettingsForTypes(UIUserNotificationType.Badge | UIUserNotificationType.Sound | UIUserNotificationType.Alert, new NSSet()));

            #if UNIT_TESTING
            Forms.ViewInitialized += (sender, e) =>
            {
                if (!string.IsNullOrWhiteSpace(e.View.StyleId))
                    e.NativeView.AccessibilityIdentifier = e.View.StyleId;
            };

            Calabash.Start();
            #endif

            return base.FinishedLaunching(uiApplication, launchOptions);
        }
コード例 #12
0
        // This method is invoked when the application has loaded its UI and its ready to run
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            window.AddSubview (navigationController.View);
            window.MakeKeyAndVisible ();

            return true;
        }
		//
		// This method is invoked when the application has loaded and is ready to run. In this 
		// method you should instantiate the window, load the UI into it and then make the window
		// visible.
		//
		// You have 17 seconds to return from this method, or iOS will terminate your application.
		//
		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{
			// create a new window instance based on the screen size
			window = new UIWindow (UIScreen.MainScreen.Bounds);
			
			// load the appropriate UI, depending on whether the app is running on an iPhone or iPad
			if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone) {
				var controller = new RootViewController ();
				navigationController = new UINavigationController (controller);
				window.RootViewController = navigationController;
			} else {
				var masterViewController = new RootViewController ();
				var masterNavigationController = new UINavigationController (masterViewController);
				var detailViewController = new DetailViewController ();
				var detailNavigationController = new UINavigationController (detailViewController);
				
				splitViewController = new UISplitViewController ();
				splitViewController.WeakDelegate = detailViewController;
				splitViewController.ViewControllers = new UIViewController[] {
					masterNavigationController,
					detailNavigationController
				};
				
				window.RootViewController = splitViewController;
			}

			// make the window visible
			window.MakeKeyAndVisible ();
			
			return true;
		}
コード例 #14
0
		// This method is invoked when the application has loaded its UI and its ready to run
		public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
		{
			window.RootViewController = viewController;
			window.MakeKeyAndVisible ();

			return true;
		}
コード例 #15
0
        public override void FinishedPickingMedia(UIImagePickerController picker, NSDictionary info)
        {
            
            MediaFile mediaFile;
            switch ((NSString)info[UIImagePickerController.MediaType])
            {
                case MediaImplementation.TypeImage:
                    mediaFile = GetPictureMediaFile(info);
                    break;

                case MediaImplementation.TypeMovie:
                    mediaFile = GetMovieMediaFile(info);
                    break;

                default:
                    throw new NotSupportedException();
            }

            if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone)
            {
                UIApplication.SharedApplication.SetStatusBarStyle(MediaImplementation.StatusBarStyle, false);
            }

            Dismiss(picker, () => 
            {
                

                this.tcs.TrySetResult(mediaFile);
            });
        }
コード例 #16
0
		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{
			// check is it 64bit or 32bit
			Console.WriteLine (IntPtr.Size);

			// Main app do nothing
			// Go to Photo > Edit then choose PhotoFilter to start app extension

			window = new UIWindow (UIScreen.MainScreen.Bounds);
			window.BackgroundColor = UIColor.White;

			note = new UILabel ();
			note.Text = "Note that the app in this sample only serves as a host for the extension. To use the sample extension, edit a photo or video using the Photos app, and tap the extension icon";
			note.Lines = 0;
			note.LineBreakMode = UILineBreakMode.WordWrap;
			var frame = note.Frame;
			note.Frame = new CGRect (0, 0, UIScreen.MainScreen.Bounds.Width * 0.75f, 0);
			note.SizeToFit ();

			window.AddSubview (note);
			note.Center = window.Center;

			window.MakeKeyAndVisible ();
			return true;
		}
コード例 #17
0
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            //
            // ENTER YOUR LICENSE INFO HERE
            //
            PXEngine.LicenseKeyForUser("SERIAL NUMBER", "USER NAME");

            // create a new window instance based on the screen size
            window = new UIWindow (UIScreen.MainScreen.Bounds);

            window.RootViewController = new MyViewController();

            // make the window visible
            window.MakeKeyAndVisible ();

            PXEngine shared = PXEngine.SharedInstance();

            // Print the version an build date
            Console.WriteLine("Pixate Engine v{0} {1}", shared.Version, shared.BuildDate);

            // Print the location of the current application-level stylesheet
            Console.WriteLine("CSS File location: {0}", PXStylesheet.CurrentApplicationStylesheet().FilePath);

            // Monitor for changes in the stylesheet and update styles live
            PXStylesheet.CurrentApplicationStylesheet().MonitorChanges = true;

            return true;
        }
コード例 #18
0
        public override void DetectWebViewLoadFinishedEvent(UIApplication application, NSDictionary launchOptions)
        {
            UIApplicationState applicationState = application.ApplicationState;
            ((UnityUI_iOSViewController_UIWebView) MainViewController ()).webView.LoadFinished += delegate {
                #if DEBUG
            log ("************** WEBVIEW LOAD FINISHED");
                #endif

                if (UIDevice.CurrentDevice.CheckSystemVersion (8, 0)) {
                    UIView.AnimationsEnabled = true;  //enable again animation in all view  (see UnityUI_iOSViewController_UIWebView#loadWebView for details)
                }

                // inform other weak delegates (if exist) about the web view finished event
                IPhoneServiceLocator.WebViewLoadingFinished(applicationState, launchOptions);

                // The NSDictionary options variable would contain any notification data if the user clicked the 'view' button on the notification
                // to launch the application.
                // This method processes these options from the FinishedLaunching.
                processLaunchOptions (launchOptions, true, applicationState);

                // Processing extra data received when launched externally (using custom scheme url)
                processLaunchData ();

            };
        }
コード例 #19
0
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            window = new UIWindow (UIScreen.MainScreen.Bounds);
            UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.BlackTranslucent;
            viewController = new FlyOutNavigationController ();
            viewController.NavigationRoot = new RootElement ("")
            {
                new Section ("Section 1"){
                    new StringElement ("View 1"),
                    new ImageStringElement("View 2",UIImage.FromFile("jhill.jpeg")),
                    new StringElement ("View 3"),
                },
                new Section ("Section 2"){
                    new StringElement ("View 1"),
                    new StringElement ("View 2"),
                }
            };
            viewController.ViewControllers = new UIViewController[]{
                 new UINavigationController (new BaseDialogViewController (viewController, new RootElement ("Section 1"){new Section (){new StringElement ("View 1")}}))
                ,new UINavigationController (new BaseDialogViewController (viewController, new RootElement ("Section 1"){new Section (){new StringElement ("View 2")}}))
                ,new UINavigationController (new BaseDialogViewController (viewController, new RootElement ("Section 1"){new Section (){new StringElement ("View 3")}}))
                ,new UINavigationController (new BaseDialogViewController (viewController, new RootElement ("Section 2"){new Section (){new StringElement ("View 1")}}))
                ,new UINavigationController (new BaseDialogViewController (viewController, new RootElement ("Section 2"){new Section (){new StringElement ("View 2")}}))
            };
            window.RootViewController = viewController;
            window.MakeKeyAndVisible ();

            return true;
        }
コード例 #20
0
ファイル: AppDelegate.cs プロジェクト: RTodorov/userdialogs
        public override bool FinishedLaunching(UIApplication app, NSDictionary options) {
            UserDialogs.Init();
            Forms.Init();
            this.LoadApplication(new App());

            return base.FinishedLaunching(app, options);
        }
コード例 #21
0
		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{
			// create a new window instance based on the screen size
			window = new UIWindow (UIScreen.MainScreen.Bounds);
			
			// make the window visible
			window.MakeKeyAndVisible ();
			
			// create our nav controller
			navController = new UINavigationController ();

			// create our home controller based on the device
			if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone) {
				homeViewController = new Tasky.Screens.iPhone.Home.controller_iPhone();
			} else {
//				homeViewController = new Hello_UniversalViewController ("Hello_UniversalViewController_iPad", null);
			}
			
			// Styling
			UINavigationBar.Appearance.TintColor = UIColor.FromRGB (38, 117 ,255); // nice blue
			UITextAttributes ta = new UITextAttributes();
			ta.Font = UIFont.FromName ("AmericanTypewriter-Bold", 0f);
			UINavigationBar.Appearance.SetTitleTextAttributes(ta);
			ta.Font = UIFont.FromName ("AmericanTypewriter", 0f);
			UIBarButtonItem.Appearance.SetTitleTextAttributes(ta, UIControlState.Normal);
			

			// push the view controller onto the nav controller and show the window
			navController.PushViewController(homeViewController, false);
			window.RootViewController = navController;
			window.MakeKeyAndVisible ();
			
			return true;
		}
コード例 #22
0
ファイル: Settings.cs プロジェクト: g7steve/monotouch-samples
		static void LoadDefaultValues ()
		{
			var settingsDict = new NSDictionary (NSBundle.MainBundle.PathForResource ("Settings.bundle/Root.plist", null));

			var prefSpecifierArray = settingsDict["PreferenceSpecifiers"] as NSArray;

			foreach (var prefItem in NSArray.FromArray<NSDictionary> (prefSpecifierArray)) {
				var key = (NSString)prefItem["Key"];
				if (key == null)
					continue;

				var val = prefItem["DefaultValue"];
				switch (key.ToString ()) {
					case firstNameKey:
						FirstName = val.ToString ();
						break;
					case lastNameKey:
						LastName = val.ToString ();
						break;
					case nameColorKey:
						TextColor = (TextColors)((NSNumber)val).Int32Value;
						break;
					case backgroundColorKey:
						BackgroundColor = (BackgroundColors)((NSNumber)val).Int32Value;
						break;
				}
			}
			var appDefaults = new NSDictionary (firstNameKey, FirstName, lastNameKey, LastName, nameColorKey, (int)TextColor, backgroundColorKey, (int)BackgroundColor);

			NSUserDefaults.StandardUserDefaults.RegisterDefaults (appDefaults);
			NSUserDefaults.StandardUserDefaults.Synchronize ();
		}
コード例 #23
0
		void AddConstraints ()
		{
			var views = new NSDictionary ("textView", textView);

			View.AddConstraints (NSLayoutConstraint.FromVisualFormat ("H:|-0-[textView]-0-|", 0, null, views));
			View.AddConstraints (NSLayoutConstraint.FromVisualFormat ("V:|-0-[textView]-0-|", 0, null, views));
		}
コード例 #24
0
ファイル: AppDelegate.cs プロジェクト: sdhakal/imageProject
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            var manager = new DBAccountManager (DropboxSyncKey, DropboxSyncSecret);
            DBAccountManager.SharedManager = manager;

            // create a new window instance based on the screen size
            window = new UIWindow (UIScreen.MainScreen.Bounds);

            window.RootViewController = new UINavigationController (new PlaygroundViewController ());

            Task.Factory.StartNew (() => {
                this.BeginInvokeOnMainThread (() => {
                    var account = DBAccountManager.SharedManager.LinkedAccount;
                    if (account != null) {
                        SetupDropbox ();
                    } else
                        manager.LinkFromController (window.RootViewController);
                });
            });
            // make the window visible
            window.MakeKeyAndVisible ();

            app.ApplicationSupportsShakeToEdit = true;
            return true;
        }
コード例 #25
0
		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{
			// create a new window instance based on the screen size
			window = new UIWindow (UIScreen.MainScreen.Bounds);
			
			// make the window visible
			window.MakeKeyAndVisible ();
			
			// create our nav controller
			navController = new UINavigationController ();

			// create our home controller based on the device
			if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone) {
				homeViewController = new Screens.HomeScreen();
			} else {
// sample does not contain an iPad UI
//				homeViewController = new Screens.iPadHomeScreen ();
			}
			
			// push the view controller onto the nav controller and show the window
			navController.PushViewController(homeViewController, false);
			window.RootViewController = navController;
			window.MakeKeyAndVisible ();
			
			return true;
		}
コード例 #26
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            Forms.Init ();
            FFImageLoading.Forms.Touch.CachedImageRenderer.Init();

            PSPDFKitGlobal.SetLicenseKey ("Y3Bqql3OalXRl48bnbk9xtd6ZuDlrCZLUpKIwqZSvsBoeoRcg3pJUv1Mkr4fAn3GZxQIB7xp+Rlqxd+rrorXvolIpe2tXXuYN0Qv+4SlZUbGwePPseh1/Co7pY2nnP0GM9ppHCu/atHaMTB89UgoMtY+SSlNhVaFzHPtCP+lmazOlajqVjGN6YwfrlIb+H4EX66qQqU3+iR6y2XLCrm2IdJ2xDssNifAL0OlpujjCtGQWpLTFy3dGp7Sai5qqwEmnrbFv9TWdNFJ0wr8lOPi6DDBmgD8IzZPz8qfV9xEwiOqHhQ6G91OBKlIetojJcxqYc4x9ZG96TCoym4JRgBiu4p/5WarK5Yw1K4pz7BezsGh3InvD0cv6YnsgulGsQbBLFjAFoWbe+VLuiaMg+f07foklE6Yf5oncn4y46pEB6ZJUkXKqdhfKCb3GiE+77D4pa1+e3ntSYj6aLrdYd4RR3OTx6Ml3cveDIT7c1uFCYYzr95hGgu4NbxImb5tRmat//NXzZqnCVkaWze/szd0d1VsX6imtffJkIuqCjGPifZeL7QWGokN32P5/hxcIK6K");
            //[PSPDFKit sharedInstance][@"com.pspdfkit.development.suppress-warning-alerts"] = @YES;
            App.CurrentDevice = new iOSDeviceInfo ().GetDeviceModel (DeviceHardware.Version);
            App.ScreenWidth = (int)UIScreen.MainScreen.Bounds.Width;
            App.ScreenHeight = (int)UIScreen.MainScreen.Bounds.Height;

            LoadApplication (new App());

            return base.FinishedLaunching (app,options);

            //			Forms.Init ();
            //			//var version = PSPDFKitGlobal.SharedInstance.Version;
            //			// Activate PSPDFKit for com.corning.mediando.opcomm
            //			//[PSPDFKit setLicenseKey:@"Y3Bqql3OalXRl48bnbk9xtd6ZuDlrCZLUpKIwqZSvsBoeoRcg3pJUv1Mkr4fAn3GZxQIB7xp+Rlqxd+rrorXvolIpe2tXXuYN0Qv+4SlZUbGwePPseh1/Co7pY2nnP0GM9ppHCu/atHaMTB89UgoMtY+SSlNhVaFzHPtCP+lmazOlajqVjGN6YwfrlIb+H4EX66qQqU3+iR6y2XLCrm2IdJ2xDssNifAL0OlpujjCtGQWpLTFy3dGp7Sai5qqwEmnrbFv9TWdNFJ0wr8lOPi6DDBmgD8IzZPz8qfV9xEwiOqHhQ6G91OBKlIetojJcxqYc4x9ZG96TCoym4JRgBiu4p/5WarK5Yw1K4pz7BezsGh3InvD0cv6YnsgulGsQbBLFjAFoWbe+VLuiaMg+f07foklE6Yf5oncn4y46pEB6ZJUkXKqdhfKCb3GiE+77D4pa1+e3ntSYj6aLrdYd4RR3OTx6Ml3cveDIT7c1uFCYYzr95hGgu4NbxImb5tRmat//NXzZqnCVkaWze/szd0d1VsX6imtffJkIuqCjGPifZeL7QWGokN32P5/hxcIK6K");
            //			//PSPDFKitGlobal.SetLicenseKey ("Y3Bqql3OalXRl48bnbk9xtd6ZuDlrCZLUpKIwqZSvsBoeoRcg3pJUv1Mkr4fAn3GZxQIB7xp+Rlqxd+rrorXvolIpe2tXXuYN0Qv+4SlZUbGwePPseh1/Co7pY2nnP0GM9ppHCu/atHaMTB89UgoMtY+SSlNhVaFzHPtCP+lmazOlajqVjGN6YwfrlIb+H4EX66qQqU3+iR6y2XLCrm2IdJ2xDssNifAL0OlpujjCtGQWpLTFy3dGp7Sai5qqwEmnrbFv9TWdNFJ0wr8lOPi6DDBmgD8IzZPz8qfV9xEwiOqHhQ6G91OBKlIetojJcxqYc4x9ZG96TCoym4JRgBiu4p/5WarK5Yw1K4pz7BezsGh3InvD0cv6YnsgulGsQbBLFjAFoWbe+VLuiaMg+f07foklE6Yf5oncn4y46pEB6ZJUkXKqdhfKCb3GiE+77D4pa1+e3ntSYj6aLrdYd4RR3OTx6Ml3cveDIT7c1uFCYYzr95hGgu4NbxImb5tRmat//NXzZqnCVkaWze/szd0d1VsX6imtffJkIuqCjGPifZeL7QWGokN32P5/hxcIK6K");
            //			//var version = PSPDFKitGlobal.SharedInstance.Version;
            //			PSPDFKitGlobal.SetLicenseKey ("blcWhXFIwpatKqQ1FoOb3HyC_2clmIg-rDyAKwQapxIFxDfXqmFqKYedy0oMW94i90ERmUNfPU4B8_V1D6TeTyNmFlL-ICnqWCW5NxT2MW1E_K1RkhWgyqo0rOACe6o5tdoKwwCHLrccRnHzDnGShjYRs9boy2bcZmegG5KIti21WRkkhiUu5kIyRG7DvIOPliWFGMoQI9020S6Ak6j8Nc6abAkVQXAjPFXbEVpFTIIRcD7xGFkEwS6oL7YatYkKYbY94GFRYv6YLedMblRntdMVOPsrSidxOqerjU2Myom9Dxkx5CxvIvWKZLV00cjma_BCy4rgq9GO9ScYytQH1qiyaK8Hyk8oBSAiGhveUP7SAA7uS2CR9ZU0buZ-Cneqli4yw91PHPwRx1GpFItvMw5og157ajhN5UixQJ76T3c=");
            //			App.CurrentDevice = new iOSDeviceInfo ().GetDeviceModel (DeviceHardware.Version);
            //			App.ScreenWidth = (int)UIScreen.MainScreen.Bounds.Width;
            //			App.ScreenHeight = (int)UIScreen.MainScreen.Bounds.Height;
            //
            //			LoadApplication (new App());
            //
            //			return base.FinishedLaunching (app,options);
        }
コード例 #27
0
		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{
			window = new UIWindow (UIScreen.MainScreen.Bounds);

			MenuViewController menuViewController = new MenuViewController(UITableViewStyle.Grouped);
			DetailsViewController detailsViewController = new DetailsViewController();
			UINavigationController navController = new UINavigationController (detailsViewController);

			SlideMenuController slideMenuViewController = new SlideMenuController();
			slideMenuViewController.SetContentViewController (navController);
			slideMenuViewController.SetLeftMenuViewController (menuViewController);

			UINavigationController cont = new UINavigationController (new MenuViewController (UITableViewStyle.Plain));

			slideMenuViewController.SetRightMenuViewController (cont);

			if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) {
				slideMenuViewController.WidthOfPortraitContentViewVisible = 300f;
				slideMenuViewController.WidthOfLandscapeContentViewVisible = 556f;
			}

			window.RootViewController = slideMenuViewController;

			window.BackgroundColor = UIColor.White;
			window.MakeKeyAndVisible ();			
			return true;
		}
コード例 #28
0
ファイル: AppDelegate.cs プロジェクト: timrisi/Hashed
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            // create a new window instance based on the screen size
            window = new UIWindow (UIScreen.MainScreen.Bounds);

            InvokeOnMainThread(delegate {
                TwitterAccount.getAccount();
            });

            flyoutController = new FlyOutNavigationController();
            tl = new Timeline(flyoutController);
            flyoutController.NavigationRoot = new RootElement("")
            {
                new Section("Navigation")
                {
                    new StringElement("Timeline")
                }
            };

            flyoutController.ViewControllers = new UIViewController[]
            {
                new UINavigationController(tl)
            };

            window.AddSubview(flyoutController.View);

            // make the window visible
            window.MakeKeyAndVisible ();

            return true;
        }
コード例 #29
0
ファイル: AppDelegate.cs プロジェクト: ARMoir/mobile-samples
		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{

			// create a new window instance based on the screen size
			window = new UIWindow (UIScreen.MainScreen.Bounds);

			var sqliteFilename = "TodoSQLite.db3";
			string documentsPath = Environment.GetFolderPath (Environment.SpecialFolder.Personal); // Documents folder
			string libraryPath = Path.Combine (documentsPath, "..", "Library"); // Library folder
			var path = Path.Combine(libraryPath, sqliteFilename);

			// This is where we copy in the prepopulated database
			Console.WriteLine (path);
			if (!File.Exists (path)) {
				File.Copy (sqliteFilename, path);
			}

			var plat = new SQLite.Net.Platform.XamarinIOS.SQLitePlatformIOS();
			var conn = new SQLite.Net.SQLiteConnection(plat, path);

			// Set the database connection string
			App.SetDatabaseConnection (conn);

//			window.RootViewController = new HybridRazorViewController ();
			window.RootViewController = new UINavigationController(new NativeListViewController ());

			// make the window visible
			window.MakeKeyAndVisible ();

			return true;
		}
コード例 #30
0
		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{
			window = new UIWindow (UIScreen.MainScreen.Bounds);
			runner = new TouchRunner (window);

			// tests can be inside the main assembly
			runner.Add (Assembly.GetExecutingAssembly ());
#if false
			// you can use the default or set your own custom writer (e.g. save to web site and tweet it ;-)
			runner.Writer = new TcpTextWriter ("10.0.1.2", 16384);
			// start running the test suites as soon as the application is loaded
			runner.AutoStart = true;
			// crash the application (to ensure it's ended) and return to springboard
			runner.TerminateAfterExecution = true;
#endif
#if false
			// you can get NUnit[2-3]-style XML reports to the console or server like this
			// replace `null` (default to Console.Out) to a TcpTextWriter to send data to a socket server
			// replace `NUnit2XmlOutputWriter` with `NUnit3XmlOutputWriter` for NUnit3 format
			runner.Writer = new NUnitOutputTextWriter (runner, null, new NUnitLite.Runner.NUnit2XmlOutputWriter ());
			// the same AutoStart and TerminateAfterExecution can be used for build automation
#endif
			window.RootViewController = new UINavigationController (runner.GetViewController ());
			window.MakeKeyAndVisible ();
			return true;
		}
コード例 #31
0
ファイル: AppDelegate.cs プロジェクト: takio12/MVVMCross
 public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
 {
     // Override point for customization after application launch.
     // If not required for your application you can safely delete this method
     return(true);
 }
コード例 #32
0
 public override void DidCancel(SIOverlayController overlayController, NSDictionary status)
 {
     // Perform actions after cancel was pressed
 }
 public override void FinishedPickingMedia(UIImagePickerController picker, NSDictionary info)
 {
     picker.DismissModalViewController(true);
     var image = info.ValueForKey(new NSString("UIImagePickerControllerOriginalImage")) as UIImage;
 }
コード例 #34
0
 internal AVAudioPlayerSettings(NSDictionary dictionary)
 {
     dict = dictionary;
 }
コード例 #35
0
 public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
 {
     LaunchGame();
     return(true);
 }
コード例 #36
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            UINavigationBar.Appearance.BarTintColor = UIColor.GroupTableViewBackgroundColor;
            UINavigationBar.Appearance.SetBackgroundImage(null, UIBarMetrics.Default);
            datepckrDate.MinimumDate = DateTime.Today;
            datepckrDate.MaximumDate = DateTime.Today.AddDays(720);
            datepckrDate.SetDate(Convert.ToDateTime(_game.release_date + " 9:00:00 AM"), true);

            btnCancel.TouchUpInside += delegate {
                this.DismissViewController(true, null);
                UINavigationBar.Appearance.BarTintColor = UIColor.FromRGB(87, 130, 23);
                UINavigationBar.Appearance.SetBackgroundImage(UIImage.FromBundle("navbar-background.png"), UIBarMetrics.Default);
            };

            btnAdd.TouchUpInside += delegate {
                if (!swtchGamebitNot.On && !swtchCalendar.On)
                {
                    new UIAlertView("Unable to Add",
                                    "Please select how you would like to be notified", null,
                                    "OK", null).Show();
                }
                if (swtchGamebitNot.On)
                {
                    var keys = new object[] {
                        "coverImage", "itemId"
                    };
                    var objects = new object[] {
                        _game.cover_image_url, _game.id
                    };
                    var userInfo = NSDictionary.FromObjectsAndKeys(objects, keys);
                    UILocalNotification notification = new UILocalNotification {
                        FireDate  = datepckrDate.Date,
                        TimeZone  = NSTimeZone.LocalTimeZone,
                        AlertBody = _game.title_2 == "" ?
                                    _game.title + "\n" + _game.release_date :
                                    _game.title + "\n" + _game.title_2 + "\n" + _game.release_date,
                        RepeatInterval = 0,
                        UserInfo       = userInfo
                    };
                    UIApplication.SharedApplication.ScheduleLocalNotification(notification);
                    if (swtchGamebitNot.On && !swtchCalendar.On)
                    {
                        ReminderAddedAnimation();
                    }
                }
                if (swtchCalendar.On)
                {
                    App.Common.EventStore.RequestAccess(EKEntityType.Event,
                                                        (bool granted, NSError e) => {
                        if (granted)
                        {
                            EKEvent newEvent      = EKEvent.FromStore(App.Common.EventStore);
                            newEvent.Availability = EKEventAvailability.Free;
                            newEvent.StartDate    = Convert.ToDateTime(_game.release_date + " 9:00:00 AM");
                            newEvent.EndDate      = newEvent.StartDate.AddSeconds(3600);
                            newEvent.Title        = String.IsNullOrEmpty(_game.title_2) ? _game.title : _game.title_2 + _game.title;
                            newEvent.Notes        = _game.description;
                            newEvent.Url          = new NSUrl(_game.game_url);
                            newEvent.Calendar     = App.Common.EventStore.DefaultCalendarForNewEvents;
                            NSError er;
                            App.Common.EventStore.SaveEvent(newEvent, EKSpan.ThisEvent, out er);
                            BeginInvokeOnMainThread(() =>
                                                    ReminderAddedAnimation());
                        }
                        else
                        {
                            BeginInvokeOnMainThread(() =>
                                                    new UIAlertView("Access Denied",
                                                                    "User Denied Access to Calendar Data", null,
                                                                    "OK", null).Show());
                        }
                    });
                }
            };
        }
コード例 #37
0
ファイル: ImportExport.cs プロジェクト: zezba9000/maccore
 static public SecStatusCode ImportPkcs12(byte[] buffer, NSDictionary options, out NSDictionary[] array)
 {
     using (NSData data = NSData.FromArray(buffer)) {
         return(ImportPkcs12(data, options, out array));
     }
 }
コード例 #38
0
 public ExternalChangeEventArgs(ABAddressBook addressBook, NSDictionary info)
 {
     AddressBook = addressBook;
     Info        = info;
 }
コード例 #39
0
 public AVAudioRecorder(NSUrl url, NSDictionary settings, NSError outError)
 {
     throw new Exception("This constructor is no longer supported, use the AVAudioRecorder.ToUrl factory method instead");
 }
コード例 #40
0
        public override bool OpenUrl(UIApplication app, NSUrl url, NSDictionary options)
        {
            AuthenticationContinuationHelper.SetAuthenticationContinuationEventArgs(url);

            return(true);
        }
コード例 #41
0
 public override void FinishedPickingImage(UIImagePickerController picker, UIImage image, NSDictionary editingInfo)
 {
     if (Callback != null)
     {
         Callback(image, editingInfo);
     }
 }
コード例 #42
0
 static AVAudioRecorder ToUrl(NSUrl url, NSDictionary settings, out NSError error)
 {
     return(Create(url, new AudioSettings(settings), out error));
 }
コード例 #43
0
 public void BeginTransparencyLayer(NSDictionary auxiliaryInfo = null)
 {
     CGContextBeginTransparencyLayer(handle, auxiliaryInfo == null ? IntPtr.Zero : auxiliaryInfo.Handle);
 }
コード例 #44
0
 private static NSDictionary StringDictToNSDict(IDictionary <string, string> dict)
 {
     return(NSDictionary.FromObjectsAndKeys(dict.Values.ToArray(), dict.Keys.ToArray()));
 }
コード例 #45
0
ファイル: AppDelegate.cs プロジェクト: kqhuynguyen/bk-news
 public override bool OpenUrl(UIApplication app, NSUrl url, NSDictionary options)
 {
     return(NewsManager.DefaultManager.CurrentClient.ResumeWithURL(url));
 }
コード例 #46
0
 public void BeginTransparencyLayer(CGRect rectangle, NSDictionary auxiliaryInfo = null)
 {
     CGContextBeginTransparencyLayerWithRect(handle, rectangle, auxiliaryInfo == null ? IntPtr.Zero : auxiliaryInfo.Handle);
 }
コード例 #47
0
ファイル: MyMoodViewController.cs プロジェクト: ruscal/myMood
 void SyncingWithServer(NSDictionary n)
 {
     this.syncStatusBtnView.ShowSyncing();
 }
コード例 #48
0
 public MvxPageViewController(UIPageViewControllerTransitionStyle style, UIPageViewControllerNavigationOrientation navigationOrientation, NSDictionary options) : base(style, navigationOrientation, options)
 {
     this.AdaptForBinding();
 }
コード例 #49
0
 protected AVPlayerItemVideoOutput(NSDictionary pixelBufferAttributes) : this(pixelBufferAttributes, InitMode.PixelAttributes)
 {
 }
コード例 #50
0
ファイル: MyMoodViewController.cs プロジェクト: ruscal/myMood
 void newPromptRecieved(NSDictionary n)
 {
     this.Refresh();
     this.ShowOutstandingPromptsView();
 }
コード例 #51
0
 //
 // This method is invoked when the application has loaded and is ready to run. In this
 // method you should instantiate the window, load the UI into it and then make the window
 // visible.
 //
 // You have 17 seconds to return from this method, or iOS will terminate your application.
 //
 public override bool FinishedLaunching(UIApplication uiApplication, NSDictionary launchOptions)
 {
     return(base.FinishedLaunching(uiApplication, launchOptions));
 }
コード例 #52
0
ファイル: MyMoodViewController.cs プロジェクト: ruscal/myMood
 void DatabaseReset(NSDictionary n)
 {
     this.DetermineState();
 }
コード例 #53
0
 public override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo)
 {
     // We need this to fire userInfo into ParsePushNotificationReceived.
     ParsePush.HandlePush(userInfo);
 }
コード例 #54
0
        private static void ResizeAndCompressImage(StoreCameraMediaOptions options, MediaFile mediaFile, string pathExtension)
        {
            var image   = UIImage.FromFile(mediaFile.Path);
            var percent = 1.0f;

            if (options.PhotoSize != PhotoSize.Full)
            {
                try
                {
                    switch (options.PhotoSize)
                    {
                    case PhotoSize.Large:
                        percent = .75f;
                        break;

                    case PhotoSize.Medium:
                        percent = .5f;
                        break;

                    case PhotoSize.Small:
                        percent = .25f;
                        break;

                    case PhotoSize.Custom:
                        percent = (float)options.CustomPhotoSize / 100f;
                        break;
                    }

                    if (options.PhotoSize == PhotoSize.MaxWidthHeight && options.MaxWidthHeight.HasValue)
                    {
                        var max = Math.Max(image.Size.Width, image.Size.Height);
                        if (max > options.MaxWidthHeight.Value)
                        {
                            percent = (float)options.MaxWidthHeight.Value / (float)max;
                        }
                    }

                    if (percent < 1.0f)
                    {
                        //begin resizing image
                        image = image.ResizeImageWithAspectRatio(percent);
                    }

                    NSDictionary meta = null;
                    try
                    {
                        //meta = PhotoLibraryAccess.GetPhotoLibraryMetadata(asset.AssetUrl);

                        //meta = info[UIImagePickerController.MediaMetadata] as NSDictionary;
                        if (meta != null && meta.ContainsKey(ImageIO.CGImageProperties.Orientation))
                        {
                            var newMeta = new NSMutableDictionary();
                            newMeta.SetValuesForKeysWithDictionary(meta);
                            var newTiffDict = new NSMutableDictionary();
                            newTiffDict.SetValuesForKeysWithDictionary(meta[ImageIO.CGImageProperties.TIFFDictionary] as NSDictionary);
                            newTiffDict.SetValueForKey(meta[ImageIO.CGImageProperties.Orientation], ImageIO.CGImageProperties.TIFFOrientation);
                            newMeta[ImageIO.CGImageProperties.TIFFDictionary] = newTiffDict;

                            meta = newMeta;
                        }
                        var location = options.Location;
                        if (meta != null && location != null)
                        {
                            meta = MediaPickerDelegate.SetGpsLocation(meta, location);
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine($"Unable to get metadata: {ex}");
                    }

                    //iOS quality is 0.0-1.0
                    var quality    = (options.CompressionQuality / 100f);
                    var savedImage = false;
                    if (meta != null)
                    {
                        savedImage = MediaPickerDelegate.SaveImageWithMetadata(image, quality, meta, mediaFile.Path, pathExtension);
                    }

                    if (!savedImage)
                    {
                        image.AsJPEG(quality).Save(mediaFile.Path, true);
                    }

                    image?.Dispose();

                    GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Unable to compress image: {ex}");
                }
            }
        }
コード例 #55
0
        internal static bool SaveImageWithMetadataiOS13(UIImage image, float quality, NSDictionary meta, string path, string pathExtension)
        {
            try
            {
                pathExtension = pathExtension.ToLowerInvariant();
                var finalQuality = quality;
                var imageData    = pathExtension == "jpg" ? image.AsJPEG(finalQuality) : image.AsPNG();

                //continue to move down quality , rare instances
                while (imageData == null && finalQuality > 0)
                {
                    finalQuality -= 0.05f;
                    imageData     = image.AsJPEG(finalQuality);
                }

                if (imageData == null)
                {
                    throw new NullReferenceException("Unable to convert image to jpeg, please ensure file exists or lower quality level");
                }

                // Copy over meta data
                using var ciImage        = CIImage.FromData(imageData);
                using var newImageSource = ciImage.CreateBySettingProperties(meta);
                using var ciContext      = new CIContext();

                if (pathExtension == "jpg")
                {
                    return(ciContext.WriteJpegRepresentation(newImageSource, NSUrl.FromFilename(path), CGColorSpace.CreateSrgb(), new NSDictionary(), out var error));
                }

                return(ciContext.WritePngRepresentation(newImageSource, NSUrl.FromFilename(path), CIFormat.ARGB8, CGColorSpace.CreateSrgb(), new NSDictionary(), out var error2));
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Unable to save image with metadata: {ex}");
            }

            return(false);
        }
コード例 #56
0
        //public override void ReceivedLocalNotification(UIApplication application, UILocalNotification notification)
        //{
        //	// show an alert
        //	UIAlertController okayAlertController = UIAlertController.Create(notification.AlertAction, notification.AlertBody, UIAlertControllerStyle.Alert);
        //	okayAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
        //	viewController.PresentViewController(okayAlertController, true, null);

        //	// reset our badge
        //	UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
        //}

        //public override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo)
        //{
        //	if (application.ApplicationState == UIApplicationState.Active)
        //	{
        //	}
        //	else if (application.ApplicationState == UIApplicationState.Background)
        //	{
        //	}
        //	else if (application.ApplicationState == UIApplicationState.Inactive)
        //	{
        //	}
        //}

        public override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo)
        {
            ProcessNotification(userInfo, false);
        }
コード例 #57
0
        private async Task <MediaFile> GetPictureMediaFile(NSDictionary info)
        {
            var image = (UIImage)info[UIImagePickerController.EditedImage] ?? (UIImage)info[UIImagePickerController.OriginalImage];

            if (image == null)
            {
                return(null);
            }

            var pathExtension = ((info[UIImagePickerController.ReferenceUrl] as NSUrl)?.PathExtension == "PNG") ? "png" : "jpg";

            var path = GetOutputPath(MediaImplementation.TypeImage,
                                     options.Directory ?? ((IsCaptured) ? string.Empty : "temp"),
                                     options.Name, pathExtension);

            var cgImage = image.CGImage;

            var   percent   = 1.0f;
            float newHeight = image.CGImage.Height;
            float newWidth  = image.CGImage.Width;

            if (options.PhotoSize != PhotoSize.Full)
            {
                try
                {
                    switch (options.PhotoSize)
                    {
                    case PhotoSize.Large:
                        percent = .75f;
                        break;

                    case PhotoSize.Medium:
                        percent = .5f;
                        break;

                    case PhotoSize.Small:
                        percent = .25f;
                        break;

                    case PhotoSize.Custom:
                        percent = (float)options.CustomPhotoSize / 100f;
                        break;
                    }

                    if (options.PhotoSize == PhotoSize.MaxWidthHeight && options.MaxWidthHeight.HasValue)
                    {
                        var max = Math.Max(image.CGImage.Width, image.CGImage.Height);
                        if (max > options.MaxWidthHeight.Value)
                        {
                            percent = (float)options.MaxWidthHeight.Value / (float)max;
                        }
                    }

                    if (percent < 1.0f)
                    {
                        //begin resizing image
                        image = image.ResizeImageWithAspectRatio(percent);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Unable to compress image: {ex}");
                }
            }


            NSDictionary meta = null;

            try
            {
                if (options.SaveMetaData)
                {
                    if (source == UIImagePickerControllerSourceType.Camera)
                    {
                        meta = info[UIImagePickerController.MediaMetadata] as NSDictionary;
                        if (meta != null && meta.ContainsKey(ImageIO.CGImageProperties.Orientation))
                        {
                            var newMeta = new NSMutableDictionary();
                            newMeta.SetValuesForKeysWithDictionary(meta);
                            var newTiffDict = new NSMutableDictionary();
                            newTiffDict.SetValuesForKeysWithDictionary(meta[ImageIO.CGImageProperties.TIFFDictionary] as NSDictionary);
                            newTiffDict.SetValueForKey(meta[ImageIO.CGImageProperties.Orientation], ImageIO.CGImageProperties.TIFFOrientation);
                            newMeta[ImageIO.CGImageProperties.TIFFDictionary] = newTiffDict;

                            meta = newMeta;
                        }
                        var location = options.Location;
                        if (meta != null && location != null)
                        {
                            meta = SetGpsLocation(meta, location);
                        }
                    }
                    else
                    {
                        var url = info[UIImagePickerController.ReferenceUrl] as NSUrl;
                        if (url != null)
                        {
                            meta = PhotoLibraryAccess.GetPhotoLibraryMetadata(url);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Unable to get metadata: {ex}");
            }

            //iOS quality is 0.0-1.0
            var quality    = pathExtension == "jpg" ? (options.CompressionQuality / 100f) : 0f;
            var savedImage = false;

            if (meta != null)
            {
                savedImage = SaveImageWithMetadata(image, quality, meta, path, pathExtension);
            }

            if (!savedImage)
            {
                var finalQuality = quality;
                var imageData    = pathExtension == "jpg" ? image.AsJPEG(finalQuality) : image.AsPNG();

                //continue to move down quality , rare instances
                while (imageData == null && finalQuality > 0)
                {
                    finalQuality -= 0.05f;
                    imageData     = image.AsJPEG(finalQuality);
                }

                if (imageData == null)
                {
                    throw new NullReferenceException("Unable to convert image to jpeg, please ensure file exists or lower quality level");
                }


                imageData.Save(path, true);
                imageData.Dispose();
            }


            string aPath = null;

            if (source != UIImagePickerControllerSourceType.Camera)
            {
                //try to get the album path's url
                var url = (NSUrl)info[UIImagePickerController.ReferenceUrl];
                aPath = url?.AbsoluteString;
            }
            else
            {
                if (options.SaveToAlbum)
                {
                    try
                    {
                        var library   = new ALAssetsLibrary();
                        var albumSave = await library.WriteImageToSavedPhotosAlbumAsync(cgImage, meta);

                        aPath = albumSave.AbsoluteString;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("unable to save to album:" + ex);
                    }
                }
            }

            Func <Stream> getStreamForExternalStorage = () =>
            {
                if (options.RotateImage)
                {
                    return(RotateImage(image, options.CompressionQuality, pathExtension));
                }
                else
                {
                    return(File.OpenRead(path));
                }
            };

            return(new MediaFile(path, () => File.OpenRead(path), streamGetterForExternalStorage: () => getStreamForExternalStorage(), albumPath: aPath));
        }
コード例 #58
0
        internal static bool SaveImageWithMetadata(UIImage image, float quality, NSDictionary meta, string path, string pathExtension)
        {
            if (UIDevice.CurrentDevice.CheckSystemVersion(13, 0))
            {
                return(SaveImageWithMetadataiOS13(image, quality, meta, path, pathExtension));
            }

            try
            {
                pathExtension = pathExtension.ToLowerInvariant();
                var finalQuality = quality;
                var imageData    = pathExtension == "jpg" ? image.AsJPEG(finalQuality) : image.AsPNG();

                //continue to move down quality , rare instances
                while (imageData == null && finalQuality > 0)
                {
                    finalQuality -= 0.05f;
                    imageData     = image.AsJPEG(finalQuality);
                }

                if (imageData == null)
                {
                    throw new NullReferenceException("Unable to convert image to jpeg, please ensure file exists or lower quality level");
                }

                var dataProvider       = new CGDataProvider(imageData);
                var cgImageFromJpeg    = CGImage.FromJPEG(dataProvider, null, false, CGColorRenderingIntent.Default);
                var imageWithExif      = new NSMutableData();
                var destination        = CGImageDestination.Create(imageWithExif, UTType.JPEG, 1);
                var cgImageMetadata    = new CGMutableImageMetadata();
                var destinationOptions = new CGImageDestinationOptions();

                if (meta.ContainsKey(ImageIO.CGImageProperties.Orientation))
                {
                    destinationOptions.Dictionary[ImageIO.CGImageProperties.Orientation] = meta[ImageIO.CGImageProperties.Orientation];
                }

                if (meta.ContainsKey(ImageIO.CGImageProperties.DPIWidth))
                {
                    destinationOptions.Dictionary[ImageIO.CGImageProperties.DPIWidth] = meta[ImageIO.CGImageProperties.DPIWidth];
                }

                if (meta.ContainsKey(ImageIO.CGImageProperties.DPIHeight))
                {
                    destinationOptions.Dictionary[ImageIO.CGImageProperties.DPIHeight] = meta[ImageIO.CGImageProperties.DPIHeight];
                }


                if (meta.ContainsKey(ImageIO.CGImageProperties.ExifDictionary))
                {
                    destinationOptions.ExifDictionary =
                        new CGImagePropertiesExif(meta[ImageIO.CGImageProperties.ExifDictionary] as NSDictionary);
                }


                if (meta.ContainsKey(ImageIO.CGImageProperties.TIFFDictionary))
                {
                    var existingTiffDict = meta[ImageIO.CGImageProperties.TIFFDictionary] as NSDictionary;
                    if (existingTiffDict != null)
                    {
                        var newTiffDict = new NSMutableDictionary();
                        newTiffDict.SetValuesForKeysWithDictionary(existingTiffDict);
                        newTiffDict.SetValueForKey(meta[ImageIO.CGImageProperties.Orientation], ImageIO.CGImageProperties.TIFFOrientation);
                        destinationOptions.TiffDictionary = new CGImagePropertiesTiff(newTiffDict);
                    }
                }
                if (meta.ContainsKey(ImageIO.CGImageProperties.GPSDictionary))
                {
                    destinationOptions.GpsDictionary =
                        new CGImagePropertiesGps(meta[ImageIO.CGImageProperties.GPSDictionary] as NSDictionary);
                }
                if (meta.ContainsKey(ImageIO.CGImageProperties.JFIFDictionary))
                {
                    destinationOptions.JfifDictionary =
                        new CGImagePropertiesJfif(meta[ImageIO.CGImageProperties.JFIFDictionary] as NSDictionary);
                }
                if (meta.ContainsKey(ImageIO.CGImageProperties.IPTCDictionary))
                {
                    destinationOptions.IptcDictionary =
                        new CGImagePropertiesIptc(meta[ImageIO.CGImageProperties.IPTCDictionary] as NSDictionary);
                }
                destination.AddImageAndMetadata(cgImageFromJpeg, cgImageMetadata, destinationOptions);
                var success = destination.Close();
                if (success)
                {
                    var saved = imageWithExif.Save(path, true, out NSError error);
                    if (error != null)
                    {
                        Debug.WriteLine($"Unable to save exif data: {error.ToString()}");
                    }

                    imageWithExif.Dispose();
                    imageWithExif = null;
                }

                return(success);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Unable to save image with metadata: {ex}");
            }

            return(false);
        }
コード例 #59
0
 public override bool FinishedLaunching(UIApplication app, NSDictionary options)
 {
     game = new SampleGame();
     game.Run();
     return(true);
 }
コード例 #60
0
        public override async void FinishedPickingMedia(UIImagePickerController picker, NSDictionary info)
        {
            if (isFinished)
            {
                return;
            }
            isFinished = true;
            RemoveOrientationChangeObserverAndNotifications();

            MediaFile mediaFile;

            switch ((NSString)info[UIImagePickerController.MediaType])
            {
            case MediaImplementation.TypeImage:
                mediaFile = await GetPictureMediaFile(info);

                break;

            case MediaImplementation.TypeMovie:
                mediaFile = await GetMovieMediaFile(info);

                break;

            default:
                throw new NotSupportedException();
            }

            if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone)
            {
                UIApplication.SharedApplication.SetStatusBarStyle(MediaImplementation.StatusBarStyle, false);
            }

            Dismiss(picker, () =>
            {
                if (mediaFile == null)
                {
                    tcs.SetException(new FileNotFoundException());
                }
                else
                {
                    tcs.TrySetResult(new List <MediaFile> {
                        mediaFile
                    });
                }
                isFinished = false;
            });
        }