Exemplo n.º 1
0
        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();
                    }
                }
            });
        }
Exemplo n.º 2
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;
            });
        }
Exemplo n.º 3
0
 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);
             }
         }
     });
 }
Exemplo n.º 4
0
 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;
             }
         }
     });
 }
Exemplo 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);
                });
            }
Exemplo n.º 6
0
        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;
            }));
        }
Exemplo n.º 7
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);
                    }
                }
            });
        }
Exemplo n.º 8
0
        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();
                    }
                }
            });
        }
Exemplo n.º 9
0
        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;
            });
        }
Exemplo 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)
 {
 }
Exemplo n.º 15
0
 public virtual void DidRemoveToken(TITokenField tokenField, TIToken token)
 {
 }
Exemplo 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);
                    }
                }
            });
        }
Exemplo 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;
            });
        }
Exemplo n.º 18
0
 public virtual void DidAddToken(TITokenField tokenField, TIToken token)
 {
 }