Esempio n. 1
0
        private void RemoveCharactersAndReplaceWithMaskPrompt()
        {
            MaskFormat maskFormat = TextMaskFormat;

            // Set to include prompts and literals;
            TextMaskFormat = MaskFormat.IncludePromptAndLiterals;
            char[] newText = base.Text.ToCharArray();
            int    savePos = SelectionStart;

            // Clear the selected non-delimiter fields.
            for (int i = SelectionStart; i < SelectionStart + SelectionLength; i++)
            {
                if (posToMaskIndex.Length > 0)
                {
                    if (posToMaskIndex[i] >= 0)
                    {
                        newText[i] = PromptChar;
                    }
                }
                else
                {
                    newText[i] = ' ';
                }
            }

            // Handle MaskedTextBox quirk when the text has whitespace.
            Text            = StripSpaces(new String(newText));
            TextMaskFormat  = maskFormat;
            SelectionStart  = savePos;
            SelectionLength = 0;
        }
Esempio n. 2
0
        /// <summary>
        /// On leave, clear the mask, allowing the control
        /// to display the null display value text if the
        /// control is in the null state.
        /// </summary>
        protected override void OnLeave(EventArgs e)
        {
            // Save text mask format.
            MaskFormat maskFormat = TextMaskFormat;

            // Set to exclude all.
            TextMaskFormat = MaskFormat.ExcludePromptAndLiterals;

            // If the Text is an empty string, then replace with the null text display value.
            if (base.Text == String.Empty)
            {
                // The mask has to be cleared.
                Mask = String.Empty;

                // Set the textbox to display the null text display value.
                Text = nullTextDisplayValue;

                // Our control value is the null value.
                Value = nullValue;
            }
            else
            {
                // valid text, set our control value to the Text property value.
                Value = base.Text;
            }

            // Restore the text mask format.
            TextMaskFormat = maskFormat;

            base.OnLeave(e);
        }
        /// <summary>
        /// Constructor for the KryptonDataGridViewMaskedTextBoxCell cell type
        /// </summary>
        public KryptonDataGridViewMaskedTextBoxCell()
        {
            // Create a thread specific KryptonMaskedTextBox control used for the painting of the non-edited cells
            if (_paintingMaskedTextBox == null)
            {
                _paintingMaskedTextBox = new KryptonMaskedTextBox();
                _paintingMaskedTextBox.SetLayoutDisplayPadding(new Padding(0, 0, 1, -1));
                _paintingMaskedTextBox.StateCommon.Border.Width = 0;
                _paintingMaskedTextBox.StateCommon.Border.Draw  = InheritBool.False;
                _paintingMaskedTextBox.StateCommon.Back.Color1  = Color.Empty;
            }

            // Set the default values of the properties:
            _promptChar         = '_';
            _allowPromptAsInput = true;
            _asciiOnly          = false;
            _beepOnError        = false;
            _cutCopyMaskFormat  = MaskFormat.IncludeLiterals;
            _hidePromptOnLeave  = false;
            _hideSelection      = true;
            _insertKeyMode      = InsertKeyMode.Default;
            _mask         = string.Empty;
            _passwordChar = '\0';
            _rejectInputOnFirstFailure = false;
            _resetOnPrompt             = true;
            _resetOnSpace          = true;
            _skipLiterals          = true;
            _textMaskFormat        = MaskFormat.IncludeLiterals;
            _useSystemPasswordChar = false;
        }
 private void Init()
 {
     BackColor              = SystemColors.Window;
     cut_copy_mask_format   = MaskFormat.IncludeLiterals;
     insert_key_overwriting = false;
     UpdateVisibleText();
 }
Esempio n. 5
0
        public static string obterStringSemMascara(MaskedTextBox tb)
        {
            string     ret  = null;
            MaskFormat prev = tb.TextMaskFormat;

            tb.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals;
            ret = tb.Text;
            tb.TextMaskFormat = prev;

            return(ret);
        }
Esempio n. 6
0
        // ---- ENDERECO

        public static String obterConteudo(Control control)
        {
            String conteudo = control.Text;

            if (control is MaskedTextBox mtb)
            {
                MaskFormat oldFormat = mtb.TextMaskFormat;
                String     oldText   = mtb.Text;
                mtb.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals;
                conteudo           = mtb.Text;
                mtb.Text           = oldText;
                mtb.TextMaskFormat = oldFormat;
            }
            return(conteudo);
        }
Esempio n. 7
0
        string GetPureDateText()
        {
            // get pure text
            MaskFormat oldformat = this.maskedTextBox_date.TextMaskFormat;

            this.IngoreTextChange++;

            this.maskedTextBox_date.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals;
            string strPureText = this.maskedTextBox_date.Text;

            this.maskedTextBox_date.TextMaskFormat = oldformat;

            this.IngoreTextChange--;

            return(strPureText);
        }
Esempio n. 8
0
        /// <summary>
        /// Recupera o caractere indicador de formato para exibição.
        /// </summary>
        /// <param name="instance"></param>
        /// <returns></returns>
        public static char GetFormatChar(this MaskFormat instance)
        {
            switch (instance)
            {
            case MaskFormat.Digit:
                return('0');

            case MaskFormat.DigitOption:
                return('#');

            case MaskFormat.Ascii:
                return('L');

            case MaskFormat.AsciiOption:
                return('?');

            case MaskFormat.Unicode:
                return('&');

            case MaskFormat.UnicodeOption:
                return('C');

            case MaskFormat.AlphaNumeric:
                return('A');

            case MaskFormat.AlphaNumericOption:
                return('a');

            case MaskFormat.Fractional:
                return('.');

            case MaskFormat.Thousands:
                return(',');

            case MaskFormat.Lowercase:
                return('<');

            case MaskFormat.Uppercase:
                return('>');

            case MaskFormat.Escape:
                return('\\');
            }
            return(' ');
        }
Esempio n. 9
0
        private DateTime get_vData()
        {
            MaskFormat msk = this.TextMaskFormat;

            try
            {
                this.TextMaskFormat = MaskFormat.IncludePromptAndLiterals;
                return(Convert.ToDateTime(this.Text));
            }
            catch
            {
                return(new DateTime());
            }
            finally
            {
                this.TextMaskFormat = msk;
            }
        }
Esempio n. 10
0
        private void btnEntrar_Click(object sender, EventArgs e)
        {
            btnEntrar.Enabled = false;

            MaskFormat format = txtCpf.TextMaskFormat;

            String Cpf      = txtCpf.Text.Trim();
            String Password = txtPassword.Text;

            txtCpf.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals;

            if (!User.ValidateCpf(txtCpf.Text.Trim()))
            {
                MessageBox.Show("CPF inválido!");

                txtCpf.Focus();
            }
            else
            {
                User user = null;

                DAOUser dao = new DAOUser();

                user = dao.DoLogin(Cpf, Password);

                if (user is User)
                {
                    WalletPanel panel = new WalletPanel(this, user);

                    panel.Show();

                    this.Visible = false;
                }
                else
                {
                    MessageBox.Show("CPF ou senha inválidos.");
                }
            }

            txtCpf.TextMaskFormat = format;

            btnEntrar.Enabled = true;
        }
Esempio n. 11
0
 /// <summary>
 /// Indica se o formato é um caractere fixo.
 /// </summary>
 /// <param name="instance"></param>
 /// <returns></returns>
 public static bool IsSeparator(this MaskFormat instance)
 {
     return((instance == MaskFormat.Separator) || (instance == MaskFormat.Fractional) || (instance == MaskFormat.Thousands));
 }
		private void Init ()
		{
			BackColor = SystemColors.Window;
			cut_copy_mask_format = MaskFormat.IncludeLiterals;
			insert_key_overwriting = false;
			UpdateVisibleText ();
		}
Esempio n. 13
0
 /// <summary>
 /// Identifica se a posição tem preenchimento obrigatório.
 /// </summary>
 /// <param name="instance"></param>
 /// <returns></returns>
 public static bool IsRequired(this MaskFormat instance)
 {
     return((instance == MaskFormat.AlphaNumeric) || (instance == MaskFormat.Ascii) || (instance == MaskFormat.Digit) || (instance == MaskFormat.Unicode));
 }
Esempio n. 14
0
 /// <summary>
 /// Indicador de formato alfanumérico.
 /// </summary>
 /// <param name="instance"></param>
 /// <returns></returns>
 public static bool IsAlphaNumeric(this MaskFormat instance)
 {
     return((instance == MaskFormat.AlphaNumeric) || (instance == MaskFormat.AlphaNumericOption) || (instance == MaskFormat.Ascii) || (instance == MaskFormat.AsciiOption) || (instance == MaskFormat.Digit) || (instance == MaskFormat.DigitOption));
 }
 private void Initialize()
 {
     TextMaskFormat = MaskFormat.IncludeLiterals;
 }
Esempio n. 16
0
        private bool ValidateUpdForm()
        {
            if (cbbUpdFlag.SelectedValue == null)
            {
                MessageBox.Show("Informe a bandeira do cartão.");

                cbbUpdFlag.Focus();

                return(false);
            }

            MaskFormat number = txtUpdNumber.TextMaskFormat;
            MaskFormat cvc    = txtUpdCvc.TextMaskFormat;
            MaskFormat limit  = txtUpdLimit.TextMaskFormat;

            txtUpdNumber.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals;
            txtUpdCvc.TextMaskFormat    = MaskFormat.ExcludePromptAndLiterals;
            txtUpdLimit.TextMaskFormat  = MaskFormat.ExcludePromptAndLiterals;

            if (txtUpdNumber.Text.Trim().Equals(""))
            {
                MessageBox.Show("Informe o número do cartão.");

                txtUpdNumber.Focus();

                return(false);
            }

            if (txtUpdCvc.Text.Trim().Equals(""))
            {
                MessageBox.Show("Informe o CVC do cartão.");

                txtUpdCvc.Focus();

                return(false);
            }

            if (cbbUpdExpireMonth.SelectedItem == null)
            {
                MessageBox.Show("Selecione o mês de validade.");

                cbbUpdExpireMonth.Focus();

                return(false);
            }

            if (cbbUpdExpireYear.SelectedItem == null)
            {
                MessageBox.Show("Selecione o ano de validade.");

                cbbUpdExpireYear.Focus();

                return(false);
            }

            if (txtUpdLimit.Text.Trim().Equals(""))
            {
                MessageBox.Show("Informe o limite do cartão.");

                txtUpdLimit.Focus();

                return(false);
            }

            txtUpdNumber.TextMaskFormat = number;
            txtUpdCvc.TextMaskFormat    = cvc;
            txtUpdLimit.TextMaskFormat  = limit;

            return(true);
        }
Esempio n. 17
0
 /// <summary>
 /// Indica se o formato é de preenchimento opcional.
 /// </summary>
 /// <param name="instance"></param>
 /// <returns></returns>
 public static bool IsOptional(this MaskFormat instance)
 {
     return((instance == MaskFormat.AlphaNumericOption) || (instance == MaskFormat.AsciiOption) || (instance == MaskFormat.DigitOption) || (instance == MaskFormat.UnicodeOption));
 }
Esempio n. 18
0
 /// <summary>
 /// Indica a possibilidade da posição ser preenchida.
 /// </summary>
 /// <param name="instance"></param>
 /// <returns></returns>
 public static bool IsPositionToFill(this MaskFormat instance)
 {
     return(instance.IsOptional() || instance.IsRequired());
 }
Esempio n. 19
0
 /// <summary>
 /// Construtor parametrizado.
 /// </summary>
 /// <param name="value"></param>
 /// <param name="format"></param>
 /// <param name="itemCase"></param>
 public FormatToken(char value, MaskFormat format, MaskCase itemCase)
 {
     _value    = value;
     _format   = format;
     _itemCase = itemCase;
 }