Пример #1
0
        partial void RegisterEvents()
        {
            _touchSubscription.Disposable = null;

            View uiControl = GetUIControl();

            var nativeButton = uiControl as Android.Widget.Button;

            if (nativeButton is Android.Widget.Button)
            {
                _isEnabledSubscription.Disposable =
                    DependencyObjectExtensions.RegisterDisposablePropertyChangedCallback(
                        this,
                        IsEnabledProperty,
                        (s, e) => uiControl.Enabled = IsEnabled
                        );

                uiControl.Enabled = IsEnabled;
            }
            else if (uiControl != null)
            {
            }
            else
            {
                if (this.Log().IsEnabled(Microsoft.Extensions.Logging.LogLevel.Debug))
                {
                    this.Log().WarnFormat("ControlTemplateRoot is not available, {0} will not be clickable", this.GetType());
                }
            }
        }
Пример #2
0
        partial void RegisterEvents()
        {
            _touchSubscription.Disposable     = null;
            _isEnabledSubscription.Disposable = null;

            View uiControl = GetUIControl();

            var nativeButton = uiControl as Android.Widget.Button;

            if (nativeButton is Android.Widget.Button)
            {
                this.Log().Debug("Template contains Android.Widget.Button, hooking up to Click and syncing IsEnabled state");

                _touchSubscription.Disposable = uiControl
                                                .RegisterClick((e, s) =>
                {
                    if (this.Log().IsEnabled(Microsoft.Extensions.Logging.LogLevel.Debug))
                    {
                        this.Log().Debug("TouchUpInside, executing command");
                    }

                    OnClick();
                });

                _isEnabledSubscription.Disposable =
                    DependencyObjectExtensions.RegisterDisposablePropertyChangedCallback(
                        this,
                        IsEnabledProperty,
                        (s, e) => uiControl.Enabled = IsEnabled
                        );

                uiControl.Enabled = IsEnabled;
            }
            else if (uiControl != null)
            {
                PointerExited   += OnPointerExited;
                PointerEntered  += OnPointerEntered;
                PointerCanceled += OnPointerCanceled;
                PointerPressed  += OnPointerPressed;
                PointerReleased += OnPointerReleased;

                _touchSubscription.Disposable = Disposable.Create(() =>
                {
                    PointerExited   -= OnPointerExited;
                    PointerEntered  -= OnPointerEntered;
                    PointerCanceled -= OnPointerCanceled;
                    PointerPressed  -= OnPointerPressed;
                    PointerReleased -= OnPointerReleased;
                });
            }
            else
            {
                if (this.Log().IsEnabled(Microsoft.Extensions.Logging.LogLevel.Debug))
                {
                    this.Log().WarnFormat("ControlTemplateRoot is not available, {0} will not be clickable", this.GetType());
                }
            }
        }
Пример #3
0
        partial void RegisterEvents()
        {
            _touchSubscription.Disposable     = null;
            _isEnabledSubscription.Disposable = null;

            View uiControl = GetUIControl();

            var nativeButton = uiControl as Android.Widget.Button;

            if (nativeButton is Android.Widget.Button)
            {
                this.Log().Debug("Template contains Android.Widget.Button, hooking up to Click and syncing IsEnabled state");

                _touchSubscription.Disposable = uiControl
                                                .RegisterClick((e, s) =>
                {
                    if (this.Log().IsEnabled(Microsoft.Extensions.Logging.LogLevel.Debug))
                    {
                        this.Log().Debug("TouchUpInside, executing command");
                    }

                    // TODO: Simulate the complete pointer sequence on "this", and remove the Tapped and Click
                    // uiControl.SetOnTouchListener()
                    OnPointerPressed(new PointerRoutedEventArgs(this));

                    OnClick();

                    var args = new TappedRoutedEventArgs {
                        OriginalSource = this
                    };

                    RaiseEvent(TappedEvent, args);
                });

                _isEnabledSubscription.Disposable =
                    DependencyObjectExtensions.RegisterDisposablePropertyChangedCallback(
                        this,
                        IsEnabledProperty,
                        (s, e) => uiControl.Enabled = IsEnabled
                        );

                uiControl.Enabled = IsEnabled;
            }
            else if (uiControl != null)
            {
            }
            else
            {
                if (this.Log().IsEnabled(Microsoft.Extensions.Logging.LogLevel.Debug))
                {
                    this.Log().WarnFormat("ControlTemplateRoot is not available, {0} will not be clickable", this.GetType());
                }
            }
        }
Пример #4
0
 /// <summary>
 /// Registers to all the attached properties on the children, so that
 /// the control is invalidated when their value changes.
 /// </summary>
 /// <param name="child"></param>
 private void CreateGridChildPropertiesSubscription(NativeView child)
 {
     if (!_childSubscriptions.ContainsKey(child))
     {
         // The tradeoff made here is to assume that registering to all property changes, and checking for DP
         // equality in the callback is less expensive that forcing the initialization of the four grid attached properties
         // storage on all the children.
         _childSubscriptions[child] =
             DependencyObjectExtensions
             .RegisterDisposablePropertyChangedCallback(child, OnChildGridPropertyChanged);
     }
 }
Пример #5
0
        public BinderDetails(DependencyObject owner)
        {
            this._store = ((IDependencyObjectStoreProvider)owner).Store;
            this._owner = owner;

            _store.RegisterPropertyChangedCallback(_store.DataContextProperty, Binder_DataContextChanged);
            _store.RegisterPropertyChangedCallback(_store.TemplatedParentProperty, Binder_TemplatedParentChanged);

            _props = DependencyProperty.GetPropertiesForType(owner.GetType());

            DependencyObjectExtensions
            .RegisterDisposablePropertyChangedCallback(_owner, (instance, p, e) => UpdateProperties());
        }