Beispiel #1
0
        public void TokenTextFieldDeleteBackward(TokenTextField tokenTextField)
        {
            if (_canNotDeletedToken)
            {
                _canNotDeletedToken = false;
            }
            else
            {
                bool removeTokenButton = false;
                foreach (TokenButton tokenButton in _tokens)
                {
                    if (tokenButton._toggled)
                    {
                        RemoveTokenForTitle(tokenButton);
                        removeTokenButton = true;
                        break;
                    }
                }

                if (!removeTokenButton)
                {
                    // Highlight last token button
                    if (_tokens.Count > 0)
                    {
                        TokenButton tokenButtonHighlight = _tokens[_tokens.Count - 1];
                        if (tokenButtonHighlight != null)
                        {
                            tokenButtonHighlight.SetToggled(true);
                        }
                    }
                }
            }
        }
Beispiel #2
0
        bool CheckTokenButtonNeedRemove(TokenButton tokenButton, string title)
        {
            bool removeTokenButton = false;

            if ((tokenButton.Title(UIControlState.Normal) == title) && (tokenButton._toggled == true))
            {
                removeTokenButton = true;
            }
            return(removeTokenButton);
        }
Beispiel #3
0
        public void AddTokenWithTitle(string title, object representedObject)
        {
            string aTitle = title.Trim();

            if (aTitle.Length > 0)
            {
                TokenButton tokenButton = TokenWithString(aTitle, representedObject);
                _tokens.Add(tokenButton);
                Delegate.DidAddToken(this, aTitle, representedObject);
                SetNeedsLayout();
            }
        }
Beispiel #4
0
        void Toggle(object sender, EventArgs ea)
        {
            foreach (TokenButton aTokenButton in _tokens)
            {
                aTokenButton.SetToggled(false);
            }

            TokenButton tokenButton = (TokenButton)sender;

            tokenButton.SetToggled(true);
            _textField.BecomeFirstResponder();
        }
Beispiel #5
0
        TokenButton TokenWithString(string title, object representedObject)
        {
            TokenButton tokenButton = TokenButton.CreateTokenButton(title, representedObject, this);
            CGRect      frame       = tokenButton.Frame;

            if (frame.Width > Frame.Width)
            {
                frame.Width = Frame.Width - (WIDTH_PADDING * 2);
            }
            tokenButton.Frame          = frame;
            tokenButton.TouchUpInside += Toggle;

            return(tokenButton);
        }
Beispiel #6
0
        public void RemoveTokenForTitle(TokenButton tokenButtonToRemove)
        {
            if (tokenButtonToRemove != null)
            {
                if (tokenButtonToRemove.IsFirstResponder)
                {
                    _textField.BecomeFirstResponder();
                }
                tokenButtonToRemove.RemoveFromSuperview();
                _tokens.Remove(tokenButtonToRemove);

                string tokenName = tokenButtonToRemove.Title(UIControlState.Normal);
                // Delegate
                Delegate.DidRemoveToken(this, tokenName, tokenButtonToRemove._representedObject);
            }
        }
Beispiel #7
0
        public static TokenButton CreateTokenButton(string title, object representedObject, TokenField parentField)
        {
            TokenButton tokenButton = new TokenButton(UIButtonType.Custom);

            tokenButton.SetTitleColor(UIColor.Blue, UIControlState.Normal);
            tokenButton.BackgroundColor = UIColor.White;
            tokenButton.SetTitle(title, UIControlState.Normal);
            tokenButton.SizeToFit();

            CGRect frame = tokenButton.Frame;

            frame.Width      += 20;
            frame.Height      = TokenField.DEFAULT_HEIGHT;
            tokenButton.Frame = frame;

            tokenButton.Layer.MasksToBounds = true;
            tokenButton.Layer.CornerRadius  = frame.Height / 2;

            tokenButton._tokenField        = parentField;
            tokenButton._representedObject = representedObject;

            return(tokenButton);
        }