コード例 #1
0
ファイル: TextEntry.cs プロジェクト: NView/NView.Controls
        /// <inheritdoc/>
        public void BindToNative(object nativeView, BindOptions options = BindOptions.None)
        {
            if (nativeView == null)
            {
                throw new ArgumentNullException("nativeView");
            }

            UnbindFromNative();

            textField = ViewHelpers.GetView <UIKit.UITextField> (nativeView);

            if (textField == null)
            {
                throw new InvalidOperationException("Cannot convert " + nativeView + " to UITextField");
            }

            if (options.HasFlag(BindOptions.PreserveNativeProperties))
            {
                text        = textField.Text;
                placeholder = textField.Placeholder;
                enabled     = textField.Enabled;
            }
            else
            {
                textField.Text        = text;
                textField.Placeholder = placeholder;
                textField.Enabled     = enabled;
            }

            textField.ValueChanged += TextField_ValueChanged;
        }
コード例 #2
0
ファイル: Switch.cs プロジェクト: NView/NView.Controls
        /// <inheritdoc/>
        public void BindToNative(object nativeView, BindOptions options = BindOptions.None)
        {
            if (nativeView == null)
            {
                throw new ArgumentNullException("nativeView");
            }

            UnbindFromNative();

            switchControl = ViewHelpers.GetView <UISwitch> (nativeView);

            if (switchControl == null)
            {
                throw new InvalidOperationException("Cannot convert " + nativeView + " to UISwitch");
            }

            if (options.HasFlag(BindOptions.PreserveNativeProperties))
            {
                isChecked = switchControl.On;
                enabled   = switchControl.Enabled;
            }
            else
            {
                switchControl.On      = isChecked;
                switchControl.Enabled = enabled;
            }

            switchControl.ValueChanged += SwitchControl_ValueChanged;
        }
コード例 #3
0
ファイル: TextEntry.cs プロジェクト: NView/NView.Controls
        /// <inheritdoc/>
        public void BindToNative(object nativeView, BindOptions options = BindOptions.None)
        {
            if (nativeView == null)
            {
                throw new ArgumentNullException("nativeView");
            }

            UnbindFromNative();

            editText = ViewHelpers.GetView <Android.Widget.EditText> (nativeView);

            if (options.HasFlag(BindOptions.PreserveNativeProperties))
            {
                text        = editText.Text;
                placeholder = editText.Hint;
                enabled     = editText.Enabled;
            }
            else
            {
                editText.Text    = text;
                editText.Hint    = placeholder;
                editText.Enabled = enabled;
            }

            editText.TextChanged += EditText_TextChanged;
        }
コード例 #4
0
        /// <inheritdoc/>
        public void BindToNative(object nativeView, BindOptions options = BindOptions.None)
        {
            if (nativeView == null)
            {
                throw new ArgumentNullException("nativeView");
            }

            UnbindFromNative();

            switchControl = ViewHelpers.GetView <NSButton> (nativeView);
            switchControl.SetButtonType(NSButtonType.Switch);
            switchControl.AllowsMixedState = false;

            if (options.HasFlag(BindOptions.PreserveNativeProperties))
            {
                isChecked = switchControl.State == NSCellStateValue.On;
                enabled   = switchControl.Enabled;
            }
            else
            {
                switchControl.State   = isChecked ? NSCellStateValue.On : NSCellStateValue.Off;
                switchControl.Enabled = enabled;
            }

            switchControl.Activated += SwitchControl_Activated;
        }
コード例 #5
0
ファイル: TextEntry.cs プロジェクト: NView/NView.Controls
        /// <inheritdoc/>
        public void BindToNative(object nativeView, BindOptions options = BindOptions.None)
        {
            if (nativeView == null)
            {
                throw new ArgumentNullException("nativeView");
            }

            UnbindFromNative();

            textField = ViewHelpers.GetView <NSTextField> (nativeView);

            if (options.HasFlag(BindOptions.PreserveNativeProperties))
            {
                text        = textField.StringValue;
                placeholder = textField.PlaceholderString;
                enabled     = textField.Enabled;
            }
            else
            {
                textField.StringValue       = text;
                textField.PlaceholderString = placeholder;
                textField.Enabled           = enabled;
            }

            textField.Changed += TextField_Changed;
        }
コード例 #6
0
        public IDisposable BindToNative(object nativeView)
        {
            var view = ViewHelpers.GetView <NativeGraphicView> (nativeView);

            view.GraphicView = this;
            return(new DisposeAction(() => {
                if (view.GraphicView == this)
                {
                    view.GraphicView = null;
                }
            }));
        }
コード例 #7
0
        /// <inheritdoc/>
        public void BindToNative(object nativeView, BindOptions options = BindOptions.None)
        {
            if (nativeView == null)
            {
                throw new ArgumentNullException("nativeView");
            }

            UnbindFromNative();

            this.nativeView = ViewHelpers.GetView <NativeView> (nativeView);

            SetStackConstraints();
        }
コード例 #8
0
ファイル: Label.cs プロジェクト: NView/NView.Controls
        /// <inheritdoc/>
        public void BindToNative(object nativeView, BindOptions options = BindOptions.None)
        {
            if (nativeView == null)
            {
                throw new ArgumentNullException("nativeView");
            }

            UnbindFromNative();

            label = ViewHelpers.GetView <UILabel> (nativeView);

            if (options.HasFlag(BindOptions.PreserveNativeProperties))
            {
                text = label.Text;
            }
            else
            {
                label.Text = text;
            }
        }
コード例 #9
0
        /// <inheritdoc/>
        public void BindToNative(object nativeView, BindOptions options = BindOptions.None)
        {
            if (nativeView == null)
            {
                throw new ArgumentNullException("nativeView");
            }

            UnbindFromNative();

            textField = ViewHelpers.GetView <NSTextField> (nativeView);

            if (options.HasFlag(BindOptions.PreserveNativeProperties))
            {
                text = textField.StringValue;
            }
            else
            {
                textField.StringValue = text;
            }
        }
コード例 #10
0
ファイル: Map.cs プロジェクト: NView/NView.Controls
        public void BindToNative(object native, BindOptions options = BindOptions.None)
        {
            UnbindFromNative();
            map = ViewHelpers.GetView <MKMapView> (native);

            singleTap = new UITapGestureRecognizer(HandleTap)
            {
                NumberOfTapsRequired = 1,
            };
            map.AddGestureRecognizer(singleTap);
            doubleTap = new UITapGestureRecognizer {
                NumberOfTapsRequired = 2,
            };
            map.AddGestureRecognizer(doubleTap);
            singleTap.RequireGestureRecognizerToFail(doubleTap);

            map.SetRegion(MKCoordinateRegion.FromDistance(
                              GetCoord(setRegionCoord), setRegionDistance, setRegionDistance),
                          false);
        }
コード例 #11
0
ファイル: Button.cs プロジェクト: NView/NView.Controls
        /// <inheritdoc/>
        public void BindToNative(object nativeView, BindOptions options = BindOptions.None)
        {
            if (nativeView == null)
            {
                throw new ArgumentNullException("nativeView");
            }

            UnbindFromNative();

            button = ViewHelpers.GetView <NSButton> (nativeView);

            if (options.HasFlag(BindOptions.PreserveNativeProperties))
            {
                enabled = button.Enabled;
                text    = button.Title;
            }
            else
            {
                button.Enabled = enabled;
                button.Title   = text;
            }

            button.Activated += Button_Activated;
        }
コード例 #12
0
ファイル: Switch.cs プロジェクト: NView/NView.Controls
        /// <inheritdoc/>
        public void BindToNative(object nativeView, BindOptions options = BindOptions.None)
        {
            if (nativeView == null)
            {
                throw new ArgumentNullException("nativeView");
            }

            UnbindFromNative();

            switchControl = ViewHelpers.GetView <Android.Widget.Switch> (nativeView);

            if (options.HasFlag(BindOptions.PreserveNativeProperties))
            {
                isChecked = switchControl.Checked;
                enabled   = switchControl.Enabled;
            }
            else
            {
                switchControl.Checked = isChecked;
                switchControl.Enabled = enabled;
            }

            switchControl.CheckedChange += SwitchControl_CheckedChange;
        }
コード例 #13
0
        /// <inheritdoc/>
        public void BindToNative(object nativeView, BindOptions options = BindOptions.None)
        {
            if (nativeView == null)
            {
                throw new ArgumentNullException("nativeView");
            }

            UnbindFromNative();

            button = ViewHelpers.GetView <UIButton> (nativeView);

            if (options.HasFlag(BindOptions.PreserveNativeProperties))
            {
                enabled = button.Enabled;
                text    = button.Title(UIControlState.Normal);
            }
            else
            {
                button.Enabled = enabled;
                button.SetTitle(text, UIControlState.Normal);
            }

            button.TouchUpInside += Button_TouchUpInside;
        }