public void Bind(Rule contentItem, UIAlertRulesTableView parent)
        {
            _parent = parent;
            lblRuleName.Text = contentItem.RuleName;
            lblMobile.Text = "Send Mobile: " + contentItem.SendMobile;
            lblSearchTerm.Text = contentItem.SearchTerm;
            lblSendDash.Text = "Send Dash:" + contentItem.SendDashboard;
            lblSendEmail.Text = "Send Email: " + contentItem.SendEmail;
            lblSendText.Text = "Send Text: " + contentItem.SendText;

            btnDelete.SetImage (UIImage.FromFile ("images/icons/delete.png"), UIControlState.Normal);
            btnDelete.TouchUpInside += (object sender, EventArgs e) => {
                _parent.DeleteItem(_contentItem);
            };

            _contentItem = contentItem;
        }
 public int RemoveItem(Rule tweet)
 {
     var index = _items.FindIndex((t)=>{return t.Id == tweet.Id;});
     _items.RemoveAt(index);
     return index;
 }
 private void OnRowClicked(Rule item)
 {
     if(RowClicked!=null)
         RowClicked(this, new RowClickedEventArgs<Rule>(){ Item = item});
 }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            scrollView.BackgroundColor = UIColor.White;

            this.NavigationItem.RightBarButtonItem.Clicked += (object sender, EventArgs e) => {

                if (!ValidateForm ()) {
                    var rule = new Rule () {
                        Email = txtEmail.Text,
                        RuleName = txtRuleName.Text,
                        SearchTerm = txtSearchTerm.Text,
                        SendDashboard = switchDashboard.On,
                        SendEmail = switchEmail.On,
                        SendMobile = switchAppAlert.On,
                        SendText = switchSMS.On,
                        Sms = txtCellNumber.Text,
                        Threashold = (int)sliderCount.Value
                    };
                    // save and upload
                    Helper.Default.ShowHud ("updating ...");
                    Api.Default.AddAlertRule (rule, (result) => {
                        this.InvokeOnMainThread (() => {
                            if (result.Result == "ok") {
                                if (Done != null)
                                    Done ();
                                this.DismissViewControllerAsync (true);
                                Helper.Default.HideHud();
                            } else {
                                Helper.Default.HideHud ("Could not add, try again.", AlertView.MBAlertViewHUDType.ExclamationMark);
                            }
                        });
                    });
                }
            };

            this.NavigationItem.LeftBarButtonItem.Clicked += (object sender, EventArgs e) => {
                if(Cancel!=null)
                    Cancel();

                this.DismissViewControllerAsync(true);
            };

            sliderCount.ValueChanged+= (object sender, EventArgs e) => {
                lblCount.Text = ((int)sliderCount.Value).ToString();
            };

            switchEmail.ValueChanged += (object sender, EventArgs e) =>  {
                txtEmail.Enabled = switchEmail.On;
            };

            switchSMS.ValueChanged += (object sender, EventArgs e) =>  {
                txtCellNumber.Enabled = switchSMS.On;
            };

            var tap = new UITapGestureRecognizer (() => {
                this.View.EndEditing(true);
            });
            scrollView.AddGestureRecognizer (tap);

            RegisterForKeyboardNotifications();
        }