Table of Contents

Class PatternMask

Namespace
MudBlazor
Assembly
MudBlazor.dll

A simple input mask consisting of characters.

public class PatternMask : BaseMask, IMask
Inheritance
PatternMask
Implements
Derived
Inherited Members
Extension Methods

Remarks

By default, the mask characters are: a (letter), 0 (digit), and * (letter or digit)

Constructors

PatternMask(string)

Creates a new mask.

public PatternMask(string mask)

Parameters

mask string

The characters which define the accepted input.

Remarks

By default, the mask characters are: a (letter), 0 (digit), and * (letter or digit)

Properties

CleanDelimiters

Removes delimiter characters from the text.

public bool CleanDelimiters { get; set; }

Property Value

bool

Remarks

Defaults to false.

Placeholder

The character used for characters which haven't yet been typed.

public char? Placeholder { get; set; }

Property Value

char?

Remarks

Defaults to null. For example: a placeholder of , mask of 000-000, and input of 1, will display 1__-__ as text.

Transformation

The function applied to all input characters, such as converting to upper-case, etc.

public Func<char, char> Transformation { get; set; }

Property Value

Func<char, char>

Remarks

Defaults to null. For example: a transformation of Char.ToUpper(c) would convert all characters to upper-case.

Methods

AlignAgainstMask(string, int)

Applies an input to the mask starting at the given offset.

protected virtual string AlignAgainstMask(string text, int maskOffset = 0)

Parameters

text string

The text to apply to the mask.

maskOffset int

Defaults to 0. The index of the mask to begin applying characters.

Returns

string

The text input with any delimiters and placeholders applied.

Backspace()

Triggers a backspace at the current cursor position.

public override void Backspace()

Remarks

Has the same effect as pressing the Backspace key.

Delete()

Triggers a delete at the current cursor position.

public override void Delete()

Remarks

Has the same effect as pressing the Delete key.

DeleteSelection(bool)

Deletes the selected characters.

protected override void DeleteSelection(bool align)

Parameters

align bool

When true, the text to the right of the selection will be shifted to the left.

FillWithPlaceholder(string)

Fills the rest of the text with Placeholder if it is set.

protected virtual string FillWithPlaceholder(string text)

Parameters

text string

The text to modify.

Returns

string

The text with appended placeholder characters.

GetCleanText()

The current text in the input, excluding delimiter or placeholder characters.

public override string GetCleanText()

Returns

string

Remarks

When CleanDelimiters is true, any undefined characters will be removed.
For example: for a mask of 0000 0000 0000 0000, the spaces would be removed if they were an undefined character.

InitInternals()

Initializes this mask's characters and delimiters.

protected override void InitInternals()

Insert(string)

Inserts text at the current cursor position.

public override void Insert(string input)

Parameters

input string

The characters to insert.

IsMatch(char, char)

Gets whether the specified character is a match for a mask character.

protected virtual bool IsMatch(char maskChar, char textChar)

Parameters

maskChar char

The mask character to compare.

textChar char

The character to compare against the mask character regular expression.

Returns

bool

When true, the character is a match for the mask character.

ModifyFinalText(string)

When overridden, applies final adjustments to the text.

protected virtual string ModifyFinalText(string text)

Parameters

text string

The final text to adjust.

Returns

string

The adjusted final text.

ModifyPartiallyAlignedMask(string, string, int, ref int, ref int, ref string)

protected virtual void ModifyPartiallyAlignedMask(string mask, string text, int maskOffset, ref int textIndex, ref int maskIndex, ref string alignedText)

Parameters

mask string
text string
maskOffset int
textIndex int
maskIndex int
alignedText string

UpdateFrom(IMask)

Copies the mask and mask characters from the specified mask.

public override void UpdateFrom(IMask other)

Parameters

other IMask

The mask to copy from.

UpdateText(string)

Overwrites the text and updates the cursor position.

protected override void UpdateText(string text)

Parameters

text string

The text to set.

See Also