white学习3(官方网站的内容)

Performing special operations on a window

Attached Keyboard and mouse
provides a keyboard or mouse which would wait for the window to be idle after every action. All the actions possible on the mouse and keyboard are supported by these.

Tooltip
any window, including it child controls can have only one visible tooltip at a time, hence this method is available on the window object.

string message = window.ToolTip;

In some applications the tool tip is associated to an error provider which looks like . When mouse is hovered on it, a message is shown as tooltip. This need not be implemented by user as it is pretty standard behaviour and white provides it out of the box. If the message is set on the error provider for ComboBox then:

var comboBox = window.Get<ComboBox>("komboBox");

string message = comboBox.ErrorProviderMessage(window);


Closing the window
Window object implements IDisposable interface, so that it can be used with the using block. Also, dispose is same as close. One can also check whether a window was closed or not. When a window.Close() is called white would try to close it using the WindowPattern provided by UIAutomation. In case this pattern is not implemented then white would make use of the close in the title bar to close it.

window.Close(); //by default it waits while the window is busy.

bool isClosed = window.IsClosed; //isClosed would be true
Tool bar
Typical a window has zero or one tool bar. But it is possible to have more than one present on a window. Most likely scenario works as a special case of generic scenario in white.

ToolStrip toolStrip1 = window.GetToolStrip("toolStripId1");

// if there is only one then one can also do following to achieve the same

toolStrip1 = window.ToolStrip;

//ToolStrip is a UIItemContainer so child items can be found from it by call get methods.

Button button = toolStrip1.Get<Button>("toolButton");


WaitWhileBusy
It makes the window wait till the user input cannot be provided as it is busy performing background tasks. This method need not be called as all operations on UIItems explicitly call this at the end of every action. This method wouldn't cause wait indicated as hour glass, since this is controlled by application. But this is taken care of explicitly inside white but is not exposed to the user. Waiting based on hour glass is the default approach which can be turned off. (Configuration)

Menu
A window can contain multiple menu bars. White supports working with multiple and since having single menu bar is so common it provides a convenience method for it.

List<MenuBar> menuBars = window.MenuBars;

MenuBar menuBar = window.MenuBar; //use it to get the only menu bar.


Display state
A window can be in three display states: maximize, minimized and restored.DisplayState property on window provides this. Core.UIItems.WindowItems.DisplayState enum can be used to specify the state to a window.
Whether or not a window is the top most window at time can be retrieved by IsCurrentlyActive property.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值