public virtual void AddToken(TIToken token)
        {
            Wrap.Method("AddToken.Object", delegate()
            {
                lock (_tokenSyncRoot)
                {
                    bool shouldAdd = true;
                    if (this.Delegate != null)
                    {
                        shouldAdd = this.Delegate.WillAddToken(this, token);
                    }
                    if (shouldAdd)
                    {
                        shouldAdd = this.WillAddToken.Raise(this, token);
                    }

                    if (shouldAdd)
                    {
                        token.TintColor = this.TokenTintColor;
                        token.MaxWidth  = this.MaxTokenWidth;
                        this.BecomeFirstResponder();

                        token.TouchDown     -= Token_TouchDown;     //safety
                        token.TouchUpInside -= Token_TouchUpInside; //safety

                        token.TouchDown     += Token_TouchDown;
                        token.TouchUpInside += Token_TouchUpInside;

                        this.AddSubview(token);

                        if (!this.Tokens.Contains(token))
                        {
                            this.Tokens.Add(token);

                            if (this.Delegate != null)
                            {
                                this.Delegate.DidAddToken(this, token);
                            }
                            this.DidAddToken.Raise(this, token);

                            if (_placeHolderLabel != null)
                            {
                                _placeHolderLabel.Hidden = true;
                            }
                        }

                        this.SetResultsModeEnabled(false);
                        this.DeselectSelectedToken();
                    }
                }
            });
        }
        public virtual void SelectToken(TIToken token)
        {
            Wrap.Method("SelectToken", delegate()
            {
                this.DeselectSelectedToken();

                this.SelectedToken          = token;
                this.SelectedToken.Selected = true;

                this.BecomeFirstResponder();
                this.Text = kTextHidden;
            });
        }
 protected virtual void Token_TouchUpInside(object sender, EventArgs e)
 {
     Wrap.Method("Token_TouchUpInside", delegate()
     {
         TIToken token = sender as TIToken;
         if (token != null)
         {
             if (this.Editable)
             {
                 this.SelectToken(token);
             }
         }
     });
 }
 protected virtual void Token_TouchDown(object sender, EventArgs e)
 {
     Wrap.Method("Token_TouchDown", delegate()
     {
         TIToken token = sender as TIToken;
         if (token != null)
         {
             if (this.SelectedToken != null && this.SelectedToken != token)
             {
                 this.SelectedToken.Selected = false;
                 this.SelectedToken          = null;
             }
         }
     });
 }
Esempio n. 5
0
            public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
            {
                Wrap.Method("RowSelected", delegate()
                {
                    object representedObject = this.Owner.ResultsArray[indexPath.Row];
                    TIToken token            = new TIToken()
                    {
                        Title             = this.Owner.TokenField.Delegate.DisplayStringForRepresentedObject(this.Owner.TokenField, representedObject),
                        RepresentedObject = representedObject
                    };
                    this.Owner.TokenField.AddToken(token);

                    tableView.DeselectRow(indexPath, true);
                    this.Owner.SetSearchResultsVisible(false);
                });
            }
        public virtual TIToken AddToken(string title, object representedObject = null)
        {
            return(Wrap.Function("AddToken.Text", delegate()
            {
                if (!string.IsNullOrEmpty(title))
                {
                    TIToken token = new TIToken()
                    {
                        Title = title,
                        RepresentedObject = representedObject,
                        Font = this.Font
                    };
                    this.AddToken(token);
                    return token;
                }

                return null;
            }));
        }
        public virtual void RemoveToken(TIToken token)
        {
            Wrap.Method("RemoveToken", delegate()
            {
                if (token == null)
                {
                    return;
                }
                lock (_tokenSyncRoot)
                {
                    if (token == this.SelectedToken)
                    {
                        this.DeselectSelectedToken();
                    }

                    bool shouldRemove = true;
                    if (this.Delegate != null)
                    {
                        shouldRemove = this.Delegate.WillRemoveToken(this, token);
                    }
                    if (this.Delegate != null)
                    {
                        shouldRemove = this.WillRemoveToken.Raise(this, token);
                    }
                    if (shouldRemove)
                    {
                        token.RemoveFromSuperview();
                        this.Tokens.Remove(token);
                        token.TouchDown     -= Token_TouchDown;
                        token.TouchUpInside -= Token_TouchUpInside;

                        if (this.Delegate != null)
                        {
                            this.Delegate.DidRemoveToken(this, token);
                        }
                        this.DidRemoveToken.Raise(this, token);

                        this.SetResultsModeEnabled(this.ForcePickSearchResult);
                    }
                }
            });
        }
        public virtual void AddToken(TIToken token)
        {
            Wrap.Method("AddToken.Object", delegate()
            {
                lock(_tokenSyncRoot)
                {
                    bool shouldAdd = true;
                    if (this.Delegate != null)
                    {
                        shouldAdd = this.Delegate.WillAddToken(this, token);
                    }
                    if (shouldAdd)
                    {
                        shouldAdd = this.WillAddToken.Raise(this, token);
                    }

                    if (shouldAdd)
                    {
                        token.TintColor = this.TokenTintColor;
                        token.MaxWidth = this.MaxTokenWidth;
                        token.TokenRadius = this.TokenRadius;
                        //this.BecomeFirstResponder();

                        token.TouchDown -= Token_TouchDown; //safety
                        token.TouchUpInside -= Token_TouchUpInside; //safety

                        token.TouchDown += Token_TouchDown;
                        token.TouchUpInside += Token_TouchUpInside;

                        this.AddSubview(token);

                        if (!this.Tokens.Contains(token))
                        {
                            this.Tokens.Add(token);

                            if (this.Delegate != null)
                            {
                                this.Delegate.DidAddToken(this, token);
                            }
                            this.DidAddToken.Raise(this, token);

                            if (_placeHolderLabel != null)
                            {
                                _placeHolderLabel.Hidden = true;
                            }
                        }

                        this.SetResultsModeEnabled(false);
                        this.DeselectSelectedToken();
                    }
                }
            });
        }
        public virtual TIToken AddToken(string title, object representedObject = null)
        {
            return Wrap.Function("AddToken.Text", delegate()
            {
                if (!string.IsNullOrEmpty(title))
                {
                    TIToken token = new TIToken()
                    {
                        Title = title,
                        RepresentedObject = representedObject,
                        Font = this.Font
                    };
                    this.AddToken(token);
                    return token;
                }

                return null;
            });
        }
Esempio n. 10
0
 public virtual bool WillRemoveToken(TITokenField tokenField, TIToken token)
 {
     return(true);
 }
            public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
            {
                Wrap.Method("RowSelected", delegate()
                {
                    object representedObject = this.Owner.ResultsArray[indexPath.Row];
                    TIToken token = new TIToken()
                    {
                        Title = this.Owner.TokenField.Delegate.DisplayStringForRepresentedObject(this.Owner.TokenField, representedObject),
                        RepresentedObject = representedObject
                    };
                    this.Owner.TokenField.AddToken(token);

                    tableView.DeselectRow(indexPath, true);
                    this.Owner.SetSearchResultsVisible(false);
                });
            }
 public virtual void DidRemoveToken(TITokenField tokenField, TIToken token)
 {
 }
 public virtual bool WillRemoveToken(TITokenField tokenField, TIToken token)
 {
     return true;
 }
 public virtual void DidAddToken(TITokenField tokenField, TIToken token)
 {
 }
Esempio n. 15
0
 public virtual void DidRemoveToken(TITokenField tokenField, TIToken token)
 {
 }
Esempio n. 16
0
        public virtual void RemoveToken(TIToken token)
        {
            Wrap.Method("RemoveToken", delegate()
            {
                if(token == null) { return; }
                lock(_tokenSyncRoot)
                {
                    if (token == this.SelectedToken)
                    {
                        this.DeselectSelectedToken();
                    }

                    bool shouldRemove = true;
                    if (this.Delegate != null)
                    {
                        shouldRemove = this.Delegate.WillRemoveToken(this, token);
                    }
                    if (this.Delegate != null)
                    {
                        shouldRemove = this.WillRemoveToken.Raise(this, token);
                    }
                    if (shouldRemove)
                    {
                        token.RemoveFromSuperview();
                        this.Tokens.Remove(token);
                        token.TouchDown -= Token_TouchDown;
                        token.TouchUpInside -= Token_TouchUpInside;

                        if (this.Delegate != null)
                        {
                            this.Delegate.DidRemoveToken(this, token);
                        }
                        this.DidRemoveToken.Raise(this, token);

                        this.SetResultsModeEnabled(this.ForcePickSearchResult);
                    }
                }
            });
        }
Esempio n. 17
0
        public virtual void SelectToken(TIToken token)
        {
            Wrap.Method("SelectToken", delegate()
            {
                this.DeselectSelectedToken();

                this.SelectedToken = token;
                this.SelectedToken.Selected = true;

                this.BecomeFirstResponder();
                this.Text = kTextHidden;
            });
        }
Esempio n. 18
0
 public virtual void DidAddToken(TITokenField tokenField, TIToken token)
 {
 }