C# Class SIL.FieldWorks.Common.Widgets.PopupTree

PopupTree is a form containing a TreeView, designed to pop up like the list of a combo box to allow a one-time choice from a list. Although this is currently implemented using the standard TreeView class, it is possible that a need will arise for items to be rendered using View code, either to support styled text in items, or to support Graphite rendering. For this reason the TreeView is not made public, and only a limited subset of its capabilities is currently exposed.
Inheritance: System.Windows.Forms.Form, IFWDisposable, IDropDownBox
Mostra file Open project: sillsdev/FieldWorks Class Usage Examples

Private Properties

Property Type Description
FindAndSelectNodeStartingWith bool
FindNode System.Windows.Forms.TreeNode
HandleTreeItemSelect void
InitializeComponent void
OnHide void
RemoveFilter void
m_treeView_AfterSelect void
m_treeView_BeforeSelect void
m_treeView_KeyDown void
m_treeView_MouseDown void
m_treeView_MouseUp void

Public Methods

Method Description
BeginUpdate ( ) : void

Begin update on the tree...when you want to add multiple nodes.

CheckDisposed ( ) : void

Check to see if the object has been disposed. All public Properties and Methods should call this before doing anything else.

EnableAfterAndBeforeSelectHandling ( bool enable ) : void

Enables or disables the handlers for the AfterSelect and BeforeSelect events

EndUpdate ( ) : void

End update started with BeginUpdate.

HideForm ( ) : void

Hide the window that shows the popup tree (and activate the parent window, if known).

HideForm ( bool activateParent ) : void

Hide the window that shows the popup tree (and activate the parent window, if requested).

Launch ( Rectangle launcherBounds, Rectangle screenBounds ) : void

Launch the PopupTree. Typical usage, where 'this' is a control that the list should appear below: m_listBox.Launch(Parent.RectangleToScreen(Bounds), Screen.GetWorkingArea(this)); Or, where rect is a rectangle in the client area of control 'this': m_listBox.Launch(RectangleToScreen(rect), Screen.GetWorkingArea(this); (Be sure to set the height and width of the PopupTree first.)

PopupTree ( ) : System

SelectNodeStartingWith ( string start ) : void

Cycle the selection to the next node that begins with the specified text. (Case insensitive.)

SelectObj ( int hvo ) : void

Find the node for the specified Hvo and select it. Note that this DOES trigger the AfterSelect event. Enhance JohnT: currently, if the hvo isn't found, it still fires off the AfterSelect event. - should we (will it work?) set m_treeView.SelectedNode to null so nothing is selected? - if it's an exception not to find the node, do we need a mechanism...maybe passing zero?... to explicitly set it to 'nothing selected' (if that's possible). None of that is needed yet, so we haven't worried about it.

SelectObjWithoutTriggeringBeforeAfterSelects ( int hvo ) : void

Find the node for the specified Hvo and select it. Note that this does NOT trigger the BeforeSelect or AfterSelect events.

Protected Methods

Method Description
Dispose ( bool disposing ) : void

Clean up any resources being used.

OnActivated ( EventArgs e ) : void

JohnT: I don't know why we need this, but for some obscure reason, after everything else happens and we are hidden, we get activated again. Then the main window is not active, and can't get keyboard events. AArgh! This is a horrible kludge but the best I can find.

OnVisibleChanged ( EventArgs e ) : void

Make sure we clean out the message filter if not already done.

Private Methods

Method Description
FindAndSelectNodeStartingWith ( int iStarting, int iEnding, string startKey ) : bool

Select the node whose text starts with the given startKey string (if node exists).

FindNode ( TreeNodeCollection nodes, int hvo ) : TreeNode

Assuming a node collection containing HvoTreeNodes, return the one whose HVO is the specified one. Null if not found.

HandleTreeItemSelect ( ) : void
InitializeComponent ( ) : void

Required method for Designer support - do not modify the contents of this method with the code editor.

OnHide ( ) : void
RemoveFilter ( ) : void
m_treeView_AfterSelect ( object sender, TreeViewEventArgs e ) : void
m_treeView_BeforeSelect ( object sender, System.Windows.Forms.TreeViewCancelEventArgs e ) : void

pass on the event to clients.

m_treeView_KeyDown ( object sender, KeyEventArgs e ) : void
m_treeView_MouseDown ( object sender, MouseEventArgs e ) : void

Handle a MouseDown event, recording the selected node if it seems likely that the TreeView Select operation will ignore it.

m_treeView_MouseUp ( object sender, MouseEventArgs e ) : void

Handle a MouseUp event, selecting the node recorded earlier for MouseDown if it is the same node in the TreeView control.

Method Details

BeginUpdate() public method

Begin update on the tree...when you want to add multiple nodes.
public BeginUpdate ( ) : void
return void

CheckDisposed() public method

Check to see if the object has been disposed. All public Properties and Methods should call this before doing anything else.
public CheckDisposed ( ) : void
return void

Dispose() protected method

Clean up any resources being used.
protected Dispose ( bool disposing ) : void
disposing bool
return void

EnableAfterAndBeforeSelectHandling() public method

Enables or disables the handlers for the AfterSelect and BeforeSelect events
public EnableAfterAndBeforeSelectHandling ( bool enable ) : void
enable bool
return void

EndUpdate() public method

End update started with BeginUpdate.
public EndUpdate ( ) : void
return void

HideForm() public method

Hide the window that shows the popup tree (and activate the parent window, if known).
public HideForm ( ) : void
return void

HideForm() public method

Hide the window that shows the popup tree (and activate the parent window, if requested).
public HideForm ( bool activateParent ) : void
activateParent bool
return void

Launch() public method

Launch the PopupTree. Typical usage, where 'this' is a control that the list should appear below: m_listBox.Launch(Parent.RectangleToScreen(Bounds), Screen.GetWorkingArea(this)); Or, where rect is a rectangle in the client area of control 'this': m_listBox.Launch(RectangleToScreen(rect), Screen.GetWorkingArea(this); (Be sure to set the height and width of the PopupTree first.)
public Launch ( Rectangle launcherBounds, Rectangle screenBounds ) : void
launcherBounds System.Drawing.Rectangle A rectangle in 'screen' coordinates indicating where to display the list. Typically, as shown /// above, the location of something the user clicked to make the list display. It's significance is that /// the tree will usually be shown with its top left just to the right of the bottom left of the rectangle, and /// (if the tree width has not already been set explicitly) its width will match the rectangle. If there is not /// room to display the tree below this rectangle, it will be displayed above instead.
screenBounds System.Drawing.Rectangle A rectangle in 'screen' coordinates indicating the location of the actual screen /// that the tree is to appear on.
return void

OnActivated() protected method

JohnT: I don't know why we need this, but for some obscure reason, after everything else happens and we are hidden, we get activated again. Then the main window is not active, and can't get keyboard events. AArgh! This is a horrible kludge but the best I can find.
protected OnActivated ( EventArgs e ) : void
e System.EventArgs
return void

OnVisibleChanged() protected method

Make sure we clean out the message filter if not already done.
protected OnVisibleChanged ( EventArgs e ) : void
e System.EventArgs
return void

PopupTree() public method

public PopupTree ( ) : System
return System

SelectNodeStartingWith() public method

Cycle the selection to the next node that begins with the specified text. (Case insensitive.)
public SelectNodeStartingWith ( string start ) : void
start string the search key
return void

SelectObj() public method

Find the node for the specified Hvo and select it. Note that this DOES trigger the AfterSelect event. Enhance JohnT: currently, if the hvo isn't found, it still fires off the AfterSelect event. - should we (will it work?) set m_treeView.SelectedNode to null so nothing is selected? - if it's an exception not to find the node, do we need a mechanism...maybe passing zero?... to explicitly set it to 'nothing selected' (if that's possible). None of that is needed yet, so we haven't worried about it.
public SelectObj ( int hvo ) : void
hvo int
return void

SelectObjWithoutTriggeringBeforeAfterSelects() public method

Find the node for the specified Hvo and select it. Note that this does NOT trigger the BeforeSelect or AfterSelect events.
public SelectObjWithoutTriggeringBeforeAfterSelects ( int hvo ) : void
hvo int
return void