Exemplo n.º 1
0
        public void RenderStream(System.IO.Stream stream)
        {
            var reader = new System.IO.StreamReader(stream);

            ad.InvokeOnMainThread(delegate
            {
                var view  = new UIViewController();
                var label = new UILabel(new RectangleF(20, 20, 300, 80))
                {
                    Text = "The HTML returned by the server:"
                };
                var tv = new UITextView(new RectangleF(20, 100, 300, 400))
                {
                    Text = reader.ReadToEnd()
                };
                view.Add(label);
                view.Add(tv);

                Console.WriteLine(tv.Text);

                if (UIDevice.CurrentDevice.CheckSystemVersion(7, 0))
                {
                    view.EdgesForExtendedLayout = UIRectEdge.None;
                }

                ad.NavigationController.PushViewController(view, true);
            });
        }
Exemplo n.º 2
0
        public void RenderStream(System.IO.Stream stream)
        {
            var reader = new System.IO.StreamReader(stream);

            ad.InvokeOnMainThread(delegate
            {
                var view = new UIViewController();
                var label = new UILabel(new RectangleF(20, 20, 300, 80))
                {
                    Text = "The HTML returned by the server:"
                };
                var tv = new UITextView(new RectangleF(20, 100, 300, 400))
                {
                    Text = reader.ReadToEnd()
                };
                view.Add(label);
                view.Add(tv);

                Console.WriteLine(tv.Text);

                if (UIDevice.CurrentDevice.CheckSystemVersion(7, 0))
                {
                    view.EdgesForExtendedLayout = UIRectEdge.None;
                }

                ad.NavigationController.PushViewController(view, true);
            });
        }
Exemplo n.º 3
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);

            var controller = new UIViewController();

            var label = new UILabel(new RectangleF(0, 0, 320, 30));

            label.Text = "SignalR Client";

            var textView = new UITextView(new RectangleF(0, 35, 320, 500));

            controller.Add(label);
            controller.Add(textView);

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

            var traceWriter = new TextViewWriter(SynchronizationContext.Current, textView);

            var client = new CommonClient(traceWriter);

            client.RunAsync("http://signalr-test1.cloudapp.net:82/");

            return(true);
        }
Exemplo n.º 4
0
		public void RenderStream (Stream stream)
		{
			var reader = new StreamReader (stream);

			InvokeOnMainThread (delegate {
				button1.Enabled = true;
				var view = new UIViewController ();
				var handler = new UILabel (new CGRect (20, 20, 300, 40)) {
					Text = "HttpClient is using " + HandlerType?.Name
				};
				var label = new UILabel (new CGRect (20, 20, 300, 80)) {
					Text = "The HTML returned by the server:"
				};
				var tv = new UITextView (new CGRect (20, 100, 300, 400)) {
					Text = reader.ReadToEnd ()
				};
				if (HandlerType != null)
					view.Add (handler);
				view.Add (label);
				view.Add (tv);

				if (UIDevice.CurrentDevice.CheckSystemVersion (7, 0)) {
					view.EdgesForExtendedLayout = UIRectEdge.None;
				}

				navigationController.PushViewController (view, true);
			});
		}
Exemplo n.º 5
0
        public void RenderStream(Stream stream)
        {
            var reader = new StreamReader(stream);

            InvokeOnMainThread(delegate {
                button1.Enabled = true;
                var view        = new UIViewController();
                var label       = new UILabel(new CGRect(20, 20, 300, 80))
                {
                    Text = "The HTML returned by the server:"
                };
                var tv = new UITextView(new CGRect(20, 100, 300, 400))
                {
                    Text = reader.ReadToEnd()
                };
                view.Add(label);
                view.Add(tv);

                if (UIDevice.CurrentDevice.CheckSystemVersion(7, 0))
                {
                    view.EdgesForExtendedLayout = UIRectEdge.None;
                }

                navigationController.PushViewController(view, true);
            });
        }
Exemplo n.º 6
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)
        {
            // create a new window instance based on the screen size
            window = new UIWindow(UIScreen.MainScreen.Bounds);

            // If you have defined a root view controller, set it here:
            controller = new UIViewController();
            controller.View.BackgroundColor = UIColor.White;
            controller.Title = "My Controller";

            UIButton mapButton = new UIButton(UIButtonType.RoundedRect);

            mapButton.SetTitle("Open Maps", UIControlState.Normal);
            mapButton.Frame = new RectangleF(window.Frame.Width / 2 - 50, 100, 100, 44);

            mapButton.TouchUpInside += (object sender, EventArgs e) => {
                //If emulateNoGmaps is on, then lauch Apple maps instead
                string mapsScheme = emulateNoGmaps.On ? string.Empty : "comgooglemaps://?center=40.765819,-73.975866&zoom=14&views=traffic";
                NSUrl  gmaps      = new NSUrl(mapsScheme);
                if (!UIApplication.SharedApplication.OpenUrl(gmaps))
                {
                    var av = new UIAlertView("Google Maps"
                                             , "It appears as though Google Maps isn't installed.  Would you like to install it?"
                                             , null
                                             , "Yes Please"
                                             , "No Thanks");
                    av.Show();

                    av.Clicked += (sender1, buttonArgs) => {
                        if (buttonArgs.ButtonIndex == 0)
                        {
                            NSUrl badMaps = new NSUrl("https://itunes.apple.com/us/app/google-maps/id585027354?mt=8");
                            UIApplication.SharedApplication.OpenUrl(badMaps);
                        }
                        else
                        {
                            NSUrl badMaps = new NSUrl("http://maps.apple.com/?ll=40.765819,-73.975866");
                            //NSUrl badMaps = new NSUrl("https://itunes.apple.com/us/app/google-maps/id585027354?mt=8");
                            UIApplication.SharedApplication.OpenUrl(badMaps);
                        }
                    };
                }
            };

            emulateNoGmaps    = new UISwitch(new RectangleF(window.Frame.Width / 2 - 50, 50, 100, 44));
            emulateNoGmaps.On = false;

            controller.Add(mapButton);
            controller.Add(emulateNoGmaps);

            navController             = new UINavigationController(controller);
            window.RootViewController = navController;

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

            return(true);
        }
Exemplo n.º 7
0
        private string ShowKeyboardInput()
        {
            UIApplication.SharedApplication.InvokeOnMainThread(delegate {
                AddObservers();

                // Create an instance of our custom UITextField that will be added to our view but hidden
                hiddenKeyInput        = new HiddenInput(new CGRect(0, 0, 1, 1));
                hiddenKeyInput.Hidden = true;

                hiddenKeyInput.AutocorrectionType = UITextAutocorrectionType.No;
                hiddenKeyInput.SpellCheckingType  = UITextSpellCheckingType.No;


                if (TextFieldInFocus.CharacterCount > 0)
                {
                    hiddenKeyInput.Text = TextFieldInFocus.Text;
                }

                //hiddenKeyInput.Delegate = this;

                gameViewController.Add(hiddenKeyInput);

                hiddenKeyInput.BecomeFirstResponder();
            }
                                                               );
            return(contentText);
        }
        protected override void OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs<Xamarin.Forms.Button> e)
        {
            base.OnElementChanged (e);

            if (e.NewElement != null) {
                Control.TouchUpInside += delegate(object sender, EventArgs e2) {

                    var formsView = new CommonFormsView ();

                    var rect = new CGRect (0, 0, 400, 400);
                    var iOSView = FormsViewToNativeiOS.ConvertFormsToNative (formsView, rect);

                    var viewController = new UIViewController();
                    viewController.Add(iOSView);
                    viewController.View.Frame = rect;

                    var popoverController = new UIPopoverController(viewController);
                    popoverController.ContentViewController.View.BackgroundColor = viewController.View.BackgroundColor;
                    popoverController.PopoverContentSize = rect.Size;
                    var frame = UIApplication.SharedApplication.KeyWindow.RootViewController.View.Frame;
                    popoverController.PresentFromRect (Control.Frame, UIApplication.SharedApplication.KeyWindow.RootViewController.View, 0, true);

                };
            }
        }
Exemplo n.º 9
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            window = new UIWindow(UIScreen.MainScreen.Bounds);

            root = new UIViewController();
            vc1  = new ViewController1();
            root.View.AddSubview(vc1.View);

            vc1.InitialActionCompleted += (object sender, EventArgs e) => {
                vc1.View.RemoveFromSuperview();

                tabController = new UITabBarController();

                vc2 = new ViewController2();
                vc3 = new ViewController3();

                tabController.ViewControllers = new UIViewController[] {
                    vc1,
                    vc2,
                    vc3
                };
                tabController.ViewControllers [0].TabBarItem.Title = "One";
                tabController.ViewControllers [1].TabBarItem.Title = "Two";
                tabController.ViewControllers [2].TabBarItem.Title = "Three";

                root.AddChildViewController(tabController);
                root.Add(tabController.View);
            };

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

            return(true);
        }
 public static void AddRange(this UIViewController v, params UIView[] arr)
 {
     for (view in arr[i])
     {
         v.Add(view)
     }
 }
Exemplo n.º 11
0
		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{
			window = new UIWindow (UIScreen.MainScreen.Bounds);

			root = new UIViewController ();
			vc1 = new ViewController1 ();
			root.View.AddSubview (vc1.View);

			vc1.InitialActionCompleted += (object sender, EventArgs e) => {

				vc1.View.RemoveFromSuperview ();

				tabController = new UITabBarController ();

				vc2 = new ViewController2 ();
				vc3 = new ViewController3 ();

				tabController.ViewControllers = new UIViewController[] {
					vc1,
					vc2,
					vc3
				};
				tabController.ViewControllers [0].TabBarItem.Title = "One";
				tabController.ViewControllers [1].TabBarItem.Title = "Two";
				tabController.ViewControllers [2].TabBarItem.Title = "Three";

				root.AddChildViewController (tabController);
				root.Add (tabController.View);
			};

			window.RootViewController = root;
			window.MakeKeyAndVisible ();
            
			return true;
		}
Exemplo n.º 12
0
        public void RenderStream(Stream stream)
        {
            var reader = new System.IO.StreamReader(stream);

            InvokeOnMainThread(delegate {
                var view  = new UIViewController();
                var label = new UILabel(new RectangleF(20, 20, 300, 80))
                {
                    Text = "The HTML returned by Google:"
                };
                var tv = new UITextView(new RectangleF(20, 100, 300, 400))
                {
                    Text = reader.ReadToEnd()
                };
                view.Add(label);
                view.Add(tv);

                navigationController.PushViewController(view, true);
            });
        }
Exemplo n.º 13
0
        public void showLoading(UIViewController aView)
        {
            var bounds = UIScreen.MainScreen.Bounds;             // portrait bounds

            if (UIApplication.SharedApplication.StatusBarOrientation == UIInterfaceOrientation.LandscapeLeft || UIApplication.SharedApplication.StatusBarOrientation == UIInterfaceOrientation.LandscapeRight)
            {
                bounds.Size = new CGSize(bounds.Size.Height, bounds.Size.Width);
            }
            // show the loading overlay on the UI thread using the correct orientation sizing
            instance = new LoadingOverlay(bounds);
            aView.Add(instance);
        }
Exemplo n.º 14
0
        public void RenderStream(Stream stream)
        {
            var reader = new System.IO.StreamReader(stream);

            InvokeOnMainThread(delegate {
                var view = new UIViewController();
                view.View.BackgroundColor = UIColor.White;
                var label = new UILabel(new CGRect(20, 60, 300, 80))
                {
                    Text = "The HTML returned by the server:"
                };
                var tv = new UITextView(new CGRect(20, 140, 300, 400))
                {
                    Text = reader.ReadToEnd()
                };
                view.Add(label);
                view.Add(tv);

                navigationController.PushViewController(view, true);
            });
        }
Exemplo n.º 15
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)
        {
            // Initialize the Parse client with your Application ID and Windows Key found on
            // your Parse dashboard
            // PARSE INTERNAL
            // To properly scrub this project for public release, the following changes must be made:
            // 1. This region should be replaced with a template Parse.Initialize call.
            // 2. The project must stop requesting intranet permission.
            // 3. The project may not access Parse.snk, or it will retain access to Parse internals.
            // 4. We must verify that Parse.snk is never copied to this project directory by msbuild.
            //ParseClient.HostName = new Uri("http://parse-local:3000/")
            ParseClient.Initialize("ZIqbEBf3PXXSzpbQbvz5BcmVcK54DjSmKwNxCah1", "EY4UfiJn0xGhvgvNhBRrY6kggn4nv9zGGk5klQQo");
            // END PARSE INTERNAL

            // Register for remote notifications
            if (Convert.ToInt16(UIDevice.CurrentDevice.SystemVersion.Split('.')[0].ToString()) < 8)
            {
                UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound;
                UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes);
            }
            else
            {
                UIUserNotificationType notificationTypes = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound;
                var settings = UIUserNotificationSettings.GetSettingsForTypes(notificationTypes, new NSSet(new string[] { }));
                UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
                UIApplication.SharedApplication.RegisterForRemoteNotifications();
            }

            // Handle Parse Push notification.
            ParsePush.ParsePushNotificationReceived += (object sender, ParsePushNotificationEventArgs args) => {
                Console.WriteLine("You received a notification!");
            };

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

            UIViewController viewController = new UIViewController();
            UILabel          label          = new UILabel(new CoreGraphics.CGRect(0, 0, 160, 20));

            label.Text      = "Parse Push is ready!";
            label.TextColor = UIColor.Gray;
            label.Center    = viewController.View.Center;
            viewController.Add(label);
            window.BackgroundColor = UIColor.White;
            // If you have defined a view, add it here:
            window.RootViewController = viewController;
            window.MakeKeyAndVisible();

            return(true);
        }
Exemplo n.º 16
0
        public void RenderStream(Stream stream)
        {
            var reader = new StreamReader(stream);

            InvokeOnMainThread(delegate {
                button1.Enabled = true;
                var view        = new UIViewController();
                var handler     = new UILabel(new CGRect(20, 20, 300, 40))
                {
                    Text  = "HttpClient is using " + HandlerType?.Name,
                    Lines = 0
                };
                handler.SizeToFit();

                var label = new UILabel(new CGRect(20, 40, 300, 80))
                {
                    Text = "JSON погоды в Челябинске:"
                };
                var tv = new UITextView(new CGRect(20, 100, 300, 400))
                {
                    Text = reader.ReadToEnd()
                };
                if (HandlerType != null)
                {
                    view.Add(handler);
                }
                view.Add(label);
                view.Add(tv);

                if (UIDevice.CurrentDevice.CheckSystemVersion(7, 0))
                {
                    view.EdgesForExtendedLayout = UIRectEdge.None;
                }

                navigationController.PushViewController(view, true);
            });
        }
Exemplo n.º 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)
        {
            window = new UIWindow(UIScreen.MainScreen.Bounds);

            var controller = new UIViewController();

            var label = new UILabel(new RectangleF(0, 0, 320, 30));
            label.Text = "SignalR Client";

            var textView = new UITextView(new RectangleF(0, 35, 320, 500));

            controller.Add(label);
            controller.Add(textView);

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

            var traceWriter = new TextViewWriter(SynchronizationContext.Current, textView);

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

            return true;
        }
Exemplo n.º 18
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            window = new UIWindow(UIScreen.MainScreen.Bounds);

            var dvc    = new UIViewController();
            var button = new UIButton(window.Bounds);

            button.SetTitle("Hello World!", UIControlState.Normal);
            dvc.Add(button);

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

            return(true);
        }
Exemplo n.º 19
0
        public void RenderResponse(String data)
        {
            InvokeOnMainThread(delegate
            {
                button1.Enabled = true;
                var view        = new UIViewController();
                var handler     = new UILabel(new CGRect(20, 20, 300, 40))
                {
                    Text  = "HttpClient is using " + HandlerType?.Name,
                    Lines = 0
                };
                handler.SizeToFit();

                var label = new UILabel(new CGRect(20, 40, 300, 80))
                {
                    Text = "The HTML returned by the server:"
                };
                var tv = new UITextView(new CGRect(20, 100, 300, 400))
                {
                    Text = data
                };
                if (HandlerType != null)
                {
                    view.Add(handler);
                }
                view.Add(label);
                view.Add(tv);

                if (UIDevice.CurrentDevice.CheckSystemVersion(7, 0))
                {
                    view.EdgesForExtendedLayout = UIRectEdge.None;
                }

                navigationController.PushViewController(view, true);
            });
        }
Exemplo n.º 20
0
        void RenderString(string str)
        {
            InvokeOnMainThread(delegate {
                TableView.AllowsSelection   = true;
                var requestResultController = new UIViewController();
                requestResultController.View.BackgroundColor = UIColor.White;

                string handlerTypeName = HandlerType != null ? HandlerType.Name : string.Empty;

                var handler = new UILabel(new CGRect(20, 20, 300, 40))
                {
                    Text  = "HttpClient is using " + handlerTypeName,
                    Lines = 0
                };
                handler.SizeToFit();

                var label = new UILabel(new CGRect(20, 40, 300, 80))
                {
                    Text = "The HTML returned by the server:"
                };

                var tv = new UITextView(new CGRect(20, 100, 300, 400))
                {
                    Text = str
                };

                if (HandlerType != null)
                {
                    requestResultController.Add(handler);
                }
                requestResultController.Add(label);
                requestResultController.Add(tv);

                NavigationController.PushViewController(requestResultController, false);
            });
        }
Exemplo n.º 21
0
 /// <summary>
 /// Handles the <see cref="E:Started" /> event.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="eventArgs">The <see cref="EventArgs"/> instance containing the event data.</param>
 private void OnStarted(object sender, EventArgs eventArgs)
 {
     //base.Element.IsFocused = true;
     if (Device.Idiom != TargetIdiom.Phone)
     {
         var vc = new UIViewController();
         vc.Add(_picker);
         vc.View.Frame           = new CGRect(0, 0, 320, 200);
         vc.PreferredContentSize = new CGSize(320, 200);
         _popOver = new UIPopoverController(vc);
         _popOver.PresentFromRect(new CGRect(Control.Frame.Width / 2, Control.Frame.Height - 3, 0, 0), Control, UIPopoverArrowDirection.Any, true);
         _popOver.DidDismiss += (object s, EventArgs e) => {
             _popOver = null;
             Control.ResignFirstResponder();
         };
     }
 }
Exemplo n.º 22
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)
        {
            // Initialize the Parse client with your Application ID and Windows Key found on
              // your Parse dashboard
              // PARSE INTERNAL
              // To properly scrub this project for public release, the following changes must be made:
              // 1. This region should be replaced with a template Parse.Initialize call.
              // 2. The project must stop requesting intranet permission.
              // 3. The project may not access Parse.snk, or it will retain access to Parse internals.
              // 4. We must verify that Parse.snk is never copied to this project directory by msbuild.
              //ParseClient.HostName = new Uri("http://parse-local:3000/")
              ParseClient.Initialize("ZIqbEBf3PXXSzpbQbvz5BcmVcK54DjSmKwNxCah1", "EY4UfiJn0xGhvgvNhBRrY6kggn4nv9zGGk5klQQo");
              // END PARSE INTERNAL

              // Register for remote notifications
              if (Convert.ToInt16(UIDevice.CurrentDevice.SystemVersion.Split('.')[0].ToString()) < 8) {
            UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound;
            UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes);
              } else {
            UIUserNotificationType notificationTypes = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound;
            var settings = UIUserNotificationSettings.GetSettingsForTypes(notificationTypes, new NSSet(new string[] { }));
            UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
            UIApplication.SharedApplication.RegisterForRemoteNotifications();
              }

              // Handle Parse Push notification.
              ParsePush.ParsePushNotificationReceived += (object sender, ParsePushNotificationEventArgs args) => {
            Console.WriteLine("You received a notification!");
              };

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

              UIViewController viewController = new UIViewController();
              UILabel label = new UILabel(new CoreGraphics.CGRect(0, 0, 160, 20));
              label.Text = "Parse Push is ready!";
              label.TextColor = UIColor.Gray;
              label.Center = viewController.View.Center;
              viewController.Add(label);
              window.BackgroundColor = UIColor.White;
              // If you have defined a view, add it here:
              window.RootViewController = viewController;
              window.MakeKeyAndVisible();

              return true;
        }
Exemplo n.º 23
0
        private UIViewController CreateTabFor(MapHashable map)
        {
            var screen = new UIViewController();

            var image = Mvx.IocConstruct <ImageLoader>().LoadImage(map.ImagePath);

            var imageView = new UIImageView(new CGRect(new CGPoint(0, 100), CGSize.Subtract(screen.View.Frame.Size, new CGSize(0, 200))))
            {
                ContentMode = UIViewContentMode.ScaleAspectFit,
                Image       = image
            };

            screen.Add(imageView);

            screen.NavigationItem.Title = map.Title;
            screen.TabBarItem           = new UITabBarItem(map.Title, null, this.tabCount++);

            return(screen);
        }
        //
        // 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)
        {
            // Initialize the Parse client with your Application ID and Windows Key found on
            // your Parse dashboard
            ParseClient.Initialize("YOUR APPLICATION ID", "YOUR .NET KEY");

            // Register for remote notifications
            if (Convert.ToInt16(UIDevice.CurrentDevice.SystemVersion.Split('.')[0].ToString()) < 8)
            {
                UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound;
                UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes);
            }
            else
            {
                UIUserNotificationType notificationTypes = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound;
                var settings = UIUserNotificationSettings.GetSettingsForTypes(notificationTypes, new NSSet(new string[] { }));
                UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
                UIApplication.SharedApplication.RegisterForRemoteNotifications();
            }

            // Handle Parse Push notification.
            ParsePush.ParsePushNotificationReceived += (object sender, ParsePushNotificationEventArgs args) => {
                Console.WriteLine("You received a notification!");
            };

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

            UIViewController viewController = new UIViewController();
            UILabel          label          = new UILabel(new CoreGraphics.CGRect(0, 0, 160, 20));

            label.Text      = "Parse Push is ready!";
            label.TextColor = UIColor.Gray;
            label.Center    = viewController.View.Center;
            viewController.Add(label);
            window.BackgroundColor = UIColor.White;
            // If you have defined a view, add it here:
            window.RootViewController = viewController;
            window.MakeKeyAndVisible();

            return(true);
        }
Exemplo n.º 25
0
        public void StartActivityInAndroid()
        {
            if (vc != null)
            {
                throw new Exception("View already showing");
            }
            vc = new UIViewController();
            var button = new UIButton(new CGRect(100, 100, 300, 300));

            button.SetTitle("Press to Exit", UIControlState.Normal);
            button.BackgroundColor = UIColor.Orange;
            button.TouchUpInside  += (object sender, EventArgs e) =>
            {
                Dismiss();
            };
            vc.Add(button);
            var rootVC = UIApplication.SharedApplication.Windows[0].RootViewController;

            rootVC.PresentViewController(vc, true, () => { });
        }
Exemplo n.º 26
0
        public override bool FinishedLaunching(UIApplication application, NSDictionary options)
        {
            window = new UIWindow();

            navcontroller = new UINavigationController();

            viewcontroller       = new UIViewController();
            viewcontroller.Title = "XibLess";

            view = new UIView(new RectangleF(0, 0, 320, 640));
            view.BackgroundColor = UIColor.Blue;

            viewcontroller.Add(view);
            navcontroller.PushViewController(viewcontroller, false);

            window.AddSubview(navcontroller.View);
            window.MakeKeyAndVisible();

            return(true);
        }
Exemplo n.º 27
0
        public override bool FinishedLaunching(UIApplication application, NSDictionary options)
        {
            window = new UIWindow();

            navcontroller = new UINavigationController();

            viewcontroller = new UIViewController();
            viewcontroller.Title = "XibLess";

            view = new UIView(new RectangleF(0, 0, 320, 640));
            view.BackgroundColor = UIColor.Blue;

            viewcontroller.Add(view);
            navcontroller.PushViewController(viewcontroller, false);

            window.AddSubview (navcontroller.View);
            window.MakeKeyAndVisible ();

            return true;
        }
        public void Start()
        {
            if (ParentController == null)
            {
                throw new Exception("Spotlight: controller is null");
            }

            SpotlightView = new SpotlightView(ParentController, ParentController.View.Bounds);

            ParentController.Add(SpotlightView);

            SpotlightView.OnTargetClosed += () =>
            {
                if (Targets.Count > 0)
                {
                    Target target = Targets[0];

                    OnTargetEnded?.Invoke(target);

                    Targets.Remove(target);

                    if (Targets.Count > 0)
                    {
                        StartTarget();
                    }
                    else
                    {
                        FinishSpotlight();
                    }
                }
            };

            SpotlightView.OnTargetClicked += () =>
            {
                FinishTarget();
            };

            StartSpotlight();
        }
Exemplo n.º 29
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) {
      // Initialize the Parse client with your Application ID and Windows Key found on
      // your Parse dashboard
      ParseClient.Initialize("YOUR APPLICATION ID", "YOUR .NET KEY");

      // Register for remote notifications
      if (Convert.ToInt16(UIDevice.CurrentDevice.SystemVersion.Split('.')[0].ToString()) < 8) {
        UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound;
        UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes);
      } else {
        UIUserNotificationType notificationTypes = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound;
        var settings = UIUserNotificationSettings.GetSettingsForTypes(notificationTypes, new NSSet(new string[] { }));
        UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
        UIApplication.SharedApplication.RegisterForRemoteNotifications();
      }

      // Handle Parse Push notification.
      ParsePush.ParsePushNotificationReceived += (object sender, ParsePushNotificationEventArgs args) => {
        Console.WriteLine("You received a notification!");
      };

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

      UIViewController viewController = new UIViewController();
      UILabel label = new UILabel(new CoreGraphics.CGRect(0, 0, 160, 20));
      label.Text = "Parse Push is ready!";
      label.TextColor = UIColor.Gray;
      label.Center = viewController.View.Center;
      viewController.Add(label);
      window.BackgroundColor = UIColor.White;
      // If you have defined a view, add it here:
      window.RootViewController = viewController;
      window.MakeKeyAndVisible();

      return true;
    }
        protected override void OnElementChanged(Xamarin.Forms.Platform.iOS.ElementChangedEventArgs <Xamarin.Forms.Button> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement != null)
            {
                Control.TouchUpInside += delegate(object sender, EventArgs e2) {
                    var formsView = new CommonFormsView();

                    var rect    = new CGRect(0, 0, 400, 400);
                    var iOSView = FormsViewToNativeiOS.ConvertFormsToNative(formsView, rect);

                    var viewController = new UIViewController();
                    viewController.Add(iOSView);
                    viewController.View.Frame = rect;

                    var popoverController = new UIPopoverController(viewController);
                    popoverController.ContentViewController.View.BackgroundColor = viewController.View.BackgroundColor;
                    popoverController.PopoverContentSize = rect.Size;
                    var frame = UIApplication.SharedApplication.KeyWindow.RootViewController.View.Frame;
                    popoverController.PresentFromRect(Control.Frame, UIApplication.SharedApplication.KeyWindow.RootViewController.View, 0, true);
                };
            }
        }
        public override void PlatformInitialize()
        {
            mainWindow         = GameInstance.Services.GetService <UIWindow>();
            gameViewController = GameInstance.Services.GetService <UIViewController>();

            textField = new UIBackwardsTextField(new CGRect(0, -400, 200, 40));
            textField.KeyboardType           = UIKeyboardType.Default;
            textField.ReturnKeyType          = UIReturnKeyType.Done;
            textField.DeleteBackwardPressed += TextField_DeleteBackward;
            textField.TextChanged           += TextField_TextChanged;;
            textField.ShouldReturn          += TextField_ShouldReturn;

            gameViewController.Add(textField);

            UIKeyboard.Notifications.ObserveWillShow((s, e) =>
            {
                _virtualKeyboardHeight = (int)e.FrameBegin.Height;
            });

            UIKeyboard.Notifications.ObserveWillHide((s, e) =>
            {
                _virtualKeyboardHeight = 0;
            });
        }
Exemplo n.º 32
0
		public void RenderStream (Stream stream)
		{
			var reader = new System.IO.StreamReader (stream);

			InvokeOnMainThread (delegate {
				var view = new UIViewController ();
				var label = new UILabel (new RectangleF (20, 20, 300, 80)){
					Text = "The HTML returned by Google:"
				};
				var tv = new UITextView (new RectangleF (20, 100, 300, 400)){
					Text = reader.ReadToEnd ()
				};
				view.Add (label);
				view.Add (tv);
					
				navigationController.PushViewController (view, true);
			});			
		}
Exemplo n.º 33
0
 public void ShowProgressDialog(string title, string message)
 {
     currentViewController.Add(loadingOverlay);
 }
Exemplo n.º 34
0
        public UIButton ResetButton; //resets the button to the default settings

        public ButtonMaintenanceScreen()
        {
            GeneralMaintenanceScreen.Saved += SaveGeneral; //

            //create screen
            Screen = new UIViewController();
            Screen.View.BackgroundColor = UIColor.White;

            //create button
            Button = new ButtonData();

            //create media picker
            MediaPicker = new UIImagePickerController();
            //MediaPicker.VideoExportPreset = AVAssetExportSessionPreset.HighestQuality.ToString();
            //System.Diagnostics.Debug.WriteLine(MediaPicker.VideoExportPreset);
            MediaPicker.SourceType = UIImagePickerControllerSourceType.PhotoLibrary;
            MediaPicker.MediaTypes = UIImagePickerController.AvailableMediaTypes(UIImagePickerControllerSourceType.PhotoLibrary);
            //MediaPicker.ImageExportPreset = UIImagePickerControllerImageUrlExportPreset.Current;
            MediaPicker.VideoExportPreset     = AVAssetExportSessionPreset.Passthrough.GetConstant().ToString();
            MediaPicker.FinishedPickingMedia += Handle_FinishedPickingMedia;
            MediaPicker.Canceled             += Handle_Canceled;

            //1. create views
            //create reset button
            ResetButton = new UIButton();
            ResetButton.BackgroundColor = UIColor.Green;
            ResetButton.SetTitle("Reset button\nsettings", UIControlState.Normal);
            ResetButton.SetTitleColor(UIColor.Black, UIControlState.Normal);

            //when video button clicked - open the media picker native interface
            ResetButton.TouchUpInside += ResetButtonData;

            ResetButton.Layer.BorderColor   = ButtonBorderColour.CGColor;
            ResetButton.Layer.BorderWidth   = ButtonBorderWidth;
            ResetButton.BackgroundColor     = ButtonBackgroundColour;
            ResetButton.LineBreakMode       = UILineBreakMode.WordWrap;//allow multiple lines for text inside video button
            ResetButton.VerticalAlignment   = UIControlContentVerticalAlignment.Center;
            ResetButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
            ResetButton.Layer.CornerRadius  = ButtonCornerRadius;

            //create video button
            VideoButton = new UIButton();
            VideoButton.BackgroundColor = UIColor.Green;
            VideoButton.SetTitle("Choose a video for\nthe button \nto play", UIControlState.Normal);
            VideoButton.SetTitleColor(UIColor.Black, UIControlState.Normal);

            //when video button clicked - open the media picker native interface
            VideoButton.TouchUpInside += (s, e) =>
            {
                try
                {
                    //set the media picker to show only videos
                    MediaPicker.MediaTypes = new string[] { UTType.Movie, UTType.Video }; //vids?
                    Screen.PresentViewControllerAsync(MediaPicker, true);
                }
                catch (Exception ex)
                {
                    //if the device doesn't have any videos, pop up an alert box with a message
                    Console.WriteLine(ex.Message);
                    UIAlertView alert = new UIAlertView()
                    {
                        Title   = "No Videos Alert",
                        Message = "You don't have any videos to select. To download or record vids..."
                    };

                    alert.AddButton("OK");
                    alert.Show();
                }
            };

            VideoButton.Layer.BorderColor = ButtonBorderColour.CGColor;
            VideoButton.Layer.BorderWidth = ButtonBorderWidth;
            VideoButton.BackgroundColor   = ButtonBackgroundColour;
            VideoButton.LineBreakMode     = UILineBreakMode.WordWrap;//allow multiple lines for text inside video button
            //VideoButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Center; //center text
            VideoButton.VerticalAlignment   = UIControlContentVerticalAlignment.Center;
            VideoButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
            VideoButton.Layer.CornerRadius  = ButtonCornerRadius;

            //create image button
            ImageButton = new UIButton();
            ImageButton.BackgroundColor = UIColor.Green;
            ImageButton.SetTitle("Choose an image for\nthe button thumbnail", UIControlState.Normal);
            ImageButton.SetTitleColor(UIColor.Black, UIControlState.Normal);
            //when image button clicked - open the media picker native interface
            ImageButton.TouchUpInside += (s, e) =>
            {
                try
                {
                    //set the media picker to show only images
                    MediaPicker.MediaTypes = new string[] { UTType.Image };
                    Screen.PresentViewControllerAsync(MediaPicker, true);
                }
                catch (Exception ex)
                {
                    //if the device doesn't have any images, pop up an alert box with a message
                    Console.WriteLine(ex.Message);
                    UIAlertView alert = new UIAlertView()
                    {
                        Title   = "No Images Alert",
                        Message = "You don't have any images to select. To download or take photos..."
                    };

                    alert.AddButton("OK");
                    alert.Show();
                }
            };
            ImageButton.Layer.BorderColor   = ButtonBorderColour.CGColor;
            ImageButton.Layer.BorderWidth   = ButtonBorderWidth;
            ImageButton.BackgroundColor     = ButtonBackgroundColour;
            ImageButton.LineBreakMode       = UILineBreakMode.WordWrap;                   //allow multiple lines for text inside video button
            ImageButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Center; //center text
            ImageButton.Layer.CornerRadius  = ButtonCornerRadius;

            //create image box
            ImageBox = new UIImageView();
            ImageBox.Layer.BorderWidth  = ButtonBorderWidth;
            ImageBox.Layer.CornerRadius = ButtonCornerRadius;
            ImageBox.ClipsToBounds      = true;
            ImageBox.Layer.BorderColor  = UIColor.Gray.CGColor;


            //create video box
            VideoBox = new UIImageView();
            VideoBox.Layer.BorderWidth  = ButtonBorderWidth;
            VideoBox.Layer.CornerRadius = ButtonCornerRadius;
            VideoBox.ClipsToBounds      = true;
            VideoBox.Layer.BorderColor  = UIColor.Gray.CGColor;

            //create back button
            BackButton = new UIButton();
            BackButton.TouchUpInside += CloseScreen;
            BackButton.SetTitle("Back", UIControlState.Normal);
            BackButton.SetTitleColor(UIColor.Black, UIControlState.Normal);
            Screen.Add(BackButton); //add back button to screen
            BackButton.Layer.BorderColor  = ButtonBorderColour.CGColor;
            BackButton.Layer.BorderWidth  = ButtonBorderWidth;
            BackButton.BackgroundColor    = ButtonBackgroundColour;
            BackButton.Layer.CornerRadius = ButtonCornerRadius;

            //create save button
            SaveButton = new UIButton();
            SaveButton.BackgroundColor = UIColor.Red;
            SaveButton.TouchUpInside  += Save;
            SaveButton.SetTitle("Save", UIControlState.Normal);
            SaveButton.SetTitleColor(UIColor.Black, UIControlState.Normal);
            Screen.Add(SaveButton); //add save button to screen
            SaveButton.Layer.BorderColor  = ButtonBorderColour.CGColor;
            SaveButton.Layer.BorderWidth  = ButtonBorderWidth;
            SaveButton.BackgroundColor    = ButtonBackgroundColour;
            SaveButton.Layer.CornerRadius = ButtonCornerRadius;

            //create colour box
            ColourBox = new UIView();
            ColourBox.Layer.BorderWidth  = ButtonBorderWidth;
            ColourBox.Layer.CornerRadius = ButtonCornerRadius;
            ColourBox.Layer.BorderColor  = UIColor.Gray.CGColor;

            //create general button
            GeneralButton = new UIButton();
            GeneralButton.BackgroundColor = UIColor.Green;
            //open the general settings modal.
            //pass some app data
            GeneralButton.TouchUpInside += (o, s) =>
            {
                //remove?
                //GeneralMaintenanceScreen.ButtonsPerPage = ButtonsPerPage;
                //GeneralMaintenanceScreen.NumberOfPages = NumberOfPages;
                Screen.PresentModalViewController(GeneralMaintenanceScreen.Screen, false); //

                GeneralMaintenanceScreen.NumberOfPages    = this.NumberOfPages;
                GeneralMaintenanceScreen.ButtonsPerPage   = this.ButtonsPerPage;
                GeneralMaintenanceScreen.BordersThickness = this.ButtonBorderWidth;
                GeneralMaintenanceScreen.SetDropDowns();
                //ImageBox.Layer.BorderColor = UIColor.Clear.CGColor;
            };
            GeneralButton.SetTitle("JustButtons\nSettings", UIControlState.Normal);
            GeneralButton.SetTitleColor(UIColor.Black, UIControlState.Normal);
            GeneralButton.Layer.BorderColor   = ButtonBorderColour.CGColor;
            GeneralButton.Layer.BorderWidth   = ButtonBorderWidth;
            GeneralButton.BackgroundColor     = ButtonBackgroundColour;
            GeneralButton.Layer.CornerRadius  = ButtonCornerRadius;
            GeneralButton.LineBreakMode       = UILineBreakMode.WordWrap;                   //allow multiple lines for text inside video button
            GeneralButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Center; //center text

            //color sliders
            RedSlider = new UISlider();
            RedSlider.ValueChanged += UpdateBorderColor;

            GreenSlider = new UISlider();
            GreenSlider.ValueChanged += UpdateBorderColor;

            BlueSlider = new UISlider();
            BlueSlider.ValueChanged += UpdateBorderColor;

            //create labels
            VideoButtonTitle               = new UILabel();
            VideoButtonTitle.Text          = "Click below to change the video played:";
            VideoButtonTitle.TextColor     = UIColor.Black;
            VideoButtonTitle.TextAlignment = UITextAlignment.Left;
            VideoButtonTitle.LineBreakMode = UILineBreakMode.WordWrap;
            VideoButtonTitle.Lines         = 2;

            ImageButtonTitle               = new UILabel();
            ImageButtonTitle.Text          = "Click below to change the button's image:";
            ImageButtonTitle.TextColor     = UIColor.Black;
            ImageButtonTitle.TextAlignment = UITextAlignment.Left;
            ImageButtonTitle.LineBreakMode = UILineBreakMode.WordWrap;
            ImageButtonTitle.Lines         = 2;

            ColourBoxTitle               = new UILabel();
            ColourBoxTitle.Text          = "Adjust the sliders to change the border colour:";
            ColourBoxTitle.TextColor     = UIColor.Black;
            ColourBoxTitle.TextAlignment = UITextAlignment.Left;
            ColourBoxTitle.LineBreakMode = UILineBreakMode.WordWrap;
            ColourBoxTitle.Lines         = 2;

            SettingsButtonTitle               = new UILabel();
            SettingsButtonTitle.Text          = "Click below to change the number of pages and buttons, and border thickness:";
            SettingsButtonTitle.TextColor     = UIColor.Black;
            SettingsButtonTitle.TextAlignment = UITextAlignment.Left;
            SettingsButtonTitle.LineBreakMode = UILineBreakMode.WordWrap;
            SettingsButtonTitle.Lines         = 2;

            //2. add views to parent view
            Screen.View.Add(VideoButton);
            Screen.View.Add(ImageButton);
            Screen.View.Add(ImageBox);
            Screen.View.Add(VideoBox);
            Screen.View.Add(BackButton);
            Screen.View.Add(SaveButton);
            Screen.Add(ColourBox);
            Screen.Add(GeneralButton);
            Screen.Add(RedSlider);
            Screen.Add(GreenSlider);
            Screen.Add(BlueSlider);
            Screen.Add(ImageButtonTitle);
            Screen.Add(VideoButtonTitle);
            Screen.Add(ColourBoxTitle);
            Screen.Add(SettingsButtonTitle);
            Screen.Add(ResetButton);

            //3. call method on parent view
            Screen.View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            //4. add constraints
            Screen.View.AddConstraints(
                VideoButton.AtTopOf(Screen.View, UIApplication.SharedApplication.StatusBarFrame.Height + 75),
                VideoButton.AtLeftOf(Screen.View, 70),
                VideoButton.WithRelativeWidth(Screen.View, 0.19f),
                VideoButton.Height().EqualTo(100),

                ImageButton.Below(VideoButton, 80),
                ImageButton.WithSameLeft(VideoButton),
                ImageButton.WithSameWidth(VideoButton),
                ImageButton.WithSameHeight(VideoButton),

                VideoBox.WithSameTop(VideoButton),
                VideoBox.Left().EqualTo().RightOf(VideoButton).Plus(35),
                VideoBox.WithRelativeWidth(Screen.View, 0.17f),
                VideoBox.Height().EqualTo(100),

                ImageBox.WithSameTop(ImageButton),
                ImageBox.WithSameLeft(VideoBox),
                ImageBox.WithSameWidth(VideoBox),
                ImageBox.WithSameHeight(VideoBox),

                BackButton.WithSameTop(VideoButton),
                BackButton.AtRightOf(Screen.View, 70),
                BackButton.WithSameWidth(VideoButton),
                BackButton.WithSameHeight(VideoButton),

                SaveButton.WithSameTop(ImageButton),
                SaveButton.AtRightOf(Screen.View, 70),
                SaveButton.WithSameWidth(VideoButton),
                SaveButton.WithSameHeight(VideoButton),

                ColourBox.Below(ImageButton, 80),
                ColourBox.WithSameLeft(VideoButton),
                ColourBox.WithSameWidth(VideoButton),
                ColourBox.WithSameHeight(VideoBox),

                GeneralButton.Below(ColourBox, 80),
                GeneralButton.WithSameLeft(VideoButton),
                GeneralButton.WithSameWidth(VideoButton),
                GeneralButton.WithSameHeight(VideoButton),

                RedSlider.WithSameTop(ColourBox),
                RedSlider.Left().EqualTo().RightOf(ColourBox).Plus(35),
                RedSlider.WithRelativeWidth(Screen.View, 0.11f),
                RedSlider.WithSameHeight(ColourBox),

                GreenSlider.WithSameTop(ColourBox),
                GreenSlider.Left().EqualTo().RightOf(RedSlider).Plus(30),
                GreenSlider.WithSameWidth(RedSlider),
                GreenSlider.WithSameHeight(ColourBox),

                BlueSlider.WithSameTop(ColourBox),
                BlueSlider.Left().EqualTo().RightOf(GreenSlider).Plus(30),
                BlueSlider.WithSameWidth(RedSlider),
                BlueSlider.WithSameHeight(ColourBox),

                VideoButtonTitle.Above(VideoButton, 5),
                VideoButtonTitle.WithSameLeft(VideoButton),
                VideoButtonTitle.WithRelativeWidth(VideoButton, 3.1f),
                VideoButtonTitle.Height().EqualTo(80),

                ImageButtonTitle.Above(ImageButton, 5),
                ImageButtonTitle.WithSameLeft(VideoButtonTitle),
                ImageButtonTitle.WithSameWidth(VideoButtonTitle),
                ImageButtonTitle.WithSameHeight(VideoButtonTitle),

                ColourBoxTitle.Above(ColourBox, 5),
                ColourBoxTitle.WithSameLeft(VideoButtonTitle),
                ColourBoxTitle.WithSameWidth(VideoButtonTitle),
                ColourBoxTitle.WithSameHeight(VideoButtonTitle),

                SettingsButtonTitle.Above(GeneralButton, 5),
                SettingsButtonTitle.WithSameLeft(VideoButtonTitle),
                SettingsButtonTitle.WithSameWidth(VideoButtonTitle),
                SettingsButtonTitle.WithSameHeight(VideoButtonTitle),

                ResetButton.WithSameTop(GeneralButton),
                ResetButton.AtRightOf(Screen.View, 70),
                ResetButton.WithSameWidth(VideoButton),
                ResetButton.WithSameHeight(VideoButton)
                );
        }
Exemplo n.º 35
0
        public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
        {
            //Event when a badge table row is selected

            indexRow = indexPath.Row;


            //Creates badge detail image -- need assets
            UIImageView image = new UIImageView(UIImage.FromFile("defaultBadge.png"));

            UIViewController badgeDetailView = new UIViewController();

            badgeDetailView.EdgesForExtendedLayout = UIRectEdge.None;
            badgeDetailView.Add(image);

            //Create badge title bar
            UILabel label = new UILabel(new System.Drawing.RectangleF(0, 230, (float)UIScreen.MainScreen.Bounds.Width, 60));

            label.Text = statues[indexPath.Row].Item1;
            if (label.Text.Length < 30)
            {
                label.Font = UIFont.FromName("Montserrat-Light", 24f);
            }
            else
            {
                label.Font = UIFont.FromName("Montserrat-Light", 18f);
            }
            label.TextColor       = UIColor.White;
            label.BackgroundColor = UIColor.LightGray;
            label.TextAlignment   = UITextAlignment.Center;
            badgeDetailView.Add(label);
            //end badge title bar

            //Holds the view map button and share button
            UIView buttonBar = new UIView(new System.Drawing.RectangleF(0, 290, (float)UIScreen.MainScreen.Bounds.Width, 90));

            buttonBar.BackgroundColor = UIColor.DarkGray;

            //Build map button
            UIButton viewInMapBtn = new UIButton(new System.Drawing.RectangleF(50, 15, 40, 40));

            viewInMapBtn.SetImage(UIImage.FromFile("mapIcon.png"), UIControlState.Normal);

            UILabel mapBtnLabel = new UILabel(new System.Drawing.RectangleF(20, 60, 100, 20));

            mapBtnLabel.Text          = "VIEW IN MAP";
            mapBtnLabel.TextAlignment = UITextAlignment.Center;
            mapBtnLabel.Font          = UIFont.FromName("Montserrat-Bold", 12f);
            mapBtnLabel.TextColor     = UIColor.White;
            buttonBar.Add(mapBtnLabel);

            viewInMapBtn.TouchUpInside += (object sender, EventArgs e) =>
            {
                owner.menu.selectedBid = statues[indexPath.Row].Item4;
                owner.menu.PerformSegue("ShowMap", (NSObject)sender);
            };

            buttonBar.Add(viewInMapBtn);
            //end map button

            //Build share button
            UIButton shareBtn = new UIButton(new System.Drawing.RectangleF((float)(UIScreen.MainScreen.Bounds.Width - 90), 15, 40, 40));

            shareBtn.SetImage(UIImage.FromFile("shareIcon.png"), UIControlState.Normal);

            UILabel shareBtnLabel = new UILabel(new System.Drawing.RectangleF((float)(UIScreen.MainScreen.Bounds.Width - 100), 60, 60, 20));

            shareBtnLabel.Text          = "SHARE";
            shareBtnLabel.TextAlignment = UITextAlignment.Center;
            shareBtnLabel.Font          = UIFont.FromName("Montserrat-Bold", 12f);
            shareBtnLabel.TextColor     = UIColor.White;
            buttonBar.Add(shareBtnLabel);

            buttonBar.Add(shareBtn);
            //end share button

            //Create badge icon
            string parsed = Regex.Replace(statues[indexPath.Row].Item1, "[^a-zA-Z0-9_.]+", "", RegexOptions.Compiled);

            var documents = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            var dbPath    = Path.Combine(documents, "db_sqlite-net.db");
            var db        = new SQLiteConnection(dbPath);

            String q = "SELECT * FROM MagpieUser WHERE bid = " + statues[indexPath.Row].Item4;

            userTuple = db.Query <MagpieUser>(q);

            UIButton badgeBtn = new UIButton(new CoreGraphics.CGRect((float)(UIScreen.MainScreen.Bounds.Width / 2) - 75, 270, 150, 128.89221556886));

            badgeLabel = new UILabel(new CGRect(0, 50, badgeBtn.Bounds.Width, badgeBtn.Bounds.Height / 4));
            badgeLabel.UserInteractionEnabled = false;

            if (userTuple.ElementAt(0).isClaimed.Equals("")) //user does not have badge
            {
                if (checkDistance(new CLLocation(statues[indexPath.Row].Item5.Latitude, statues[indexPath.Row].Item5.Longitude), currentLoc))
                {
                    //user is within collection distance

                    parsed          = "badges/SSW_" + parsed + ".png";
                    badgeLabel.Text = "COLLECT";
                }
                else
                {
                    parsed          = "graybadges/SSW_" + parsed + ".png";
                    badgeLabel.Text = "MOVE CLOSER";
                }
                badgeLabel.Font            = UIFont.FromName("Montserrat-Bold", 14f);
                badgeLabel.TextColor       = UIColor.White;
                badgeLabel.TextAlignment   = UITextAlignment.Center;
                badgeLabel.BackgroundColor = UIColor.DarkGray.ColorWithAlpha(0.5f);
            }
            else //user has badge
            {
                parsed = "badges/SSW_" + parsed + ".png";
                badgeBtn.UserInteractionEnabled = false;
            }

            UIImageView icon = new UIImageView(UIImage.FromFile(parsed));

            icon.Frame = new CoreGraphics.CGRect((float)(UIScreen.MainScreen.Bounds.Width / 2) - 75, 270, 150, 128.89221556886);
            icon.UserInteractionEnabled = false;

            icon.AddSubview(badgeLabel);

            badgeDetailView.Add(buttonBar);

            badgeBtn.TouchUpInside += (object sender, EventArgs e) =>
            {
                //Collect badge event
                if (checkDistance(new CLLocation(statues[indexPath.Row].Item5.Latitude, statues[indexPath.Row].Item5.Longitude), currentLoc))
                {
                    //user can collect
                    badgeLabel.Text            = "";
                    badgeLabel.BackgroundColor = UIColor.Clear;
                    ClaimBadge claim = new ClaimBadge();
                    claim.claimLocalBadge(statues[indexPath.Row].Item5);
                }
            };

            badgeDetailView.Add(icon);
            badgeDetailView.Add(badgeBtn);

            //Controls the scroll view of the description and artist
            UIScrollView textScroll = new UIScrollView(new System.Drawing.RectangleF(0, 380, (float)UIScreen.MainScreen.Bounds.Width, (float)UIScreen.MainScreen.Bounds.Height - 440));

            textScroll.ScrollEnabled   = true;
            textScroll.BackgroundColor = UIColor.White;

            //Build artist and year description
            UILabel subLabel = new UILabel(new System.Drawing.RectangleF(5, 0, (float)textScroll.Bounds.Width, 40));

            subLabel.Text      = "ARTIST: " + statues[indexPath.Row].Item2.ToUpper();
            subLabel.TextColor = UIColor.LightGray;
            subLabel.Font      = UIFont.FromName("Montserrat-Bold", 16f);

            //Builds the badge description
            UITextView description = new UITextView(new System.Drawing.RectangleF(20, 20, (float)(textScroll.Bounds.Width - 40), (float)textScroll.Bounds.Height));

            description.Add(subLabel);
            description.Text = "\n\n" + statues[indexPath.Row].Item3;
            description.UserInteractionEnabled = false;

            description.TextColor = UIColor.Black;
            description.Font      = UIFont.FromName("Montserrat-Regular", 16f);

            textScroll.AddSubview(description);

            badgeDetailView.Add(textScroll);
            //End badge description build



            //show badge detail view controller
            owner.NavigationController.PushViewController(badgeDetailView, true);

            /*
             * creates popup for debugging
             *
             * UIAlertController okAlertController = UIAlertController.Create("Row Selected", statues[indexPath.Row].Item1 + "\n" + statues[indexPath.Row].Item2, UIAlertControllerStyle.Alert);
             * okAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
             * owner.PresentViewController(okAlertController, true, null);
             */

            tableView.DeselectRow(indexPath, true);

            //loop for badge button updating

            /*
             * while (!checkDistance(new CLLocation(statues[indexPath.Row].Item5.Latitude, statues[indexPath.Row].Item5.Longitude), currentLoc)) {
             * //not close enough
             * badgeLabel.Text = "MOVE CLOSER";
             * }
             * if (checkDistance(new CLLocation(statues[indexPath.Row].Item5.Latitude, statues[indexPath.Row].Item5.Longitude), currentLoc)) {
             * //close enough
             * badgeLabel.Text = "COLLECT";
             *
             * }
             */
        }
Exemplo n.º 36
0
		public void RenderStream (Stream stream)
		{
			var reader = new System.IO.StreamReader (stream);

			InvokeOnMainThread (delegate {
				var view = new UIViewController ();
				view.View.BackgroundColor = UIColor.White;
				var label = new UILabel (new CGRect (20, 60, 300, 80)){
					Text = "The HTML returned by the server:"
				};
				var tv = new UITextView (new CGRect (20, 140, 300, 400)){
					Text = reader.ReadToEnd ()
				};
				view.Add (label);
				view.Add (tv);
					
				navigationController.PushViewController (view, true);
			});			
		}
Exemplo n.º 37
0
 public static void AddEx([NotNull] this UIViewController controller, UIView view)
 {
     Should.NotBeNull(controller, "controller");
     controller.Add(view);
     view.RaiseParentChanged();
 }
Exemplo n.º 38
0
        public void goToBadge()
        {
            //Creates badge detail image -- need assets
            UIImageView image = new UIImageView(UIImage.FromFile("defaultBadge.png"));

            UIViewController badgeDetailView = new UIViewController();

            badgeDetailView.EdgesForExtendedLayout = UIRectEdge.None;
            badgeDetailView.Add(image);

            //Create badge title bar
            UILabel label               = new UILabel(new System.Drawing.RectangleF(0, 230, (float)UIScreen.MainScreen.Bounds.Width, 60));
            var     documents           = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            var     dbPath              = Path.Combine(documents, "db_sqlite-net.db");
            var     db                  = new SQLiteConnection(dbPath);
            var     table               = db.Table <MagpieBadge>();
            CLLocationCoordinate2D anno = annotationScrollList[currentAnno];
            var query = db.Query <MagpieBadge>("SELECT * FROM MagpieBadge WHERE lon = " + anno.Longitude);

            label.Text = query[0].bname;
            if (label.Text.Length < 30)
            {
                label.Font = UIFont.FromName("Montserrat-Light", 24f);
            }
            else
            {
                label.Font = UIFont.FromName("Montserrat-Light", 18f);
            }
            label.TextColor       = UIColor.White;
            label.BackgroundColor = UIColor.LightGray;
            label.TextAlignment   = UITextAlignment.Center;
            badgeDetailView.Add(label);
            //end badge title bar

            //Holds the view map button and share button
            UIView buttonBar = new UIView(new System.Drawing.RectangleF(0, 290, (float)UIScreen.MainScreen.Bounds.Width, 90));

            buttonBar.BackgroundColor = UIColor.DarkGray;

            //Build map button
            UIButton viewInMapBtn = new UIButton(new System.Drawing.RectangleF(50, 15, 40, 40));

            viewInMapBtn.SetImage(UIImage.FromFile("mapIcon.png"), UIControlState.Normal);

            UILabel mapBtnLabel = new UILabel(new System.Drawing.RectangleF(20, 60, 100, 20));

            mapBtnLabel.Text          = "VIEW IN MAP";
            mapBtnLabel.TextAlignment = UITextAlignment.Center;
            mapBtnLabel.Font          = UIFont.FromName("Montserrat-Bold", 12f);
            mapBtnLabel.TextColor     = UIColor.White;
            buttonBar.Add(mapBtnLabel);

            viewInMapBtn.TouchUpInside += (object sender, EventArgs e) =>
            {
                this.selected = query[0].bid;
                NavigationController.PopViewController(true);
            };


            buttonBar.Add(viewInMapBtn);
            //end map button

            //Build share button
            UIButton shareBtn = new UIButton(new System.Drawing.RectangleF((float)(UIScreen.MainScreen.Bounds.Width - 90), 15, 40, 40));

            shareBtn.SetImage(UIImage.FromFile("shareIcon.png"), UIControlState.Normal);

            UILabel shareBtnLabel = new UILabel(new System.Drawing.RectangleF((float)(UIScreen.MainScreen.Bounds.Width - 100), 60, 60, 20));

            shareBtnLabel.Text          = "SHARE";
            shareBtnLabel.TextAlignment = UITextAlignment.Center;
            shareBtnLabel.Font          = UIFont.FromName("Montserrat-Bold", 12f);
            shareBtnLabel.TextColor     = UIColor.White;
            buttonBar.Add(shareBtnLabel);

            buttonBar.Add(shareBtn);
            //end share button

            //Create badge icon
            string parsed = Regex.Replace(query[0].bname, "[^a-zA-Z0-9_.]+", "", RegexOptions.Compiled);


            String q = "SELECT * FROM MagpieUser WHERE bid = " + query[0].bid;

            System.Collections.Generic.List <MagpieUser> userTuple = db.Query <MagpieUser>(q);


            UIButton badgeBtn   = new UIButton(new CoreGraphics.CGRect((float)(UIScreen.MainScreen.Bounds.Width / 2) - 75, 270, 150, 128.89221556886));
            UILabel  badgeLabel = new UILabel(new CGRect(0, 50, badgeBtn.Bounds.Width, badgeBtn.Bounds.Height / 4));

            badgeLabel.UserInteractionEnabled = false;

            if (userTuple.ElementAt(0).isClaimed.Equals("")) //user does not have badge
            {
                if (checkDistance(new CLLocation(query[0].lat, query[0].lon), new CLLocation(map.UserLocation.Location.Coordinate.Latitude, map.UserLocation.Location.Coordinate.Longitude)))
                {
                    //user is within collection distance

                    parsed          = "badges/SSW_" + parsed + ".png";
                    badgeLabel.Text = "COLLECT";
                }
                else
                {
                    parsed          = "graybadges/SSW_" + parsed + ".png";
                    badgeLabel.Text = "MOVE CLOSER";
                }
                badgeLabel.Font            = UIFont.FromName("Montserrat-Bold", 14f);
                badgeLabel.TextColor       = UIColor.White;
                badgeLabel.TextAlignment   = UITextAlignment.Center;
                badgeLabel.BackgroundColor = UIColor.DarkGray.ColorWithAlpha(0.5f);
            }
            else //user has badge
            {
                parsed = "badges/SSW_" + parsed + ".png";
                badgeBtn.UserInteractionEnabled = false;
            }

            UIImageView icon = new UIImageView(UIImage.FromFile(parsed));

            icon.Frame = new CoreGraphics.CGRect((float)(UIScreen.MainScreen.Bounds.Width / 2) - 75, 270, 150, 128.89221556886);
            icon.UserInteractionEnabled = false;

            icon.AddSubview(badgeLabel);

            badgeDetailView.Add(buttonBar);

            badgeBtn.TouchUpInside += (object sender, EventArgs e) =>
            {
                //Collect badge event

                if (checkDistance(new CLLocation(query[0].lat, query[0].lon), new CLLocation(map.UserLocation.Location.Coordinate.Latitude, map.UserLocation.Location.Coordinate.Longitude)))
                {
                    //user can collect
                    badgeLabel.Text            = "";
                    badgeLabel.BackgroundColor = UIColor.Clear;
                    ClaimBadge claim = new ClaimBadge();
                    claim.claimLocalBadge(new CLLocationCoordinate2D(query[0].lat, query[0].lon));
                }
            };

            badgeDetailView.Add(icon);
            badgeDetailView.Add(badgeBtn);
            //Controls the scroll view of the description and artist
            UIScrollView textScroll = new UIScrollView(new System.Drawing.RectangleF(0, 380, (float)UIScreen.MainScreen.Bounds.Width, (float)UIScreen.MainScreen.Bounds.Height - 440));

            textScroll.ScrollEnabled   = true;
            textScroll.BackgroundColor = UIColor.White;

            //Build artist and year description
            UILabel subLabel = new UILabel(new System.Drawing.RectangleF(5, 0, (float)textScroll.Bounds.Width, 40));

            subLabel.Text      = "ARTIST: " + query[0].art.ToUpper();
            subLabel.TextColor = UIColor.LightGray;
            subLabel.Font      = UIFont.FromName("Montserrat-Bold", 16f);

            //Builds the badge description
            UITextView description = new UITextView(new System.Drawing.RectangleF(20, 20, (float)(textScroll.Bounds.Width - 40), (float)textScroll.Bounds.Height));

            description.Add(subLabel);
            description.Text = "\n\n" + query[0].desc;

            description.TextColor = UIColor.Black;
            description.Font      = UIFont.FromName("Montserrat-Regular", 16f);

            textScroll.AddSubview(description);

            badgeDetailView.Add(textScroll);
            //End badge description build


            //show badge detail view controller
            this.NavigationController.PushViewController(badgeDetailView, true);
        }
Exemplo n.º 39
0
                                                        

 public void NativeRelativePopup(View view, Point point, double width, double height) 

                                                        {
                                                            
 var size = new CGRect(0, 0, width, height); 
 var pos_x = 0.05; 
 var pos_y = 0.04; 

                     if (point.X > 700)

                                                            {
                                                                
                     {
                                                                    
 pos_x = 0.12; 
 pos_y = 0.05; 

                                                                }
                                                            }
                                                            
                      if (point.Y > 500)
                                                            {
                                                                
                     {
                                                                    
 pos_x = 0.06; 
 pos_y = 0.18; 

                                                                }
                                                            }


                                                            //var p = new CGRect(new CGPoint(point.X, point.Y), new  CGSize(0, 0));
                                                            var position = new CGRect(point.X + (point.X * pos_x), point.Y + (point.Y * pos_y), 0, 0); 
 var iOSView = ConvertFormsToNative(view, size); 
 var arrowDiretion = UIPopoverArrowDirection.Up; 

                       if (point.Y <= 500)
                                                            {
                                                                
 arrowDiretion = UIPopoverArrowDirection.Up;
                                                            }
                                                            
 else
 arrowDiretion = UIPopoverArrowDirection.Down; 

 var viewController = new UIViewController(); 
 viewController.Add(iOSView); 
 viewController.View.Frame = size; 
 popoverController = new UIPopoverController(viewController); 
 popoverController.ContentViewController.View.BackgroundColor = viewController.View.BackgroundColor; 
 popoverController.PopoverContentSize = size.Size; 

 var frame = UIApplication.SharedApplication.KeyWindow.RootViewController.View;

                                                            if (view.ToString() == "ServiceRequest.Views.PopUp.AddActionView")
                                                            {
                                                                
                     {
                                                                    position = new CGRect(500, 400, 0, 0); 
 popoverController.PresentFromRect(position, frame, 0, true); 

                                                                }
                                                            }
                                                            else if (view.ToString() == ("ServiceRequest.Views.PopUp.AddVisitsPopUp"))
                                                            {
                                                                
                     {
                                                                    position = new CGRect(500, 400, 0, 0); 
 popoverController.PresentFromRect(position, frame, 0, true); 

                                                                }
                                                            }
                                                            
                      else if (view.ToString() == ("ServiceRequest.Views.PopUp.AddressesNearbyView"))
                                                            {
                                                                
                        {
                                                                    position = new CGRect(500, 400, 0, 0); 
 popoverController.PresentFromRect(position, frame, 0, true); 

                                                                }
                                                            }
                                                            

                     else if (Xamarin.Forms.Application.Current.MainPage.ToString() == "ServiceRequest.Pages.VisitActionPage")
                                                            {
                                                                
                      {
                                                                    
 position = new CGRect(500, 400, 0, 0);

                                                                    popoverController.PresentFromRect(position, frame, 0, true);
                                                                }
                                                            }
                                                            

 else
                   {
                                                                
 popoverController.PresentFromRect(position, frame, arrowDiretion, true); 

                                                            } 
 AppContext.AppContext.IsAlertOnDisplay = true; 
 PopUpSample.PopupLayouts.DismissPopup = () =>
                                                            {
                                                                if (popoverController.PopoverVisible)
                                                                {
                                                                    AppContext.AppContext.IsAlertOnDisplay = false;
                                                                }
                                                                popoverController.Dismiss(true); 

                                                            }; 

                                                        }
Exemplo n.º 40
0
    
 public class NativePopup : INativePopup
        { 

 private UIPopoverController popoverController; 


 public void NativeCenterPopup(View view, double width, double height) 

                                                        {
                                                            
 var size = new CGRect(0, 0, width, height); 
 var iOSView = ConvertFormsToNative(view, size); 

 var viewController = new UIViewController(); 
 viewController.Add(iOSView); 
 viewController.View.Frame = size; 

 popoverController = new UIPopoverController(viewController); 
 popoverController.ContentViewController.View.BackgroundColor = viewController.View.BackgroundColor; 
 popoverController.PopoverContentSize = size.Size; 

 var frame = UIApplication.SharedApplication.KeyWindow.RootViewController.View; 

 popoverController.PresentFromRect(frame.Frame, frame, 0, true); 

 popoverController.ShouldDismiss += (popoverController) =>

                                                            {
                                                                return(false); 

                                                            }; 
 AppContext.AppContext.IsAlertOnDisplay = true; 
 PopUpSample.PopupLayouts.DismissPopup = () => 
                  {
                                                                if (popoverController.PopoverVisible)
                                                                {
                                                                    AppContext.AppContext.IsAlertOnDisplay = false;
                                                                }
                                                                popoverController.Dismiss(true); 

                                                            }; 

                                                        }
Exemplo n.º 41
0
    public override bool FinishedLaunching(UIApplication app, NSDictionary options)
    {
        window = new UIWindow (UIScreen.MainScreen.Bounds);

        NSTimer.CreateScheduledTimer (0.1, (v) => TickOnce ());

        dvc = new UIViewController ();
        dvc.View.BackgroundColor = UIColor.White;
        button = new UIButton (window.Bounds);
        button.TouchDown += (object sender, EventArgs e) =>
        {
            Tapped ();
        };
        button.SetTitleColor (UIColor.Blue, UIControlState.Normal);
        button.SetTitleColor (UIColor.Gray, UIControlState.Highlighted);
        button.SetTitle ("Click here", UIControlState.Normal);
        dvc.Add (button);

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

        return true;
    }
Exemplo n.º 42
0
		private void ShowPicture()
		{
			var data = presenter.Model.Image;
			if (data == null)
			{
				new UIAlertView("Error","No saved imaged for this item",null,"OK",null).Show();
				return;
			}
			NSData imageData = NSData.FromArray(data);
			var image = UIImage.LoadFromData(imageData);
			var imageView = new UIImageView(View.Bounds);
			imageView.Image = image;
			var vc = new UIViewController();
			vc.Add(imageView);
			NavigationController.PushViewController(vc,true);
		}