/// <summary>
        /// Indicates that the value at the specified keyPath relative to this object has changed.
        /// </summary>
        /// <param name="keyPath">Key-path to use to perform the value lookup.   The keypath consists of a series of lowercase ASCII-strings with no spaces in them separated by dot characters.</param>
        /// <param name="ofObject">The of object.</param>
        /// <param name="change">A dictionary that describes the changes that have been made to the value of the property at the key path keyPath relative to object. Entries are described in Change Dictionary Keys.</param>
        /// <param name="context">The value that was provided when the receiver was registered to receive key-value observation notifications.</param>
        /// <remarks>This method is invoked if you have registered an observer using the <see cref="M:Foundation.NSObject.AddObserver" /> method</remarks>
        public override void ObserveValue(Foundation.NSString keyPath, Foundation.NSObject ofObject, Foundation.NSDictionary change, IntPtr context)
        {
            if (Equals(ofObject, _player))
            {
                if (keyPath.Equals((Foundation.NSString) "status"))
                {
                    if (_player.Status == AVPlayerStatus.ReadyToPlay)
                    {
                        System.Diagnostics.Debug.WriteLine("Player ReadyToPlay");

                        Element.OnMediaLoaded();

                        if (Element.AutoPlay)
                        {
                            Element.PlayCommand.Execute(null);
                        }
                    }
                }
                else if (keyPath.Equals((Foundation.NSString) "error") && _player.Error != null)
                {
                    System.Diagnostics.Debug.WriteLine("Error");

                    Element.OnMediaErrorOccurred(_player.Error?.LocalizedDescription ?? "Error loading player");
                }
            }

            //base.ObserveValue(keyPath, ofObject, change, context);
        }
 protected ReactiveTableViewSource(UITableView tableView, IReactiveNotifyCollectionChanged <TViewModel> collection,
                                   Foundation.NSString cellKey, nfloat height, nfloat?heightHint = null, Action <UITableViewCell> initializeCellAction = null)
     : base(tableView, collection, cellKey, (float)height, initializeCellAction)
 {
     tableView.RowHeight          = height;
     tableView.EstimatedRowHeight = heightHint ?? tableView.EstimatedRowHeight;
 }
 protected ReactiveTableViewSource(UITableView tableView, IReactiveNotifyCollectionChanged <TViewModel> collection,
                                   Foundation.NSString cellKey, nfloat sizeHint, Action <UITableViewCell> initializeCellAction = null)
     : base(tableView, collection, cellKey, (float)sizeHint, initializeCellAction)
 {
     tableView.RowHeight          = sizeHint;
     tableView.EstimatedRowHeight = sizeHint;
     collection.CountChanged.Select(x => x == 0).Subscribe(_isEmptySubject.OnNext);
 }
Beispiel #4
0
 protected ReactiveTableViewSource(UITableView tableView, IReactiveNotifyCollectionChanged <TViewModel> collection,
                                   Foundation.NSString cellKey, nfloat height, nfloat?heightHint = null, Action <UITableViewCell> initializeCellAction = null)
     : base(tableView, collection, cellKey, (float)height, initializeCellAction)
 {
     tableView.RowHeight          = height;
     tableView.EstimatedRowHeight = heightHint ?? tableView.EstimatedRowHeight;
     collection.CountChanged.Select(x => x == 0).Subscribe(_isEmptySubject.OnNext);
     (collection as IReactiveCollection <TViewModel>).Do(x => _isEmptySubject.OnNext(!x.Any()));
 }
        public override SizeRequest GetDesiredSize(double widthConstraint, double heightConstraint)
        {
            var baseResult = base.GetDesiredSize(widthConstraint, heightConstraint);
            var testString = new Foundation.NSString("Tj");
            var testSize   = testString.GetSizeUsingAttributes(new UIStringAttributes {
                Font = Control.Font
            });
            double height = baseHeight + testSize.Height;

            height = Math.Round(height);

            return(new SizeRequest(new global::Xamarin.Forms.Size(baseResult.Request.Width, height)));
        }
Beispiel #6
0
        public static Dictionary <string, object> NSDictToPureDict(Foundation.NSDictionary nsDict)
        {
            if (nsDict == null)
            {
                return(null);
            }
            Foundation.NSError  error;
            Foundation.NSData   jsonData     = Foundation.NSJsonSerialization.Serialize(nsDict, (Foundation.NSJsonWritingOptions) 0, out error);
            Foundation.NSString jsonNSString = Foundation.NSString.FromData(jsonData, Foundation.NSStringEncoding.UTF8);
            string jsonString = jsonNSString.ToString();

            return(Json.Deserialize(jsonString) as Dictionary <string, object>);
        }
Beispiel #7
0
        public static void SetBinding(this UIView view, string propertyName, BindingBase bindingBase,
                                      string updateSourceEventName = null)
        {
            var binding = bindingBase as Binding;

            //This will allow setting bindings from Xaml by reusing the MarkupExtension
            updateSourceEventName = updateSourceEventName ?? binding?.UpdateSourceEventName;

            if (!IsNullOrEmpty(updateSourceEventName))
            {
                NativeBindingHelpers.SetBinding(view, propertyName, bindingBase, updateSourceEventName);
                return;
            }

            NativeViewPropertyListener nativePropertyListener = null;

            if (bindingBase.Mode == BindingMode.TwoWay)
            {
                nativePropertyListener = new NativeViewPropertyListener(propertyName);
                try
                {
                    //TODO: We need to figure a way to map the value back to the real objectiveC property.
                    //the X.IOS camelcase property name won't work
                    var key      = new Foundation.NSString(propertyName.ToLower());
                    var valueKey = view.ValueForKey(key);
                    if (valueKey != null)
                    {
                        view.AddObserver(nativePropertyListener, key, Foundation.NSKeyValueObservingOptions.New, IntPtr.Zero);
                    }
                }
#if __MOBILE__
                catch (Foundation.MonoTouchException ex)
                {
                    nativePropertyListener = null;
                    if (ex.Name == "NSUnknownKeyException")
                    {
                        System.Diagnostics.Debug.WriteLine("KVO not supported, try specify a UpdateSourceEventName instead.");
                        return;
                    }
                    throw ex;
                }
#else
                catch (Exception ex)
                {
                    throw ex;
                }
#endif
            }

            NativeBindingHelpers.SetBinding(view, propertyName, bindingBase, nativePropertyListener);
        }
        protected override void OnAttached()
        {
            var searchbar = Control as UISearchBar;

            if (searchbar != null)
            {
                oldstyle                  = searchbar.SearchBarStyle;
                searchbar.BarStyle        = UIBarStyle.Default;
                searchbar.BackgroundImage = new UIImage();
                Foundation.NSString _searchField = new Foundation.NSString("searchField");
                var textFieldInsideSearchBar     = (UITextField)searchbar.ValueForKey(_searchField);
                textFieldInsideSearchBar.BackgroundColor = UIColor.FromRGB(220, 220, 220);
            }
        }
Beispiel #9
0
 public static void OutputStringToConsole(string text)
 {
     using (var nsText = new Foundation.NSString(text))
     {
         if (IsDevice && Is64Bit)
         {
             NSLog_ARM64(nsFormat.Handle, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, nsText.Handle);
         }
         else
         {
             NSLog(nsFormat.Handle, nsText.Handle);
         }
     }
 }
        protected override void OnElementChanged(ElementChangedEventArgs <SearchBar> e)
        {
            base.OnElementChanged(e);

            var searchbar = (UISearchBar)this.Control;

            if (e.NewElement != null)
            {
                //add inner border and corner radius
                Foundation.NSString _searchField = new Foundation.NSString("searchField");
                var textFieldInsideSearchBar     = (UITextField)searchbar.ValueForKey(_searchField);
                textFieldInsideSearchBar.Layer.CornerRadius = 10;
                textFieldInsideSearchBar.Layer.BorderWidth  = 2;
                //light grey colour for the border
                textFieldInsideSearchBar.Layer.BorderColor = UIColor.FromRGB(200, 200, 200).CGColor;
            }
        }
        protected override void OnElementChanged(ElementChangedEventArgs <SearchBar> e)
        {
            base.OnElementChanged(e);
            var searchbar = (UISearchBar)Control;

            if (e.NewElement != null)
            {
                Foundation.NSString _searchField = new Foundation.NSString("searchField");
                var textFieldInsideSearchBar     = (UITextField)searchbar.ValueForKey(_searchField);
                textFieldInsideSearchBar.BackgroundColor = UIColor.FromRGB(224, 220, 220);
                textFieldInsideSearchBar.TextColor       = UIColor.White;
                searchbar.TintColor      = UIColor.White;
                searchbar.BarTintColor   = UIColor.White;
                searchbar.SearchBarStyle = UISearchBarStyle.Minimal;
                searchbar.BarTintColor   = UIColor.Clear;
            }
        }
Beispiel #12
0
        public void TestIOKitPInvokes()
        {
            // Test the pinvokes don't crash. Don't care about the details returned

            var matchingDict = MacTelemetryDetails.IOServiceMatching("IOService");

            // IOServiceGetMatchingServices takes ownership of matchingDict, so no need to CFRelease it
            var success = MacTelemetryDetails.IOServiceGetMatchingServices(0, matchingDict, out var iter);

            if (MacTelemetryDetails.IOIteratorIsValid(iter) == 0)
            {
                // An invalid iter isn't a test failure, but it means we can't really test anything else
                // so just return
                return;
            }

            var entry = MacTelemetryDetails.IOIteratorNext(iter);

            if (entry == 0)
            {
                MacTelemetryDetails.IOObjectRelease(iter);
                return;
            }

            success = MacTelemetryDetails.IORegistryEntryGetChildIterator(entry, "IOService", out var childIter);
            if (success != 0)
            {
                MacTelemetryDetails.IOObjectRelease(entry);
                return;
            }

            MacTelemetryDetails.IOObjectRelease(childIter);

            var name    = new Foundation.NSString("testService");
            var namePtr = MacTelemetryDetails.IORegistryEntrySearchCFProperty(entry, "IOService", name.Handle, IntPtr.Zero, 0x0);

            MacTelemetryDetails.IOObjectRelease(entry);
            MacTelemetryDetails.IOObjectRelease(iter);

            MacTelemetryDetails.CFRelease(namePtr);
        }
        protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.SearchBar> e)
        {
            base.OnElementChanged(e);
            var searchbar = (UISearchBar)Control;

            if (e.NewElement != null)
            {
                Foundation.NSString _searchField = new Foundation.NSString("searchField");
                var textFieldInsideSearchBar     = (UITextField)searchbar.ValueForKey(_searchField);
                textFieldInsideSearchBar.BackgroundColor = new UIColor(224 / 255f, 224 / 255f, 224 / 255f, 1.0f);
                //textFieldInsideSearchBar.TextColor = UIColor.White;
                //searchbar.Layer.BackgroundColor = UIColor.Cyan.CGColor;

                //searchbar.TintColor = UIColor.Clear;
                //searchbar.BarTintColor = UIColor.Clear;
                //searchbar.Layer.CornerRadius = 20;
                //searchbar.Layer.BorderWidth = 0;
                //searchbar.Layer.BorderColor = UIColor.FromRGB(0, 73, 135).CGColor;
                //searchbar.ShowsCancelButton = false;
            }
        }
Beispiel #14
0
        protected override void OnElementChanged(ElementChangedEventArgs <SearchBar> args)
        {
            base.OnElementChanged(args);

            UISearchBar bar = Control;

            bar.ShowsCancelButton = false;
            bar.SearchBarStyle    = UISearchBarStyle.Minimal;
            bar.SetImageforSearchBarIcon(UIImage.FromBundle("location"), UISearchBarIcon.Search, UIControlState.Normal);


            Foundation.NSString _searchField = new Foundation.NSString("searchField");
            var textFieldInsideSearchBar     = ( UITextField )bar.ValueForKey(_searchField);

            textFieldInsideSearchBar.BorderStyle        = UITextBorderStyle.None;
            textFieldInsideSearchBar.ClipsToBounds      = true;
            textFieldInsideSearchBar.Layer.BorderWidth  = 0.3f;
            textFieldInsideSearchBar.Layer.CornerRadius = 5f;
            textFieldInsideSearchBar.Layer.BorderColor  = UIColor.LightGray.CGColor;
            textFieldInsideSearchBar.BackgroundColor    = UIColor.White;
        }
Beispiel #15
0
        protected override void OnElementChanged(ElementChangedEventArgs <SearchBar> e)
        {
            base.OnElementChanged(e);

            var searchbar = (UISearchBar)Control;

            if (e.NewElement != null)
            {
                Foundation.NSString _searchField = new Foundation.NSString("searchField");
                var textFieldInsideSearchBar     = (UITextField)searchbar.ValueForKey(_searchField);
                textFieldInsideSearchBar.BackgroundColor = UIColor.White;
                textFieldInsideSearchBar.TextColor       = UIColor.Black;
                textFieldInsideSearchBar.BorderStyle     = UITextBorderStyle.None;
                searchbar.BarTintColor           = UIColor.LightTextColor;
                searchbar.Layer.CornerRadius     = 2.0f;
                searchbar.Layer.BorderWidth      = 1.0f;
                searchbar.Layer.BorderColor      = UIColor.FromRGB(169, 169, 169).CGColor;
                searchbar.ShowsCancelButton      = false;
                searchbar.AutocapitalizationType = UITextAutocapitalizationType.None;

                if (e.NewElement != null)
                {
                    this.Control.TextChanged += (s, ea) =>
                    {
                        this.Control.ShowsCancelButton = false;
                    };

                    this.Control.OnEditingStarted += (s, ea) =>
                    {
                        this.Control.ShowsCancelButton = false;
                    };

                    this.Control.OnEditingStopped += (s, ea) =>
                    {
                        this.Control.ShowsCancelButton = false;
                    };
                }
            }
        }
        protected override void OnElementChanged(ElementChangedEventArgs <SearchBar> e)
        {
            base.OnElementChanged(e);

            var searchbar = (UISearchBar)Control;

            if (e.NewElement != null)
            {
                Foundation.NSString _searchField = new Foundation.NSString("searchField");
                var textFieldInsideSearchBar     = (UITextField)searchbar.ValueForKey(_searchField);
                textFieldInsideSearchBar.BackgroundColor = UIColor.White;
                textFieldInsideSearchBar.TextColor       = UIColor.Gray;

                searchbar.Layer.CornerRadius    = 20;
                searchbar.Layer.BorderWidth     = 12;
                searchbar.ClipsToBounds         = true;
                searchbar.Layer.BackgroundColor = Color.White.ToCGColor();
                searchbar.Layer.BorderColor     = Color.White.ToCGColor();
                searchbar.TintColor             = UIColor.Gray;
                searchbar.BarTintColor          = UIColor.White;
            }
        }
        private void InitLeadCam()
        {
            if (leadCamera.Camera == null)
            {
                _cameraObjectNotReady = true;
                return;
            }

            if (!cleanup || AppResumed)
            {
                leadCamera.Camera.Start();
                //reset the clean up flag
                cleanup    = true;
                AppResumed = false;

                leadCamera.RotationChanged += LeadCamera_RotationChanged;
                leadCamera.PictureReceived += LeadCamera_PictureReceived;


                if (_enableAutoCapture)
                {
                    leadCamera.FrameReceived += LeadCamera_FrameReceived;
                }

                return;
            }

            if (_enableAutoCapture)
            {
                Animation labelFadeAnimation = new Animation();

                Animation fadeOutAnimation = new Animation
                                             (
                    callback: d => autoCaptureLabel.Opacity = d,
                    start: 1,
                    end: 0.25,
                    easing: Easing.SinInOut
                                             );

                Animation fadeInAnimation = new Animation
                                            (
                    callback: e =>
                {
                    autoCaptureLabel.Opacity = e;
                },
                    start: 0.25,
                    end: 1,
                    easing: Easing.SinInOut
                                            );

                labelFadeAnimation.Add(0, 0.5, fadeOutAnimation);
                labelFadeAnimation.Add(0.5, 1, fadeInAnimation);

                autoCaptureLabel.Animate("FadeInOut", labelFadeAnimation, length: 1000, easing: Easing.SinInOut, repeat: () => true);
                UpdateCardDetectionStatus();
            }

            leadCamera.RotationChanged += LeadCamera_RotationChanged;
            leadCamera.PictureReceived += LeadCamera_PictureReceived;

            leadCamera.CameraOptions.AutoRotateImage = _autoRotateImage;
            leadCamera.Camera.FocusMode = FocusMode.Continuous;
#if __IOS__
            var ioscam = leadCamera.Camera.NativeCamera as AVFoundation.AVCaptureSession;
            if (ioscam != null)
            {
                var presetValue = ioscam.SessionPreset;
                if (HomePage.CurrentAppData.CameraQuality == Utils.CameraQuality.Medium)
                {
                    presetValue = new Foundation.NSString("AVCaptureSessionPreset1920x1080");
                }
                else
                {
                    presetValue = new Foundation.NSString("AVCaptureSessionPreset3840x2160");
                }

                try
                {
                    foreach (AVFoundation.AVCaptureOutput output in ioscam.Outputs)
                    {
                        if (output is AVFoundation.AVCaptureStillImageOutput stillImageOutput)
                        {
                            stillImageOutput.HighResolutionStillImageOutputEnabled = (HomePage.CurrentAppData.CameraQuality == Utils.CameraQuality.High) ? true : false;
                        }
                    }
                    ioscam.SessionPreset = presetValue;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
#else
            //set capture quality setting
#pragma warning disable CS0618 // Type or member is obsolete
            var droidcam     = leadCamera.Camera.NativeCamera as Android.Hardware.Camera;
            var parameters   = droidcam.GetParameters();
            var pictureSizes = parameters.SupportedPictureSizes;
            if (pictureSizes != null)
            {
                Android.Hardware.Camera.Size closestMatch = null;
                if (HomePage.CurrentAppData.CameraQuality == Utils.CameraQuality.Medium)
                {
                    // Get the first camera size with width bigger than 2000
                    var closestMatches = pictureSizes.OrderByDescending(x => x.Width).Where(x => x.Width > 2000);
                    if (closestMatches != null && closestMatches.Count() > 0)
                    {
                        closestMatch = closestMatches.Last();
                    }
                }
                else
                {
                    var closestMatches = pictureSizes.OrderByDescending(x => x.Width).Where(x => x.Width > 3800);
                    if (closestMatches != null && closestMatches.Count() > 0)
                    {
                        closestMatch = closestMatches.Last();
                    }
                }

                if (closestMatch == null)
                {
                    closestMatch = pictureSizes.OrderByDescending(x => x.Height).First();
                }

                parameters.SetPictureSize(closestMatch.Width, closestMatch.Height);
                droidcam.SetParameters(parameters);
            }
#pragma warning restore CS0618 // Type or member is obsolete
#endif

            autoCaptureGrid.IsVisible = _enableAutoCapture;
            if (_enableAutoCapture)
            {
                leadCamera.FrameReceived += LeadCamera_FrameReceived;
            }
        }
 private void JoiningCompleted(Foundation.NSString arg1, nuint arg2, nint arg3)
 {
     _myId = arg2;
     _agoraEngine.SetEnableSpeakerphone(true);
     JoinChannelSuccess((uint)_myId);
 }
Beispiel #19
0
 public virtual override void WillChange(Foundation.NSKeyValueChange changeKind, Foundation.NSIndexSet indexes, Foundation.NSString forKey)
 {
 }
 private void JoiningCompleted(Foundation.NSString arg1, nuint arg2, nint arg3)
 {
     _myId = arg2;
     JoinChannelSuccess((uint)_myId);
 }
Beispiel #21
0
 public virtual override void WillChange(Foundation.NSString forKey, Foundation.NSKeyValueSetMutationKind mutationKind, Foundation.NSSet objects)
 {
 }
Beispiel #22
0
 public override void SetValueForKeyPath(IntPtr handle, Foundation.NSString keyPath)
 {
 }
Beispiel #23
0
 public virtual override Foundation.NSObject ValueForUndefinedKey(Foundation.NSString key)
 {
     throw new NotImplementedException();
 }
Beispiel #24
0
 [Foundation.Export("isTestDone:")]         // notice the colon at the end of the method name
 public Foundation.NSString IsTestDoneBackdoor(Foundation.NSString value) => new Foundation.NSString(IsTestDone(value).ToString());
Beispiel #25
0
 public override IDisposable AddObserver(Foundation.NSString key, Foundation.NSKeyValueObservingOptions options, Action <Foundation.NSObservedChange> observer)
 {
     throw new NotImplementedException();
 }
Beispiel #26
0
 protected ReactiveTableViewCell(UIKit.UITableViewCellStyle style, Foundation.NSString reuseIdentifier)
     : base(style, reuseIdentifier)
 {
 }
Beispiel #27
0
 [Foundation.Export("runTest:")]         // notice the colon at the end of the method name
 public Foundation.NSString RunTestBackdoor(Foundation.NSString value) => new Foundation.NSString(RunTest(value));
Beispiel #28
0
 public override void Unbind(Foundation.NSString binding)
 {
 }
Beispiel #29
0
 [Foundation.Export("getDisplayScreenScaling:")]         // notice the colon at the end of the method name
 public Foundation.NSString GetDisplayScreenScalingBackdoor(Foundation.NSString value) => new Foundation.NSString(GetDisplayScreenScaling(value).ToString());
Beispiel #30
0
 public virtual override Foundation.NSObject ValueForKeyPath(Foundation.NSString keyPath)
 {
     throw new NotImplementedException();
 }