Download Demonstration Question? Contact Us
FlexToolBarTextBox
class
It
derived from FlexToolBarBaseButton. This tool item allows the user to enter text.
Examples
The
following example shows how to use the CommandID attribute of a tool
item.
public partial class RenameTextBox : FlexToolBarTextBox
{
public RenameTextBox()
: base()
{
//
******* //
CommandID =
RENAME_COMMAND_ID;
}
}
class RenameCommand : LinsUICommand
{
public RenameCommand(long nCommandID, object data) : base(nCommandID, data)
{
//
Assign a help file to this command. The help file must be stored at the
location
//
specified by FlexUISettings.DefaultHelpFilePath,
HelpFile = "Rename.rtf";
}
[CommandEventAttribute(COMMAND_EVENT.KEY_UP)]
protected void KeyUp(object
sender, EventArgs e)
{
if (!(e is KeyEventArgs))
{
return;
}
KeyEventArgs keyEvent = e as KeyEventArgs;
if (keyEvent.Key == Key.Return)
{
//
******* //
}
}
[CommandEventAttribute(COMMAND_EVENT.TEXT_CHANGED)]
protected void TextChanged(object sender, EventArgs e)
{
}
[CommandEventAttribute(COMMAND_EVENT.TEXT_INPUT)]
protected void TextInput(object sender, EventArgs e)
{
}
[CommandEventAttribute(COMMAND_EVENT.HELPBUTTON_CLICK)]
protected void HelpClick(object sender, EventArgs e)
{
//
******* //
}
public override bool
CanExecute(object parameter)
{
return true;
}
}
public partial class MainWindow : LinsMDIWindow
{
public MainWindow()
{
InitializeComponent();
CreateCommands();
}
private void CreateCommands()
{
//
Create Rename command instance
LinsUICommand command = new RenameCommand(RENAME_COMMAND_ID, null);
}
}
§
Constructors
1)
public
FlexToolBarTextBox()
Remarks
Initialize
a new instance of FlexToolBarTextBox.
§
Members
1)
public
bool
AcceptsTab { get; set; }
Remarks
Gets
or sets a value determining how TAB keys are handled for multiline
configurations.
2)
public
virtual ToolBarItemDisplayStyle Appearence { get; set;
}
Remarks
Gets
or sets the appearance of the tool item.
The default is ToolBarItemDisplayStyle.ImageAndText.
It can be one of the following values,
§
None:
Assigned
Text and assigned Icon are to be rendered.
§
Text:
Only
Text is to be rendered.
§
Image:
Only
Icon is to be rendered.
§
ImageAndText:
Both
Text and Icon are to be rendered.
3)
public
bool
AutoWordSelection { get; set; }
Remarks
Gets
or sets a value indicating whether automatic word selection is
enabled.
4)
public virtual Rect Bounds { get; }
Remarks
Retrieve
both the size and the location of the tool item, in pixels, relative to its
parent.
5)
public virtual Rect BoundsAtMDIFrame { get; }
Remarks
Retrieve
both the size and the location of the tool item, in pixels, relative to MDI
frame.
6)
public
virtual bool Checked { get; set; }
Remarks
Gets
or sets the check status of the tool item.
The default is false.
7)
public
long CommandID
{ get; set; }
Remarks
If
this attribute is assigned, then this tool item will be associated to the
correspondent command with the same CommandID. See the above example for
creating a command.
8)
public
string Content
{ get; set; }
Remarks
Gets
or sets the text associated with this control.
9)
public
FontFamily Font {
get; set; }
Remarks
Gets
or sets the font of the tool item.
The default is SystemFonts.MenuFontFamily.
10)public Color FontColor { get; set; }
Remarks
Gets
or sets the font color of the tool item.
The default is SystemManager.FlexParameters.DefaultToolItemFontColor.
11)public double FontSize { get; set; }
Remarks
Gets
or sets the font size of the tool item.
The default is SystemFonts.MenuFontSize.
12)public FontStyle FontStyle { get; set; }
Remarks
Gets
or sets the font style of the tool item.
The default is normal.
13)public FontWeight FontWeight { get; set; }
Remarks
Gets
or sets the font weight of the tool item.
The default is normal.
14)public string
HelpContext { get; set; }
Remarks
Gets
or sets the help content for the tool item.
If this tool item has been associated to a command (CommandID attribute is
assigned), then this attribute will be ignored, instead the COMMAND_EVENT.HELPBUTTON_CLICK
event defined inside the correspondent command will be executed once the help
button on the tooltip is clicked.
15)public string
HelpFile { get; set; }
Remarks
Gets
or sets the help file for the tool item.
If this tool item has been associated to a command (CommandID attribute is
assigned), then this attribute will be ignored, instead the COMMAND_EVENT.HELPBUTTON_CLICK
event defined inside the correspondent command will be executed once the help
button on the tooltip is clicked.
16)public virtual ImageSource Icon { get; set; }
Remarks
Gets
or sets the icon of the tool item.
17)public double IconSize { get; set; }
Remarks
Gets
or sets the icon size of the tool item.
The default is 16
pixels.
18)public virtual long
ID { get; set; }
Remarks
Every
tool item should have a unique ID. If the user does not assign a number to the
ID, a unique number which is larger than FlexConstants.m_nUserDefinedControlStartID
(10,000,000) will be automatically generated and assigned to it. If the ID
is between FlexConstants.m_nUserDefinedControlStartID (1000) and
FlexConstants.m_nUserDefinedControlStartID
(10,000,000), then once the tool item is created, it will never been
destroyed, and its layout will be persistent and customizable. You can always
use LinsUIToolItemManager.GetToolItem()
to retrieve its instance, once it is created.
19)public bool
IsCheckable { get; set; }
Remarks
Gets
or sets the check ability of the tool item.
The default is false.
20)public bool IsReadOnly { get; set; }
Remarks
Gets
or sets a value that indicates whether the text editing control is read-only to
a user interacting with the control.
21)public virtual bool
IsSubMenu { get; }
Remarks
Always
false.
22)public bool IsUndoEnabled { get; set; }
Remarks
Gets
or sets a value that indicates whether undo support is enabled for the
text-editing control.
23)public bool MultiLine { get; set; }
Remarks
Gets
or sets a value indicating whether this is a multiline text box
control.
24)public virtual TextImageRelation Relation { get; set; }
Remarks
Gets
or sets the appearance of the tool item.
The default is TextImageRelation.TextBeforeImage.
It can be one of the following values,
§
Overlay:
The
Icon and the Text share the same space.
§
ImageAboveText:
The
Icon is displayed vertically above the Text.
§
TextAboveImage:
The
Text is displayed vertically above the Icon.
§
ImageBeforeText:
The
Icon is displayed horizontally before the Text.
§
TextBeforeImage:
The
Text is displayed horizontally before the Icon.
25)public SpellCheck SpellCheck { get; }
Remarks
Gets
a SpellCheck
object that provides access to spelling errors in the text contents.
26)public override string Text { get; set; }
Remarks
Gets
or sets the text of the tool item.
27)public double TextBoxLength { get; set; }
Remarks
Gets
or sets the TextBox width.
28)public string
ToolTipText { get; set; }
Remarks
Gets
or sets the tooltip of the tool item.
29)public int UndoLimit { get; set; }
Remarks
Gets
or sets the number of actions stored in the undo queue. Setting UndoLimit clears the undo queue. When UndoLimit is set to –1,
the undo queue is limited only by the memory that is available. When UndoLimit is set to 0,
undo is disabled.
§
Methods
1)
public void AppendText(
string
textData)
Parameters
textData
Type:
string
A
string that specifies the text to append to the current contents of the text
control.
Remarks
Appends
a string to the contents of a text control.
2)
public void BeginChange()
Remarks
Begins
a change block.
A change block logically groups multiple changes into
a single undo unit and prevents text content or selection change events from
being raised until after the change block. This way you can make multiple edits
to the text element without the danger of the text element being changed at the
same time by another listener. When you call BeginChange, you must also call EndChange
to complete the change block otherwise an exception will be
thrown.
3)
public void Copy()
Remarks
Copies
the current selection in the text box to the Clipboard.
4)
public void Cut()
Remarks
Removes
the current selection from the text editing control and copies it to the
Clipboard.
5)
public void EndChange()
Remarks
Ends
a change block.
A change block logically groups multiple changes into
a single undo unit and prevents text content or selection change events from
being raised until after the change block. This way you can make multiple edits
to the text element without the danger of the text element being changed at the
same time by another listener. When you call BeginChange, you must also call EndChange
to complete the change block otherwise an exception will be
thrown.
6)
public int GetNextSpellingErrorCharacterIndex(
int
charIndex,
LogicalDirection
direction)
Parameters
charIndex
Type:
int
The
zero-based character index indicating a position from which to search for the
next spelling error.
direction
Type:
LogicalDirection
One
of the LogicalDirection values that specify the direction in which to search for
the next spelling error, starting at the specified charIndex.
Return
Returns
the beginning character index for the next spelling error in the contents of the
text box.
7)
public Rect GetRectFromCharacterIndex(
int
charIndex)
Parameters
charIndex
Type:
int
The
zero-based character index of the character for which to retrieve the bounding
rectangle.
Return
A
bounding rectangle for the character at the specified character index, or
Rect..::.Empty
if a bounding rectangle cannot be determined.
8)
public Rect GetRectFromCharacterIndex(
int
charIndex,
bool
trailingEdge)
Parameters
charIndex
Type:
int
The
zero-based character index of the character for which to retrieve the bounding
rectangle.
trailingEdge
Type:
bool
True
to include the trailing edge of the character; false
to include leading edge of the character.
Return
A
bounding rectangle for the character at the specified character index, or
Rect..::.Empty
if a bounding rectangle cannot be determined.
9)
public SpellingError GetSpellingError(
int
charIndex)
Parameters
charIndex
Type:
int
The
zero-based character index of a position in content to examine for a spelling
error.
Return
A
SpellingError
object containing the details of the spelling error found at the character
indicated by charIndex,
or nullNothingnullptra null
reference (Nothing
in Visual Basic)
if no spelling error exists at the specified character.
Remarks
Returns
a SpellingError
object associated with any spelling error at the specified character
index.
10)public int
GetSpellingErrorLength(
int
charIndex)
Parameters
charIndex
Type:
int
The
zero-based character index of a position in content to examine for a spelling
error.
Return
Returns
the length of any spelling error that includes the specified
character.
Remarks
The
length of any spelling error that includes the character specified by
charIndex,
or 0
if the specified character is not part of a spelling error.
11)public int
GetSpellingErrorStart(
int
charIndex)
Parameters
charIndex
Type:
int
The
zero-based character index of a position in content to examine for a spelling
error.
Return
The
beginning character index for any spelling error that includes the character
specified by charIndex,
or –1
if the specified character is not part of a spelling error.
Remarks
Returns
the beginning character index for any spelling error that includes the specified
character.
12)public virtual bool
HitTest(
Point
ptMousePosAtMDIFrame)
Parameters
ptMousePosAtMDIFrame
Type:
Point
A
location which is in MDI Frame coordinate.
Remarks
Test
whether the point, ptMousePosAtMDIFrame,
which is in MDI Frame coordinate, is inside this tool item.
13)public void
LineDown()
Remarks
Scrolls
the contents of the control down by one line.
14)public void
LineLeft()
Remarks
Scrolls
the contents of the control left by one line.
15)public void
LineRight()
Remarks
Scrolls
the contents of the control right by one line.
16)public void
LineUp()
Remarks
Scrolls
the contents of the control up by one line.
17)public void
LockCurrentUndoUnit()
Remarks
Locks
the most recent undo unit of the undo stack of the application. This prevents
the locked unit from being merged with undo units that are added
subsequently.
Call this method when a non-text undo unit is added
to the application's main undo stack. This prevents the locked unit from being
merged with undo units that are added subsequently.
18)public virtual Size
MeasureSize(
bool
bDropDown,
FLEX_DOCKING_ALIGN
nDock)
Parameters
bDropDown
Type:
bool
True,
if this tool item is on a dropdown list, for example a context menu or a
sub-menu.
nDock
Type:
FLEX_DOCKING_ALIGN
The
docking style of the tool item’s container. Always pass in FLEX_DOCKING_ALIGN
.TOP,
except the container is a FlexToolBar, and then pass the toolbar’s
FlexDock.
Remarks
This
calculates how much space the tool item requires. If the user wants to customize
the tool item, this method may need to be overridden by the user.
19)public virtual void
OnDragEnter(
DragEventArgs e)
Parameters
e
Type:
DragEventArgs
An
object that contains event data.
Remarks
Called
when the drag drop operation is in progress and the pointer enters the tool item
bounds.
20)public virtual void
OnDragLeave(
DragEventArgs e)
Parameters
e
Type:
DragEventArgs
An
object that contains event data.
Remarks
Called
when the drag drop operation is in progress and the pointer leaves the tool item
bounds.
21)public virtual void
OnDragOver(
DragEventArgs e)
Parameters
e
Type:
DragEventArgs
An
object that contains event data.
Remarks
Called
when the drag drop operation is in progress and the pointer is within the tool
item bounds.
22)public virtual void
OnDrop(
DragEventArgs e)
Parameters
e
Type:
DragEventArgs
An
object that contains event data.
Remarks
Called
when the dragged item is dropped on the tool item.
23)public virtual void
OnSelectionChanged(
RoutedEventArgs e)
Parameters
e
Type:
RoutedEventArgs
An
object that contains event data.
Remarks
Called
when the text content selection has changed.
24)public virtual void
OnTextChanged(
TextChangedEventArgs e)
Parameters
e
Type:
TextChangedEventArgs
An
object that contains event data.
Remarks
Called
when the user changes the text in the text box.
25)public void
Paste()
Remarks
Replaces
the current selection in the text box with the contents of the
Clipboard.
26)public void
Redo()
Remarks
Undoes
the most recent undo command. In other words, redoes the most recent undo unit
on the undo stack.
27)public virtual void
Refresh()
Remarks
This
forces to redraw the tool item.
28)public void
Select(
int
start,
int
length)
Parameters
start
Type:
int
The
position of the first character in the current text selection within the text
box.
length
Type:
int
The
number of characters to select.
Remarks
Selects
a range of text in the text box.
29)public void
SelectAll()
Remarks
Selects
the entire contents of the text editing control.
30)public void
Undo()
Remarks
Undoes
the most recent undo command. In other words, undoes the most recent undo unit
on the undo stack.
§
Events
1)
public
event TextChangedEventHandler
ContentChanged
Remarks
This
event is fired when the text content has
changed.
2)
public
event HitReturnEventhandler
HitReturn
Remarks
This
event is fired when the enter key is released.
3)
public
event RoutedEventHandler
GotFocus
Remarks
This
event is fired when the tool item receives focus.
4)
public
event RoutedEventHandler
LostFocus
Remarks
This
event is fired when the tool item lost focus.
5)
public
event RoutedEventHandler
SelectionChanged
Remarks
This
event is fired when the text content selection has
changed.
References:
No comments:
Post a Comment