public override void ObserveValue(NSString keyPath, NSObject ofObject, NSDictionary change, IntPtr context)
        {
            if (Equals(ofObject, playerItem))
            {
                if (keyPath.Equals((NSString)"loadedTimeRanges"))
                {
                    slider.FileDuration = TimeSpan.FromSeconds(playerItem.Duration.Seconds).TotalMilliseconds;
                }
            }
            if (Equals(ofObject, bootomToolbarView))
            {
                if (keyPath.Equals((NSString)"bounds"))
                {
                    if (!bootomToolbarView.Bounds.IsEmpty)
                    {
                        gradientLayer.Frame = bootomToolbarView.Bounds;
                    }
                }
            }
            if (Equals(ofObject, videoPlayerAV))
            {
                if (keyPath.Equals((NSString)"videoBounds"))
                {
                    if (!videoPlayerAV.VideoBounds.IsEmpty && slider != null)
                    {
                        videoView.Frame = videoPlayerAV.VideoBounds;

                        //mainView.Frame = videoPlayerAV.VideoBounds;
                        // playerLayer.Frame = videoPlayerAV.VideoBounds;
                        //bootomToolbarView.TopAnchor.ConstraintEqualTo(TopAnchor, videoPlayerAV.VideoBounds.Bottom-40).Active=true;
                        //bootomToolbarView.Frame = new CGRect(videoPlayerAV.VideoBounds.Left + 10, videoPlayerAV.VideoBounds.Bottom - 10, Control.Bounds.Width - 20, 40);

                        //labelTimePlayed.Frame = new CGRect(bootomToolbarView.Frame.X, bootomToolbarView.Frame.Y, 50, 20);
                        //seekBar.Frame = new CGRect(bootomToolbarView.Frame.X + labelTimePlayed.Frame.Width, bootomToolbarView.Frame.Y, bootomToolbarView.Frame.Width - 100, 20);
                        //labelTimeLeft.Frame = new CGRect(bootomToolbarView.Frame.X + labelTimePlayed.Frame.Width + seekBar.Frame.Width, bootomToolbarView.Frame.Y, 50, 20);

                        //bootomToolbarView.Frame = new CGRect(videoPlayerAV.VideoBounds.Left, videoPlayerAV.VideoBounds.Bottom - 10, Control.Bounds.Width, 40);
                        //labelTimePlayed.Frame = new CGRect(10, 10, 50, 20);
                        //seekBar.Frame = new CGRect(60, 10, bootomToolbarView.Frame.Width-120, 20);
                        //labelTimeLeft.Frame = new CGRect(seekBar.Frame.Width+60, 10, 50, 20);
                        //labelTimePlayed = new UILabel();
                        //labelTimePlayed.Text = "00:00";
                        //labelTimePlayed.TextColor = UIColor.White;

                        //labelTimeLeft = new UILabel();
                        //labelTimeLeft.Text = string.Format("{0:mm\\:ss}", TimeSpan.FromMilliseconds(slider.FileDuration ?? 0));
                        //labelTimeLeft.TextColor = UIColor.White;
                    }
                    //if (!playerLayer.VideoRect.IsEmpty && slider != null)
                    //{
                    //    slider.Frame = new CGRect(playerLayer.VideoRect.Left+20, playerLayer.VideoRect.Bottom-20, View.Bounds.Width - 20, 20);
                    //    //new CGRect(View.Bounds.Left + 20, View.Bounds.Bottom - 20, View.Bounds.Width - 20, 40);
                    //}
                }
            }

            //base.ObserveValue(keyPath, ofObject, change, context);
        }
Example #2
0
 public void Equality()
 {
     using (var s1 = new NSString("\u00f6"))                     // o-umlaut
         using (var s2 = new NSString("o\u0308")) {              // o + combining diaeresis
             // since ObjC thinks it's different
             Assert.That(s1.GetHashCode(), Is.Not.EqualTo(s2.GetHashCode()), "GetHashCode");
             // then it's "correct" to return false for equality
             Assert.False(s1.Equals((object)s2), "Equal(object)");
             Assert.False(s1.Equals((NSObject)s2), "Equal(NSObject)");
             Assert.False(s1.Equals((NSString)s2), "Equal(NSString)");
             Assert.False(NSString.Equals(s1, s2), "static");
             // and people need to call compare
             Assert.That(s1.Compare(s2), Is.EqualTo(NSComparisonResult.Same), "Same");
         }
 }
Example #3
0
        public UICollectionReusableView GetViewForSupplementaryElement(UICollectionView collectionView, NSString elementKind, NSIndexPath indexPath)
        {
            var section = Sections[indexPath.Section];

            switch (section.Type)
            {
            case ImagePickerSection.CellType.SelectableImage:
            {
                using (var headerKind = new NSString("UICollectionElementKindSectionHeader"))
                {
                    if (elementKind.Equals(headerKind) && section.Type == ImagePickerSection.CellType.SelectableImage)
                    {
                        var headerView = collectionView.DequeueReusableSupplementaryView(elementKind, SelectableDateCollectionHeaderView.Identifier, indexPath) as SelectableDateCollectionHeaderView;
                        headerView.UpdateHeader(section.Date, section.Selected);
                        headerView.AddGestureRecognizer(CreateHeaderTapGesture());
                        return(headerView);
                    }
                }
                break;
            }

            case ImagePickerSection.CellType.TakePhoto:
                return(collectionView.DequeueReusableSupplementaryView(elementKind, headerId, indexPath));
            }
            return(null);
        }
Example #4
0
        public bool CheckRunning()
        {
            var appPathKey = new NSString("NSApplicationPath");
            var appPathVal = new NSString(AppleSdkSettings.XcodePath);

            return(NSWorkspace.SharedWorkspace.LaunchedApplications.Any(app => appPathVal.Equals(app[appPathKey])));
        }
Example #5
0
        public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
        {
            //The deviceToken is of interest here, this is what your push notification server needs to send out a notification
            // to the device.  So, most times you'd want to send the device Token to your servers when it has changed

            //First, get the last device token we know of
            string lastDeviceToken = NSUserDefaults.StandardUserDefaults.StringForKey("deviceToken");

            //There's probably a better way to do this
            NSString strFormat      = new NSString("%@");
            NSString newDeviceToken = new NSString(MonoTouch.ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr_IntPtr(new MonoTouch.ObjCRuntime.Class("NSString").Handle, new MonoTouch.ObjCRuntime.Selector("stringWithFormat:").Handle, strFormat.Handle, deviceToken.Handle));

            //We only want to send the device token to the server if it hasn't changed since last time
            // no need to incur extra bandwidth by sending the device token every time
            if (!newDeviceToken.Equals(lastDeviceToken))
            {
                ///////////////////
                // Push the device registration to Azure Mobile Services.
                ///////////////////

                UserDeviceManager.Instance.Insert(new BL.UserDeviceRegistration {
                    Name = "Tim", ServiceType = "APNS", ServiceKey = newDeviceToken
                });

                //Save the new device token for next application launch
                NSUserDefaults.StandardUserDefaults.SetString(newDeviceToken, "deviceToken");
            }
        }
 public UICollectionReusableView GetViewForSupplementaryElement(UICollectionView collectionView, NSString elementKind, NSIndexPath indexPath)
 {
     if (!elementKind.Equals(UICollectionElementKindSectionKey.Header))
     {
         return(null);
     }
     return(collectionView.DequeueReusableSupplementaryView(UICollectionElementKindSectionKey.Header, nameof(SearchHeader), indexPath) as SearchHeader);
 }
Example #7
0
 public override void ObserveValue(NSString keyPath, NSObject ofObject, NSDictionary change, IntPtr context)
 {
     //base.ObserveValue (keyPath, ofObject, change, context);
     if (ofObject == _viewController && keyPath.Equals("title"))
     {
         _contentView.Title = _viewController.Title;
         _contentView.SetNeedsDisplay();
     }
 }
Example #8
0
        public override void ObserveValue(NSString keyPath, NSObject ofObject, NSDictionary change, IntPtr context)
        {
            if (ofObject == _textLabel && keyPath.Equals(@"text"))
            {
                NSString text = (NSString)change.ObjectForKey((NSObject)NSObject.ChangeNewKey);
                Hidden = text.Length == 0;

                if (!Hidden)
                {
                    SetNeedsDisplay();
                }
                return;
            }

            base.ObserveValue(keyPath, ofObject, change, context);
        }
        public override void ObserveValue(NSString keyPath, NSObject ofObject, NSDictionary change, IntPtr context)
        {
            base.ObserveValue(keyPath, ofObject, change, context);

            if (keyPath.Equals(KeyThickness))
            {
                MDRadialProgressView view = (MDRadialProgressView)ofObject;

                float offset = view.Theme.Thickness;
                RectangleF frame = view.Frame;
                float sideDimension = Math.Min(frame.Width, frame.Height) - offset;
                var adjustedFrame = new RectangleF(frame.X + offset, frame.Y + offset, sideDimension, sideDimension);
                Bounds = adjustedFrame;

                SetNeedsLayout();
            }
        }
Example #10
0
        /*
         * public override void ViewDidUnload ()
         * {
         *      base.ViewDidUnload ();
         *
         *      // Clear any references to subviews of the main view in order to
         *      // allow the Garbage Collector to collect them sooner.
         *      //
         *      // e.g. myOutlet.Dispose (); myOutlet = null;
         *
         *      ReleaseDesignerOutlets ();
         * }
         */


        public override UIStatusBarStyle PreferredStatusBarStyle()
        {
            UIStatusBarStyle statusBarStyle = UIStatusBarStyle.Default;

            try {
                var      myStatusBarStyle         = NSBundle.MainBundle.ObjectForInfoDictionary("Appverse_StatusBarStyle");
                NSString myStatusBarStyleNSString = new NSString("dark");
                if (myStatusBarStyle != null)
                {
                    if (myStatusBarStyle is NSString)
                    {
                        myStatusBarStyleNSString = (NSString)myStatusBarStyle;

                                                #if DEBUG
                        log("Preferred StatusBar Style: " + myStatusBarStyleNSString);
                                                #endif
                    }
                    if (myStatusBarStyleNSString != null && myStatusBarStyleNSString.Equals(new NSString("light")))
                    {
                                                #if DEBUG
                        log("Preferred StatusBar Style: " + myStatusBarStyleNSString + ", applying light content status bar style");
                                                #endif
                        statusBarStyle = UIStatusBarStyle.LightContent;                          // Content in the status bar is drawn with light values. Preferable for use wth darker-colored content views.
                    }
                    else
                    {
                                                #if DEBUG
                        log("Preferred StatusBar Style: " + myStatusBarStyleNSString + ", applying default status bar style (dark)");
                                                #endif
                    }
                }
            } catch (Exception ex) {
                                #if DEBUG
                log("Exception getting 'Appverse_StatusBarStyle' from application preferences: " + ex.Message);
                                #endif
            }

            return(statusBarStyle);
        }
Example #11
0
        public MonoTouch.UIKit.UIViewController GetViewController(MonoTouch.UIKit.UIApplication application, string[] restorationIdentifierComponents, MonoTouch.Foundation.NSCoder coder)
        {
            NSString key = (NSString)restorationIdentifierComponents.Last <Object> ();

            if (key.Equals("MMDrawer"))
            {
                return(this.Window.RootViewController);
            }
            else if (key.Equals("MMExampleCenterNavigationControllerRestorationKey"))
            {
                return(((MMDrawerController.MMDrawerController) this.Window.RootViewController).CenterViewController);
            }
            else if (key.Equals("MMExampleRightNavigationControllerRestorationKey"))
            {
                return(((MMDrawerController.MMDrawerController) this.Window.RootViewController).RightDrawerViewController);
            }
            else if (key.Equals("MMExampleLeftNavigationControllerRestorationKey"))
            {
                return(((MMDrawerController.MMDrawerController) this.Window.RootViewController).LeftDrawerViewController);
            }
            else if (key.Equals("MMExampleLeftSideDrawerController"))
            {
                UIViewController leftVC = ((MMDrawerController.MMDrawerController) this.Window.RootViewController).LeftDrawerViewController;
                if (leftVC.GetType() == typeof(UINavigationController))
                {
                    return(((UINavigationController)leftVC).TopViewController);
                }
                else
                {
                    return(leftVC);
                }
            }
            else if (key.Equals("MMExampleRightSideDrawerController"))
            {
                UIViewController rightVC = ((MMDrawerController.MMDrawerController) this.Window.RootViewController).RightDrawerViewController;
                if (rightVC.GetType() == typeof(UINavigationController))
                {
                    return(((UINavigationController)rightVC).TopViewController);
                }
                else
                {
                    return(rightVC);
                }
            }
            return(null);
        }
Example #12
0
        /// <summary>
        /// Succcessful registration for remote notifications.
        /// </summary>
        /// <param name="application">Application.</param>
        /// <param name="deviceToken">Device token.</param>
        public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
        {
            // The deviceToken is what the push notification server needs to send out a notification
            // to the device. Most times application needs to send the device Token to its servers when it has changed

            #if DEBUG
            log ("Success registering for Remote Notifications");
            #endif

            // First, get the last device token we know of
            string lastDeviceToken = NSUserDefaults.StandardUserDefaults.StringForKey("deviceToken");

            //There's probably a better way to do this
            NSString strFormat = new NSString("%@");
            NSString newDeviceToken = new NSString(MonoTouch.ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr_IntPtr(new MonoTouch.ObjCRuntime.Class("NSString").Handle, new MonoTouch.ObjCRuntime.Selector("stringWithFormat:").Handle, strFormat.Handle, deviceToken.Handle));
            #if DEBUG
            log ("New device token: " + newDeviceToken);
            #endif
            // We only want to send the device token to the server if it hasn't changed since last time
            // no need to incur extra bandwidth by sending the device token every time
            if (!newDeviceToken.Equals(lastDeviceToken))
            {
                // Send the new device token to your application server

                RegitrationToken registrationToken = new RegitrationToken();
                registrationToken.StringRepresentation = newDeviceToken;
                byte[] buffer = new byte[deviceToken.Length];
                Marshal.Copy(deviceToken.Bytes, buffer,0,buffer.Length);
                registrationToken.Binary = buffer;
                IPhoneUtils.GetInstance().FireUnityJavascriptEvent("Unity.OnRegisterForRemoteNotificationsSuccess", registrationToken);

                //Save the new device token for next application launch
                NSUserDefaults.StandardUserDefaults.SetString(newDeviceToken, "deviceToken");
            }
        }
 public UICollectionReusableView GetViewForSupplementaryElement(UICollectionView collectionView, NSString elementKind, NSIndexPath indexPath)
 {
     if (!elementKind.Equals(UICollectionElementKindSectionKey.Header)) return null;
     return collectionView.DequeueReusableSupplementaryView(UICollectionElementKindSectionKey.Header, nameof(AccountHeader), indexPath) as AccountHeader;
 }
        /*
        public override void ViewDidUnload ()
        {
            base.ViewDidUnload ();

            // Clear any references to subviews of the main view in order to
            // allow the Garbage Collector to collect them sooner.
            //
            // e.g. myOutlet.Dispose (); myOutlet = null;

            ReleaseDesignerOutlets ();
        }
        */
        public override UIStatusBarStyle PreferredStatusBarStyle()
        {
            UIStatusBarStyle statusBarStyle = UIStatusBarStyle.Default;

            try {
                var myStatusBarStyle = NSBundle.MainBundle.ObjectForInfoDictionary("Appverse_StatusBarStyle");
                NSString myStatusBarStyleNSString = new NSString("dark");
                if(myStatusBarStyle!=null) {
                    if(myStatusBarStyle is NSString) {
                        myStatusBarStyleNSString = (NSString) myStatusBarStyle;

                        #if DEBUG
                        log ("Preferred StatusBar Style: " + myStatusBarStyleNSString);
                        #endif
                    }
                    if(myStatusBarStyleNSString!=null && myStatusBarStyleNSString.Equals(new NSString("light"))) {
                        #if DEBUG
                        log ("Preferred StatusBar Style: " + myStatusBarStyleNSString + ", applying light content status bar style");
                        #endif
                        statusBarStyle = UIStatusBarStyle.LightContent;  // Content in the status bar is drawn with light values. Preferable for use wth darker-colored content views.
                    } else {
                        #if DEBUG
                        log ("Preferred StatusBar Style: " + myStatusBarStyleNSString + ", applying default status bar style (dark)");
                        #endif
                    }
                }
            } catch(Exception ex) {
                #if DEBUG
                log ("Exception getting 'Appverse_StatusBarStyle' from application preferences: " + ex.Message);
                #endif
            }

            return statusBarStyle;
        }
Example #15
0
        public override void ObserveValue(NSString keyPath, NSObject @object, NSDictionary change, IntPtr context)
        {
            if (@object == this.CenterController)
            {
                if (keyPath.Equals(new NSString("tabBarItem.title")))
                {
                    this.TabBarItem.Title = this.CenterController.TabBarItem.Title;
                    return;
                }

                if (keyPath.Equals(new NSString("tabBarItem.image")))
                {
                    this.TabBarItem.Image = this.CenterController.TabBarItem.Image;
                    return;
                }

                if (keyPath.Equals(new NSString("hidesBottomBarWhenPushed")))
                {
                    this.HidesBottomBarWhenPushed = this.CenterController.HidesBottomBarWhenPushed;
                    this.TabBarController.HidesBottomBarWhenPushed = this.CenterController.HidesBottomBarWhenPushed;
                    return;
                }
            }

            if (keyPath.Equals(new NSString("title")))
            {
                if (this.Title != this.CenterController.Title)
                {
                    this.Title = this.CenterController.Title ?? string.Empty;
                }
                return;
            }

            if (keyPath.Equals(new NSString("bounds")))
            {
                var offset = this.SlidingControllerView.Frame.Location.X;
                this.SetSlidingFrameForOffset(offset);

                this.SlidingControllerView.Layer.ShadowPath = UIBezierPath.FromRect(this.ReferenceBounds).CGPath;
                UINavigationController navController = this.CenterController.GetType().IsSubclassOf(typeof(UINavigationController)) ? (UINavigationController)this.CenterController : null;

                if (navController != null && !navController.NavigationBarHidden)
                {
                    navController.NavigationBarHidden = true;
                    navController.NavigationBarHidden = false;
                }

                return;
            }
        }
Example #16
0
        /// <summary>
        /// The iOS will call the APNS in the background and issue a device token to the device. when that's 
        /// accomplished, this method will be called.
        /// 
        /// Note: the device token can change, so this needs to register with your server application everytime 
        /// this method is invoked, or at a minimum, cache the last token and check for a change.
        /// </summary>
        public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
        {
            //The deviceToken is of interest here, this is what your push notification server needs to send out a notification
            // to the device.  So, most times you'd want to send the device Token to your servers when it has changed

            //First, get the last device token we know of
            string lastDeviceToken = NSUserDefaults.StandardUserDefaults.StringForKey ("deviceToken");

            //There's probably a better way to do this
            NSString strFormat = new NSString ("%@");
            NSString newDeviceToken = new NSString (MonoTouch.ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr_IntPtr (new MonoTouch.ObjCRuntime.Class ("NSString").Handle, new MonoTouch.ObjCRuntime.Selector ("stringWithFormat:").Handle, strFormat.Handle, deviceToken.Handle));

            //We only want to send the device token to the server if it hasn't changed since last time
            // no need to incur extra bandwidth by sending the device token every time
            if (!newDeviceToken.Equals (lastDeviceToken)) {
                //TODO: Insert your own code to send the new device token to your application server

                //Save the new device token for next application launch
                NSUserDefaults.StandardUserDefaults.SetString (newDeviceToken, "deviceToken");
            }
        }
Example #17
0
		public override void ObserveValue(NSString keyPath, NSObject ofObject, NSDictionary change, IntPtr context)
		{
			if (ofObject == _textLabel && keyPath.Equals(@"text"))
			{
				NSString text = (NSString)change.ObjectForKey((NSObject)NSObject.ChangeNewKey);
				Hidden = text.Length == 0;
				
				if (!Hidden)
				{
					SetNeedsDisplay();
				}
				return;
			}
			
			base.ObserveValue(keyPath, ofObject, change, context);
		}