Exemple #1
0
        public override UITableViewCell GetCell(UITableView tv)
        {
            if (_switch == null)
            {
                _switch = new UISwitch
                {
                    BackgroundColor = UIColor.Clear,
                    Tag             = 1,
                    On = Value
                };
                _switch.AddTarget(delegate
                {
                    Value = _switch.On;
                }, UIControlEvent.ValueChanged);
            }
            else
            {
                _switch.On = Value;
            }

            var cell = tv.DequeueReusableCell("boolean_element");

            if (cell == null)
            {
                cell = new UITableViewCell(UITableViewCellStyle.Default, "boolean_element");
                cell.SelectionStyle = UITableViewCellSelectionStyle.None;
            }

            cell.BackgroundColor     = StyledStringElement.BgColor;
            cell.TextLabel.Font      = StyledStringElement.DefaultTitleFont.WithSize(StyledStringElement.DefaultTitleFont.PointSize);
            cell.TextLabel.TextColor = StyledStringElement.DefaultTitleColor;
            cell.TextLabel.Text      = Caption;
            cell.AccessoryView       = _switch;
            return(cell);
        }
		public override UITableViewCell GetCell (UITableView tv)
		{
			if (sw == null){
				sw = new UISwitch (){
					BackgroundColor = UIColor.Clear,
					Tag = 1,
					On = Value
				};
				sw.AddTarget (delegate {
					Value = sw.On;
				}, UIControlEvent.ValueChanged);
			} else
				sw.On = Value;
			
			var cell = tv.DequeueReusableCell (CellKey);
			if (cell == null){
				cell = new UITableViewCell (UITableViewCellStyle.Default, CellKey);
				cell.SelectionStyle = UITableViewCellSelectionStyle.None;
			} else
				RemoveTag (cell, 1);
		
			cell.TextLabel.Text = Caption;
			cell.AccessoryView = sw;

			return cell;
		}
        public override UITableViewCell GetCell(UITableView tv)
        {
            if (_switch == null)
            {
                _switch = new UISwitch
                {
                    BackgroundColor = UIColor.Clear,
                    Tag = 1,
                    On = Value
                };
                _switch.AddTarget(delegate
                {
                    Value = _switch.On;
                }, UIControlEvent.ValueChanged);
            }
            else
            {
                _switch.On = Value;
            }

            var cell = tv.DequeueReusableCell ("boolean_element");
            if (cell == null){
                cell = new UITableViewCell (UITableViewCellStyle.Default, "boolean_element");
                cell.SelectionStyle = UITableViewCellSelectionStyle.None;
            }

            cell.BackgroundColor = StringElement.BgColor;
            cell.TextLabel.Font = StringElement.DefaultTitleFont.WithSize(StringElement.DefaultTitleFont.PointSize);
            cell.TextLabel.TextColor = StringElement.DefaultTitleColor;
            cell.TextLabel.Text = Caption;
            cell.AccessoryView = _switch;
            return cell;
        }
        protected override UITableViewCell GetCellImpl(UITableView tv)
        {
            if (_switch == null)
            {
                _switch = new UISwitch
                {
                    BackgroundColor = UIColor.Clear,
                    Tag             = 1,
                    On = Value
                };
                _switch.AddTarget(delegate { base.OnUserValueChanged(_switch.On); }, UIControlEvent.ValueChanged);
            }
            else
            {
                _switch.On = Value;
            }

            var cell = tv.DequeueReusableCell(CellKey);

            if (cell == null)
            {
                cell = new UITableViewCell(UITableViewCellStyle.Default, CellKey);
                cell.SelectionStyle = UITableViewCellSelectionStyle.None;
            }
            else
            {
                RemoveTag(cell, 1);
            }

            cell.TextLabel.Text = Caption;
            cell.AccessoryView  = _switch;

            return(cell);
        }
		private void prepareCell(){
			_switch = new UISwitch (){
				BackgroundColor = UIColor.Clear
			};
			_switch.AddTarget (delegate {
				_element.Value = _switch.On;
			}, UIControlEvent.ValueChanged);
			
			AccessoryView = _switch;
		}
//		public BooleanElement(RectangleF frame) : this("")
//		{
//			Frame = frame;
//		}
		
		public override void InitializeContent()
		{
			if (Switch == null)
			{
				Switch = new UISwitch { BackgroundColor = UIColor.Clear, Tag = 1 };
				
				Switch.AddTarget(delegate { DataBinding.UpdateDataContext(); }, UIControlEvent.ValueChanged);
			}
			
			Cell.AccessoryView = Switch;
		}
Exemple #7
0
        private void prepareCell()
        {
            _switch = new UISwitch()
            {
                BackgroundColor = UIColor.Clear
            };
            _switch.AddTarget(delegate {
                _element.Value = _switch.On;
            }, UIControlEvent.ValueChanged);

            AccessoryView = _switch;
        }
Exemple #8
0
        public override void InitializeContent()
        {
            if (Switch == null)
            {
                Switch = new UISwitch {
                    BackgroundColor = UIColor.Clear, Tag = 1
                };

                Switch.AddTarget(delegate { DataContextProperty.Update(); }, UIControlEvent.ValueChanged);
            }

            Cell.AccessoryView = Switch;
        }
		public override void InitializeCell(UITableView tableView)
		{
			RemoveTag(1);
			if (Switch == null)
			{
				Switch = new UISwitch { BackgroundColor = UIColor.Clear, Tag = 1, On = Value };
				Switch.AddTarget(delegate
				{
					Value = Switch.On;
				}, UIControlEvent.ValueChanged);
			}

			Cell.TextLabel.Text = Caption;
			Cell.AccessoryView = Switch;
		}
        public override void InitializeCell(UITableView tableView)
        {
            RemoveTag(1);
            if (Switch == null)
            {
                Switch = new UISwitch {
                    BackgroundColor = UIColor.Clear, Tag = 1, On = Value
                };
                Switch.AddTarget(delegate
                {
                    Value = Switch.On;
                }, UIControlEvent.ValueChanged);
            }

            Cell.TextLabel.Text = Caption;
            Cell.AccessoryView  = Switch;
        }
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            var drawLabelsSwitch = new UISwitch(new CGRect(View.Frame.Size.Width - 180, 20, 0, 0));

            drawLabelsSwitch.On = pieSeries.DrawLabels;
            drawLabelsSwitch.AddTarget((sender, e) =>
            {
                pieSeries.DrawLabels = (sender as UISwitch).On;
                Surface.InvalidateElement();
            }, UIControlEvent.ValueChanged);

            var drawLabelsLabel = new UILabel(new CGRect(View.Frame.Size.Width - 120, 20, 110, 30));

            drawLabelsLabel.Text      = "Draw Labels";
            drawLabelsLabel.TextColor = UIColor.White;

            Surface.AddSubview(drawLabelsLabel);
            Surface.AddSubview(drawLabelsSwitch);
        }
Exemple #12
0
        public MyListViewCell(NSString cellId) : base(UITableViewCellStyle.Default, cellId)
        {
            SelectionStyle = UITableViewCellSelectionStyle.Gray;


            switchBtn = new UISwitch();
            switchBtn.AddTarget((sender, args) =>
            {
                UISwitch mySwitch = sender as UISwitch;
                RefreshEvent(this, mySwitch.On);
            }, UIControlEvent.ValueChanged);


            switchBtn.TranslatesAutoresizingMaskIntoConstraints = false;

            ContentView.Add(switchBtn);

            this.ContentView.AddConstraint(NSLayoutConstraint.Create(switchBtn, NSLayoutAttribute.Left, NSLayoutRelation.Equal, this.ContentView, NSLayoutAttribute.Left, 1, 0));
            this.ContentView.AddConstraint(NSLayoutConstraint.Create(switchBtn, NSLayoutAttribute.Right, NSLayoutRelation.Equal, this.ContentView, NSLayoutAttribute.Right, 1, 0));
            this.ContentView.AddConstraint(NSLayoutConstraint.Create(switchBtn, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this.ContentView, NSLayoutAttribute.Top, 1, 0));
            this.ContentView.AddConstraint(NSLayoutConstraint.Create(switchBtn, NSLayoutAttribute.Bottom, NSLayoutRelation.GreaterThanOrEqual, this.ContentView, NSLayoutAttribute.Bottom, 1, 0));
        }
        protected override UITableViewCell GetCellImpl(UITableView tv)
        {
            if (_switch == null)
            {
                _switch = CreateSwitch();
                _switch.AddTarget(delegate { base.OnUserValueChanged(_switch.On); }, UIControlEvent.ValueChanged);
            }
            else
            {
                _switch.On = Value;
            }

            var cell = tv.DequeueReusableCell(CellKey);

            if (cell == null)
            {
                cell = new UITableViewCell(UITableViewCellStyle.Default, CellKey);
                cell.SelectionStyle = UITableViewCellSelectionStyle.None;
            }
            else
            {
                cell.AccessoryView = null;
            }

            if (_switch.Superview != null)
            {
                var oldCell = _switch.Superview as UITableViewCell;
                if (oldCell != null)
                {
                    oldCell.AccessoryView = null;
                }
            }

            cell.TextLabel.Text = Caption;
            cell.AccessoryView  = _switch;

            return(cell);
        }
Exemple #14
0
        public override UITableViewCell GetCell(UITableView tv)
        {
            if (sw == null){
                sw = new UISwitch (new RectangleF (198, 12, 94, 27)){
                    BackgroundColor = UIColor.Clear,
                    Tag = 1,
                    On = Value
                };
                sw.AddTarget (delegate {
                    Value = sw.On;
                }, UIControlEvent.ValueChanged);
            }

            var cell = tv.DequeueReusableCell (bkey);
            if (cell == null){
                cell = new UITableViewCell (UITableViewCellStyle.Default, bkey);
                cell.SelectionStyle = UITableViewCellSelectionStyle.None;
            } else
                RemoveTag (cell, 1);

            cell.TextLabel.Text = Caption;
            cell.ContentView.AddSubview (sw);

            return cell;
        }
		public override UITableViewCell GetCell (UITableView tv)
		{
			// screen right edge to switch right edge (aligns with accessory) switch is for iPad / iPhone
			int rightPadding = tv.Frame.Width <= 480 ? 30 : 100;
			
			if (sw == null) {
				sw = new UISwitch (new RectangleF (198, 12, 94, 27)) {
					BackgroundColor = UIColor.Clear,
					Tag = 1,
					On = Value
				};
				sw.AddTarget (delegate {
					Value = sw.On;
				}, UIControlEvent.ValueChanged);
			}
			
			var cell = tv.DequeueReusableCell (bkey);
			if (cell == null) {
				cell = new UITableViewCell (UITableViewCellStyle.Default, bkey);
				cell.SelectionStyle = UITableViewCellSelectionStyle.None;
			} else
				RemoveTag (cell, 1);
		
			cell.TextLabel.Text = Caption;
			
			var switchLeft = tv.Frame.Width - sw.Frame.Width - rightPadding;
			var switchTop = (cell.ContentView.Frame.Height - sw.Frame.Height) / 2;
			sw.Frame = new RectangleF (switchLeft, switchTop, sw.Frame.Width, sw.Frame.Height);
			
			cell.ContentView.AddSubview (sw);

			return cell;
		}
Exemple #16
0
        public override UITableViewCell GetCell(UITableView tv)
        {
            if (sw == null) {
                sw = new UISwitch () {
                    BackgroundColor = UIColor.Clear,
                    Tag = 1,
                    On = Value
                };
                sw.AddTarget (SwitchChanged, UIControlEvent.ValueChanged);
            } else
                sw.On = Value;

            var cell = tv.DequeueReusableCell (bkey) ?? new UITableViewCell (UITableViewCellStyle.Subtitle, bkey) {
                SelectionStyle = UITableViewCellSelectionStyle.None
            };

            cell.TextLabel.Text = Caption;
            cell.TextLabel.TextColor = TextColor;
            cell.AccessoryView = sw;

            return cell;
        }