|
Lines 17-23
Link Here
|
| 17 |
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
17 |
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| 18 |
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
18 |
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 19 |
// |
19 |
// |
| 20 |
// Copyright (c) 2008 Novell, Inc. (http://www.novell.com) |
20 |
// Copyright (c) 2008,2009 Novell, Inc. (http://www.novell.com) |
| 21 |
// |
21 |
// |
| 22 |
// Authors: |
22 |
// Authors: |
| 23 |
// Mario Carrion <mcarrion@novell.com> |
23 |
// Mario Carrion <mcarrion@novell.com> |
|
Lines 48-56
namespace Mono.UIAutomation.Winforms
Link Here
|
| 48 |
public ListViewProvider (SWF.ListView listView) : base (listView) |
48 |
public ListViewProvider (SWF.ListView listView) : base (listView) |
| 49 |
{ |
49 |
{ |
| 50 |
this.listView = listView; |
50 |
this.listView = listView; |
| 51 |
|
51 |
|
| 52 |
lastView = Helper.SynchronizedGet<SWF.ListView, SWF.View> (listView, v => listView.View); |
52 |
lastView = listView.InvokeSync (c => c.View); |
| 53 |
showGroups = Helper.SynchronizedGet<SWF.ListView, bool> (listView, g => listView.ShowGroups); |
53 |
showGroups = listView.InvokeSync (c => c.ShowGroups); |
| 54 |
groups = new Dictionary<SWF.ListViewGroup, ListViewGroupProvider> (); |
54 |
groups = new Dictionary<SWF.ListViewGroup, ListViewGroupProvider> (); |
| 55 |
} |
55 |
} |
| 56 |
|
56 |
|
|
Lines 70-83
namespace Mono.UIAutomation.Winforms
Link Here
|
| 70 |
protected override object GetProviderPropertyValue (int propertyId) |
70 |
protected override object GetProviderPropertyValue (int propertyId) |
| 71 |
{ |
71 |
{ |
| 72 |
if (propertyId == AutomationElementIdentifiers.ControlTypeProperty.Id) { |
72 |
if (propertyId == AutomationElementIdentifiers.ControlTypeProperty.Id) { |
| 73 |
if (Helper.SynchronizedGet<SWF.ListView, SWF.View> (listView, |
73 |
if (listView.InvokeSync (c => c.View == SWF.View.Details)) |
| 74 |
v => listView.View) == SWF.View.Details) |
|
|
| 75 |
return ControlType.DataGrid.Id; |
74 |
return ControlType.DataGrid.Id; |
| 76 |
else |
75 |
else |
| 77 |
return ControlType.List.Id; |
76 |
return ControlType.List.Id; |
| 78 |
} else if (propertyId == AutomationElementIdentifiers.LocalizedControlTypeProperty.Id) { |
77 |
} else if (propertyId == AutomationElementIdentifiers.LocalizedControlTypeProperty.Id) { |
| 79 |
if (Helper.SynchronizedGet<SWF.ListView, SWF.View> (listView, |
78 |
if (listView.InvokeSync (c => c.View == SWF.View.Details)) |
| 80 |
v => listView.View) == SWF.View.Details) |
|
|
| 81 |
return Catalog.GetString ("data grid"); |
79 |
return Catalog.GetString ("data grid"); |
| 82 |
else |
80 |
else |
| 83 |
return Catalog.GetString ("list"); |
81 |
return Catalog.GetString ("list"); |
|
Lines 101-120
namespace Mono.UIAutomation.Winforms
Link Here
|
| 101 |
else if (behavior == SelectionPatternIdentifiers.Pattern) |
99 |
else if (behavior == SelectionPatternIdentifiers.Pattern) |
| 102 |
return new SelectionProviderBehavior (this); |
100 |
return new SelectionProviderBehavior (this); |
| 103 |
else if (behavior == GridPatternIdentifiers.Pattern) { |
101 |
else if (behavior == GridPatternIdentifiers.Pattern) { |
| 104 |
if (Helper.SynchronizedGet<SWF.ListView, bool> (listView, |
102 |
if (listView.InvokeSync (c => !c.ShowGroups |
| 105 |
s => listView.ShowGroups == false) |
103 |
|| !SWF.Application.VisualStylesEnabled |
| 106 |
|| Helper.SynchronizedGet<SWF.ListView, bool> (listView, |
104 |
|| c.View == SWF.View.List |
| 107 |
v => SWF.Application.VisualStylesEnabled == false) |
105 |
|| c.View == SWF.View.Details)) |
| 108 |
|| Helper.SynchronizedGet<SWF.ListView, bool> (listView, |
|
|
| 109 |
vi => listView.View == SWF.View.List) |
| 110 |
|| Helper.SynchronizedGet<SWF.ListView, bool> (listView, |
| 111 |
d => listView.View == SWF.View.Details)) |
| 112 |
return new GridProviderBehavior (this); |
106 |
return new GridProviderBehavior (this); |
| 113 |
else |
107 |
else |
| 114 |
return null; |
108 |
return null; |
| 115 |
} else if (behavior == TablePatternIdentifiers.Pattern) { |
109 |
} else if (behavior == TablePatternIdentifiers.Pattern) { |
| 116 |
if (Helper.SynchronizedGet<SWF.ListView, bool> (listView, |
110 |
if (listView.InvokeSync (c => c.View == SWF.View.Details)) |
| 117 |
v => listView.View == SWF.View.Details)) |
|
|
| 118 |
return new TableProviderBehavior (this); |
111 |
return new TableProviderBehavior (this); |
| 119 |
else |
112 |
else |
| 120 |
return null; |
113 |
return null; |
|
Lines 131-157
namespace Mono.UIAutomation.Winforms
Link Here
|
| 131 |
return new ListItemSelectionItemProviderBehavior (listItem); |
124 |
return new ListItemSelectionItemProviderBehavior (listItem); |
| 132 |
else if (behavior == GridItemPatternIdentifiers.Pattern) { |
125 |
else if (behavior == GridItemPatternIdentifiers.Pattern) { |
| 133 |
// LAMESPEC: GridItem implemented *only* when: listView.View != SWF.View.Details |
126 |
// LAMESPEC: GridItem implemented *only* when: listView.View != SWF.View.Details |
| 134 |
if (Helper.SynchronizedGet<SWF.ListView, bool> (listView, |
127 |
if (listView.InvokeSync (c => c.View != SWF.View.Details) |
| 135 |
v => listView.View != SWF.View.Details) |
|
|
| 136 |
|| IsBehaviorEnabled (GridPatternIdentifiers.Pattern)) |
128 |
|| IsBehaviorEnabled (GridPatternIdentifiers.Pattern)) |
| 137 |
return new ListItemGridItemProviderBehavior (listItem); |
129 |
return new ListItemGridItemProviderBehavior (listItem); |
| 138 |
else |
130 |
else |
| 139 |
return null; |
131 |
return null; |
| 140 |
} else if (behavior == ValuePatternIdentifiers.Pattern) { |
132 |
} else if (behavior == ValuePatternIdentifiers.Pattern) { |
| 141 |
if (Helper.SynchronizedGet<SWF.ListView, bool> (listView, |
133 |
if (listView.InvokeSync (c => c.LabelEdit)) |
| 142 |
e => listView.LabelEdit)) |
|
|
| 143 |
return new ListItemValueProviderBehavior (listItem); |
134 |
return new ListItemValueProviderBehavior (listItem); |
| 144 |
else |
135 |
else |
| 145 |
return null; |
136 |
return null; |
| 146 |
} else if (behavior == TogglePatternIdentifiers.Pattern) { |
137 |
} else if (behavior == TogglePatternIdentifiers.Pattern) { |
| 147 |
if (Helper.SynchronizedGet<SWF.ListView, bool> (listView, |
138 |
if (listView.InvokeSync (c => c.CheckBoxes)) |
| 148 |
e => listView.CheckBoxes)) |
|
|
| 149 |
return new ListItemToggleProviderBehavior (listItem); |
139 |
return new ListItemToggleProviderBehavior (listItem); |
| 150 |
else |
140 |
else |
| 151 |
return null; |
141 |
return null; |
| 152 |
} else if (behavior == TableItemPatternIdentifiers.Pattern) { |
142 |
} else if (behavior == TableItemPatternIdentifiers.Pattern) { |
| 153 |
if (Helper.SynchronizedGet<SWF.ListView, bool> (listView, |
143 |
if (listView.InvokeSync (c => c.View == SWF.View.Details)) |
| 154 |
d => listView.View == SWF.View.Details)) |
|
|
| 155 |
return new ListItemTableItemProviderBehavior (listItem); |
144 |
return new ListItemTableItemProviderBehavior (listItem); |
| 156 |
else |
145 |
else |
| 157 |
return null; |
146 |
return null; |
|
Lines 173-209
namespace Mono.UIAutomation.Winforms
Link Here
|
| 173 |
if (propertyId == AutomationElementIdentifiers.NameProperty.Id) |
162 |
if (propertyId == AutomationElementIdentifiers.NameProperty.Id) |
| 174 |
return ((SWF.ListViewItem) item.ObjectItem).Text; |
163 |
return ((SWF.ListViewItem) item.ObjectItem).Text; |
| 175 |
else if (propertyId == AutomationElementIdentifiers.HasKeyboardFocusProperty.Id) |
164 |
else if (propertyId == AutomationElementIdentifiers.HasKeyboardFocusProperty.Id) |
| 176 |
return Helper.SynchronizedGet<SWF.ListView, bool> (listView, |
165 |
return listView.InvokeSync (c => c.Focused |
| 177 |
f => listView.Focused) |
166 |
&& ((SWF.ListViewItem) item.ObjectItem).Focused); |
| 178 |
&& ((SWF.ListViewItem)item.ObjectItem).Focused; |
|
|
| 179 |
else if (propertyId == AutomationElementIdentifiers.BoundingRectangleProperty.Id) { |
167 |
else if (propertyId == AutomationElementIdentifiers.BoundingRectangleProperty.Id) { |
| 180 |
int index = item.Index; |
168 |
int index = item.Index; |
| 181 |
|
169 |
|
| 182 |
if (index == -1 |
170 |
if (index == -1 |
| 183 |
|| index >= Helper.SynchronizedGet<SWF.ListView, int> (listView, |
171 |
|| listView.InvokeSync (l => index >= l.UIAItemsLocationLength)) |
| 184 |
i => listView.UIAItemsLocationLength)) |
|
|
| 185 |
return Helper.RectangleToRect (SD.Rectangle.Empty); |
172 |
return Helper.RectangleToRect (SD.Rectangle.Empty); |
| 186 |
|
173 |
|
| 187 |
SD.Rectangle itemRec |
174 |
SD.Rectangle itemRec |
| 188 |
= Helper.SynchronizedGet<SWF.ListView, SD.Rectangle> (listView, |
175 |
= listView.InvokeSync (c => c.GetItemRect (index)); |
| 189 |
i => listView.GetItemRect (index)); |
|
|
| 190 |
SD.Rectangle rectangle |
176 |
SD.Rectangle rectangle |
| 191 |
= Helper.SynchronizedGet<SWF.ListView, SD.Rectangle> (listView, |
177 |
= listView.InvokeSync (c => c.Bounds); |
| 192 |
i => listView.Bounds); |
|
|
| 193 |
|
178 |
|
| 194 |
itemRec.X += rectangle.X; |
179 |
itemRec.X += rectangle.X; |
| 195 |
itemRec.Y += rectangle.Y; |
180 |
itemRec.Y += rectangle.Y; |
| 196 |
|
181 |
|
| 197 |
itemRec = Helper.SynchronizedGet<SWF.ListView, SD.Rectangle> (listView, |
182 |
itemRec = listView.InvokeSync (c => c.Parent.RectangleToScreen (itemRec)); |
| 198 |
i => listView.Parent.RectangleToScreen (itemRec)); |
|
|
| 199 |
|
183 |
|
| 200 |
return Helper.RectangleToRect (itemRec); |
184 |
return Helper.RectangleToRect (itemRec); |
| 201 |
} else if (propertyId == AutomationElementIdentifiers.IsOffscreenProperty.Id) |
185 |
} else if (propertyId == AutomationElementIdentifiers.IsOffscreenProperty.Id) |
| 202 |
return Helper.IsListItemOffScreen ((Rect) item.GetPropertyValue (AutomationElementIdentifiers.BoundingRectangleProperty.Id), |
186 |
return Helper.IsListItemOffScreen ((Rect) item.GetPropertyValue (AutomationElementIdentifiers.BoundingRectangleProperty.Id), |
| 203 |
listView, |
187 |
listView, |
| 204 |
HeaderProvider != null, |
188 |
HeaderProvider != null, |
| 205 |
Helper.SynchronizedGet<SWF.ListView, SD.Rectangle> (listView, |
189 |
listView.InvokeSync (c => c.UIAHeaderControl), |
| 206 |
i => listView.UIAHeaderControl), |
|
|
| 207 |
ScrollBehaviorObserver); |
190 |
ScrollBehaviorObserver); |
| 208 |
else if (propertyId == AutomationElementIdentifiers.IsKeyboardFocusableProperty.Id) |
191 |
else if (propertyId == AutomationElementIdentifiers.IsKeyboardFocusableProperty.Id) |
| 209 |
return true; |
192 |
return true; |
|
Lines 226-234
namespace Mono.UIAutomation.Winforms
Link Here
|
| 226 |
{ |
209 |
{ |
| 227 |
base.InitializeChildControlStructure (); |
210 |
base.InitializeChildControlStructure (); |
| 228 |
|
211 |
|
| 229 |
Helper.SynchronizedSet (listView, delegate { |
212 |
listView.Items.UIACollectionChanged += OnCollectionChanged; |
| 230 |
listView.Items.UIACollectionChanged += OnCollectionChanged; |
|
|
| 231 |
}); |
| 232 |
|
213 |
|
| 233 |
// Use to regenerate children when view changes |
214 |
// Use to regenerate children when view changes |
| 234 |
listView.UIAViewChanged += OnUIAViewChanged; |
215 |
listView.UIAViewChanged += OnUIAViewChanged; |
|
Lines 239-267
namespace Mono.UIAutomation.Winforms
Link Here
|
| 239 |
{ |
220 |
{ |
| 240 |
base.FinalizeChildControlStructure (); |
221 |
base.FinalizeChildControlStructure (); |
| 241 |
|
222 |
|
| 242 |
Helper.SynchronizedSet (listView, delegate { |
223 |
listView.Items.UIACollectionChanged -= OnCollectionChanged; |
| 243 |
listView.Items.UIACollectionChanged -= OnCollectionChanged; |
|
|
| 244 |
}); |
| 245 |
|
224 |
|
| 246 |
listView.UIAViewChanged -= OnUIAViewChanged; |
225 |
listView.UIAViewChanged -= OnUIAViewChanged; |
| 247 |
} |
226 |
} |
| 248 |
|
227 |
|
| 249 |
public override int ItemsCount { |
228 |
public override int ItemsCount { |
| 250 |
get { |
229 |
get { return listView.InvokeSync (c => c.Items.Count); } |
| 251 |
return Helper.SynchronizedGet<SWF.ListView, int> (listView, |
|
|
| 252 |
c => listView.Items.Count); |
| 253 |
} |
| 254 |
} |
230 |
} |
| 255 |
|
231 |
|
| 256 |
public override int IndexOfObjectItem (object objectItem) |
232 |
public override int IndexOfObjectItem (object objectItem) |
| 257 |
{ |
233 |
{ |
| 258 |
return Helper.SynchronizedGet<SWF.ListView, int> (listView, |
234 |
return listView.InvokeSync (c => c.Items.IndexOf (objectItem as SWF.ListViewItem)); |
| 259 |
c => listView.Items.IndexOf (objectItem as SWF.ListViewItem)); |
|
|
| 260 |
} |
235 |
} |
| 261 |
|
236 |
|
| 262 |
public override void FocusItem (object objectItem) |
237 |
public override void FocusItem (object objectItem) |
| 263 |
{ |
238 |
{ |
| 264 |
((SWF.ListViewItem)objectItem).Focused = true; |
239 |
listView.InvokeSync (delegate { |
|
|
240 |
((SWF.ListViewItem) objectItem).Focused = true; |
| 241 |
}); |
| 265 |
} |
242 |
} |
| 266 |
|
243 |
|
| 267 |
#endregion |
244 |
#endregion |
|
Lines 269-297
namespace Mono.UIAutomation.Winforms
Link Here
|
| 269 |
#region ListItem: Selection Methods and Properties |
246 |
#region ListItem: Selection Methods and Properties |
| 270 |
|
247 |
|
| 271 |
public override int SelectedItemsCount { |
248 |
public override int SelectedItemsCount { |
| 272 |
get { |
249 |
get { return listView.InvokeSync (c => c.SelectedIndices.Count); } |
| 273 |
return Helper.SynchronizedGet<SWF.ListView, int> (listView, |
|
|
| 274 |
c => listView.SelectedItems.Count); |
| 275 |
} |
| 276 |
} |
250 |
} |
| 277 |
|
251 |
|
| 278 |
public override bool IsItemSelected (ListItemProvider item) |
252 |
public override bool IsItemSelected (ListItemProvider item) |
| 279 |
{ |
253 |
{ |
| 280 |
return Helper.SynchronizedGet<SWF.ListView, bool> (listView, |
254 |
return listView.InvokeSync (c => c.SelectedIndices.Contains (item.Index)); |
| 281 |
c => listView.SelectedIndices.Contains (item.Index)); |
|
|
| 282 |
} |
255 |
} |
| 283 |
|
256 |
|
| 284 |
public override IRawElementProviderSimple[] GetSelectedItems () |
257 |
public override IRawElementProviderSimple[] GetSelectedItems () |
| 285 |
{ |
258 |
{ |
| 286 |
if (Helper.SynchronizedGet<SWF.ListView, bool> (listView, |
259 |
if (listView == null) |
| 287 |
c => listView.SelectedIndices.Count == 0)) |
260 |
return new ListItemProvider [0]; |
|
|
261 |
|
| 262 |
if (listView.InvokeSync (c => c.SelectedIndices.Count == 0)) |
| 288 |
return new ListItemProvider [0]; |
263 |
return new ListItemProvider [0]; |
| 289 |
else { |
264 |
else { |
| 290 |
return Helper.SynchronizedGet<SWF.ListView, ListItemProvider[]> (listView, delegate { |
265 |
return listView.InvokeSync (c => { |
| 291 |
ListItemProvider []providers = new ListItemProvider [listView.SelectedItems.Count]; |
266 |
ListItemProvider []providers = new ListItemProvider [c.SelectedItems.Count]; |
| 292 |
|
267 |
|
| 293 |
for (int index = 0; index < listView.SelectedItems.Count; index++) |
268 |
for (int index = 0; index < c.SelectedItems.Count; index++) |
| 294 |
providers [index] = GetItemProviderFrom (this, listView.SelectedItems [index], false); |
269 |
providers [index] = GetItemProviderFrom (this, c.SelectedItems [index], false); |
| 295 |
|
270 |
|
| 296 |
return providers; |
271 |
return providers; |
| 297 |
}); |
272 |
}); |
|
Lines 301-307
namespace Mono.UIAutomation.Winforms
Link Here
|
| 301 |
public override void SelectItem (ListItemProvider item) |
276 |
public override void SelectItem (ListItemProvider item) |
| 302 |
{ |
277 |
{ |
| 303 |
if (ContainsItem (item) == true) |
278 |
if (ContainsItem (item) == true) |
| 304 |
Helper.SynchronizedSet (listView, delegate { |
279 |
listView.InvokeSync (delegate { |
| 305 |
listView.Items [item.Index].Selected = true; |
280 |
listView.Items [item.Index].Selected = true; |
| 306 |
}); |
281 |
}); |
| 307 |
} |
282 |
} |
|
Lines 309-315
namespace Mono.UIAutomation.Winforms
Link Here
|
| 309 |
public override void UnselectItem (ListItemProvider item) |
284 |
public override void UnselectItem (ListItemProvider item) |
| 310 |
{ |
285 |
{ |
| 311 |
if (ContainsItem (item) == true) |
286 |
if (ContainsItem (item) == true) |
| 312 |
Helper.SynchronizedSet (listView, delegate { |
287 |
listView.InvokeSync (delegate { |
| 313 |
listView.Items [item.Index].Selected = false; |
288 |
listView.Items [item.Index].Selected = false; |
| 314 |
}); |
289 |
}); |
| 315 |
} |
290 |
} |
|
Lines 320-332
namespace Mono.UIAutomation.Winforms
Link Here
|
| 320 |
|
295 |
|
| 321 |
public override ToggleState GetItemToggleState (ListItemProvider item) |
296 |
public override ToggleState GetItemToggleState (ListItemProvider item) |
| 322 |
{ |
297 |
{ |
| 323 |
if (Helper.SynchronizedGet<SWF.ListView, bool> (listView, c => !listView.CheckBoxes) |
298 |
if (listView.InvokeSync (c => !c.CheckBoxes) |
| 324 |
|| item.Index == -1) |
299 |
|| item.Index == -1) |
| 325 |
return ToggleState.Indeterminate; |
300 |
return ToggleState.Indeterminate; |
| 326 |
|
301 |
|
| 327 |
if (ContainsItem (item) == true) |
302 |
if (ContainsItem (item) == true) |
| 328 |
return Helper.SynchronizedGet<SWF.ListView, bool> (listView, |
303 |
return listView.InvokeSync (c => c.Items [item.Index].Checked) |
| 329 |
c => listView.Items [item.Index].Checked) |
|
|
| 330 |
? ToggleState.On : ToggleState.Off; |
304 |
? ToggleState.On : ToggleState.Off; |
| 331 |
else |
305 |
else |
| 332 |
return ToggleState.Indeterminate; |
306 |
return ToggleState.Indeterminate; |
|
Lines 334-345
namespace Mono.UIAutomation.Winforms
Link Here
|
| 334 |
|
308 |
|
| 335 |
public override void ToggleItem (ListItemProvider item) |
309 |
public override void ToggleItem (ListItemProvider item) |
| 336 |
{ |
310 |
{ |
| 337 |
if (Helper.SynchronizedGet<SWF.ListView, bool> (listView, c => !listView.CheckBoxes)) |
311 |
if (listView.InvokeSync (c => !c.CheckBoxes)) |
| 338 |
return; |
312 |
return; |
| 339 |
|
313 |
|
| 340 |
if (ContainsItem (item) == true) |
314 |
if (ContainsItem (item) == true) |
| 341 |
Helper.SynchronizedSet (listView, delegate { |
315 |
listView.InvokeSync (delegate { |
| 342 |
listView.Items [item.Index].Checked = !listView.Items [item.Index].Checked; |
316 |
listView.Items [item.Index].Checked = !listView.Items [item.Index].Checked; |
| 343 |
}); |
317 |
}); |
| 344 |
} |
318 |
} |
| 345 |
|
319 |
|
|
Lines 365-371
namespace Mono.UIAutomation.Winforms
Link Here
|
| 365 |
if (ContainsItem (item) == false) |
339 |
if (ContainsItem (item) == false) |
| 366 |
return; |
340 |
return; |
| 367 |
|
341 |
|
| 368 |
Helper.SynchronizedSet (listView, delegate { |
342 |
listView.InvokeSync(delegate { |
| 369 |
// According to http://msdn.microsoft.com/en-us/library/system.windows.forms.listview.topitem.aspx |
343 |
// According to http://msdn.microsoft.com/en-us/library/system.windows.forms.listview.topitem.aspx |
| 370 |
if (listView.View == SWF.View.LargeIcon |
344 |
if (listView.View == SWF.View.LargeIcon |
| 371 |
|| listView.View == SWF.View.SmallIcon |
345 |
|| listView.View == SWF.View.SmallIcon |
|
Lines 407-417
namespace Mono.UIAutomation.Winforms
Link Here
|
| 407 |
#region Scroll Methods and Properties |
381 |
#region Scroll Methods and Properties |
| 408 |
|
382 |
|
| 409 |
protected override SWF.ScrollBar HorizontalScrollBar { |
383 |
protected override SWF.ScrollBar HorizontalScrollBar { |
| 410 |
get { return Helper.SynchronizedGet<SWF.ListView, SWF.ScrollBar> (listView, c => listView.UIAHScrollBar); } |
384 |
get { return listView.InvokeSync (c => c.UIAHScrollBar); } |
| 411 |
} |
385 |
} |
| 412 |
|
386 |
|
| 413 |
protected override SWF.ScrollBar VerticalScrollBar { |
387 |
protected override SWF.ScrollBar VerticalScrollBar { |
| 414 |
get { return Helper.SynchronizedGet<SWF.ListView, SWF.ScrollBar> (listView, c => listView.UIAVScrollBar); } |
388 |
get { return listView.InvokeSync (c => c.UIAVScrollBar); } |
| 415 |
} |
389 |
} |
| 416 |
|
390 |
|
| 417 |
#endregion |
391 |
#endregion |
|
Lines 430-436
namespace Mono.UIAutomation.Winforms
Link Here
|
| 430 |
public SWF.ListViewGroup GetDefaultGroup () |
404 |
public SWF.ListViewGroup GetDefaultGroup () |
| 431 |
{ |
405 |
{ |
| 432 |
if (listViewNullGroup == null) |
406 |
if (listViewNullGroup == null) |
| 433 |
listViewNullGroup = Helper.SynchronizedGet<SWF.ListView, SWF.ListViewGroup> (listView, v => listView.UIADefaultListViewGroup); |
407 |
listViewNullGroup = listView.InvokeSync (c => c.UIADefaultListViewGroup); |
| 434 |
|
408 |
|
| 435 |
return listViewNullGroup; |
409 |
return listViewNullGroup; |
| 436 |
} |
410 |
} |
|
Lines 462-468
namespace Mono.UIAutomation.Winforms
Link Here
|
| 462 |
|
436 |
|
| 463 |
// Using groups |
437 |
// Using groups |
| 464 |
if (showGroups == true |
438 |
if (showGroups == true |
| 465 |
&& Helper.SynchronizedGet<SWF.ListView, bool> (listView, b => listView.View != SWF.View.List) |
439 |
&& listView.InvokeSync (c => c.View != SWF.View.List) |
| 466 |
&& SWF.Application.VisualStylesEnabled == true) { |
440 |
&& SWF.Application.VisualStylesEnabled == true) { |
| 467 |
|
441 |
|
| 468 |
SWF.ListViewItem listViewItem = (SWF.ListViewItem) objectItem; |
442 |
SWF.ListViewItem listViewItem = (SWF.ListViewItem) objectItem; |
|
Lines 506-512
namespace Mono.UIAutomation.Winforms
Link Here
|
| 506 |
{ |
480 |
{ |
| 507 |
// Using groups |
481 |
// Using groups |
| 508 |
if (showGroups == true |
482 |
if (showGroups == true |
| 509 |
&& Helper.SynchronizedGet<SWF.ListView, bool> (listView, b => listView.View != SWF.View.List) |
483 |
&& listView.InvokeSync (c => c.View != SWF.View.List) |
| 510 |
&& SWF.Application.VisualStylesEnabled == true) { |
484 |
&& SWF.Application.VisualStylesEnabled == true) { |
| 511 |
|
485 |
|
| 512 |
SWF.ListViewItem listViewItem = (SWF.ListViewItem) objectItem; |
486 |
SWF.ListViewItem listViewItem = (SWF.ListViewItem) objectItem; |
|
Lines 535-541
namespace Mono.UIAutomation.Winforms
Link Here
|
| 535 |
|
509 |
|
| 536 |
private void UpdateChildrenStructure (bool forceUpdate) |
510 |
private void UpdateChildrenStructure (bool forceUpdate) |
| 537 |
{ |
511 |
{ |
| 538 |
bool updateView = Helper.SynchronizedGet<SWF.ListView, bool> (listView, b => lastView != listView.View); |
512 |
bool updateView = listView.InvokeSync (c => lastView != c.View); |
| 539 |
|
513 |
|
| 540 |
if (updateView == true || forceUpdate == true) { |
514 |
if (updateView == true || forceUpdate == true) { |
| 541 |
foreach (ListViewGroupProvider groupProvider in groups.Values) { |
515 |
foreach (ListViewGroupProvider groupProvider in groups.Values) { |
|
Lines 556-562
namespace Mono.UIAutomation.Winforms
Link Here
|
| 556 |
ClearItemsList (); |
530 |
ClearItemsList (); |
| 557 |
} |
531 |
} |
| 558 |
|
532 |
|
| 559 |
if (Helper.SynchronizedGet<SWF.ListView, bool> (listView, b => listView.View == SWF.View.Details)) { |
533 |
if (listView.InvokeSync (c => c.View == SWF.View.Details)) { |
| 560 |
if (header == null) { |
534 |
if (header == null) { |
| 561 |
header = new ListViewHeaderProvider (listView); |
535 |
header = new ListViewHeaderProvider (listView); |
| 562 |
header.Initialize (); |
536 |
header.Initialize (); |
|
Lines 565-571
namespace Mono.UIAutomation.Winforms
Link Here
|
| 565 |
} |
539 |
} |
| 566 |
|
540 |
|
| 567 |
foreach (object objectItem |
541 |
foreach (object objectItem |
| 568 |
in Helper.SynchronizedGet<SWF.ListView, SWF.ListView.ListViewItemCollection> (listView, b => listView.Items)) |
542 |
in listView.InvokeSync (c => c.Items)) |
| 569 |
InitializeProviderFrom (objectItem); |
543 |
InitializeProviderFrom (objectItem); |
| 570 |
} |
544 |
} |
| 571 |
|
545 |
|
|
Lines 584-601
namespace Mono.UIAutomation.Winforms
Link Here
|
| 584 |
|
558 |
|
| 585 |
UpdateChildrenStructure (false); |
559 |
UpdateChildrenStructure (false); |
| 586 |
|
560 |
|
| 587 |
lastView = Helper.SynchronizedGet<SWF.ListView, SWF.View> (listView, b => listView.View); |
561 |
lastView = listView.InvokeSync (c => c.View); |
| 588 |
} |
562 |
} |
| 589 |
|
563 |
|
| 590 |
private void OnUIAShowGroupsChanged (object sender, EventArgs args) |
564 |
private void OnUIAShowGroupsChanged (object sender, EventArgs args) |
| 591 |
{ |
565 |
{ |
| 592 |
bool oldValue = showGroups; |
566 |
bool oldValue = showGroups; |
| 593 |
showGroups = Helper.SynchronizedGet<SWF.ListView, bool> (listView, b => listView.ShowGroups); |
567 |
showGroups = listView.InvokeSync (c => c.ShowGroups); |
| 594 |
|
568 |
|
| 595 |
//We will have to regenerate children |
569 |
//We will have to regenerate children |
| 596 |
if (Helper.SynchronizedGet<SWF.ListView, bool> (listView, |
570 |
if (listView.InvokeSync (c => c.ShowGroups != oldValue |
| 597 |
b => listView.ShowGroups != oldValue |
571 |
&& c.View != SWF.View.List)) { |
| 598 |
&& listView.View != SWF.View.List)) { |
|
|
| 599 |
UpdateChildrenStructure (true); |
572 |
UpdateChildrenStructure (true); |
| 600 |
if (SWF.Application.VisualStylesEnabled == true) |
573 |
if (SWF.Application.VisualStylesEnabled == true) |
| 601 |
SetBehavior (GridPatternIdentifiers.Pattern, |
574 |
SetBehavior (GridPatternIdentifiers.Pattern, |
|
Lines 717-739
namespace Mono.UIAutomation.Winforms
Link Here
|
| 717 |
|
690 |
|
| 718 |
private Rect HeaderRectangle { |
691 |
private Rect HeaderRectangle { |
| 719 |
get { |
692 |
get { |
| 720 |
return Helper.SynchronizedGet<SWF.ListView, Rect> (listView, |
693 |
return listView.InvokeSync (c => { |
| 721 |
delegate { |
|
|
| 722 |
|
| 723 |
// Lets Union the Header Bounds |
694 |
// Lets Union the Header Bounds |
| 724 |
SD.Rectangle headerRec = listView.UIAGetHeaderBounds (group); |
695 |
SD.Rectangle headerRec = c.UIAGetHeaderBounds (group); |
| 725 |
SD.Rectangle rectangle = listView.Bounds; |
696 |
SD.Rectangle rectangle = c.Bounds; |
| 726 |
|
697 |
|
| 727 |
headerRec.X += rectangle.X; |
698 |
headerRec.X += rectangle.X; |
| 728 |
headerRec.Y += rectangle.Y; |
699 |
headerRec.Y += rectangle.Y; |
| 729 |
|
700 |
|
| 730 |
if (listView.FindForm () == listView.Parent) |
701 |
if (c.FindForm () == c.Parent) |
| 731 |
headerRec = listView.TopLevelControl.RectangleToScreen (headerRec); |
702 |
headerRec = c.TopLevelControl.RectangleToScreen (headerRec); |
| 732 |
else |
703 |
else |
| 733 |
headerRec = listView.Parent.RectangleToScreen (headerRec); |
704 |
headerRec = c.Parent.RectangleToScreen (headerRec); |
| 734 |
|
705 |
|
| 735 |
return Helper.RectangleToRect (headerRec); |
706 |
return Helper.RectangleToRect (headerRec); |
| 736 |
|
|
|
| 737 |
}); |
707 |
}); |
| 738 |
} |
708 |
} |
| 739 |
} |
709 |
} |
|
Lines 839-845
namespace Mono.UIAutomation.Winforms
Link Here
|
| 839 |
{ |
809 |
{ |
| 840 |
base.InitializeChildControlStructure (); |
810 |
base.InitializeChildControlStructure (); |
| 841 |
|
811 |
|
| 842 |
Helper.SynchronizedSet (listView, delegate { |
812 |
listView.InvokeSync (delegate { |
| 843 |
//Event used to update columns in ListItem when View.Details |
813 |
//Event used to update columns in ListItem when View.Details |
| 844 |
listView.Columns.UIACollectionChanged += OnUIAColumnsCollectionChanged; |
814 |
listView.Columns.UIACollectionChanged += OnUIAColumnsCollectionChanged; |
| 845 |
|
815 |
|
|
Lines 857-863
namespace Mono.UIAutomation.Winforms
Link Here
|
| 857 |
{ |
827 |
{ |
| 858 |
base.FinalizeChildControlStructure (); |
828 |
base.FinalizeChildControlStructure (); |
| 859 |
|
829 |
|
| 860 |
Helper.SynchronizedSet (listView, delegate { |
830 |
listView.InvokeSync (delegate { |
| 861 |
//Event used to update columns in ListItem when View.Details |
831 |
//Event used to update columns in ListItem when View.Details |
| 862 |
listView.Columns.UIACollectionChanged -= OnUIAColumnsCollectionChanged; |
832 |
listView.Columns.UIACollectionChanged -= OnUIAColumnsCollectionChanged; |
| 863 |
}); |
833 |
}); |
|
Lines 961-977
namespace Mono.UIAutomation.Winforms
Link Here
|
| 961 |
else if (propertyId == AutomationElementIdentifiers.IsEnabledProperty.Id) |
931 |
else if (propertyId == AutomationElementIdentifiers.IsEnabledProperty.Id) |
| 962 |
return true; |
932 |
return true; |
| 963 |
else if (propertyId == AutomationElementIdentifiers.BoundingRectangleProperty.Id) { |
933 |
else if (propertyId == AutomationElementIdentifiers.BoundingRectangleProperty.Id) { |
| 964 |
return Helper.SynchronizedGet<SWF.ListView, Rect> (headerProvider.ListView, delegate { |
934 |
return headerProvider.ListView.InvokeSync (c => { |
| 965 |
int indexOf = headerProvider.ListView.Columns.IndexOf (columnHeader); |
935 |
int indexOf = c.Columns.IndexOf (columnHeader); |
| 966 |
Rect headerBounds |
936 |
Rect headerBounds |
| 967 |
= (Rect) headerProvider.GetPropertyValue (AutomationElementIdentifiers.BoundingRectangleProperty.Id); |
937 |
= (Rect) headerProvider.GetPropertyValue (AutomationElementIdentifiers.BoundingRectangleProperty.Id); |
| 968 |
if (headerBounds.IsEmpty) |
938 |
if (headerBounds.IsEmpty) |
| 969 |
return headerBounds; |
939 |
return headerBounds; |
| 970 |
|
940 |
|
| 971 |
for (int index = 0; index < indexOf; index++) |
941 |
for (int index = 0; index < indexOf; index++) |
| 972 |
headerBounds.X += headerProvider.ListView.Columns [index].Width; |
942 |
headerBounds.X += c.Columns [index].Width; |
| 973 |
|
943 |
|
| 974 |
headerBounds.Width = headerProvider.ListView.Columns [indexOf].Width; |
944 |
headerBounds.Width = c.Columns [indexOf].Width; |
| 975 |
|
945 |
|
| 976 |
return headerBounds; |
946 |
return headerBounds; |
| 977 |
}); |
947 |
}); |
|
Lines 1025-1035
namespace Mono.UIAutomation.Winforms
Link Here
|
| 1025 |
public ListViewListItemEditProvider GetEditProviderAtColumn (int column) |
995 |
public ListViewListItemEditProvider GetEditProviderAtColumn (int column) |
| 1026 |
{ |
996 |
{ |
| 1027 |
if (column < 0 |
997 |
if (column < 0 |
| 1028 |
|| column >= Helper.SynchronizedGet<SWF.ListView, int> (listView, c => listView.Columns.Count)) |
998 |
|| listView.InvokeSync (c => column >= c.Columns.Count)) |
| 1029 |
return null; |
999 |
return null; |
| 1030 |
|
1000 |
|
| 1031 |
ListViewListItemEditProvider editProvider = null; |
1001 |
ListViewListItemEditProvider editProvider = null; |
| 1032 |
providers.TryGetValue (Helper.SynchronizedGet<SWF.ListView, SWF.ColumnHeader> (listView, c => listView.Columns [column]), |
1002 |
providers.TryGetValue (listView.InvokeSync (c => c.Columns [column]), |
| 1033 |
out editProvider); |
1003 |
out editProvider); |
| 1034 |
|
1004 |
|
| 1035 |
return editProvider; |
1005 |
return editProvider; |
|
Lines 1041-1047
namespace Mono.UIAutomation.Winforms
Link Here
|
| 1041 |
|
1011 |
|
| 1042 |
protected override object GetProviderPropertyValue (int propertyId) |
1012 |
protected override object GetProviderPropertyValue (int propertyId) |
| 1043 |
{ |
1013 |
{ |
| 1044 |
if (Helper.SynchronizedGet<SWF.ListView, bool> (ListView, b => ListView.View == SWF.View.Details)) { |
1014 |
if (ListView.InvokeSync (c => c.View == SWF.View.Details)) { |
| 1045 |
//According to: http://msdn.microsoft.com/en-us/library/ms742561.aspx |
1015 |
//According to: http://msdn.microsoft.com/en-us/library/ms742561.aspx |
| 1046 |
if (propertyId == AutomationElementIdentifiers.ControlTypeProperty.Id) |
1016 |
if (propertyId == AutomationElementIdentifiers.ControlTypeProperty.Id) |
| 1047 |
return ControlType.DataItem.Id; |
1017 |
return ControlType.DataItem.Id; |
|
Lines 1079-1085
namespace Mono.UIAutomation.Winforms
Link Here
|
| 1079 |
if (lastView == SWF.View.Details) |
1049 |
if (lastView == SWF.View.Details) |
| 1080 |
AddEditChildren (); |
1050 |
AddEditChildren (); |
| 1081 |
|
1051 |
|
| 1082 |
if (Helper.SynchronizedGet<SWF.ListView, bool> (listView, b => listView.CheckBoxes == true)) { |
1052 |
if (listView.InvokeSync (c => c.CheckBoxes)) { |
| 1083 |
checkboxProvider = new ListViewListItemCheckBoxProvider (this); |
1053 |
checkboxProvider = new ListViewListItemCheckBoxProvider (this); |
| 1084 |
checkboxProvider.Initialize (); |
1054 |
checkboxProvider.Initialize (); |
| 1085 |
AddChildProvider (checkboxProvider); |
1055 |
AddChildProvider (checkboxProvider); |
|
Lines 1103-1110
namespace Mono.UIAutomation.Winforms
Link Here
|
| 1103 |
private void AddEditChildren () |
1073 |
private void AddEditChildren () |
| 1104 |
{ |
1074 |
{ |
| 1105 |
foreach (SWF.ColumnHeader column |
1075 |
foreach (SWF.ColumnHeader column |
| 1106 |
in Helper.SynchronizedGet<SWF.ListView, SWF.ListView.ColumnHeaderCollection> (listView, |
1076 |
in listView.InvokeSync (c => c.Columns)) { |
| 1107 |
c => listView.Columns)) { |
|
|
| 1108 |
ListViewListItemEditProvider editProvider |
1077 |
ListViewListItemEditProvider editProvider |
| 1109 |
= new ListViewListItemEditProvider (column, this); |
1078 |
= new ListViewListItemEditProvider (column, this); |
| 1110 |
editProvider.Initialize (); |
1079 |
editProvider.Initialize (); |
|
Lines 1140-1157
namespace Mono.UIAutomation.Winforms
Link Here
|
| 1140 |
if (lastView == SWF.View.Details) { |
1109 |
if (lastView == SWF.View.Details) { |
| 1141 |
providers.Clear (); |
1110 |
providers.Clear (); |
| 1142 |
OnNavigationChildrenCleared (); |
1111 |
OnNavigationChildrenCleared (); |
| 1143 |
} else if (Helper.SynchronizedGet<SWF.ListView, bool> (listView, |
1112 |
} else if (listView.InvokeSync (c => c.View == SWF.View.Details)) |
| 1144 |
c => listView.View == SWF.View.Details)) |
|
|
| 1145 |
AddEditChildren (); |
1113 |
AddEditChildren (); |
| 1146 |
|
1114 |
|
| 1147 |
lastView = Helper.SynchronizedGet<SWF.ListView, SWF.View> (listView, c => listView.View); |
1115 |
lastView = listView.InvokeSync (c => c.View); |
| 1148 |
} |
1116 |
} |
| 1149 |
|
1117 |
|
| 1150 |
private void OnUIAColumnsCollectionChanged (object sender, |
1118 |
private void OnUIAColumnsCollectionChanged (object sender, |
| 1151 |
CollectionChangeEventArgs args) |
1119 |
CollectionChangeEventArgs args) |
| 1152 |
{ |
1120 |
{ |
| 1153 |
if (Helper.SynchronizedGet<SWF.ListView, bool> (listView, |
1121 |
if (listView.InvokeSync (c => c.View != SWF.View.Details)) |
| 1154 |
c => listView.View != SWF.View.Details)) |
|
|
| 1155 |
return; |
1122 |
return; |
| 1156 |
|
1123 |
|
| 1157 |
SWF.ColumnHeader column = (SWF.ColumnHeader) args.Element; |
1124 |
SWF.ColumnHeader column = (SWF.ColumnHeader) args.Element; |
|
Lines 1258-1265
namespace Mono.UIAutomation.Winforms
Link Here
|
| 1258 |
IValueProvider valueProvider = (IValueProvider) GetBehavior (ValuePatternIdentifiers.Pattern); |
1225 |
IValueProvider valueProvider = (IValueProvider) GetBehavior (ValuePatternIdentifiers.Pattern); |
| 1259 |
return valueProvider.Value; |
1226 |
return valueProvider.Value; |
| 1260 |
} else if (propertyId == AutomationElementIdentifiers.IsKeyboardFocusableProperty.Id) |
1227 |
} else if (propertyId == AutomationElementIdentifiers.IsKeyboardFocusableProperty.Id) |
| 1261 |
return IsFirstColumn || Helper.SynchronizedGet<SWF.ListView, bool> (itemProvider.ListView, |
1228 |
return IsFirstColumn || itemProvider.ListView.InvokeSync (c => c.FullRowSelect); |
| 1262 |
b => itemProvider.ListView.FullRowSelect); |
|
|
| 1263 |
else if (propertyId == AutomationElementIdentifiers.HasKeyboardFocusProperty.Id) { |
1229 |
else if (propertyId == AutomationElementIdentifiers.HasKeyboardFocusProperty.Id) { |
| 1264 |
if (IsFirstColumn) |
1230 |
if (IsFirstColumn) |
| 1265 |
return itemProvider.GetPropertyValue (propertyId); |
1231 |
return itemProvider.GetPropertyValue (propertyId); |
|
Lines 1270-1293
namespace Mono.UIAutomation.Winforms
Link Here
|
| 1270 |
else if (propertyId == AutomationElementIdentifiers.LabeledByProperty.Id) |
1236 |
else if (propertyId == AutomationElementIdentifiers.LabeledByProperty.Id) |
| 1271 |
return null; |
1237 |
return null; |
| 1272 |
else if (propertyId == AutomationElementIdentifiers.HelpTextProperty.Id) { |
1238 |
else if (propertyId == AutomationElementIdentifiers.HelpTextProperty.Id) { |
| 1273 |
if (Helper.SynchronizedGet<SWF.ListView, bool> (ItemProvider.ListView, |
1239 |
if (itemProvider.ListView.InvokeSync (c => c.Columns.Count == 0 |
| 1274 |
b => ItemProvider.ListView.Columns.Count == 0 |
1240 |
|| c.Columns [0] == header)) |
| 1275 |
|| ItemProvider.ListView.Columns [0] == header)) |
|
|
| 1276 |
return string.Empty; |
1241 |
return string.Empty; |
| 1277 |
else |
1242 |
else |
| 1278 |
return itemProvider.ListViewItem.ToolTipText; |
1243 |
return itemProvider.ListViewItem.ToolTipText; |
| 1279 |
} else if (propertyId == AutomationElementIdentifiers.BoundingRectangleProperty.Id) { |
1244 |
} else if (propertyId == AutomationElementIdentifiers.BoundingRectangleProperty.Id) { |
| 1280 |
return Helper.SynchronizedGet<SWF.ListView, Rect> (itemProvider.ListView, delegate { |
1245 |
return itemProvider.ListView.InvokeSync (c => { |
| 1281 |
int indexOf = itemProvider.ListView.Columns.IndexOf (header); |
1246 |
int indexOf = c.Columns.IndexOf (header); |
| 1282 |
Rect itemBounds |
1247 |
Rect itemBounds |
| 1283 |
= (Rect) itemProvider.GetPropertyValue (AutomationElementIdentifiers.BoundingRectangleProperty.Id); |
1248 |
= (Rect) itemProvider.GetPropertyValue (AutomationElementIdentifiers.BoundingRectangleProperty.Id); |
| 1284 |
if (itemBounds.IsEmpty) |
1249 |
if (itemBounds.IsEmpty) |
| 1285 |
return itemBounds; |
1250 |
return itemBounds; |
| 1286 |
|
1251 |
|
| 1287 |
for (int index = 0; index < indexOf; index++) |
1252 |
for (int index = 0; index < indexOf; index++) |
| 1288 |
itemBounds.X += itemProvider.ListView.Columns [index].Width; |
1253 |
itemBounds.X += c.Columns [index].Width; |
| 1289 |
|
1254 |
|
| 1290 |
itemBounds.Width = itemProvider.ListView.Columns [indexOf].Width; |
1255 |
itemBounds.Width = c.Columns [indexOf].Width; |
| 1291 |
|
1256 |
|
| 1292 |
return itemBounds; |
1257 |
return itemBounds; |
| 1293 |
}); |
1258 |
}); |