My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using System.Windows.Automation;
using White.Core.Recording;
using White.Core.UIItemEvents;
using White.Core.UIItems.Actions;

namespace White.Core.UIItems
{
public class CheckBox : Button
{
private AutomationPropertyChangedEventHandler handler;

protected CheckBox()
{
}

public CheckBox(AutomationElement automationElement, ActionListener actionListener) : base(automationElement, actionListener)
{
}

public virtual void Select()
{
Checked = true;
}

/// <summary>
/// true when CheckBox is checked
/// </summary>
public virtual bool IsSelected
{
get { return Checked; }
}

public virtual bool Checked
{
get { return State.Equals(ToggleState.On); }
set
{
if (Checked == value) return;
Click();
}
}

/// <summary>
/// Unchecks the checkbox
/// </summary>
public virtual void UnSelect()
{
Checked = false;
}

public override void HookEvents(UIItemEventListener eventListener)
{
handler = delegate
{
ActionPerformed();
eventListener.EventOccured(new CheckBoxEvent(this));
};
Automation.AddAutomationPropertyChangedEventHandler(automationElement, TreeScope.Element, handler,
TogglePattern.ToggleStateProperty);
}

public override void UnHookEvents()
{
Automation.RemoveAutomationPropertyChangedEventHandler(automationElement, handler);
}

public override void SetValue(object value)
{
if (!(value is bool))
throw new UIActionException("Cannot set non bool value to a checkbox. Trying to set: " + value);
Checked = (bool) value;
}
}
}

Change log

r39 by petmongrels on Jan 31, 2010   Diff
Moved changes from 0.19 to trunk.
Go to: 
Project members, sign in to write a code review

Older revisions

r22 by petmongrels on Jan 17, 2010   Diff
Minor refactoring
r9 by petmongrels on Nov 16, 2009   Diff
creating project
All revisions of this file

File info

Size: 2157 bytes, 74 lines
Powered by Google Project Hosting