protected void OnLoad(object sender, EventArgs e)
        {
            try
            {
                flagsChangedHandler             = flagsChanged;
                windowWillUseFullScreenHandler  = windowWillUseFullScreen;
                windowDidEnterFullScreenHandler = windowDidEnterFullScreen;
                windowDidExitFullScreenHandler  = windowDidExitFullScreen;
                windowShouldZoomToFrameHandler  = windowShouldZoomToFrame;

                var fieldImplementation   = typeof(NativeWindow).GetRuntimeFields().Single(x => x.Name == "implementation");
                var typeCocoaNativeWindow = typeof(NativeWindow).Assembly.GetTypes().Single(x => x.Name == "CocoaNativeWindow");
                var fieldWindowClass      = typeCocoaNativeWindow.GetRuntimeFields().Single(x => x.Name == "windowClass");

                nativeWindow = fieldImplementation.GetValue(Implementation);
                var windowClass = (IntPtr)fieldWindowClass.GetValue(nativeWindow);

                // register new methods
                Class.RegisterMethod(windowClass, flagsChangedHandler, "flagsChanged:", "v@:@");
                Class.RegisterMethod(windowClass, windowWillUseFullScreenHandler, "window:willUseFullScreenPresentationOptions:", "I@:@I");
                Class.RegisterMethod(windowClass, windowDidEnterFullScreenHandler, "windowDidEnterFullScreen:", "v@:@");
                Class.RegisterMethod(windowClass, windowDidExitFullScreenHandler, "windowDidExitFullScreen:", "v@:@");

                // replace methods that currently break
                Class.RegisterMethod(windowClass, windowShouldZoomToFrameHandler, "windowShouldZoom:toFrame:", "b@:@{NSRect={NSPoint=ff}{NSSize=ff}}");

                NSNotificationCenter.AddObserver(WindowInfo.Handle, Selector.Get("windowDidEnterFullScreen:"), NSNotificationCenter.WINDOW_DID_ENTER_FULL_SCREEN, IntPtr.Zero);
                NSNotificationCenter.AddObserver(WindowInfo.Handle, Selector.Get("windowDidExitFullScreen:"), NSNotificationCenter.WINDOW_DID_EXIT_FULL_SCREEN, IntPtr.Zero);

                methodKeyDown = nativeWindow.GetType().GetRuntimeMethods().Single(x => x.Name == "OnKeyDown");
                methodKeyUp   = nativeWindow.GetType().GetRuntimeMethods().Single(x => x.Name == "OnKeyUp");
                methodInvalidateCursorRects = nativeWindow.GetType().GetRuntimeMethods().Single(x => x.Name == "InvalidateCursorRects");
            }
            catch
            {
                Logger.Log("Window initialisation couldn't complete, likely due to the SDL backend being enabled.", LoggingTarget.Runtime, LogLevel.Important);
                Logger.Log("Execution will continue but keyboard functionality may be limited.", LoggingTarget.Runtime, LogLevel.Important);
            }
        }
        void StartMetadataQuery()
        {
            if (documentMetadataQuery == null)
            {
                NSMetadataQuery metadataQuery = new NSMetadataQuery {
                    SearchScopes = new NSObject[] {
                        NSMetadataQuery.UbiquitousDocumentsScope
                    },
                    Predicate = NSPredicate.FromFormat("(%K.pathExtension = %@)",
                                                       NSMetadataQuery.ItemFSNameKey,
                                                       (NSString)AppConfig.ListerFileExtension)
                };
                documentMetadataQuery = metadataQuery;

                NSNotificationCenter notificationCenter = NSNotificationCenter.DefaultCenter;
                // TODO: use typed overload https://trello.com/c/1RyX6cJL
                finishGatheringToken = notificationCenter.AddObserver(NSMetadataQuery.DidFinishGatheringNotification,
                                                                      HandleMetadataQueryUpdates, metadataQuery);
                updateToken = notificationCenter.AddObserver(NSMetadataQuery.DidUpdateNotification,
                                                             HandleMetadataQueryUpdates, metadataQuery);
            }

            documentMetadataQuery.StartQuery();
        }
        void Initialize(NSPhoto photo, UIView loadingView, NSNotificationCenter notificationCenter)
        {
            _photo = photo;

            if (photo.ImageData != null)
            {
                ScalingImageView = new DNAScalingImageView(photo.ImageData, CGRect.Empty);
            }
            else
            {
                var photoImage = (photo.Image != null) ? photo.Image : photo.PlaceholderImage;
                ScalingImageView = new DNAScalingImageView(photoImage, CGRect.Empty);

                if (photoImage == null)
                {
                    SetUpLoadingView(loadingView);
                }
            }

            ScalingImageView.Delegate = this;
            _notificationCenter       = notificationCenter;

            SetUpGestureRecognizers();
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            //Google Cast button
            var castButton = new UICastButton(new CGRect(0, 0, 24, 24));

            NavigationItem.RightBarButtonItem = new UIBarButtonItem(castButton);

            //NSNotificationCenter.DefaultCenter.AddObserver(this, castDidChangeState(), CastContext.CastStateDidChangeNotification, CastContext.SharedInstance);
            sessionManager = CastContext.SharedInstance.SessionManager;
            CastContext.SharedInstance.SessionManager.AddListener(this);

            NSNotificationCenter aNotificationCenter = NSNotificationCenter.DefaultCenter;

            aNotificationCenter.AddObserver(this, new ObjCRuntime.Selector("castDidChangeState:"), CastContext.CastStateDidChangeNotification, CastContext.SharedInstance);


            videoController = new UIView();
            videoController.BackgroundColor = UIColor.Red;
            videoController.Frame           = new CGRect(0, 100, 375, 207.5);

            //table = new UITableView(); // defaults to Plain style
            //table.Frame = new CGRect(0, 335, View.Frame.Width, View.Frame.Height - 215);
            //string[] tableItems = new string[] { "Basic Video", "DRM Video" };
            //table.Source = new TableSource(tableItems, this);

            //playbackController Setup
            playbackController = sDKManager.CreatePlaybackController();
            playbackController.SetAutoPlay(true);
            playbackController.SetAutoAdvance(true);
            playbackController.Delegate = new BCPlaybackControllerDelegate();

            BCOVGoogleCastManager googleCastManager = new BCOVGoogleCastManager();

            googleCastManager.Delegate = new BCGoogleCastManagerDelegate(playbackController);
            playbackController.AddSessionConsumer(googleCastManager);

            //playerView Setup
            var options = new BCOVPUIPlayerViewOptions()
            {
                PresentingViewController = this
            };
            var playerView = new BCOVPUIPlayerView(playbackController, options, BCOVPUIBasicControlView.BasicControlViewWithVODLayout());

            playerView.Frame = new CGRect(0, 0, 375, 207.5);


            playbackService.FindVideoWithVideoID(videoID: videoId, parameters: new NSDictionary(), completionHandler: (arg0, arg1, arg2) =>
            {
                if (arg0 != null)
                {
                    playbackController.SetVideos(NSArray.FromObjects(arg0));
                }
                else
                {
                    Debug.WriteLine($"View Controller Debug - Error retrieving video : {arg2.LocalizedDescription} ");
                }
            });

            playerView.PlaybackController = playbackController;
            videoController.AddSubview(playerView);
            View.AddSubview(videoController);
            //View.AddSubview(table);
        }
		private void SetupButtons(){

			this.center = NSNotificationCenter.DefaultCenter;

			center.AddObserver(
				UIKeyboard.WillHideNotification, (notify) => { 
					try{
						var keyboardBounds = (NSValue)notify.UserInfo.ObjectForKey(UIKeyboard.BoundsUserInfoKey);
						var keyboardSize = keyboardBounds.RectangleFValue;
						if((nameInput.Text != this.appDelegate.contactListView.name) ||
							(emailInput.Text != this.appDelegate.contactListView.email) ||
							(mobileInput.Text != this.appDelegate.contactListView.mobile)){
							SetEditing(false,false);
							UpdateContact();
						}
					}catch(Exception ex){
						Console.Write(ex.Message);
					}
				}
			);	


			this.killKeyboardButton.AllTouchEvents += (sender, e) => {
				DismissKeyboard();
			};

			this.emailInput.EditingDidEnd += (sender, e) => {
				ResignFirstResponder();
				DismissKeyboard();
			};

			this.inviteButton.TouchUpInside += (sender, e) => {
				ShowInviteOptions();
			};

			this.nameInput.Ended += (sender, e) => {
//				if((nameInput.Text != this.appDelegate.contactListView.name) ||
//					(emailInput.Text != this.appDelegate.contactListView.email) ||
//					(mobileInput.Text != this.appDelegate.contactListView.mobile)){
//					SetEditing(false,false);
//					UpdateContact();
//				}
			};

			this.processingCancelButton.TouchUpInside += (sender, e) => {
				this.processingView.Hidden = true;
			};

		}
Example #6
0
 /// <summary>
 /// Notificationses the specified notification key.
 /// </summary>
 /// <param name="notificationCenter">The notification center.</param>
 /// <param name="notificationKey">The notification key.</param>
 /// <returns>An observable sequence of NSNotifications.</returns>
 public static IObservable <NSNotification> Notifications(this NSNotificationCenter notificationCenter, NSString notificationKey) =>
 Observable.Create <NSNotification>(obs =>
 {
     var nsObserver = notificationCenter.AddObserver(notificationKey, obs.OnNext);
     return(Disposable.Create(() => notificationCenter.RemoveObserver(nsObserver)));
 });
 public DNAPhotoViewController(NSPhoto photo, UIView loadingView, NSNotificationCenter notificationCenter) : base(null, null)
 {
     Initialize(photo, loadingView, notificationCenter);
 }
		public void Dealloc(){
			NSNotificationCenter defaultCenter = new NSNotificationCenter ();
			defaultCenter.RemoveObserver (this, null);
		}
		public override void ViewDidLoad(){
			base.ViewDidLoad ();
			NSNotificationCenter defaultCenter = new NSNotificationCenter ();
			defaultCenter.AddObserver (null, ContentSizeDidChangeNotification, this);
			//defaultCenter.PerformSelector(MonoTouch.ObjCRuntime.Selector, ContentSizeDidChangeNotification);
		}
Example #10
0
        public void Dealloc()
        {
            NSNotificationCenter defaultCenter = new NSNotificationCenter();

            defaultCenter.RemoveObserver(this, null);
        }
		public override void ViewDidLoad()
		{

			this.appDelegate = (AppDelegate)UIApplication.SharedApplication.Delegate;
			NavigationItem.SetRightBarButtonItem(lockButton, false);
			this.center = NSNotificationCenter.DefaultCenter;

			EndEditing();
			SetupButtons();

			InitExpandableTextView();
			AddExpandableAccessoryView();
			SetExpandableTextViewSize();

			var g = new UITapGestureRecognizer(() => View.EndEditing(true));
			View.AddGestureRecognizer(g);

			center.AddObserver(
				UIKeyboard.WillHideNotification, (notify) => { 
				try {
					isKeyboardVisible = false;
					var keyboardBounds = (NSValue)notify.UserInfo.ObjectForKey(UIKeyboard.BoundsUserInfoKey);
					var keyboardSize = keyboardBounds.RectangleFValue;
					this.keyboardHeight = keyboardSize.Height;
					SetTableSize();
					AnimateToolbar();	
				} catch (Exception ex) {
					Console.Write(ex.Message);
				}
			}
			);	


			center.AddObserver(
				UIKeyboard.WillShowNotification, (notify) => { 
				try {
					this.toolbarFakeMessage.Hidden = true;
					this.accessoryTextView.BecomeFirstResponder();

					isKeyboardVisible = true;

					var keyboardBounds = (NSValue)notify.UserInfo.ObjectForKey(UIKeyboard.BoundsUserInfoKey);
					var keyboardSize = keyboardBounds.RectangleFValue;
					this.keyboardHeight = keyboardSize.Height;

					CheckEmptyTextView();
					SetTableSize();

					this.accessoryTextView.BecomeFirstResponder();
				} catch (Exception ex) {
					Console.Write(ex.Message);
				}
			}
			);	
		}
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            TableView.SeparatorColor = UIColor.Clear;

            if (UIDevice.CurrentDevice.UserInterfaceIdiom != UIUserInterfaceIdiom.Pad)
            {
                NSNotificationCenter defaultCenter = NSNotificationCenter.DefaultCenter;
                defaultCenter.AddObserver(UIKeyboard.WillHideNotification, OnKeyboardNotification);
                defaultCenter.AddObserver(UIKeyboard.WillShowNotification, OnKeyboardNotification);
            }

            if (String.IsNullOrEmpty(tokenPayment.Token))
            {
                DispatchQueue.MainQueue.DispatchAfter(DispatchTime.Now, () => {
                    UIAlertView _error = new UIAlertView("Missing Token", "No Card Token found. Please provide application with token via Pre-Authentication or Payment", null, "ok", null);
                    _error.Show();

                    _error.Clicked += (sender, args) => {
                        PaymentButton.Disable();
                        if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
                        {
                            this.DismissViewController(true, null);
                        }
                        else
                        {
                            this.NavigationController.PopViewController(true);
                        }
                    };
                });
            }
            else
            {
                SetUpTableView();

                UITapGestureRecognizer tapRecognizer = new UITapGestureRecognizer();

                tapRecognizer.AddTarget(() => {
                    if (KeyboardVisible)
                    {
                        DismissKeyboardAction();
                    }
                });

                tapRecognizer.NumberOfTapsRequired    = 1;
                tapRecognizer.NumberOfTouchesRequired = 1;

                EncapsulatingView.AddGestureRecognizer(tapRecognizer);
                PaymentButton.Disable();

                PaymentButton.SetTitleColor(UIColor.Black, UIControlState.Application);

                PaymentButton.TouchUpInside += (sender, ev) => {
                    MakeTokenPayment();
                };

                if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
                {
                    FormClose.TouchUpInside += (sender, ev) => {
                        this.DismissViewController(true, null);
                    };
                }
            }
        }
Example #13
0
 public NotificationCenterListener()
 {
     center = NSDistributedNotificationCenter.DefaultCenter as NSNotificationCenter;
 }