Skip to main content

SegmentedModal class

Namespace: Arlecchino.Modals.Setting · Assembly: Arlecchino

A value edited as a row of fixed-width number segments, the way dates and times are. Digits are collected per segment and only applied once the segment fills up, so a half-typed segment never produces a nonsensical intermediate value.

public abstract class SegmentedModal : Modal

Inherits from Modal
Derived types DateModal, TimeModal

Constructors

MemberSummary
SegmentedModal()

Properties

MemberSummary
SegmentWhich segment the arrows and digits act on.
SegmentCountHow many segments the value is made of.
SeparatorWhat is drawn between the segments.

Methods

MemberSummary
Add(int)Steps the active segment, carrying into the neighbors as that value type requires.
ApplyTypedValue(int, int)Stores what was typed into a segment, keeping the whole value legal.
ClearTypedDigits()Throws away a partly typed segment, restoring what was stored.
CommitTypedDigits()Applies a partly typed segment, padding it with leading zeroes. Called before anything that reads the value, so confirming the dialog keeps what was typed.
EditedSegmentTexts()What to draw: the stored value, but with half-typed digits shown in place of the segment being edited so typing is visible before it takes effect.
Handle(ModalFrame, KeyPress)
MoveSegment(int)Moves between segments, stopping at the ends. Anything half-typed is applied first.
SegmentLength(int)How many digits a segment holds, which is also when typing moves on to the next one.
SegmentTexts()The stored value as one padded string per segment.
Submit()Hands the value over to whoever asked for it, once the segments have been committed.
TypeDigit(char)Adds a digit to the active segment. A full segment is applied and left behind, and typing past it starts the next one over rather than being dropped.

Constructors in detail

SegmentedModal()

Obsolete

Constructors of types with required members are not supported in this version of your compiler.

public SegmentedModal();

Properties in detail

Segment

public int Segment { get; }

Which segment the arrows and digits act on.

Type int

SegmentCount

public abstract int SegmentCount { get; }

How many segments the value is made of.

Type int

Separator

public abstract string Separator { get; }

What is drawn between the segments.

Type string

Methods in detail

Add(int)

public abstract void Add(int delta);

Steps the active segment, carrying into the neighbors as that value type requires.

Parameters

NameTypeDescription
deltaintHow far to step; negative goes down.

ApplyTypedValue(int, int)

public abstract void ApplyTypedValue(int segment, int value);

Stores what was typed into a segment, keeping the whole value legal.

Parameters

NameTypeDescription
segmentintIndex of the segment that was typed into.
valueintThe digits, parsed.

ClearTypedDigits()

public void ClearTypedDigits();

Throws away a partly typed segment, restoring what was stored.

CommitTypedDigits()

public void CommitTypedDigits();

Applies a partly typed segment, padding it with leading zeroes. Called before anything that reads the value, so confirming the dialog keeps what was typed.

EditedSegmentTexts()

public string[] EditedSegmentTexts();

What to draw: the stored value, but with half-typed digits shown in place of the segment being edited so typing is visible before it takes effect.

Returns string[] — One string per segment.

Handle(ModalFrame, KeyPress)

public override void Handle(ModalFrame frame, KeyPress key);

Parameters

NameTypeDescription
frameModalFrame
keyKeyPress

MoveSegment(int)

public void MoveSegment(int delta);

Moves between segments, stopping at the ends. Anything half-typed is applied first.

Parameters

NameTypeDescription
deltaintHow far to move; negative goes left.

SegmentLength(int)

public abstract int SegmentLength(int segment);

How many digits a segment holds, which is also when typing moves on to the next one.

Parameters

NameTypeDescription
segmentintIndex of the segment.

Returns int — Its digit count.

SegmentTexts()

public abstract string[] SegmentTexts();

The stored value as one padded string per segment.

Returns string[] — A fresh array the caller may modify.

Submit()

public abstract void Submit();

Hands the value over to whoever asked for it, once the segments have been committed.

TypeDigit(char)

public void TypeDigit(char digit);

Adds a digit to the active segment. A full segment is applied and left behind, and typing past it starts the next one over rather than being dropped.

Parameters

NameTypeDescription
digitcharThe digit that was typed.