View | Details | Raw Unified | Return to bug 494034
Collapse All | Expand All

(-)a/UIAutomationWinforms/UIAutomationWinforms/Makefile.am (-1 / +1 lines)
Lines 296-303 FILES = \ Link Here
296
	Mono.UIAutomation.Winforms.Events/DateTimePicker/AutomationNamePropertyEvent.cs \
296
	Mono.UIAutomation.Winforms.Events/DateTimePicker/AutomationNamePropertyEvent.cs \
297
	Mono.UIAutomation.Winforms.Events/DateTimePicker/ButtonInvokePatternInvokedEvent.cs \
297
	Mono.UIAutomation.Winforms.Events/DateTimePicker/ButtonInvokePatternInvokedEvent.cs \
298
	Mono.UIAutomation.Winforms.Events/DateTimePicker/CheckboxAutomationHasKeyboardFocusPropertyEvent.cs \
298
	Mono.UIAutomation.Winforms.Events/DateTimePicker/CheckboxAutomationHasKeyboardFocusPropertyEvent.cs \
299
	Mono.UIAutomation.Winforms.Events/DateTimePicker/PartAutomationIsEnabledPropertyEvent.cs \
300
	Mono.UIAutomation.Winforms.Events/DateTimePicker/PartAutomationHasKeyboardFocusPropertyEvent.cs \
299
	Mono.UIAutomation.Winforms.Events/DateTimePicker/PartAutomationHasKeyboardFocusPropertyEvent.cs \
300
	Mono.UIAutomation.Winforms.Events/DateTimePicker/PartAutomationIsEnabledPropertyEvent.cs \
301
	Mono.UIAutomation.Winforms.Events/DateTimePicker/PartListItemAutomationHasKeyboardFocusPropertyEvent.cs \
301
	Mono.UIAutomation.Winforms.Events/DateTimePicker/PartListItemAutomationHasKeyboardFocusPropertyEvent.cs \
302
	Mono.UIAutomation.Winforms.Events/DateTimePicker/PartListItemSelectionItemPatternElementSelectedEvent.cs \
302
	Mono.UIAutomation.Winforms.Events/DateTimePicker/PartListItemSelectionItemPatternElementSelectedEvent.cs \
303
	Mono.UIAutomation.Winforms.Events/DateTimePicker/PartListItemSelectionItemPatternIsSelectedEvent.cs \
303
	Mono.UIAutomation.Winforms.Events/DateTimePicker/PartListItemSelectionItemPatternIsSelectedEvent.cs \
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/BalloonWindow/EmbeddedImageProviderBehavior.cs (-4 / +3 lines)
Lines 67-79 namespace Mono.UIAutomation.Winforms.Behaviors.BalloonWindow Link Here
67
				// from ThemeWin32Classic.cs
67
				// from ThemeWin32Classic.cs
68
				int borderSize = 8;
68
				int borderSize = 8;
69
				int iconSize = 0;
69
				int iconSize = 0;
70
				if (Helper.SynchronizedGet<SWF.NotifyIcon.BalloonWindow, bool> (balloonWindow,
70
				if (balloonWindow.InvokeSync (c => !(c.Icon == SWF.ToolTipIcon.None)))
71
				                                                                b => !(balloonWindow.Icon == SWF.ToolTipIcon.None)))
72
					iconSize = 16;
71
					iconSize = 16;
73
				if (iconSize == 0)
72
				if (iconSize == 0)
74
					return Rect.Empty;
73
					return Rect.Empty;
75
				int imageX, imageY, imageWidth, imageHeight;
74
				int imageX, imageY, imageWidth, imageHeight;
76
75
	
77
				Rect balloonRect 
76
				Rect balloonRect 
78
					= (Rect) Provider.GetPropertyValue (AutomationElementIdentifiers.BoundingRectangleProperty.Id);
77
					= (Rect) Provider.GetPropertyValue (AutomationElementIdentifiers.BoundingRectangleProperty.Id);
79
			
78
			
Lines 81-87 namespace Mono.UIAutomation.Winforms.Behaviors.BalloonWindow Link Here
81
				imageY = (int) balloonRect.Y + borderSize;
80
				imageY = (int) balloonRect.Y + borderSize;
82
				imageWidth = iconSize;
81
				imageWidth = iconSize;
83
				imageHeight = iconSize;
82
				imageHeight = iconSize;
84
83
	
85
				Rect imageRect = new Rect (imageX, imageY, imageWidth, imageHeight);
84
				Rect imageRect = new Rect (imageX, imageY, imageWidth, imageHeight);
86
				balloonRect.Intersect (imageRect);
85
				balloonRect.Intersect (imageRect);
87
				return balloonRect;
86
				return balloonRect;
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/Button/InvokeProviderBehavior.cs (-4 / +2 lines)
Lines 90-101 namespace Mono.UIAutomation.Winforms.Behaviors.Button Link Here
90
		
90
		
91
		public virtual void Invoke ()
91
		public virtual void Invoke ()
92
		{
92
		{
93
			if (Helper.SynchronizedGet<SWF.Button, bool> (button, b => !b.Enabled)) 
93
			if (button.InvokeSync (c => !c.Enabled))
94
				throw new ElementNotEnabledException ();
94
				throw new ElementNotEnabledException ();
95
95
96
			Helper.SynchronizedSet (button, delegate {
96
			button.InvokeSync (delegate { button.PerformClick (); });
97
				button.PerformClick ();
98
			});
99
		}
97
		}
100
		
98
		
101
		#endregion
99
		#endregion
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/CheckBox/ToggleProviderBehavior.cs (-18 / +12 lines)
Lines 87-114 namespace Mono.UIAutomation.Winforms.Behaviors.CheckBox Link Here
87
	
87
	
88
		public void Toggle ()
88
		public void Toggle ()
89
		{
89
		{
90
			if (!Helper.SynchronizedGet<SWF.CheckBox, bool> (checkbox, c => c.Enabled))
90
			if (checkbox.InvokeSync (c => !c.Enabled))
91
				throw new ElementNotEnabledException ();
91
				throw new ElementNotEnabledException ();
92
92
93
			switch (Helper.SynchronizedGet<SWF.CheckBox, SWF.CheckState> (checkbox, 
93
			SWF.CheckState newState = SWF.CheckState.Checked;
94
			                                                              c => c.CheckState)) {
94
95
			switch (checkbox.InvokeSync (c => c.CheckState)) {
95
			case SWF.CheckState.Checked:
96
			case SWF.CheckState.Checked:
96
				PerformToggle (checkbox, SWF.CheckState.Unchecked);
97
				newState = SWF.CheckState.Unchecked;
97
				break;
98
				break;
98
			case SWF.CheckState.Unchecked:
99
			case SWF.CheckState.Unchecked:
99
				if (Helper.SynchronizedGet<SWF.CheckBox, bool> (checkbox, 
100
				if (checkbox.InvokeSync (c => c.ThreeState))
100
				                                                c => c.ThreeState))
101
					newState = SWF.CheckState.Indeterminate;
101
					PerformToggle (checkbox, SWF.CheckState.Indeterminate);
102
				else
102
				else
103
					PerformToggle (checkbox, SWF.CheckState.Checked);
103
					newState = SWF.CheckState.Checked;
104
				break;
104
				break;
105
			// Control could still have been set to intermediate
105
			// Control could still have been set to intermediate
106
			// programatically, regardless of ThreeState value.
106
			// programatically, regardless of ThreeState value.
107
			case SWF.CheckState.Indeterminate:
107
			case SWF.CheckState.Indeterminate:
108
			default:
108
			default:
109
				PerformToggle (checkbox, SWF.CheckState.Checked);
109
				newState = SWF.CheckState.Checked;
110
				break;
110
				break;
111
			}
111
			}
112
113
			checkbox.InvokeSync (delegate { PerformToggle (newState); });
112
		}
114
		}
113
115
114
		public ToggleState ToggleState {
116
		public ToggleState ToggleState {
Lines 129-142 namespace Mono.UIAutomation.Winforms.Behaviors.CheckBox Link Here
129
		
131
		
130
		#region Private Methods
132
		#region Private Methods
131
		
133
		
132
		private void PerformToggle (SWF.CheckBox checkbox, SWF.CheckState state)
134
		private void PerformToggle (SWF.CheckState state)
133
		{
135
		{
134
			if (checkbox.InvokeRequired == true) {
135
				checkbox.BeginInvoke (new PerformToggleDelegate (PerformToggle),
136
				                      new object [] { checkbox, state });
137
				return;
138
			}
139
140
			// NOTE: We can count on presence of InvokeOnClick;
136
			// NOTE: We can count on presence of InvokeOnClick;
141
			//       it is a protected member of CheckBox.
137
			//       it is a protected member of CheckBox.
142
			//
138
			//
Lines 153-158 namespace Mono.UIAutomation.Winforms.Behaviors.CheckBox Link Here
153
		}
149
		}
154
		#endregion
150
		#endregion
155
	}
151
	}
156
	
157
	delegate void PerformToggleDelegate (SWF.CheckBox checkbox, SWF.CheckState state);
158
}
152
}
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/ComboBox/ButtonInvokeBehavior.cs (-20 / +6 lines)
Lines 83-111 namespace Mono.UIAutomation.Winforms.Behaviors.ComboBox Link Here
83
		
83
		
84
		public void Invoke ()
84
		public void Invoke ()
85
		{
85
		{
86
			if (Helper.SynchronizedGet<SWF.Control, bool> (Provider.Control, 
86
			if (Provider.Control.InvokeSync (b => !b.Enabled))
87
			                                                b => !b.Enabled))
88
				throw new ElementNotEnabledException ();
87
				throw new ElementNotEnabledException ();
89
			
90
			PerformComboBoxClick ((SWF.ComboBox) Provider.Control);
91
		}
92
		
93
		#endregion	
94
88
95
		#region Private Methods
89
			SWF.ComboBox combobox = (SWF.ComboBox) Provider.Control;
96
		
90
			combobox.InvokeSync (delegate {
97
		private void PerformComboBoxClick (SWF.ComboBox combobox)
91
				combobox.DroppedDown = !combobox.DroppedDown;
98
		{
92
			});
99
	        if (Provider.Control.InvokeRequired == true) {
100
	            Provider.Control.BeginInvoke (new PerformComboBoxClickDelegate (PerformComboBoxClick),
101
				                              new object [] { combobox });
102
	            return;
103
	        }
104
			combobox.DroppedDown = !combobox.DroppedDown;
105
		}
93
		}
106
		
94
		
107
		#endregion
95
		#endregion	
108
	}
96
	}
109
	
110
	delegate void PerformComboBoxClickDelegate (SWF.ComboBox combobox);
111
}
97
}
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/ComboBox/ExpandCollapseProviderBehavior.cs (-8 / +5 lines)
Lines 80-87 namespace Mono.UIAutomation.Winforms.Behaviors.ComboBox Link Here
80
		public ExpandCollapseState ExpandCollapseState {
80
		public ExpandCollapseState ExpandCollapseState {
81
			get {
81
			get {
82
				SWF.ComboBox combobox = (SWF.ComboBox) Provider.Control;
82
				SWF.ComboBox combobox = (SWF.ComboBox) Provider.Control;
83
				if (Helper.SynchronizedGet<SWF.ComboBox, bool> (combobox, 
83
				if (combobox.InvokeSync (c => c.DroppedDown))
84
				                                                c => c.DroppedDown))
85
					return ExpandCollapseState.Expanded;
84
					return ExpandCollapseState.Expanded;
86
				else
85
				else
87
					return ExpandCollapseState.Collapsed;
86
					return ExpandCollapseState.Collapsed;
Lines 92-102 namespace Mono.UIAutomation.Winforms.Behaviors.ComboBox Link Here
92
		{
91
		{
93
			SWF.ComboBox combobox = (SWF.ComboBox) Provider.Control;
92
			SWF.ComboBox combobox = (SWF.ComboBox) Provider.Control;
94
			
93
			
95
			if (Helper.SynchronizedGet<SWF.ComboBox, bool> (combobox, 
94
			if (combobox.InvokeSync (c => !c.Enabled))
96
			                                                c => !c.Enabled))
97
				throw new ElementNotEnabledException ();
95
				throw new ElementNotEnabledException ();
98
			
96
			
99
			Helper.SynchronizedSet (combobox, delegate {
97
			combobox.InvokeSync (delegate {
100
				combobox.DroppedDown = false;
98
				combobox.DroppedDown = false;
101
			});
99
			});
102
		}
100
		}
Lines 105-115 namespace Mono.UIAutomation.Winforms.Behaviors.ComboBox Link Here
105
		{
103
		{
106
			SWF.ComboBox combobox = (SWF.ComboBox) Provider.Control;
104
			SWF.ComboBox combobox = (SWF.ComboBox) Provider.Control;
107
			
105
			
108
			if (Helper.SynchronizedGet<SWF.ComboBox, bool> (combobox, 
106
			if (combobox.InvokeSync (c => !c.Enabled))
109
			                                                c => !c.Enabled))
110
				throw new ElementNotEnabledException ();
107
				throw new ElementNotEnabledException ();
111
108
112
			Helper.SynchronizedSet (combobox, delegate {
109
			combobox.InvokeSync (delegate {
113
				combobox.DroppedDown = true;
110
				combobox.DroppedDown = true;
114
			});
111
			});
115
		}
112
		}
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/ComboBox/ListBoxSelectionProviderBehavior.cs (-2 / +1 lines)
Lines 71-78 namespace Mono.UIAutomation.Winforms.Behaviors.ComboBox Link Here
71
71
72
		public override bool IsSelectionRequired {
72
		public override bool IsSelectionRequired {
73
			get {
73
			get {
74
				return Helper.SynchronizedGet<SWF.ComboBox, bool> ((SWF.ComboBox) Provider.Control,
74
				return ((SWF.ComboBox) Provider.Control).InvokeSync (c => c.SelectedIndex != -1);
75
				                                                   c => c.SelectedIndex != -1);
76
			}
75
			}
77
		}
76
		}
78
		
77
		
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/ComboBox/SelectionProviderBehavior.cs (-2 / +1 lines)
Lines 96-103 namespace Mono.UIAutomation.Winforms.Behaviors.ComboBox Link Here
96
96
97
		public virtual bool IsSelectionRequired {
97
		public virtual bool IsSelectionRequired {
98
			get {
98
			get {
99
				return Helper.SynchronizedGet<SWF.ComboBox, bool> ((SWF.ComboBox) Provider.Control,
99
				return ((SWF.ComboBox) Provider.Control).InvokeSync (c => c.SelectedIndex != -1);
100
				                                                   c => c.SelectedIndex != -1);
101
			}
100
			}
102
		}
101
		}
103
		
102
		
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/ComboBox/ValueProviderBehavior.cs (-3 / +3 lines)
Lines 83-93 namespace Mono.UIAutomation.Winforms.Behaviors.ComboBox Link Here
83
		#region IValueProvider Interface
83
		#region IValueProvider Interface
84
		
84
		
85
		public bool IsReadOnly {
85
		public bool IsReadOnly {
86
			get { return Helper.SynchronizedGet<Control, bool> (Provider.Control, c => !c.Enabled); }
86
			get { return Provider.Control.InvokeSync (c => !c.Enabled); }
87
		}
87
		}
88
88
89
		public string Value {
89
		public string Value {
90
			get { return Helper.SynchronizedGet<Control, string> (Provider.Control, c => c.Text); }
90
			get { return Provider.Control.InvokeSync (c => c.Text); }
91
		}
91
		}
92
92
93
		public void SetValue (string value)
93
		public void SetValue (string value)
Lines 95-101 namespace Mono.UIAutomation.Winforms.Behaviors.ComboBox Link Here
95
			if (IsReadOnly == true)
95
			if (IsReadOnly == true)
96
				throw new ElementNotEnabledException ();
96
				throw new ElementNotEnabledException ();
97
97
98
			Helper.SynchronizedSet (Provider.Control, delegate {
98
			Provider.Control.InvokeSync (delegate {
99
				Provider.Control.Text = value;
99
				Provider.Control.Text = value;
100
			});
100
			});
101
		}
101
		}
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/Form/TransformProviderBehavior.cs (-9 / +4 lines)
Lines 91-108 namespace Mono.UIAutomation.Winforms.Behaviors.Form Link Here
91
	
91
	
92
		public bool CanMove {
92
		public bool CanMove {
93
			get {
93
			get {
94
				//return Helper.SynchronizedGet<SWF.Form, bool> (form,
94
				return form.InvokeSync (f => f.WindowState == SWF.FormWindowState.Normal);
95
				return Helper.SynchronizedGet<SWF.Form, bool> ((SWF.Form) Provider.Control,
96
				                                               f => f.WindowState == SWF.FormWindowState.Normal);
97
			}
95
			}
98
		}
96
		}
99
97
100
		public bool CanResize {
98
		public bool CanResize {
101
			get {
99
			get {
102
				//switch (Helper.SynchronizedGet<SWF.Form, SWF.FormBorderStyle> (form,
100
				switch (form.InvokeSync (f => f.FormBorderStyle)) {
103
				//switch (Helper.SynchronizedGet<SWF.Form, SWF.FormBorderStyle> ((SWF.Form) Provider.Control,
104
				//                                                               v => v.FormBorderStyle)) {
105
				switch (form.FormBorderStyle) {
106
				case SWF.FormBorderStyle.Fixed3D:
101
				case SWF.FormBorderStyle.Fixed3D:
107
				case SWF.FormBorderStyle.FixedDialog:
102
				case SWF.FormBorderStyle.FixedDialog:
108
				case SWF.FormBorderStyle.FixedSingle:
103
				case SWF.FormBorderStyle.FixedSingle:
Lines 125-131 namespace Mono.UIAutomation.Winforms.Behaviors.Form Link Here
125
			if (!CanMove)
120
			if (!CanMove)
126
				throw new InvalidOperationException ("CanMove is false");
121
				throw new InvalidOperationException ("CanMove is false");
127
122
128
			Helper.SynchronizedSet (form, delegate {
123
			form.InvokeSync (delegate {
129
				form.Location = new Point ((int) x, (int) y);
124
				form.Location = new Point ((int) x, (int) y);
130
			});
125
			});
131
		}
126
		}
Lines 137-143 namespace Mono.UIAutomation.Winforms.Behaviors.Form Link Here
137
			if (!CanResize)
132
			if (!CanResize)
138
				throw new InvalidOperationException ("CanResize is false");
133
				throw new InvalidOperationException ("CanResize is false");
139
134
140
			Helper.SynchronizedSet (form, delegate {
135
			form.InvokeSync (delegate { 
141
				form.Size = new Size ((int) width, (int) height);
136
				form.Size = new Size ((int) width, (int) height);
142
			});
137
			});
143
		}
138
		}
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/Form/WindowProviderBehavior.cs (-30 / +8 lines)
Lines 141-148 namespace Mono.UIAutomation.Winforms.Behaviors.Form Link Here
141
		
141
		
142
		public void SetVisualState (WindowVisualState state)
142
		public void SetVisualState (WindowVisualState state)
143
		{
143
		{
144
			SWF.FormWindowState newState = Helper.SynchronizedGet<SWF.Form, SWF.FormWindowState> (form,
144
			SWF.FormWindowState newState = form.InvokeSync (f => f.WindowState);
145
			                                                                                      f => f.WindowState);
146
			switch (state) {
145
			switch (state) {
147
			case WindowVisualState.Maximized:
146
			case WindowVisualState.Maximized:
148
				newState = SWF.FormWindowState.Maximized;
147
				newState = SWF.FormWindowState.Maximized;
Lines 155-202 namespace Mono.UIAutomation.Winforms.Behaviors.Form Link Here
155
				break;
154
				break;
156
			}
155
			}
157
156
158
			Helper.SynchronizedSet (form, delegate {
157
			form.InvokeSync (delegate { form.WindowState = newState; });
159
				form.WindowState = newState;
160
			});
161
		}
158
		}
162
		
159
		
163
		public void Close ()
160
		public void Close ()
164
		{
161
		{
165
			Helper.SynchronizedSet (form, delegate {
162
			form.InvokeSync (delegate { form.Close (); });
166
				form.Close ();
167
			});
168
		}
163
		}
169
		
164
		
170
		public bool Minimizable {
165
		public bool Minimizable {
171
			get {
166
			get { return form.InvokeSync (f => f.MinimizeBox); }
172
				//return Helper.SynchronizedGet<SWF.Form, bool> (form,
173
				return Helper.SynchronizedGet<SWF.Form, bool> ((SWF.Form) Provider.Control,
174
				                                               f => f.MinimizeBox);
175
			}
176
		}
167
		}
177
		
168
		
178
		public bool Maximizable {
169
		public bool Maximizable {
179
			get {
170
			get { return form.InvokeSync (f => f.MaximizeBox); }
180
				//return Helper.SynchronizedGet<SWF.Form, bool> (form,
181
				return Helper.SynchronizedGet<SWF.Form, bool> ((SWF.Form) Provider.Control,
182
				                                               f => f.MaximizeBox);
183
			}
184
		}
171
		}
185
		
172
		
186
		public bool IsTopmost {
173
		public bool IsTopmost {
187
			get {
174
			get { return form.InvokeSync (f => f.TopMost); }
188
				//return Helper.SynchronizedGet<SWF.Form, bool> (form,
189
				return Helper.SynchronizedGet<SWF.Form, bool> ((SWF.Form) Provider.Control,
190
				                                               f => f.TopMost);
191
			}
192
		}
175
		}
193
		
176
		
194
		public bool IsModal {
177
		public bool IsModal {
195
			get {
178
			get { return form.InvokeSync (f => f.Modal); }
196
				return Helper.SynchronizedGet<SWF.Form, bool> ((SWF.Form) Provider.Control,
197
//				return Helper.SynchronizedGet<SWF.Form, bool> (form,
198
				                                               f => f.Modal);
199
			}
200
		}
179
		}
201
		
180
		
202
		public WindowInteractionState InteractionState {
181
		public WindowInteractionState InteractionState {
Lines 211-218 namespace Mono.UIAutomation.Winforms.Behaviors.Form Link Here
211
		
190
		
212
		public WindowVisualState VisualState {
191
		public WindowVisualState VisualState {
213
			get {
192
			get {
214
				switch (Helper.SynchronizedGet<SWF.Form, SWF.FormWindowState> (form,
193
				switch (form.InvokeSync (f => f.WindowState)) {
215
				                                                               f => f.WindowState)) {
216
				case SWF.FormWindowState.Maximized:
194
				case SWF.FormWindowState.Maximized:
217
					return WindowVisualState.Maximized;
195
					return WindowVisualState.Maximized;
218
				case SWF.FormWindowState.Minimized:
196
				case SWF.FormWindowState.Minimized:
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/Generic/ScrollProviderBehavior.cs (-36 / +19 lines)
Lines 105-116 namespace Mono.UIAutomation.Winforms.Behaviors.Generic Link Here
105
				if (HorizontallyScrollable == false)
105
				if (HorizontallyScrollable == false)
106
					return ScrollPatternIdentifiers.NoScroll;
106
					return ScrollPatternIdentifiers.NoScroll;
107
				else {
107
				else {
108
					return Helper.SynchronizedGet<SWF.ScrollBar, double> (hscrollbar,
108
					return hscrollbar.InvokeSync (c => {
109
					                                                      delegate {
109
						if (c.Maximum == 0)
110
						if (hscrollbar.Maximum == 0)
111
							return ScrollPatternIdentifiers.NoScroll;
110
							return ScrollPatternIdentifiers.NoScroll;
112
						else
111
						else
113
							return (hscrollbar.Value * 100) / hscrollbar.Maximum;
112
							return (double) ((c.Value * 100) / c.Maximum);
114
					});
113
					});
115
				}
114
				}
116
			}
115
			}
Lines 138-149 namespace Mono.UIAutomation.Winforms.Behaviors.Generic Link Here
138
				if (VerticallyScrollable == false)
137
				if (VerticallyScrollable == false)
139
					return ScrollPatternIdentifiers.NoScroll;
138
					return ScrollPatternIdentifiers.NoScroll;
140
				else {
139
				else {
141
					return Helper.SynchronizedGet<SWF.ScrollBar, double> (vscrollbar, 
140
					return vscrollbar.InvokeSync (c => {
142
					                                                      delegate {
141
						if (c.Maximum == 0)
143
						if (vscrollbar.Maximum == 0)
144
							return ScrollPatternIdentifiers.NoScroll;
142
							return ScrollPatternIdentifiers.NoScroll;
145
						else
143
						else
146
							return (vscrollbar.Value * 100) / vscrollbar.Maximum;
144
							return (double) ((c.Value * 100) / c.Maximum);
147
					});
145
					});
148
				}
146
				}
149
			}
147
			}
Lines 179-187 namespace Mono.UIAutomation.Winforms.Behaviors.Generic Link Here
179
				if (horizontalPercent < 0 || horizontalPercent > 100)
177
				if (horizontalPercent < 0 || horizontalPercent > 100)
180
					throw new ArgumentOutOfRangeException ();
178
					throw new ArgumentOutOfRangeException ();
181
				else {
179
				else {
182
					double maximum = Helper.SynchronizedGet<SWF.ScrollBar, double> (hscrollbar,
180
					double maximum = hscrollbar.InvokeSync (h => h.Maximum);
183
					                                                                h => h.Maximum);
181
					hscrollbar.InvokeSync (delegate {
184
					PerformScrollByPercent (hscrollbar, (int) ((horizontalPercent * maximum) / 100));
182
						hscrollbar.Value = (int) ((horizontalPercent * maximum) / 100);
183
					});
185
				}
184
				}
186
			}
185
			}
187
			
186
			
Lines 189-197 namespace Mono.UIAutomation.Winforms.Behaviors.Generic Link Here
189
			    if (verticalPercent < 0 || verticalPercent > 100)
188
			    if (verticalPercent < 0 || verticalPercent > 100)
190
					throw new ArgumentOutOfRangeException ();
189
					throw new ArgumentOutOfRangeException ();
191
				else {
190
				else {
192
					double maximum = Helper.SynchronizedGet<SWF.ScrollBar, double> (vscrollbar,
191
					double maximum = vscrollbar.InvokeSync (v => v.Maximum);
193
					                                                                v => v.Maximum);
192
					hscrollbar.InvokeSync (delegate {
194
					PerformScrollByPercent (vscrollbar, (int) ((verticalPercent * maximum) / 100));
193
						vscrollbar.Value = (int) ((verticalPercent * maximum) / 100);
194
					});
195
				}
195
				}
196
			}
196
			}
197
		}
197
		}
Lines 242-269 namespace Mono.UIAutomation.Winforms.Behaviors.Generic Link Here
242
			invoke
242
			invoke
243
				= (Action<SWF.ScrollBar>) Delegate.CreateDelegate (typeof (Action<SWF.ScrollBar>), 
243
				= (Action<SWF.ScrollBar>) Delegate.CreateDelegate (typeof (Action<SWF.ScrollBar>), 
244
				                                                   methodInfo);
244
				                                                   methodInfo);
245
			PerformScrollByAmount (scrollbar);
245
246
		}
246
			scrollbar.InvokeSync (delegate { 
247
		
247
				invoke (scrollbar);
248
		private void PerformScrollByAmount (SWF.ScrollBar scrollbar)
248
				invoke = null;
249
		{
249
			});
250
			if (scrollbar.InvokeRequired == true) {
251
				scrollbar.BeginInvoke (new ScrollByAmountDelegate (PerformScrollByAmount),
252
				                       new object [] { scrollbar });
253
				return;
254
			}
255
			invoke (scrollbar);
256
			invoke = null;
257
		}
258
		
259
		private void PerformScrollByPercent (SWF.ScrollBar scrollbar, int value)
260
		{
261
			if (scrollbar.InvokeRequired == true) {
262
				scrollbar.BeginInvoke (new ScrollByPercentDelegate (PerformScrollByPercent),
263
				                       new object [] { scrollbar, value });
264
				return;
265
			}
266
			scrollbar.Value = value;
267
		}
250
		}
268
251
269
		#endregion
252
		#endregion
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/Generic/SelectionItemProviderBehavior.cs (-2 / +2 lines)
Lines 123-129 namespace Mono.UIAutomation.Winforms.Behaviors.Generic Link Here
123
			if (IsSelected)
123
			if (IsSelected)
124
				return;
124
				return;
125
125
126
			Helper.SynchronizedSet (itemProvider.ContainerControl, delegate {
126
			itemProvider.ContainerControl.InvokeSync (delegate {
127
				itemProvider.Select ();
127
				itemProvider.Select ();
128
			});
128
			});
129
		}
129
		}
Lines 163-169 namespace Mono.UIAutomation.Winforms.Behaviors.Generic Link Here
163
163
164
		private void PerformUnselect ()
164
		private void PerformUnselect ()
165
		{
165
		{
166
			Helper.SynchronizedSet (itemProvider.ContainerControl, delegate {
166
			itemProvider.ContainerControl.InvokeSync (delegate {
167
				itemProvider.Unselect ();
167
				itemProvider.Unselect ();
168
			});
168
			});
169
		}
169
		}
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/LinkLabel/InvokeProviderBehavior.cs (-21 / +17 lines)
Lines 86-134 namespace Mono.UIAutomation.Winforms.Behaviors.LinkLabel Link Here
86
		#region IHypertext Specialization
86
		#region IHypertext Specialization
87
		
87
		
88
		public int NumberOfLinks { 
88
		public int NumberOfLinks { 
89
			get { 
89
			get { return linkLabel.InvokeSync (c => c.Links.Count); }
90
				return Helper.SynchronizedGet<SWF.LinkLabel, int> (linkLabel,
91
				                                                    l=> l.Links.Count);
92
			}
93
		}
90
		}
94
		
91
		
95
		public int Start (int index) 
92
		public int Start (int index) 
96
		{
93
		{
97
			return Helper.SynchronizedGet<SWF.LinkLabel, int> (linkLabel, delegate {
94
			return linkLabel.InvokeSync (c => {
98
				if (index >= linkLabel.Links.Count || index < 0)
95
				if (index >= c.Links.Count || index < 0)
99
					return -1;
96
					return -1;
100
				else
97
				else
101
					return linkLabel.Links [index].Start;
98
					return c.Links [index].Start;
102
			});
99
			});
103
		}
100
		}
104
		
101
		
105
		public int Length (int index)
102
		public int Length (int index)
106
		{
103
		{
107
			return Helper.SynchronizedGet<SWF.LinkLabel, int> (linkLabel, delegate {
104
			return linkLabel.InvokeSync (c => {
108
				if (index >= linkLabel.Links.Count || index < 0)
105
				if (index >= c.Links.Count || index < 0)
109
					return -1;
106
					return -1;
110
				else
107
				else
111
					return linkLabel.Links [index].Length;
108
					return c.Links [index].Length;
112
			});
109
			});
113
		}
110
		}
114
		
111
		
115
		public string Uri (int index)
112
		public string Uri (int index)
116
		{
113
		{
117
			return Helper.SynchronizedGet<SWF.LinkLabel, string> (linkLabel, delegate {
114
			return linkLabel.InvokeSync (c => {
118
				if (index >= linkLabel.Links.Count || index < 0)
115
				if (index >= c.Links.Count || index < 0)
119
					return null;
116
					return null;
120
				else
117
				else
121
					return linkLabel.Links [index].LinkData as string;
118
					return c.Links [index].LinkData as string;
122
			});
119
			});
123
		}
120
		}
124
		
121
		
125
		public bool Enabled (int index)
122
		public bool Enabled (int index)
126
		{
123
		{
127
			return Helper.SynchronizedGet<SWF.LinkLabel, bool> (linkLabel, delegate {
124
			return linkLabel.InvokeSync (c => {
128
				if (!linkLabel.Enabled || index >= linkLabel.Links.Count || index < 0)
125
				if (!c.Enabled || index >= c.Links.Count || index < 0)
129
					return false;
126
					return false;
130
				else
127
				else
131
					return linkLabel.Links [index].Enabled;
128
					return c.Links [index].Enabled;
132
			});
129
			});
133
		}
130
		}
134
		
131
		
Lines 137-145 namespace Mono.UIAutomation.Winforms.Behaviors.LinkLabel Link Here
137
			if (!Enabled (index))
134
			if (!Enabled (index))
138
				throw new ElementNotEnabledException ();
135
				throw new ElementNotEnabledException ();
139
			
136
			
140
			Helper.SynchronizedSet (linkLabel, delegate {
137
			linkLabel.InvokeSync (c => {
141
138
				if (index >= c.Links.Count || index < 0)
142
				if (index >= linkLabel.Links.Count || index < 0)
143
					return;
139
					return;
144
	
140
	
145
				MethodInfo methodInfo = typeof (SWF.LinkLabel).GetMethod ("OnLinkClicked",
141
				MethodInfo methodInfo = typeof (SWF.LinkLabel).GetMethod ("OnLinkClicked",
Lines 152-160 namespace Mono.UIAutomation.Winforms.Behaviors.LinkLabel Link Here
152
						 methodInfo);
148
						 methodInfo);
153
	
149
	
154
				SWF.LinkLabelLinkClickedEventArgs args 
150
				SWF.LinkLabelLinkClickedEventArgs args 
155
					= new SWF.LinkLabelLinkClickedEventArgs (linkLabel.Links [index],
151
					= new SWF.LinkLabelLinkClickedEventArgs (c.Links [index],
156
					                                         SWF.MouseButtons.Left);
152
					                                         SWF.MouseButtons.Left);
157
				invokeMethod (linkLabel, args);
153
				invokeMethod (c, args);
158
			});
154
			});
159
		}
155
		}
160
		
156
		
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/ListBox/SelectionProviderBehavior.cs (-3 / +2 lines)
Lines 95-103 namespace Mono.UIAutomation.Winforms.Behaviors.ListBox Link Here
95
			get {
95
			get {
96
				SWF.ListBox listBoxControl = (SWF.ListBox) Provider.Control;
96
				SWF.ListBox listBoxControl = (SWF.ListBox) Provider.Control;
97
97
98
				return Helper.SynchronizedGet<SWF.ListBox, bool> (listBoxControl,
98
				return listBoxControl.InvokeSync (c => c.SelectionMode == SWF.SelectionMode.MultiExtended
99
				                                                  l => l.SelectionMode == SWF.SelectionMode.MultiExtended
99
				                                   || c.SelectionMode == SWF.SelectionMode.MultiSimple);
100
				                                                  || l.SelectionMode == SWF.SelectionMode.MultiSimple);
101
			}
100
			}
102
		}
101
		}
103
102
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/ListItem/ScrollItemProviderBehavior.cs (-1 / +1 lines)
Lines 70-76 namespace Mono.UIAutomation.Winforms.Behaviors.ListItem Link Here
70
		public void ScrollIntoView ()
70
		public void ScrollIntoView ()
71
		{
71
		{
72
			IListProvider itemProvider = ((ListItemProvider) Provider).ListProvider;
72
			IListProvider itemProvider = ((ListItemProvider) Provider).ListProvider;
73
			Helper.SynchronizedSet (itemProvider.Control, delegate {
73
			itemProvider.Control.InvokeSync (delegate {
74
				itemProvider.ScrollItemIntoView ((ListItemProvider) Provider);
74
				itemProvider.ScrollItemIntoView ((ListItemProvider) Provider);
75
			});
75
			});
76
		}
76
		}
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/ListItem/ToggleProviderBehavior.cs (-1 / +1 lines)
Lines 79-85 namespace Mono.UIAutomation.Winforms.Behaviors.ListItem Link Here
79
		{
79
		{
80
			ListItemProvider provider = (ListItemProvider) Provider;
80
			ListItemProvider provider = (ListItemProvider) Provider;
81
81
82
			Helper.SynchronizedSet (provider.ListProvider.Control, delegate {
82
			provider.ListProvider.Control.InvokeSync (delegate {
83
				provider.ListProvider.ToggleItem (provider);
83
				provider.ListProvider.ToggleItem (provider);
84
			});
84
			});
85
		}
85
		}
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/ListView/GridProviderBehavior.cs (-11 / +10 lines)
Lines 89-103 namespace Mono.UIAutomation.Winforms.Behaviors.ListView Link Here
89
89
90
		public int ColumnCount {
90
		public int ColumnCount {
91
			get {
91
			get {
92
				return Helper.SynchronizedGet<SWF.ListView, int> (listView, delegate {
92
				return listView.InvokeSync (c => {
93
					if (listView.View == SWF.View.Details)
93
					if (c.View == SWF.View.Details)
94
						return listView.Columns.Count;
94
						return c.Columns.Count;
95
					else { //Is View.List
95
					else { //Is View.List
96
						if (RowCount == 0)
96
						if (RowCount == 0)
97
							return -1;
97
							return -1;
98
	
98
	
99
						bool module = listView.Items.Count % RowCount > 0;
99
						bool module = c.Items.Count % RowCount > 0;
100
						return (listView.Items.Count / RowCount) + (module ? 1 : 0);
100
						return (c.Items.Count / RowCount) + (module ? 1 : 0);
101
					}
101
					}
102
				});
102
				});
103
			}
103
			}
Lines 105-115 namespace Mono.UIAutomation.Winforms.Behaviors.ListView Link Here
105
105
106
		public int RowCount {
106
		public int RowCount {
107
			get {
107
			get {
108
				return Helper.SynchronizedGet<SWF.ListView, int> (listView, delegate {
108
				return listView.InvokeSync (c => {
109
					if (listView.View == SWF.View.Details)
109
					if (c.View == SWF.View.Details)
110
						return listView.Items.Count;
110
						return c.Items.Count;
111
					else //Is View.List
111
					else //Is View.List
112
						return listView.UIARows;
112
						return c.UIARows;
113
				});
113
				});
114
			}
114
			}
115
		}
115
		}
Lines 125-132 namespace Mono.UIAutomation.Winforms.Behaviors.ListView Link Here
125
125
126
			ListViewProvider provider = (ListViewProvider) Provider;
126
			ListViewProvider provider = (ListViewProvider) Provider;
127
127
128
			if (Helper.SynchronizedGet<SWF.ListView, bool> (listView, 
128
			if (listView.InvokeSync (c => c.View == SWF.View.Details)) {
129
			                                                l => l.View == SWF.View.Details)) {
130
				// FIXME: In Vista when listView.Groups == 0 no Groups are added,
129
				// FIXME: In Vista when listView.Groups == 0 no Groups are added,
131
				// and we should iterate when listView.Groups > 0
130
				// and we should iterate when listView.Groups > 0
132
				SWF.ListViewItem item = listView.Items [row];
131
				SWF.ListViewItem item = listView.Items [row];
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/ListView/GroupGridProviderBehavior.cs (-8 / +6 lines)
Lines 97-108 namespace Mono.UIAutomation.Winforms.Behaviors.ListView Link Here
97
		
97
		
98
		public int ColumnCount {
98
		public int ColumnCount {
99
			get {
99
			get {
100
				return Helper.SynchronizedGet<SWF.ListView, int> (viewGroupProvider.ListView, 
100
				return viewGroupProvider.ListView.InvokeSync (c => {
101
				                                                  delegate {
102
					if (viewGroupProvider.ListView.View == SWF.View.Details)
101
					if (viewGroupProvider.ListView.View == SWF.View.Details)
103
						return viewGroupProvider.ListView.Columns.Count;
102
						return c.Columns.Count;
104
					else {
103
					else {
105
						int maxColums = viewGroupProvider.ListView.UIAColumns;
104
						int maxColums = c.UIAColumns;
106
						int itemsInGroup = ItemsInGroupCount ();
105
						int itemsInGroup = ItemsInGroupCount ();
107
		
106
		
108
						if (itemsInGroup < maxColums)
107
						if (itemsInGroup < maxColums)
Lines 138-151 namespace Mono.UIAutomation.Winforms.Behaviors.ListView Link Here
138
137
139
		private int ItemsInGroupCount ()
138
		private int ItemsInGroupCount ()
140
		{
139
		{
141
			return Helper.SynchronizedGet<SWF.ListView, int> (viewGroupProvider.ListView, 
140
			return viewGroupProvider.ListView.InvokeSync (c => {
142
			                                                  delegate {
143
				ListViewProvider listViewProvider
141
				ListViewProvider listViewProvider
144
					= (ListViewProvider) ProviderFactory.FindProvider (viewGroupProvider.ListView);
142
					= (ListViewProvider) ProviderFactory.FindProvider (viewGroupProvider.ListView);
145
				if (listViewProvider.IsDefaultGroup (viewGroupProvider.Group) == true) {
143
				if (listViewProvider.IsDefaultGroup (viewGroupProvider.Group) == true) {
146
					int itemsInGroup = 0;
144
					int itemsInGroup = 0;
147
					for (int index = 0; index < viewGroupProvider.ListView.Items.Count; index++) {
145
					for (int index = 0; index < c.Items.Count; index++) {
148
						if (viewGroupProvider.ListView.Items [index].Group == null)
146
						if (c.Items [index].Group == null)
149
							itemsInGroup++;
147
							itemsInGroup++;
150
					}
148
					}
151
					return itemsInGroup;
149
					return itemsInGroup;
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/ListView/ListItemCheckBoxToggleProviderBehavior.cs (-1 / +1 lines)
Lines 85-91 namespace Mono.UIAutomation.Winforms.Behaviors.ListView Link Here
85
		{
85
		{
86
			ListItemProvider provider = checkboxProvider.ItemProvider;
86
			ListItemProvider provider = checkboxProvider.ItemProvider;
87
87
88
			Helper.SynchronizedSet (provider.ListProvider.Control, delegate {
88
			provider.ListProvider.Control.InvokeSync (delegate {
89
				provider.ListProvider.ToggleItem (provider);
89
				provider.ListProvider.ToggleItem (provider);
90
			});
90
			});
91
		}
91
		}
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/ListView/ListItemClipboardProviderBehavior.cs (-1 / +1 lines)
Lines 77-83 namespace Mono.UIAutomation.Winforms.Behaviors.ListView Link Here
77
			position = (int) System.Math.Min (position, text.Length);
77
			position = (int) System.Math.Min (position, text.Length);
78
78
79
			string newValue = viewItem.Text.Insert (position, SWF.Clipboard.GetText ());
79
			string newValue = viewItem.Text.Insert (position, SWF.Clipboard.GetText ());
80
			Helper.SynchronizedSet (viewItem.ListView, delegate {
80
			viewItem.ListView.InvokeSync (delegate {
81
				viewItem.Text = newValue;
81
				viewItem.Text = newValue;
82
			});
82
			});
83
		}
83
		}
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/ListView/ListItemEditGridItemProviderBehavior.cs (-8 / +2 lines)
Lines 106-125 namespace Mono.UIAutomation.Winforms.Behaviors.ListView Link Here
106
		public int Row {
106
		public int Row {
107
			get {
107
			get {
108
				SWF.ListView listView = editProvider.ItemProvider.ListView;
108
				SWF.ListView listView = editProvider.ItemProvider.ListView;
109
				return Helper.SynchronizedGet<SWF.ListView, int> (listView,
109
				return listView.InvokeSync (c => c.Items.IndexOf (editProvider.ItemProvider.ListViewItem) );
110
				                                                  delegate {
111
					return listView.Items.IndexOf (editProvider.ItemProvider.ListViewItem);
112
				});
113
			}
110
			}
114
		}
111
		}
115
		
112
		
116
		public int Column {
113
		public int Column {
117
			get {
114
			get {
118
				SWF.ListView listView = editProvider.ItemProvider.ListView;
115
				SWF.ListView listView = editProvider.ItemProvider.ListView;
119
				return Helper.SynchronizedGet<SWF.ListView, int> (listView,
116
				return listView.InvokeSync (c => c.Columns.IndexOf (editProvider.ColumnHeader) );
120
				                                                  delegate {
121
					return listView.Columns.IndexOf (editProvider.ColumnHeader);
122
				});
123
			}
117
			}
124
		}
118
		}
125
		
119
		
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/ListView/ListItemEditValueProviderBehavior.cs (-7 / +3 lines)
Lines 102-118 namespace Mono.UIAutomation.Winforms.Behaviors.ListView Link Here
102
		}
102
		}
103
		
103
		
104
		public bool IsReadOnly {
104
		public bool IsReadOnly {
105
			get {
105
			get { return listView.InvokeSync (l => !l.LabelEdit); }
106
				return Helper.SynchronizedGet<SWF.ListView, bool> (listView,
107
				                                                    l => !l.LabelEdit);
108
			}
109
		}
106
		}
110
		
107
		
111
		public string Value {
108
		public string Value {
112
			get {
109
			get {
113
				return Helper.SynchronizedGet<SWF.ListView, string> (listView,
110
				return listView.InvokeSync (c => {
114
				                                                     delegate {
111
					int indexOf = c.Columns.IndexOf (columnHeader);
115
					int indexOf = listView.Columns.IndexOf (columnHeader);
116
	
112
	
117
					if (indexOf < 0 || indexOf >= listViewItem.SubItems.Count)
113
					if (indexOf < 0 || indexOf >= listViewItem.SubItems.Count)
118
						return string.Empty;
114
						return string.Empty;
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/ListView/ListItemEmbeddedImageProviderBehavior.cs (-4 / +4 lines)
Lines 68-82 namespace Mono.UIAutomation.Winforms.Behaviors.ListView Link Here
68
				if (item == null || item.ListView == null)
68
				if (item == null || item.ListView == null)
69
					return System.Windows.Rect.Empty;
69
					return System.Windows.Rect.Empty;
70
70
71
				return Helper.SynchronizedGet<SWF.ListView, System.Windows.Rect> (item.ListView, delegate {
71
				return item.ListView.InvokeSync (c => {
72
				    if (item.ImageIndex == -1 && item.ImageKey == string.Empty)
72
				    if (item.ImageIndex == -1 && item.ImageKey == string.Empty)
73
						return System.Windows.Rect.Empty;
73
						return System.Windows.Rect.Empty;
74
74
75
					SWF.ImageList imageList = null;
75
					SWF.ImageList imageList = null;
76
					if (item.ListView.View == SWF.View.LargeIcon)
76
					if (c.View == SWF.View.LargeIcon)
77
						imageList = item.ListView.LargeImageList;
77
						imageList = c.LargeImageList;
78
					else
78
					else
79
						imageList = item.ListView.SmallImageList;
79
						imageList = c.SmallImageList;
80
	
80
	
81
					if (imageList == null)
81
					if (imageList == null)
82
						return System.Windows.Rect.Empty;
82
						return System.Windows.Rect.Empty;
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/ListView/ListItemGridItemProviderBehavior.cs (-15 / +14 lines)
Lines 107-116 namespace Mono.UIAutomation.Winforms.Behaviors.ListView Link Here
107
			get { 
107
			get { 
108
				SWF.ListView view = (SWF.ListView) viewProvider.Control;
108
				SWF.ListView view = (SWF.ListView) viewProvider.Control;
109
109
110
				return Helper.SynchronizedGet<SWF.ListView, int> (view, delegate {
110
				return view.InvokeSync (c => {
111
					if (view.View == SWF.View.List) //From Top to Bottom
111
					if (c.View == SWF.View.List) //From Top to Bottom
112
						return MaxRows == 0 ? -1 : IndexOf % MaxRows;
112
						return MaxRows == 0 ? -1 : IndexOf % MaxRows;
113
					else if (view.View == SWF.View.Details)
113
					else if (c.View == SWF.View.Details)
114
						return itemProvider.Index;
114
						return itemProvider.Index;
115
					else //From Left to Right
115
					else //From Left to Right
116
					return MaxColumns == 0 ? -1 : IndexOf / MaxColumns;
116
					return MaxColumns == 0 ? -1 : IndexOf / MaxColumns;
Lines 122-131 namespace Mono.UIAutomation.Winforms.Behaviors.ListView Link Here
122
			get {
122
			get {
123
				SWF.ListView view = (SWF.ListView) viewProvider.Control;
123
				SWF.ListView view = (SWF.ListView) viewProvider.Control;
124
124
125
				return Helper.SynchronizedGet<SWF.ListView, int> (view, delegate {
125
				return view.InvokeSync (c => {
126
					if (view.View == SWF.View.List) //From Top to Bottom
126
					if (c.View == SWF.View.List) //From Top to Bottom
127
						return MaxRows == 0 ? -1 : IndexOf / MaxRows;
127
						return MaxRows == 0 ? -1 : IndexOf / MaxRows;
128
					else if (view.View == SWF.View.Details) // Always 0
128
					else if (c.View == SWF.View.Details) // Always 0
129
						return 0;
129
						return 0;
130
					else //From Left to Right
130
					else //From Left to Right
131
					return IndexOf - (Row * MaxColumns);
131
					return IndexOf - (Row * MaxColumns);
Lines 153-171 namespace Mono.UIAutomation.Winforms.Behaviors.ListView Link Here
153
			get {
153
			get {
154
				SWF.ListViewItem item = (SWF.ListViewItem) itemProvider.ObjectItem;
154
				SWF.ListViewItem item = (SWF.ListViewItem) itemProvider.ObjectItem;
155
155
156
				return Helper.SynchronizedGet<SWF.ListView, int> (view, delegate {
156
				return view.InvokeSync (c => {
157
	
157
					if (c.View == SWF.View.List || c.ShowGroups == false)
158
					if (view.View == SWF.View.List || view.ShowGroups == false)
158
						return c.Items.IndexOf (item);
159
						return view.Items.IndexOf (item);
160
	
159
	
161
					if (viewProvider.IsDefaultGroup (group) == true) {					
160
					if (viewProvider.IsDefaultGroup (group) == true) {					
162
						int indexOf = 0;
161
						int indexOf = 0;
163
						bool found = false;					
162
						bool found = false;					
164
						
163
						
165
						//TODO: Is this OK??
164
						//TODO: Is this OK??
166
						for (int index = 0; index < view.Items.Count; index++) {
165
						for (int index = 0; index < c.Items.Count; index++) {
167
							if (view.Items [index].Group == null) {
166
							if (c.Items [index].Group == null) {
168
								if (view.Items [index] == item) {
167
								if (c.Items [index] == item) {
169
									found = true;
168
									found = true;
170
									break;
169
									break;
171
								}
170
								}
Lines 181-191 namespace Mono.UIAutomation.Winforms.Behaviors.ListView Link Here
181
		}
180
		}
182
		
181
		
183
		private int MaxColumns {
182
		private int MaxColumns {
184
			get { return Helper.SynchronizedGet<SWF.ListView, int> (view, v => v.UIAColumns); }
183
			get { return view.InvokeSync (v => v.UIAColumns); }
185
		}
184
		}
186
185
187
		private int MaxRows {
186
		private int MaxRows {
188
			get { return Helper.SynchronizedGet<SWF.ListView, int> (view, v => v.UIARows); }
187
			get { return view.InvokeSync (v => v.UIARows); }
189
		}
188
		}
190
		
189
		
191
		#endregion
190
		#endregion
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/ListView/ListItemValueProviderBehavior.cs (-5 / +2 lines)
Lines 86-101 namespace Mono.UIAutomation.Winforms.Behaviors.ListView Link Here
86
			if (IsReadOnly == true)
86
			if (IsReadOnly == true)
87
				throw new ElementNotEnabledException ();
87
				throw new ElementNotEnabledException ();
88
88
89
			Helper.SynchronizedSet (viewItem.ListView, delegate {
89
			viewItem.ListView.InvokeSync (delegate {
90
				viewItem.Text = value;
90
				viewItem.Text = value;
91
			});
91
			});
92
		}
92
		}
93
		
93
		
94
		public bool IsReadOnly {
94
		public bool IsReadOnly {
95
			get {
95
			get { return viewItem.ListView.InvokeSync (v => !v.LabelEdit); }
96
				return Helper.SynchronizedGet<SWF.ListView, bool> (viewItem.ListView,
97
				                                                   v => !v.LabelEdit);
98
			}
99
		}
96
		}
100
		
97
		
101
		public string Value {
98
		public string Value {
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/ListView/SelectionProviderBehavior.cs (-2 / +1 lines)
Lines 95-102 namespace Mono.UIAutomation.Winforms.Behaviors.ListView Link Here
95
		public bool CanSelectMultiple {
95
		public bool CanSelectMultiple {
96
			get {
96
			get {
97
				SWF.ListView listview = (SWF.ListView) Provider.Control;
97
				SWF.ListView listview = (SWF.ListView) Provider.Control;
98
				return Helper.SynchronizedGet<SWF.ListView, bool> (listview,
98
				return listview.InvokeSync (c => c.MultiSelect);
99
				                                                   l => l.MultiSelect); 
100
			}
99
			}
101
		}
100
		}
102
101
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/MaskedTextBox/InsertDeleteTextProviderBehavior.cs (-6 / +4 lines)
Lines 64-76 namespace Mono.UIAutomation.Winforms.Behaviors.MaskedTextBox Link Here
64
		// rejected as it contains too many characters.
64
		// rejected as it contains too many characters.
65
		public void InsertText (string str, ref int position)
65
		public void InsertText (string str, ref int position)
66
		{
66
		{
67
			if (Helper.SynchronizedGet<SWF.MaskedTextBox, bool> (maskedTextBox,
67
			if (maskedTextBox.InvokeSync (m => m.ReadOnly))
68
			                                                     m => m.ReadOnly))
69
				throw new ElementNotEnabledException ();
68
				throw new ElementNotEnabledException ();
70
			
69
			
71
			int newPosition = position;
70
			int newPosition = position;
72
71
73
			Helper.SynchronizedSet (maskedTextBox, delegate {
72
			maskedTextBox.InvokeSync (delegate {
74
73
75
				System.ComponentModel.MaskedTextProvider prov
74
				System.ComponentModel.MaskedTextProvider prov
76
					= maskedTextBox.MaskedTextProvider;
75
					= maskedTextBox.MaskedTextProvider;
Lines 130-140 namespace Mono.UIAutomation.Winforms.Behaviors.MaskedTextBox Link Here
130
129
131
		public void DeleteText (int start, int end)
130
		public void DeleteText (int start, int end)
132
		{
131
		{
133
			if (Helper.SynchronizedGet<SWF.MaskedTextBox, bool> (maskedTextBox,
132
			if (maskedTextBox.InvokeSync (m => m.ReadOnly))
134
			                                                     m => m.ReadOnly))
135
				throw new ElementNotEnabledException ();
133
				throw new ElementNotEnabledException ();
136
134
137
			Helper.SynchronizedSet (maskedTextBox, delegate {
135
			maskedTextBox.InvokeSync (delegate {
138
				// MaskedTextProvider.RemoveAt does not work for this.
136
				// MaskedTextProvider.RemoveAt does not work for this.
139
				System.ComponentModel.MaskedTextProvider prov
137
				System.ComponentModel.MaskedTextProvider prov
140
					= maskedTextBox.MaskedTextProvider;
138
					= maskedTextBox.MaskedTextProvider;
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/NumericUpDown/EditableRangeProviderBehavior.cs (-4 / +3 lines)
Lines 65-82 namespace Mono.UIAutomation.Winforms.Behaviors.NumericUpDown Link Here
65
		#region IEditableRange Members
65
		#region IEditableRange Members
66
		public void BeginEdit (string text)
66
		public void BeginEdit (string text)
67
		{
67
		{
68
			if (Helper.SynchronizedGet<SWF.NumericUpDown, bool> (numericUpDown,
68
			if (numericUpDown.InvokeSync (n => numericUpDown.ReadOnly))
69
			                                                     n => numericUpDown.ReadOnly))
70
				throw new ElementNotEnabledException ();
69
				throw new ElementNotEnabledException ();
71
70
72
			Helper.SynchronizedSet (numericUpDown, delegate {
71
			numericUpDown.InvokeSync (delegate {
73
				numericUpDown.txtView.Text = text;
72
				numericUpDown.txtView.Text = text;
74
			});
73
			});
75
		}
74
		}
76
75
77
		public void CommitEdit ()
76
		public void CommitEdit ()
78
		{
77
		{
79
			Helper.SynchronizedSet (numericUpDown, delegate {
78
			numericUpDown.InvokeSync (delegate {
80
				decimal value = decimal.Parse (numericUpDown.Text);
79
				decimal value = decimal.Parse (numericUpDown.Text);
81
				if (value < numericUpDown.Minimum)
80
				if (value < numericUpDown.Minimum)
82
					value = numericUpDown.Minimum;
81
					value = numericUpDown.Minimum;
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/NumericUpDown/RangeValueProviderBehavior.cs (-23 / +6 lines)
Lines 107-147 namespace Mono.UIAutomation.Winforms.Behaviors.NumericUpDown Link Here
107
		#region IRangeValueProvider Members
107
		#region IRangeValueProvider Members
108
	
108
	
109
		public bool IsReadOnly {
109
		public bool IsReadOnly {
110
			get { 
110
			get { return numericUpDown.InvokeSync (c => c.ReadOnly); }
111
				return Helper.SynchronizedGet<SWF.NumericUpDown, bool> (numericUpDown, 
112
				                                                        n => n.ReadOnly);
113
			}
114
		}
111
		}
115
		
112
		
116
		public double Minimum {
113
		public double Minimum {
117
			get { 
114
			get { return numericUpDown.InvokeSync (c => (double) c.Minimum); }
118
				return Helper.SynchronizedGet<SWF.NumericUpDown, double> (numericUpDown,
119
				                                                          n => (double) n.Minimum);
120
			}
121
		}
115
		}
122
		
116
		
123
		public double Maximum {
117
		public double Maximum {
124
			get { 
118
			get { return numericUpDown.InvokeSync (c => (double) c.Maximum); }
125
				return Helper.SynchronizedGet<SWF.NumericUpDown, double> (numericUpDown,
126
				                                                          n => (double) numericUpDown.Maximum);
127
			}
128
		}
119
		}
129
		
120
		
130
		public double LargeChange {
121
		public double LargeChange {
131
			get { return double.NaN; }
122
			get { return double.NaN; }
132
		}
123
		}
133
		public double SmallChange {
124
		public double SmallChange {
134
			get { 
125
			get { return numericUpDown.InvokeSync (c => (double) c.Increment); }
135
				return Helper.SynchronizedGet<SWF.NumericUpDown, double> (numericUpDown,
136
				                                                          n => (double) numericUpDown.Increment);
137
			}
138
		}
126
		}
139
127
140
		public double Value {
128
		public double Value {
141
			get { 
129
			get { return numericUpDown.InvokeSync (c => (double) c.Value); }
142
				return Helper.SynchronizedGet<SWF.NumericUpDown, double> (numericUpDown,
143
				                                                           n => (double) numericUpDown.Value);
144
			}
145
		}
130
		}
146
		
131
		
147
		public void SetValue (double value)
132
		public void SetValue (double value)
Lines 149-157 namespace Mono.UIAutomation.Winforms.Behaviors.NumericUpDown Link Here
149
			if (value < Minimum || value > Maximum)
134
			if (value < Minimum || value > Maximum)
150
				throw new ArgumentOutOfRangeException ();
135
				throw new ArgumentOutOfRangeException ();
151
136
152
			Helper.SynchronizedSet (numericUpDown, delegate {
137
			numericUpDown.InvokeSync (delegate { numericUpDown.Value = (decimal) value; });
153
				numericUpDown.Value = (decimal) value;
154
			});
155
		}
138
		}
156
			
139
			
157
		#endregion
140
		#endregion
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/PictureBox/EmbeddedImageProviderBehavior.cs (-4 / +3 lines)
Lines 63-75 namespace Mono.UIAutomation.Winforms.Behaviors.PictureBox Link Here
63
#region IEmbeddedImageProvider Interface
63
#region IEmbeddedImageProvider Interface
64
		public Rect Bounds {
64
		public Rect Bounds {
65
			get {
65
			get {
66
				return Helper.SynchronizedGet<SWF.PictureBox, Rect> (control,
66
				return control.InvokeSync (c => {
67
					delegate {
67
						if (c.Image == null)
68
						if (control.Image == null)
69
							return Rect.Empty;
68
							return Rect.Empty;
70
69
71
						GraphicsUnit unit = GraphicsUnit.Pixel;
70
						GraphicsUnit unit = GraphicsUnit.Pixel;
72
						RectangleF rectF = control.Image.GetBounds (ref unit);
71
						RectangleF rectF = c.Image.GetBounds (ref unit);
73
72
74
						if (unit != GraphicsUnit.Pixel)
73
						if (unit != GraphicsUnit.Pixel)
75
							return Rect.Empty;
74
							return Rect.Empty;
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/ProgressBar/RangeValueProviderBehavior.cs (-2 / +2 lines)
Lines 101-107 namespace Mono.UIAutomation.Winforms.Behaviors.ProgressBar Link Here
101
		#region IRangeValueProvider Members
101
		#region IRangeValueProvider Members
102
		
102
		
103
		public double Value {
103
		public double Value {
104
			get { return Helper.SynchronizedGet<SWF.ProgressBar, double> (progressBar, p => p.Value); }
104
			get { return progressBar.InvokeSync (p => p.Value); }
105
		}
105
		}
106
		
106
		
107
		public bool IsReadOnly {
107
		public bool IsReadOnly {
Lines 129-135 namespace Mono.UIAutomation.Winforms.Behaviors.ProgressBar Link Here
129
			if (value < Minimum || value > Maximum)
129
			if (value < Minimum || value > Maximum)
130
				throw new ArgumentOutOfRangeException ();
130
				throw new ArgumentOutOfRangeException ();
131
			
131
			
132
			Helper.SynchronizedSet (progressBar, delegate {
132
			progressBar.InvokeSync (delegate {
133
				progressBar.Value = (int) value;
133
				progressBar.Value = (int) value;
134
			});
134
			});
135
		}
135
		}
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/RadioButton/SelectionItemProviderBehavior.cs (-1 / +1 lines)
Lines 120-126 namespace Mono.UIAutomation.Winforms.Behaviors.RadioButton Link Here
120
120
121
		public void Select ()
121
		public void Select ()
122
		{
122
		{
123
			Helper.SynchronizedSet (radioButton, delegate {
123
			radioButton.InvokeSync (delegate {
124
				radioButton.Checked = true;
124
				radioButton.Checked = true;
125
			});
125
			});
126
		}
126
		}
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/ScrollBar/ButtonInvokeProviderBehavior.cs (-4 / +4 lines)
Lines 84-90 namespace Mono.UIAutomation.Winforms.Behaviors.ScrollBar Link Here
84
		
84
		
85
		public void Invoke ()
85
		public void Invoke ()
86
		{
86
		{
87
			if (!Provider.Control.Enabled)
87
			if (!Provider.Control.InvokeSync (c => c.Enabled))
88
				throw new ElementNotEnabledException ();
88
				throw new ElementNotEnabledException ();
89
89
90
			string methodName = string.Empty;
90
			string methodName = string.Empty;
Lines 106-114 namespace Mono.UIAutomation.Winforms.Behaviors.ScrollBar Link Here
106
				Action<SWF.ScrollBar> invokeMethod
106
				Action<SWF.ScrollBar> invokeMethod
107
					= (Action<SWF.ScrollBar>) Delegate.CreateDelegate (typeof (Action<SWF.ScrollBar>), 
107
					= (Action<SWF.ScrollBar>) Delegate.CreateDelegate (typeof (Action<SWF.ScrollBar>), 
108
					                                                   methodInfo);
108
					                                                   methodInfo);
109
				Helper.SynchronizedSet (provider.ScrollBarContainer,
109
				provider.ScrollBarContainer.InvokeSync (delegate {
110
					c => { invokeMethod (provider.ScrollBarContainer); }
110
					invokeMethod (provider.ScrollBarContainer);
111
				);
111
				});
112
			}
112
			}
113
		}
113
		}
114
		
114
		
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/ScrollBar/RangeValueProviderBehavior.cs (-8 / +7 lines)
Lines 112-147 namespace Mono.UIAutomation.Winforms.Behaviors.ScrollBar Link Here
112
			if (value < Minimum || value > Maximum)
112
			if (value < Minimum || value > Maximum)
113
				throw new ArgumentOutOfRangeException ();
113
				throw new ArgumentOutOfRangeException ();
114
			
114
			
115
			Helper.SynchronizedSet (scrollbar, delegate {
115
			scrollbar.InvokeSync (delegate {
116
				scrollbar.Value = (int) value;
116
				scrollbar.Value = (int) value;
117
			});
117
			});
118
		}
118
		}
119
		
119
		
120
		public bool IsReadOnly {
120
		public bool IsReadOnly {
121
			get {
121
			get {
122
				return Helper.SynchronizedGet<SWF.ScrollBar, bool> (
122
				return scrollbar.InvokeSync (s => !s.Enabled || !s.Visible);
123
					scrollbar, s => !s.Enabled || !s.Visible);
124
			}
123
			}
125
		}
124
		}
126
		
125
		
127
		public double LargeChange {
126
		public double LargeChange {
128
			get { return Helper.SynchronizedGet<SWF.ScrollBar, double> (scrollbar, s => s.LargeChange); }
127
			get { return scrollbar.InvokeSync (s => s.LargeChange); }
129
		}
128
		}
130
		
129
		
131
		public double Maximum {
130
		public double Maximum {
132
			get { return Helper.SynchronizedGet<SWF.ScrollBar, double> (scrollbar, s => s.Maximum); }
131
			get { return scrollbar.InvokeSync (s => s.Maximum); }
133
		}
132
		}
134
		
133
		
135
		public double Minimum {
134
		public double Minimum {
136
			get { return Helper.SynchronizedGet<SWF.ScrollBar, double> (scrollbar, s => s.Minimum); }
135
			get { return scrollbar.InvokeSync (s => s.Minimum); }
137
		}
136
		}
138
		
137
		
139
		public double SmallChange {
138
		public double SmallChange {
140
			get { return Helper.SynchronizedGet<SWF.ScrollBar, double> (scrollbar, s => s.SmallChange); }
139
			get { return scrollbar.InvokeSync (s => s.SmallChange); }
141
		}
140
		}
142
		
141
		
143
		public double Value {
142
		public double Value {
144
			get { return Helper.SynchronizedGet<SWF.ScrollBar, double> (scrollbar, s => s.Value); }
143
			get { return scrollbar.InvokeSync (s => s.Value); }
145
		}
144
		}
146
		
145
		
147
		#endregion 
146
		#endregion 
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/SplitContainer/DockProviderBehavior.cs (-8 / +2 lines)
Lines 76-93 namespace Mono.UIAutomation.Winforms.Behaviors.SplitContainer Link Here
76
		#region IDockProvider Members
76
		#region IDockProvider Members
77
		
77
		
78
		public DockPosition DockPosition {
78
		public DockPosition DockPosition {
79
			get {
79
			get { return splitContainer.InvokeSync (s => Helper.GetDockPosition (s.Dock)); }
80
				return Helper.SynchronizedGet<SWF.SplitContainer, DockPosition> (
81
					splitContainer, s => Helper.GetDockPosition (s.Dock)
82
				);
83
			}
84
		}
80
		}
85
		
81
		
86
		public void SetDockPosition (DockPosition dockPosition)
82
		public void SetDockPosition (DockPosition dockPosition)
87
		{
83
		{
88
			//throw new InvalidOperationException ();
84
			//throw new InvalidOperationException ();
89
			
85
			
90
			Helper.SynchronizedSet (splitContainer, delegate {
86
			splitContainer.InvokeSync (delegate {
91
				splitContainer.Dock = Helper.GetDockStyle (dockPosition);
87
				splitContainer.Dock = Helper.GetDockStyle (dockPosition);
92
			});
88
			});
93
		}
89
		}
Lines 100-105 namespace Mono.UIAutomation.Winforms.Behaviors.SplitContainer Link Here
100
		
96
		
101
		#endregion
97
		#endregion
102
	}
98
	}
103
	
104
	delegate void PerformSetDockPositionDelegate (DockPosition dockPosition);
105
}
99
}
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/SplitContainer/RangeValueProviderBehavior.cs (-21 / +5 lines)
Lines 92-108 namespace Mono.UIAutomation.Winforms.Behaviors.SplitContainer Link Here
92
			if (value < Minimum || value > Maximum)
92
			if (value < Minimum || value > Maximum)
93
				throw new ArgumentOutOfRangeException ();
93
				throw new ArgumentOutOfRangeException ();
94
			
94
			
95
			Helper.SynchronizedSet (splitcontainer, delegate {
95
			splitcontainer.InvokeSync (delegate {
96
				splitcontainer.SplitterDistance = (int) value;
96
				splitcontainer.SplitterDistance = (int) value;
97
			});
97
			});
98
		}
98
		}
99
		
99
		
100
		public bool IsReadOnly {
100
		public bool IsReadOnly {
101
			get {
101
			get { return splitcontainer.InvokeSync (s => !s.Enabled || !s.Visible); }
102
				return Helper.SynchronizedGet<SWF.SplitContainer, bool> (
103
					(SWF.SplitContainer) Provider.Control, s => !s.Enabled || !s.Visible
104
				);
105
			}
106
		}
102
		}
107
		
103
		
108
		public double LargeChange {
104
		public double LargeChange {
Lines 110-128 namespace Mono.UIAutomation.Winforms.Behaviors.SplitContainer Link Here
110
		}
106
		}
111
		
107
		
112
		public double Maximum {
108
		public double Maximum {
113
			get {
109
			get { return splitcontainer.InvokeSync (s => s.Width - (s.SplitterWidth + s.Panel2MinSize)); }
114
				return Helper.SynchronizedGet<SWF.SplitContainer, double> (
115
					(SWF.SplitContainer) Provider.Control, s => s.Width - (s.SplitterWidth + s.Panel2MinSize)
116
				);
117
			}
118
		}
110
		}
119
		
111
		
120
		public double Minimum {
112
		public double Minimum {
121
			get {
113
			get { return splitcontainer.InvokeSync (s => s.Panel1MinSize); }
122
				return Helper.SynchronizedGet<SWF.SplitContainer, double> (
123
					(SWF.SplitContainer) Provider.Control, s => s.Panel1MinSize
124
				);
125
			}
126
		}
114
		}
127
		
115
		
128
		public double SmallChange {
116
		public double SmallChange {
Lines 130-140 namespace Mono.UIAutomation.Winforms.Behaviors.SplitContainer Link Here
130
		}
118
		}
131
		
119
		
132
		public double Value {
120
		public double Value {
133
			get {
121
			get { return splitcontainer.InvokeSync (s => s.SplitterDistance); }
134
				return Helper.SynchronizedGet<SWF.SplitContainer, double> (
135
					(SWF.SplitContainer) Provider.Control, s => s.SplitterDistance
136
				);
137
			}
138
		}
122
		}
139
		
123
		
140
		#endregion 
124
		#endregion 
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/SplitContainer/SplitterPanelTransformProviderBehavior.cs (-7 / +2 lines)
Lines 87-98 namespace Mono.UIAutomation.Winforms.Behaviors.SplitContainer Link Here
87
		}
87
		}
88
		
88
		
89
		public bool CanResize {
89
		public bool CanResize {
90
			get {
90
			get { return splitContainer.InvokeSync (s => !(s.Panel1Collapsed || s.Panel2Collapsed)); }
91
				return Helper.SynchronizedGet<SWF.SplitContainer, bool> (
92
					splitContainer,
93
					s => !(s.Panel1Collapsed || s.Panel2Collapsed)
94
				);
95
			}
96
		}
91
		}
97
		
92
		
98
		public bool CanRotate {
93
		public bool CanRotate {
Lines 109-115 namespace Mono.UIAutomation.Winforms.Behaviors.SplitContainer Link Here
109
			if (!CanResize)
104
			if (!CanResize)
110
				throw new InvalidOperationException ();
105
				throw new InvalidOperationException ();
111
106
112
			Helper.SynchronizedSet (splitContainer, delegate {
107
			splitContainer.InvokeSync (delegate {
113
				if (splitContainer.Orientation == SWF.Orientation.Horizontal)
108
				if (splitContainer.Orientation == SWF.Orientation.Horizontal)
114
					splitContainer.Panel1.Width = (int) width;
109
					splitContainer.Panel1.Width = (int) width;
115
				else
110
				else
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/StatusBar/GridProviderBehavior.cs (-5 / +1 lines)
Lines 86-96 namespace Mono.UIAutomation.Winforms.Behaviors.StatusBar Link Here
86
		}
86
		}
87
		
87
		
88
		public int ColumnCount {
88
		public int ColumnCount {
89
			get {
89
			get { return statusBar.InvokeSync (s => s.Panels.Count); }
90
				return Helper.SynchronizedGet<SWF.StatusBar, int> (
91
					statusBar, s => s.Panels.Count
92
				);
93
			}
94
		}
90
		}
95
		
91
		
96
		public IRawElementProviderSimple GetItem (int row, int column)
92
		public IRawElementProviderSimple GetItem (int row, int column)
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/StatusBar/StatusBarPanelGridItemProviderBehavior.cs (-3 / +1 lines)
Lines 101-109 namespace Mono.UIAutomation.Winforms.Behaviors.StatusBar Link Here
101
		
101
		
102
		public int Column {
102
		public int Column {
103
			get {
103
			get {
104
				return Helper.SynchronizedGet<SWF.StatusBar, int> (
104
				return statusBarPanel.Parent.InvokeSync (s => s.Panels.IndexOf (statusBarPanel));
105
					statusBarPanel.Parent, s => s.Panels.IndexOf (statusBarPanel)
106
				);
107
			}
105
			}
108
		}
106
		}
109
		
107
		
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/StatusStrip/GridProviderBehavior.cs (-5 / +1 lines)
Lines 86-96 namespace Mono.UIAutomation.Winforms.Behaviors.StatusStrip Link Here
86
		}
86
		}
87
		
87
		
88
		public int ColumnCount {
88
		public int ColumnCount {
89
			get {
89
			get { return statusStrip.InvokeSync (s => s.Items.Count); }
90
				return Helper.SynchronizedGet<SWF.StatusStrip, int> (
91
					statusStrip, s => s.Items.Count
92
				);
93
			}
94
		}
90
		}
95
		
91
		
96
		public IRawElementProviderSimple GetItem (int row, int column)
92
		public IRawElementProviderSimple GetItem (int row, int column)
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/TabControl/ScrollProviderBehavior.cs (-8 / +4 lines)
Lines 105-122 namespace Mono.UIAutomation.Winforms.Behaviors.TabControl Link Here
105
105
106
		public double HorizontalScrollPercent {
106
		public double HorizontalScrollPercent {
107
			get {
107
			get {
108
				return Helper.SynchronizedGet<SWF.TabControl, double> (tabControl, t => {
108
				return tabControl.InvokeSync (t => {
109
					if (!t.ShowSlider)
109
					if (!t.ShowSlider)
110
						return ScrollPatternIdentifiers.NoScroll;
110
						return ScrollPatternIdentifiers.NoScroll;
111
					else
111
					else
112
						return 100 / t.TabCount;
112
						return (double) (100 / t.TabCount);
113
				});
113
				});
114
			}
114
			}
115
		}
115
		}
116
116
117
		public double HorizontalViewSize {
117
		public double HorizontalViewSize {
118
			get {
118
			get {
119
				return Helper.SynchronizedGet<SWF.TabControl, double> (tabControl, t => {
119
				return tabControl.InvokeSync (t => {
120
					if (!t.ShowSlider)
120
					if (!t.ShowSlider)
121
						return 100;
121
						return 100;
122
					else {
122
					else {
Lines 146-156 namespace Mono.UIAutomation.Winforms.Behaviors.TabControl Link Here
146
		}
146
		}
147
147
148
		public bool HorizontallyScrollable {
148
		public bool HorizontallyScrollable {
149
			get {
149
			get { return tabControl.InvokeSync (t => t.ShowSlider); }
150
				return Helper.SynchronizedGet<SWF.TabControl, bool> (
151
					tabControl, t => t.ShowSlider
152
				);
153
			}
154
		}
150
		}
155
151
156
		public bool VerticallyScrollable {
152
		public bool VerticallyScrollable {
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/TabPage/SelectionItemProviderBehavior.cs (-1 / +1 lines)
Lines 112-118 namespace Mono.UIAutomation.Winforms.Behaviors.TabPage Link Here
112
				return;
112
				return;
113
			}
113
			}
114
114
115
			Helper.SynchronizedSet (pageProvider.TabControlProvider.Control, delegate {
115
			pageProvider.TabControlProvider.Control.InvokeSync (delegate {
116
				pageProvider.TabControlProvider.SelectItem (pageProvider);
116
				pageProvider.TabControlProvider.SelectItem (pageProvider);
117
			});
117
			});
118
		}
118
		}
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/TextBox/CaretProviderBehavior.cs (-31 / +23 lines)
Lines 70-77 namespace Mono.UIAutomation.Winforms.Behaviors.TextBox Link Here
70
			get {
70
			get {
71
				// TODO: This won't scale; we really should
71
				// TODO: This won't scale; we really should
72
				// find a better way of doing it
72
				// find a better way of doing it
73
				return Helper.SynchronizedGet<SWF.Control, int> (Provider.Control, 
73
				return Provider.Control.InvokeSync (c => {
74
					delegate {
75
						SWF.Document document = Document;
74
						SWF.Document document = Document;
76
						if (document.caret.line.line_no > document.Lines)
75
						if (document.caret.line.line_no > document.Lines)
77
							return Text.Length;
76
							return Text.Length;
Lines 84-108 namespace Mono.UIAutomation.Winforms.Behaviors.TextBox Link Here
84
83
85
		public bool SetCaretOffset (int offset)
84
		public bool SetCaretOffset (int offset)
86
		{
85
		{
87
			return Helper.SynchronizedGet<SWF.Control, bool> (Provider.Control,
86
			return Provider.Control.InvokeSync (c => {
88
				delegate {
87
				if (offset < 0)
89
					if (offset < 0)
90
						return false;
91
					SWF.Document document = Document;
92
					int curPos = 0;
93
					SWF.Line line = null;
94
					for (int i = 1;i <= document.Lines;i++) {
95
						line = document.GetLine (i);
96
						int length = line.Text.ToString().Length;
97
						if (curPos + length >= offset) {
98
							document.PositionCaret (line, offset - curPos);
99
							return true;
100
						}
101
						curPos += length;
102
					}
103
					return false;
88
					return false;
89
				SWF.Document document = Document;
90
				int curPos = 0;
91
				SWF.Line line = null;
92
				for (int i = 1;i <= document.Lines;i++) {
93
					line = document.GetLine (i);
94
					int length = line.Text.ToString().Length;
95
					if (curPos + length >= offset) {
96
						document.PositionCaret (line, offset - curPos);
97
						return true;
98
					}
99
					curPos += length;
104
				}
100
				}
105
			);
101
				return false;
102
			});
106
		}
103
		}
107
104
108
		public string GetSelection (int selectionNum, out int startOffset, out int endOffset)
105
		public string GetSelection (int selectionNum, out int startOffset, out int endOffset)
Lines 112-119 namespace Mono.UIAutomation.Winforms.Behaviors.TextBox Link Here
112
				return null;
109
				return null;
113
			SWF.TextBoxBase textBoxBase = TextBoxBase;
110
			SWF.TextBoxBase textBoxBase = TextBoxBase;
114
			if (TextBoxBase.Document.SelectionVisible) {
111
			if (TextBoxBase.Document.SelectionVisible) {
115
				int sel_start = Helper.SynchronizedGet<SWF.TextBoxBase, int> (textBoxBase, t => t.SelectionStart);
112
				int sel_start = textBoxBase.InvokeSync (t => t.SelectionStart);
116
				int sel_len = Helper.SynchronizedGet<SWF.TextBoxBase, int> (textBoxBase, t => t.SelectionLength);
113
				int sel_len = textBoxBase.InvokeSync (t => t.SelectionLength);
117
				string text = Text;
114
				string text = Text;
118
115
119
				startOffset = sel_start;
116
				startOffset = sel_start;
Lines 136-142 namespace Mono.UIAutomation.Winforms.Behaviors.TextBox Link Here
136
				if (Provider.Control is SWF.TextBoxBase)
133
				if (Provider.Control is SWF.TextBoxBase)
137
					return (SWF.TextBoxBase)Provider.Control;
134
					return (SWF.TextBoxBase)Provider.Control;
138
				else if (Provider.Control is SWF.UpDownBase)
135
				else if (Provider.Control is SWF.UpDownBase)
139
					return ((SWF.UpDownBase)Provider.Control).txtView;
136
					return ((SWF.UpDownBase)Provider.Control).InvokeSync (c => c.txtView);
140
				else
137
				else
141
					throw new Exception ("TextBoxBase: Unknown type: " + Provider.Control);
138
					throw new Exception ("TextBoxBase: Unknown type: " + Provider.Control);
142
			}
139
			}
Lines 145-163 namespace Mono.UIAutomation.Winforms.Behaviors.TextBox Link Here
145
		private string Text {
142
		private string Text {
146
			get {
143
			get {
147
				if (TextBoxBase is SWF.MaskedTextBox) {
144
				if (TextBoxBase is SWF.MaskedTextBox) {
148
					return Helper.SynchronizedGet<SWF.MaskedTextBox, string> (
145
					return ((SWF.MaskedTextBox) TextBoxBase).InvokeSync (t => t.MaskedTextProvider.ToDisplayString ());
149
						(SWF.MaskedTextBox) TextBoxBase, t => t.MaskedTextProvider.ToDisplayString ()
150
					);
151
				} else {
146
				} else {
152
					return Helper.SynchronizedGet<SWF.TextBoxBase, string> (
147
					return TextBoxBase.InvokeSync (t => t.Text);
153
						TextBoxBase, t => t.Text
154
					);
155
				}
148
				}
156
			}
149
			}
157
			set {
150
			set {
158
				Helper.SynchronizedSet (TextBoxBase, delegate {
151
				SWF.TextBoxBase textBoxBase = TextBoxBase;
159
					TextBoxBase.Text = value;
152
				textBoxBase.InvokeSync (delegate { textBoxBase.Text = value; });
160
				});
161
			}
153
			}
162
		}
154
		}
163
155
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/TextBox/ClipboardProviderBehavior.cs (-6 / +9 lines)
Lines 62-68 namespace Mono.UIAutomation.Winforms.Behaviors.TextBox Link Here
62
62
63
		public void Copy (int start, int end)
63
		public void Copy (int start, int end)
64
		{
64
		{
65
			Helper.SynchronizedSet (TextBoxBase, delegate {
65
			TextBoxBase.InvokeSync (delegate {
66
				string text = Text;
66
				string text = Text;
67
				start = (int) System.Math.Max (start, 0);
67
				start = (int) System.Math.Max (start, 0);
68
				end = (int) System.Math.Min (end, text.Length);
68
				end = (int) System.Math.Min (end, text.Length);
Lines 72-78 namespace Mono.UIAutomation.Winforms.Behaviors.TextBox Link Here
72
		
72
		
73
		public void Paste (int position)
73
		public void Paste (int position)
74
		{
74
		{
75
			Helper.SynchronizedSet (TextBoxBase, delegate {
75
			TextBoxBase.InvokeSync (delegate {
76
				string text = Text;
76
				string text = Text;
77
				position = (int) System.Math.Max (position, 0);
77
				position = (int) System.Math.Max (position, 0);
78
				position = (int) System.Math.Min (position, text.Length);
78
				position = (int) System.Math.Min (position, text.Length);
Lines 105-111 namespace Mono.UIAutomation.Winforms.Behaviors.TextBox Link Here
105
				if (Provider.Control is SWF.TextBoxBase)
105
				if (Provider.Control is SWF.TextBoxBase)
106
					return (SWF.TextBoxBase)Provider.Control;
106
					return (SWF.TextBoxBase)Provider.Control;
107
				else if (Provider.Control is SWF.UpDownBase)
107
				else if (Provider.Control is SWF.UpDownBase)
108
					return ((SWF.UpDownBase)Provider.Control).txtView;
108
					return ((SWF.UpDownBase)Provider.Control).InvokeSync (c => c.txtView);
109
				else
109
				else
110
					throw new Exception ("TextBoxBase: Unknown type: " + Provider.Control);
110
					throw new Exception ("TextBoxBase: Unknown type: " + Provider.Control);
111
			}
111
			}
Lines 114-124 namespace Mono.UIAutomation.Winforms.Behaviors.TextBox Link Here
114
		private string Text {
114
		private string Text {
115
			get {
115
			get {
116
				if (TextBoxBase is SWF.MaskedTextBox)
116
				if (TextBoxBase is SWF.MaskedTextBox)
117
					return ((SWF.MaskedTextBox) TextBoxBase).MaskedTextProvider.ToDisplayString ();
117
					return ((SWF.MaskedTextBox) TextBoxBase).InvokeSync (c => c.MaskedTextProvider.ToDisplayString ());
118
				else
118
				else
119
					return TextBoxBase.Text;
119
					return TextBoxBase.InvokeSync (c => c.Text);
120
			}
121
			set {
122
				SWF.TextBoxBase textBoxBase = TextBoxBase;
123
				textBoxBase.InvokeSync (delegate { textBoxBase.Text = value; }); 
120
			}
124
			}
121
			set { TextBoxBase.Text = value; }
122
		}
125
		}
123
126
124
	}
127
	}
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/TextBox/TextProviderBehavior.cs (-13 / +16 lines)
Lines 72-78 namespace Mono.UIAutomation.Winforms.Behaviors.TextBox Link Here
72
			if (propertyId == AutomationElementIdentifiers.IsPasswordProperty.Id) {
72
			if (propertyId == AutomationElementIdentifiers.IsPasswordProperty.Id) {
73
				if (Provider.Control is SWF.TextBox) {
73
				if (Provider.Control is SWF.TextBox) {
74
					SWF.TextBox textbox = TextBox;
74
					SWF.TextBox textbox = TextBox;
75
					return (textbox.UseSystemPasswordChar || (int) textbox.PasswordChar != 0);
75
					return textbox.InvokeSync (c => c.UseSystemPasswordChar || (int) c.PasswordChar != 0);
76
				} else if (Provider.Control is SWF.RichTextBox) {
76
				} else if (Provider.Control is SWF.RichTextBox) {
77
					return false;
77
					return false;
78
				}
78
				}
Lines 102-122 namespace Mono.UIAutomation.Winforms.Behaviors.TextBox Link Here
102
				
102
				
103
			//TODO: Return null when system cursor is not present, how to?
103
			//TODO: Return null when system cursor is not present, how to?
104
104
105
			if (!TextBoxBase.Document.SelectionVisible)
105
			return TextBoxBase.InvokeSync (c => {
106
				return new ITextRangeProvider [0];
106
				if (!c.Document.SelectionVisible)
107
107
					return new ITextRangeProvider [0];
108
			int sel_len = Helper.SynchronizedGet<SWF.TextBoxBase, int> (TextBoxBase, t => t.SelectionLength);
108
	
109
			int sel_start = Helper.SynchronizedGet<SWF.TextBoxBase, int> (TextBoxBase, t => t.SelectionStart);
109
				int sel_len = c.SelectionLength;
110
110
				int sel_start = c.SelectionStart;
111
			return new ITextRangeProvider [] { 
111
	
112
				new TextRangeProvider (this, TextBoxBase, sel_start, sel_start + sel_len)
112
				return new ITextRangeProvider [] { 
113
			};
113
					new TextRangeProvider (this, TextBoxBase, sel_start, sel_start + sel_len)
114
				};
115
			});
114
		}
116
		}
115
		
117
		
116
		public ITextRangeProvider[] GetVisibleRanges ()
118
		public ITextRangeProvider[] GetVisibleRanges ()
117
		{
119
		{
118
			int start_line = -1, end_line = -1;
120
			int start_line = -1, end_line = -1;
119
			Document.GetVisibleLineIndexes (TextBoxBase.Bounds, out start_line, out end_line);
121
			System.Drawing.Rectangle bounds = TextBoxBase.InvokeSync (c => c.Bounds);
122
			Document.GetVisibleLineIndexes (bounds, out start_line, out end_line);
120
123
121
			ITextRangeProvider range = DocumentRange.Clone ();
124
			ITextRangeProvider range = DocumentRange.Clone ();
122
			range.MoveEndpointByUnit (TextPatternRangeEndpoint.Start, TextUnit.Line, start_line);
125
			range.MoveEndpointByUnit (TextPatternRangeEndpoint.Start, TextUnit.Line, start_line);
Lines 158-164 namespace Mono.UIAutomation.Winforms.Behaviors.TextBox Link Here
158
				if (Provider.Control is SWF.TextBoxBase)
161
				if (Provider.Control is SWF.TextBoxBase)
159
					return (SWF.TextBoxBase)Provider.Control;
162
					return (SWF.TextBoxBase)Provider.Control;
160
				else if (Provider.Control is SWF.UpDownBase)
163
				else if (Provider.Control is SWF.UpDownBase)
161
					return ((SWF.UpDownBase)Provider.Control).txtView;
164
					return ((SWF.UpDownBase)Provider.Control).InvokeSync (c => c.txtView);
162
				else
165
				else
163
					throw new Exception ("TextBoxBase: Unknown type: " + Provider.Control);
166
					throw new Exception ("TextBoxBase: Unknown type: " + Provider.Control);
164
			}
167
			}
Lines 171-177 namespace Mono.UIAutomation.Winforms.Behaviors.TextBox Link Here
171
		}
174
		}
172
175
173
		private SWF.Document Document { 
176
		private SWF.Document Document { 
174
			get { return TextBoxBase.Document; }
177
			get { return TextBoxBase.InvokeSync (c => c.Document); }
175
		}
178
		}
176
	}
179
	}
177
}
180
}
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/TextBox/ValueProviderBehavior.cs (-12 / +6 lines)
Lines 84-93 namespace Mono.UIAutomation.Winforms.Behaviors.TextBox Link Here
84
		
84
		
85
		public bool IsReadOnly {
85
		public bool IsReadOnly {
86
			get {
86
			get {
87
				return Helper.SynchronizedGet<SWF.TextBoxBase, bool> (
87
				return ((SWF.TextBoxBase) Provider.Control).InvokeSync (c => c.ReadOnly 
88
					(SWF.TextBoxBase) Provider.Control,
88
				                                                         || !c.Enabled);
89
					t => t.ReadOnly || !t.Enabled
90
				);
91
			}
89
			}
92
		}
90
		}
93
		
91
		
Lines 95-110 namespace Mono.UIAutomation.Winforms.Behaviors.TextBox Link Here
95
			get {
93
			get {
96
				if (Provider.Control is SWF.MaskedTextBox) {
94
				if (Provider.Control is SWF.MaskedTextBox) {
97
					System.ComponentModel.MaskedTextProvider mtp
95
					System.ComponentModel.MaskedTextProvider mtp
98
						= ((SWF.MaskedTextBox) Provider.Control).MaskedTextProvider;
96
						= ((SWF.MaskedTextBox) Provider.Control).InvokeSync (c => c.MaskedTextProvider);
99
					if (mtp != null) {
97
					if (mtp != null) {
100
						return Helper.SynchronizedGet<SWF.Control, string> (Provider.Control,
98
						return mtp.ToDisplayString ();
101
							c => { return mtp.ToDisplayString (); }
102
						);
103
					}
99
					}
104
				}
100
				}
105
101
106
				return Helper.SynchronizedGet<SWF.Control, string> (
102
				return Provider.Control.InvokeSync (c => c.Text);
107
					Provider.Control, c => c.Text);
108
			}
103
			}
109
		}
104
		}
110
105
Lines 113-120 namespace Mono.UIAutomation.Winforms.Behaviors.TextBox Link Here
113
			if (IsReadOnly)
108
			if (IsReadOnly)
114
				throw new ElementNotEnabledException ();
109
				throw new ElementNotEnabledException ();
115
110
116
			Helper.SynchronizedSet (Provider.Control, 
111
			Provider.Control.InvokeSync (delegate {
117
				delegate {
118
					int maxLength = ((TextBoxProvider) Provider).MaxLength;
112
					int maxLength = ((TextBoxProvider) Provider).MaxLength;
119
					if (maxLength > 0
113
					if (maxLength > 0
120
					    && value.Length > maxLength) {
114
					    && value.Length > maxLength) {
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/ToolBar/ToolBarButtonExpandCollapseProviderBehavior.cs (-3 / +2 lines)
Lines 83-90 namespace Mono.UIAutomation.Winforms.Behaviors.ToolBar Link Here
83
				if (menu == null)
83
				if (menu == null)
84
					return ExpandCollapseState.Collapsed;
84
					return ExpandCollapseState.Collapsed;
85
85
86
				return Helper.SynchronizedGet<SWF.ToolBar, ExpandCollapseState> (
86
				return toolBar.InvokeSync (t => toolBarButton.Pushed ? ExpandCollapseState.Expanded
87
					toolBar, t => toolBarButton.Pushed ? ExpandCollapseState.Expanded
88
					                                   : ExpandCollapseState.Collapsed
87
					                                   : ExpandCollapseState.Collapsed
89
				);
88
				);
90
			}
89
			}
Lines 112-118 namespace Mono.UIAutomation.Winforms.Behaviors.ToolBar Link Here
112
111
113
		private void PerformExpandCollapse ()
112
		private void PerformExpandCollapse ()
114
		{
113
		{
115
			Helper.SynchronizedSet (toolBar, delegate {
114
			toolBar.InvokeSync (delegate {
116
				SWF.ContextMenu menu = toolBarButton.DropDownMenu as SWF.ContextMenu;
115
				SWF.ContextMenu menu = toolBarButton.DropDownMenu as SWF.ContextMenu;
117
				if (menu == null)
116
				if (menu == null)
118
					return;
117
					return;
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/ToolBar/ToolBarButtonInvokeProviderBehavior.cs (-5 / +3 lines)
Lines 71-85 namespace Mono.UIAutomation.Winforms.Behaviors.ToolBar Link Here
71
		
71
		
72
		public void Invoke ()
72
		public void Invoke ()
73
		{
73
		{
74
			bool notEnabled = Helper.SynchronizedGet<SWF.ToolBar, bool> (
74
			bool notEnabled = toolBar.InvokeSync (t => !t.Enabled || !toolBarButton.Enabled);
75
				toolBar, t => !t.Enabled || !toolBarButton.Enabled
76
			);
77
				
75
				
78
			if (notEnabled)
76
			if (notEnabled)
79
				throw new ElementNotEnabledException ();
77
				throw new ElementNotEnabledException ();
80
78
81
			Helper.SynchronizedSet (toolBar, delegate {
79
			toolBar.InvokeSync (delegate {
82
				toolBarButton.Parent.UIAPerformClick (toolBarButton);
80
				toolBar.UIAPerformClick (toolBarButton);
83
			});
81
			});
84
		}
82
		}
85
		
83
		
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/ToolBar/ToolBarButtonToggleProviderBehavior.cs (-4 / +5 lines)
Lines 79-87 namespace Mono.UIAutomation.Winforms.Behaviors.ToolBar Link Here
79
		public ToggleState ToggleState
79
		public ToggleState ToggleState
80
		{
80
		{
81
			get {
81
			get {
82
				return Helper.SynchronizedGet<SWF.ToolBar, ToggleState> (
82
				if (toolBar.InvokeSync (t => toolBarButton.Pushed))
83
					toolBar, t => toolBarButton.Pushed ? ToggleState.On : ToggleState.Off
83
					return ToggleState.On;
84
				);
84
				else
85
					return ToggleState.Off;
85
			}
86
			}
86
		}
87
		}
87
88
Lines 90-96 namespace Mono.UIAutomation.Winforms.Behaviors.ToolBar Link Here
90
			if (!toolBarButton.Enabled)
91
			if (!toolBarButton.Enabled)
91
				throw new ElementNotEnabledException ();
92
				throw new ElementNotEnabledException ();
92
93
93
			Helper.SynchronizedSet (toolBar, delegate {
94
			toolBar.InvokeSync (delegate {
94
				toolBar.UIAPerformClick (toolBarButton);
95
				toolBar.UIAPerformClick (toolBarButton);
95
			});
96
			});
96
		}
97
		}
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/ToolStripButton/InvokeProviderBehavior.cs (-1 / +1 lines)
Lines 72-78 namespace Mono.UIAutomation.Winforms.Behaviors.ToolStripButton Link Here
72
				throw new ElementNotEnabledException ();
72
				throw new ElementNotEnabledException ();
73
73
74
			SWF.ToolStrip toolstrip = ((SWF.ToolStripButton) Provider.Component).Owner;
74
			SWF.ToolStrip toolstrip = ((SWF.ToolStripButton) Provider.Component).Owner;
75
			Helper.SynchronizedSet (toolstrip, delegate {
75
			toolstrip.InvokeSync (delegate {
76
				button.PerformClick ();
76
				button.PerformClick ();
77
			});
77
			});
78
		}
78
		}
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/ToolStripButton/ToggleProviderBehavior.cs (-9 / +3 lines)
Lines 75-83 namespace Mono.UIAutomation.Winforms.Behaviors.ToolStripButton Link Here
75
		public ToggleState ToggleState {
75
		public ToggleState ToggleState {
76
			get {
76
			get {
77
				SWF.CheckState state =
77
				SWF.CheckState state =
78
					Helper.SynchronizedGet<SWF.ToolStrip, SWF.CheckState> (
78
					Owner.InvokeSync (delegate { return button.CheckState; });
79
						Owner, delegate { return button.CheckState; }
80
					);
81
79
82
				switch (state) {
80
				switch (state) {
83
				case SWF.CheckState.Checked:
81
				case SWF.CheckState.Checked:
Lines 97-105 namespace Mono.UIAutomation.Winforms.Behaviors.ToolStripButton Link Here
97
				throw new ElementNotEnabledException ();
95
				throw new ElementNotEnabledException ();
98
96
99
			SWF.CheckState state =
97
			SWF.CheckState state =
100
				Helper.SynchronizedGet<SWF.ToolStrip, SWF.CheckState> (
98
				Owner.InvokeSync (delegate { return button.CheckState; });
101
					Owner, delegate { return button.CheckState; }
102
				);
103
99
104
			switch (state) {
100
			switch (state) {
105
			case SWF.CheckState.Checked:
101
			case SWF.CheckState.Checked:
Lines 119-125 namespace Mono.UIAutomation.Winforms.Behaviors.ToolStripButton Link Here
119
#region Private Methods
115
#region Private Methods
120
		private void PerformToggle (SWF.ToolStripButton button, SWF.CheckState state)
116
		private void PerformToggle (SWF.ToolStripButton button, SWF.CheckState state)
121
		{
117
		{
122
			Helper.SynchronizedSet (Owner, delegate {
118
			Owner.InvokeSync (delegate {
123
				button.CheckState = state;
119
				button.CheckState = state;
124
			});
120
			});
125
		}
121
		}
Lines 135-140 namespace Mono.UIAutomation.Winforms.Behaviors.ToolStripButton Link Here
135
		private SWF.ToolStripButton button;
131
		private SWF.ToolStripButton button;
136
#endregion
132
#endregion
137
	}
133
	}
138
139
	delegate void PerformToggleDelegate (SWF.ToolStripButton button, SWF.CheckState state);
140
}
134
}
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/ToolStripItem/InvokeProviderBehavior.cs (-1 / +1 lines)
Lines 93-99 namespace Mono.UIAutomation.Winforms.Behaviors.ToolStripItem Link Here
93
		{
93
		{
94
			SWF.ToolStripItem item = (SWF.ToolStripItem) Provider.Component;
94
			SWF.ToolStripItem item = (SWF.ToolStripItem) Provider.Component;
95
			if (item.Owner != null)
95
			if (item.Owner != null)
96
				Helper.SynchronizedSet (item.Owner, delegate { 
96
				item.Owner.InvokeSync (delegate { 
97
					PerformClick (item); 
97
					PerformClick (item); 
98
				});
98
				});
99
			else // Hopefully we shouldn't have any issue
99
			else // Hopefully we shouldn't have any issue
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/ToolStripSplitButton/ExpandCollapseProviderBehavior.cs (-4 / +3 lines)
Lines 77-84 namespace Mono.UIAutomation.Winforms.Behaviors.ToolStripSplitButton Link Here
77
				if (dropdown == null)
77
				if (dropdown == null)
78
					return ExpandCollapseState.Collapsed;
78
					return ExpandCollapseState.Collapsed;
79
79
80
				return Helper.SynchronizedGet<SWF.ToolStrip, ExpandCollapseState> (
80
				return Owner.InvokeSync (o => dropdown.Visible ? ExpandCollapseState.Expanded
81
					Owner, o => dropdown.Visible ? ExpandCollapseState.Expanded
82
				                                     : ExpandCollapseState.Collapsed
81
				                                     : ExpandCollapseState.Collapsed
83
				);
82
				);
84
			}
83
			}
Lines 86-99 namespace Mono.UIAutomation.Winforms.Behaviors.ToolStripSplitButton Link Here
86
85
87
		public void Collapse ()
86
		public void Collapse ()
88
		{
87
		{
89
			Helper.SynchronizedSet (Owner, delegate {
88
			Owner.InvokeSync (delegate {
90
				((SWF.ToolStripSplitButton) Provider.Component).HideDropDown ();
89
				((SWF.ToolStripSplitButton) Provider.Component).HideDropDown ();
91
			});
90
			});
92
		}
91
		}
93
92
94
		public void Expand ()
93
		public void Expand ()
95
		{
94
		{
96
			Helper.SynchronizedSet (Owner, delegate {
95
			Owner.InvokeSync (delegate {
97
				((SWF.ToolStripSplitButton) Provider.Component).ShowDropDown ();
96
				((SWF.ToolStripSplitButton) Provider.Component).ShowDropDown ();
98
			});
97
			});
99
		}
98
		}
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/TrackBar/ButtonInvokeProviderBehavior.cs (-2 / +2 lines)
Lines 84-93 namespace Mono.UIAutomation.Winforms.Behaviors.TrackBar Link Here
84
		
84
		
85
		public void Invoke ()
85
		public void Invoke ()
86
		{
86
		{
87
			if (!Provider.Control.Enabled)
87
			if (Provider.Control.InvokeSync (c => !c.Enabled))
88
				throw new ElementNotEnabledException ();
88
				throw new ElementNotEnabledException ();
89
89
90
			Helper.SynchronizedSet (Provider.Control, delegate {
90
			Provider.Control.InvokeSync (delegate {
91
				if (provider.Orientation == TrackBarProvider.TrackBarButtonOrientation.LargeBack)
91
				if (provider.Orientation == TrackBarProvider.TrackBarButtonOrientation.LargeBack)
92
					((SWF.TrackBar)Provider.Control).LargeDecrement ();
92
					((SWF.TrackBar)Provider.Control).LargeDecrement ();
93
				else if (provider.Orientation == TrackBarProvider.TrackBarButtonOrientation.LargeForward)
93
				else if (provider.Orientation == TrackBarProvider.TrackBarButtonOrientation.LargeForward)
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/TrackBar/RangeValueProviderBehavior.cs (-31 / +7 lines)
Lines 112-168 namespace Mono.UIAutomation.Winforms.Behaviors.TrackBar Link Here
112
			if (value < Minimum || value > Maximum)
112
			if (value < Minimum || value > Maximum)
113
				throw new ArgumentOutOfRangeException ();
113
				throw new ArgumentOutOfRangeException ();
114
			
114
			
115
			Helper.SynchronizedSet (trackbar, delegate {
115
			trackbar.InvokeSync (delegate {
116
				trackbar.Value = (int) value;
116
				trackbar.Value = (int) value;
117
			});
117
			});
118
		}
118
		}
119
		
119
		
120
		public bool IsReadOnly {
120
		public bool IsReadOnly {
121
			get {
121
			get { return trackbar.InvokeSync (t => !t.Enabled || !t.Visible); }
122
				return Helper.SynchronizedGet<SWF.TrackBar, bool> (
123
					trackbar, t => !t.Enabled || !t.Visible
124
				);
125
			}
126
		}
122
		}
127
		
123
		
128
		public double LargeChange {
124
		public double LargeChange {
129
			get {
125
			get { return trackbar.InvokeSync (t => t.LargeChange); }
130
				return Helper.SynchronizedGet<SWF.TrackBar, double> (
131
					trackbar, t => t.LargeChange
132
				);
133
			}
134
		}
126
		}
135
		
127
		
136
		public double Maximum {
128
		public double Maximum {
137
			get {
129
			get { return trackbar.InvokeSync (t => t.Maximum); }
138
				return Helper.SynchronizedGet<SWF.TrackBar, double> (
139
					trackbar, t => t.Maximum
140
				);
141
			}
142
		}
130
		}
143
		
131
		
144
		public double Minimum {
132
		public double Minimum {
145
			get {
133
			get { return trackbar.InvokeSync (t => t.Minimum); }
146
				return Helper.SynchronizedGet<SWF.TrackBar, double> (
147
					trackbar, t => t.Minimum
148
				);
149
			}
150
		}
134
		}
151
		
135
		
152
		public double SmallChange {
136
		public double SmallChange {
153
			get {
137
			get { return trackbar.InvokeSync (t => t.SmallChange); }
154
				return Helper.SynchronizedGet<SWF.TrackBar, double> (
155
					trackbar, t => t.SmallChange
156
				);
157
			}
158
		}
138
		}
159
		
139
		
160
		public double Value {
140
		public double Value {
161
			get {
141
			get { return trackbar.InvokeSync (t => t.Value); }
162
				return Helper.SynchronizedGet<SWF.TrackBar, double> (
163
					trackbar, t => t.Value
164
				);
165
			}
166
		}
142
		}
167
		
143
		
168
		#endregion 
144
		#endregion 
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/TreeView/SelectionProviderBehavior.cs (-4 / +2 lines)
Lines 92-98 namespace Mono.UIAutomation.Winforms.Behaviors.TreeView Link Here
92
		
92
		
93
		public IRawElementProviderSimple [] GetSelection ()
93
		public IRawElementProviderSimple [] GetSelection ()
94
		{
94
		{
95
			SWF.TreeNode selectedNode = treeView.SelectedNode;
95
			SWF.TreeNode selectedNode = treeView.InvokeSync (c => c.SelectedNode);
96
			TreeNodeProvider selectedNodeProvider = null;
96
			TreeNodeProvider selectedNodeProvider = null;
97
			
97
			
98
			if (selectedNode != null)
98
			if (selectedNode != null)
Lines 110-118 namespace Mono.UIAutomation.Winforms.Behaviors.TreeView Link Here
110
		
110
		
111
		public bool IsSelectionRequired {
111
		public bool IsSelectionRequired {
112
			get {
112
			get {
113
				return Helper.SynchronizedGet<SWF.TreeView, bool> (
113
				return treeView.InvokeSync (t => t.SelectedNode != null);
114
					treeView, t => t.SelectedNode != null
115
				);
116
			}
114
			}
117
		}
115
		}
118
		
116
		
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/UpDownBase/ButtonInvokeProviderBehavior.cs (-1 / +1 lines)
Lines 69-75 namespace Mono.UIAutomation.Winforms.Behaviors.UpDownBase Link Here
69
		
69
		
70
		public void Invoke ()
70
		public void Invoke ()
71
		{
71
		{
72
			Helper.SynchronizedSet (provider.UpDownBase, delegate {
72
			provider.UpDownBase.InvokeSync (delegate {
73
				if (provider.Orientation == UpDownBaseProvider.UpDownBaseButtonOrientation.Forward)
73
				if (provider.Orientation == UpDownBaseProvider.UpDownBaseButtonOrientation.Forward)
74
					provider.UpDownBase.UpButton ();
74
					provider.UpDownBase.UpButton ();
75
				else if (provider.Orientation == UpDownBaseProvider.UpDownBaseButtonOrientation.Backward)
75
				else if (provider.Orientation == UpDownBaseProvider.UpDownBaseButtonOrientation.Backward)
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/UpDownBase/ValueProviderBehavior.cs (-15 / +5 lines)
Lines 82-110 namespace Mono.UIAutomation.Winforms.Behaviors.UpDownBase Link Here
82
		#region IValueProvider Members
82
		#region IValueProvider Members
83
		
83
		
84
		public bool IsReadOnly {
84
		public bool IsReadOnly {
85
			get {
85
			get { return upDownBase.InvokeSync (c => c.ReadOnly); }
86
				return Helper.SynchronizedGet<SWF.UpDownBase, bool> (
87
					(SWF.UpDownBase) Provider.Control, u => u.ReadOnly
88
				);
89
			}
90
		}
86
		}
91
		
87
		
92
		public string Value {
88
		public string Value {
93
			get {
89
			get { return upDownBase.InvokeSync (c => c.Text); }
94
				return Helper.SynchronizedGet<SWF.UpDownBase, string> (
95
					(SWF.UpDownBase) Provider.Control, u => u.Text
96
				);
97
			}
98
		}
90
		}
99
		
91
		
100
		public void SetValue (string value)
92
		public void SetValue (string value)
101
		{
93
		{
102
			if (!upDownBase.Enabled || upDownBase.ReadOnly)
94
			if (upDownBase.InvokeSync (c => !c.Enabled || c.ReadOnly))
103
				throw new ElementNotEnabledException ();
95
				throw new ElementNotEnabledException ();
104
			
96
105
			Helper.SynchronizedSet (upDownBase, delegate {
97
			upDownBase.InvokeSync (delegate { upDownBase.Text = value; });
106
				upDownBase.Text = value;
107
			});
108
		}
98
		}
109
		
99
		
110
		#endregion
100
		#endregion
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Events/AutomationIsOffscreenPropertyEvent.cs (-4 / +4 lines)
Lines 48-73 namespace Mono.UIAutomation.Winforms.Events Link Here
48
		
48
		
49
		public override void Connect ()
49
		public override void Connect ()
50
		{
50
		{
51
//			Helper.SynchronizedSet (Provider.Control, delegate {
51
			Provider.Control.InvokeSync (delegate {
52
				Provider.Control.Resize += new EventHandler (OnIsOffScreen);
52
				Provider.Control.Resize += new EventHandler (OnIsOffScreen);
53
				Provider.Control.LocationChanged += new EventHandler (OnIsOffScreen);
53
				Provider.Control.LocationChanged += new EventHandler (OnIsOffScreen);
54
				if (Provider.Control.Parent != null)
54
				if (Provider.Control.Parent != null)
55
					Provider.Control.Parent.LocationChanged += new EventHandler (OnIsOffScreen);
55
					Provider.Control.Parent.LocationChanged += new EventHandler (OnIsOffScreen);
56
				if (Provider.Control.FindForm () != null)
56
				if (Provider.Control.FindForm () != null)
57
				Provider.Control.FindForm ().Resize += new EventHandler (OnIsOffScreen);
57
				Provider.Control.FindForm ().Resize += new EventHandler (OnIsOffScreen);
58
//			});
58
			});
59
		}
59
		}
60
60
61
		public override void Disconnect ()
61
		public override void Disconnect ()
62
		{
62
		{
63
//			Helper.SynchronizedSet (Provider.Control, delegate {
63
			Provider.Control.InvokeSync (delegate {
64
				Provider.Control.Resize -= new EventHandler (OnIsOffScreen);
64
				Provider.Control.Resize -= new EventHandler (OnIsOffScreen);
65
				Provider.Control.LocationChanged -= new EventHandler (OnIsOffScreen);
65
				Provider.Control.LocationChanged -= new EventHandler (OnIsOffScreen);
66
				if (Provider.Control.Parent != null)
66
				if (Provider.Control.Parent != null)
67
					Provider.Control.Parent.LocationChanged -= new EventHandler (OnIsOffScreen);
67
					Provider.Control.Parent.LocationChanged -= new EventHandler (OnIsOffScreen);
68
				if (Provider.Control.FindForm () != null)
68
				if (Provider.Control.FindForm () != null)
69
				Provider.Control.FindForm ().Resize -= new EventHandler (OnIsOffScreen);
69
				Provider.Control.FindForm ().Resize -= new EventHandler (OnIsOffScreen);
70
//			});
70
			});
71
		}
71
		}
72
		
72
		
73
		#endregion
73
		#endregion
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Events/AutomationIsPatternAvailablePropertyEvent.cs (-4 lines)
Lines 116-131 namespace Mono.UIAutomation.Winforms.Events Link Here
116
					return;
116
					return;
117
				
117
				
118
				bool newValue = val ?? false;
118
				bool newValue = val ?? false;
119
//				Helper.DelegateQueue.Get ().Enqueue (delegate {
120
//				System.Threading.ThreadPool.QueueUserWorkItem (v => {
121
				
122
				AutomationPropertyChangedEventArgs args 
119
				AutomationPropertyChangedEventArgs args 
123
					= new AutomationPropertyChangedEventArgs (property,
120
					= new AutomationPropertyChangedEventArgs (property,
124
					                                          !newValue,
121
					                                          !newValue,
125
					                                          newValue);
122
					                                          newValue);
126
				AutomationInteropProvider.RaiseAutomationPropertyChangedEvent (Provider, 
123
				AutomationInteropProvider.RaiseAutomationPropertyChangedEvent (Provider, 
127
				                                                               args);
124
				                                                               args);
128
//				});
129
			}
125
			}
130
		}
126
		}
131
		
127
		
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Events/BaseAutomationEvent.cs (-2 / +2 lines)
Lines 55-68 namespace Mono.UIAutomation.Winforms.Events Link Here
55
		protected void RaiseAutomationEvent ()
55
		protected void RaiseAutomationEvent ()
56
		{
56
		{
57
			if (AutomationInteropProvider.ClientsAreListening == true) {
57
			if (AutomationInteropProvider.ClientsAreListening == true) {
58
				Helper.DelegateQueue.Get ().Enqueue (delegate {
58
//				Helper.DelegateQueue.Get ().Enqueue (delegate {
59
//				System.Threading.ThreadPool.QueueUserWorkItem (v => {
59
//				System.Threading.ThreadPool.QueueUserWorkItem (v => {
60
					AutomationEventArgs args = 
60
					AutomationEventArgs args = 
61
						new AutomationEventArgs (Event);
61
						new AutomationEventArgs (Event);
62
					AutomationInteropProvider.RaiseAutomationEvent (Event, 
62
					AutomationInteropProvider.RaiseAutomationEvent (Event, 
63
					                                                Provider, 
63
					                                                Provider, 
64
					                                                args);
64
					                                                args);
65
				});
65
//				});
66
			}
66
			}
67
		}
67
		}
68
		
68
		
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Events/BaseAutomationPropertyEvent.cs (-11 / +7 lines)
Lines 69-85 namespace Mono.UIAutomation.Winforms.Events Link Here
69
				object newValue = GetNewPropertyValue ();
69
				object newValue = GetNewPropertyValue ();
70
70
71
				if (object.Equals (OldValue, newValue) == false) {
71
				if (object.Equals (OldValue, newValue) == false) {
72
					object oldValue = newValue;
72
					AutomationPropertyChangedEventArgs args =					
73
					OldValue = oldValue;
73
						new AutomationPropertyChangedEventArgs (Property,
74
					Helper.DelegateQueue.Get ().Enqueue (delegate {
74
						                                        OldValue,
75
//					System.Threading.ThreadPool.QueueUserWorkItem (v => {
75
						                                        newValue);
76
						AutomationPropertyChangedEventArgs args =					
76
					AutomationInteropProvider.RaiseAutomationPropertyChangedEvent (Provider, 
77
							new AutomationPropertyChangedEventArgs (Property,
77
					                                                               args);
78
							                                        oldValue,
78
					OldValue = newValue;
79
							                                        newValue);
80
						AutomationInteropProvider.RaiseAutomationPropertyChangedEvent (Provider, 
81
						                                                               args);
82
					});
83
				}
79
				}
84
			}
80
			}
85
		}
81
		}
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Events/ComboBox/ListItemSelectionItemPatternElementSelectedEvent.cs (-1 / +1 lines)
Lines 66-72 namespace Mono.UIAutomation.Winforms.Events.ComboBox Link Here
66
		{
66
		{
67
			ListItemProvider provider = (ListItemProvider) Provider;
67
			ListItemProvider provider = (ListItemProvider) Provider;
68
			
68
			
69
			if (provider.Index == ((SWF.ComboBox) provider.Control).SelectedIndex)
69
			if (provider.Index == ((SWF.ComboBox) provider.Control).InvokeSync (c => c.SelectedIndex))
70
				RaiseAutomationEvent ();
70
				RaiseAutomationEvent ();
71
		}
71
		}
72
		
72
		
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Events/ListBox/ListItemSelectionItemPatternElementSelectedEvent.cs (-3 / +5 lines)
Lines 68-76 namespace Mono.UIAutomation.Winforms.Events.ListBox Link Here
68
		{
68
		{
69
			ListItemProvider provider = (ListItemProvider) Provider;
69
			ListItemProvider provider = (ListItemProvider) Provider;
70
			
70
			
71
			if (((SWF.ListBox) provider.Control).SelectedIndex == provider.Index
71
			((SWF.ListBox) provider.Control).InvokeSync (c => {
72
			    && provider.ListProvider.SelectedItemsCount == 1)
72
				if (c.SelectedIndex == provider.Index
73
				RaiseAutomationEvent ();
73
				    && provider.ListProvider.SelectedItemsCount == 1)
74
					RaiseAutomationEvent ();
75
			});
74
		}
76
		}
75
77
76
		#endregion
78
		#endregion
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Events/ListView/HeaderItemAutomationBoundingRectanglePropertyEvent.cs (-3 / +5 lines)
Lines 60-68 namespace Mono.UIAutomation.Winforms.Events.ListView Link Here
60
60
61
		private void OnColumnWidthChanged (object sender, ColumnWidthChangedEventArgs args)
61
		private void OnColumnWidthChanged (object sender, ColumnWidthChangedEventArgs args)
62
		{
62
		{
63
			if (args.ColumnIndex
63
			itemProvider.HeaderProvider.ListView.InvokeSync (delegate {
64
			    == itemProvider.HeaderProvider.ListView.Columns.IndexOf (itemProvider.ColumnHeader))
64
				if (args.ColumnIndex
65
			    RaiseAutomationPropertyChangedEvent ();
65
				    == itemProvider.HeaderProvider.ListView.Columns.IndexOf (itemProvider.ColumnHeader))
66
				    RaiseAutomationPropertyChangedEvent ();
67
			});
66
		}
68
		}
67
69
68
		#endregion
70
		#endregion
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Events/ListView/HeaderItemAutomationIsOffScreenPropertyEvent.cs (-3 / +5 lines)
Lines 60-68 namespace Mono.UIAutomation.Winforms.Events.ListView Link Here
60
60
61
		private void OnColumnWidthChanged (object sender, ColumnWidthChangedEventArgs args)
61
		private void OnColumnWidthChanged (object sender, ColumnWidthChangedEventArgs args)
62
		{
62
		{
63
			if (args.ColumnIndex
63
			itemProvider.HeaderProvider.ListView.InvokeSync (delegate {
64
			    == itemProvider.HeaderProvider.ListView.Columns.IndexOf (itemProvider.ColumnHeader))
64
				if (args.ColumnIndex
65
			    RaiseAutomationPropertyChangedEvent ();
65
				    == itemProvider.HeaderProvider.ListView.Columns.IndexOf (itemProvider.ColumnHeader))
66
				    RaiseAutomationPropertyChangedEvent ();
67
			});
66
		}
68
		}
67
69
68
		#endregion
70
		#endregion
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Events/ListView/ListItemEditValuePatternValueEvent.cs (-9 / +13 lines)
Lines 61-79 namespace Mono.UIAutomation.Winforms.Events.ListView Link Here
61
61
62
		private void OnUIATextChanged (object sender, SWF.LabelEditEventArgs args)
62
		private void OnUIATextChanged (object sender, SWF.LabelEditEventArgs args)
63
		{
63
		{
64
			if (args.Item == editProvider.ItemProvider.ListView.Columns.IndexOf (editProvider.ColumnHeader)) {
64
			editProvider.ItemProvider.ListView.InvokeSync (delegate {
65
				newText = (string) editProvider.GetPropertyValue (ValuePatternIdentifiers.ValueProperty.Id);
65
				if (args.Item == editProvider.ItemProvider.ListView.Columns.IndexOf (editProvider.ColumnHeader)) {
66
				RaiseAutomationPropertyChangedEvent ();
66
					newText = (string) editProvider.GetPropertyValue (ValuePatternIdentifiers.ValueProperty.Id);
67
			}
67
					RaiseAutomationPropertyChangedEvent ();
68
				}
69
			});
68
		}
70
		}
69
71
70
		private void OnAfterLabelEdit (object sender, SWF.LabelEditEventArgs args)
72
		private void OnAfterLabelEdit (object sender, SWF.LabelEditEventArgs args)
71
		{
73
		{
72
			if (editProvider.ItemProvider.ListView.Items.IndexOf (editProvider.ItemProvider.ListViewItem) 
74
			editProvider.ItemProvider.ListView.InvokeSync (delegate {
73
			    == args.Item) {
75
				if (editProvider.ItemProvider.ListView.Items.IndexOf (editProvider.ItemProvider.ListViewItem) 
74
				newText = args.Label;
76
				    == args.Item) {
75
				RaiseAutomationPropertyChangedEvent ();
77
					newText = args.Label;
76
			}
78
					RaiseAutomationPropertyChangedEvent ();
79
				}
80
			});
77
		}
81
		}
78
82
79
		//We are doing this because AfterLabelEdit event is generated before commiting the text
83
		//We are doing this because AfterLabelEdit event is generated before commiting the text
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Events/ListView/ListItemSelectionItemPatternElementAddedEvent.cs (-7 / +9 lines)
Lines 66-78 namespace Mono.UIAutomation.Winforms.Events.ListView Link Here
66
		{
66
		{
67
			ListItemProvider provider = (ListItemProvider) Provider;
67
			ListItemProvider provider = (ListItemProvider) Provider;
68
			SWF.ListView listView = (SWF.ListView) sender;
68
			SWF.ListView listView = (SWF.ListView) sender;
69
			
69
70
			if (selected == false
70
			listView.InvokeSync (delegate {
71
			    && listView.SelectedIndices.Count > 1
71
				if (selected == false
72
			    && listView.SelectedIndices.Contains (provider.Index) == true)
72
				    && listView.SelectedIndices.Count > 1
73
				RaiseAutomationEvent ();
73
				    && listView.SelectedIndices.Contains (provider.Index) == true)
74
			
74
					RaiseAutomationEvent ();
75
			selected = listView.SelectedIndices.Contains (provider.Index);
75
				
76
				selected = listView.SelectedIndices.Contains (provider.Index);
77
			});
76
		}
78
		}
77
79
78
		#endregion
80
		#endregion
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Events/ListView/ListItemSelectionItemPatternElementRemovedEvent.cs (-7 / +9 lines)
Lines 68-80 namespace Mono.UIAutomation.Winforms.Events.ListView Link Here
68
		{
68
		{
69
			ListItemProvider provider = (ListItemProvider) Provider;
69
			ListItemProvider provider = (ListItemProvider) Provider;
70
			SWF.ListView listView = (SWF.ListView) sender;
70
			SWF.ListView listView = (SWF.ListView) sender;
71
			
71
72
			if (selected == true
72
			listView.InvokeSync (delegate {
73
			    && listView.SelectedIndices.Count > 1
73
				if (selected == true
74
			    && listView.SelectedIndices.Contains (provider.Index) == false)
74
				    && listView.SelectedIndices.Count > 1
75
				RaiseAutomationEvent ();
75
				    && listView.SelectedIndices.Contains (provider.Index) == false)
76
			
76
					RaiseAutomationEvent ();
77
			selected = listView.SelectedIndices.Contains (provider.Index);
77
				
78
				selected = listView.SelectedIndices.Contains (provider.Index);
79
			});
78
		}
80
		}
79
81
80
		#endregion
82
		#endregion
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Events/ListView/ListItemSelectionItemPatternElementSelectedEvent.cs (-4 / +6 lines)
Lines 65-74 namespace Mono.UIAutomation.Winforms.Events.ListView Link Here
65
		{
65
		{
66
			ListItemProvider provider = (ListItemProvider) Provider;
66
			ListItemProvider provider = (ListItemProvider) Provider;
67
			SWF.ListView listView = (SWF.ListView) sender;
67
			SWF.ListView listView = (SWF.ListView) sender;
68
			
68
69
			if (listView.SelectedIndices.Count == 1
69
			listView.InvokeSync (delegate {
70
			    && listView.SelectedIndices.Contains (provider.Index) == true)
70
				if (listView.SelectedIndices.Count == 1
71
				RaiseAutomationEvent ();
71
				    && listView.SelectedIndices.Contains (provider.Index) == true)
72
					RaiseAutomationEvent ();
73
			});
72
		}
74
		}
73
75
74
		#endregion
76
		#endregion
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Events/ListView/ListItemSelectionItemPatternIsSelectedEvent.cs (-7 / +9 lines)
Lines 67-79 namespace Mono.UIAutomation.Winforms.Events.ListView Link Here
67
		{
67
		{
68
			SWF.ListView listView = (SWF.ListView) sender;
68
			SWF.ListView listView = (SWF.ListView) sender;
69
			ListItemProvider provider = (ListItemProvider) Provider;
69
			ListItemProvider provider = (ListItemProvider) Provider;
70
			
70
71
			bool selectedChanged = listView.SelectedIndices.Contains (provider.Index);
71
			listView.InvokeSync (delegate {
72
			
72
				bool selectedChanged = listView.SelectedIndices.Contains (provider.Index);
73
			if (selectedChanged != selected) {
73
				
74
			    RaiseAutomationPropertyChangedEvent ();
74
				if (selectedChanged != selected) {
75
				selected = selectedChanged;
75
				    RaiseAutomationPropertyChangedEvent ();
76
			}
76
					selected = selectedChanged;
77
				}
78
			});
77
		}
79
		}
78
80
79
		#endregion
81
		#endregion
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Events/RadioButton/SelectionItemPatternElementSelectedEvent.cs (-1 / +1 lines)
Lines 59-65 namespace Mono.UIAutomation.Winforms.Events.RadioButton Link Here
59
		
59
		
60
		private void OnElementSelectedEvent (object sender, System.EventArgs e)
60
		private void OnElementSelectedEvent (object sender, System.EventArgs e)
61
		{
61
		{
62
			if (((SWF.RadioButton) Provider.Control).Checked)
62
			if (((SWF.RadioButton) Provider.Control).InvokeSync (c => c.Checked))
63
				RaiseAutomationEvent ();
63
				RaiseAutomationEvent ();
64
		}
64
		}
65
		
65
		
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Events/TextBox/TextPatternCaretMovedEvent.cs (-1 / +1 lines)
Lines 63-69 namespace Mono.UIAutomation.Winforms.Events.TextBox Link Here
63
				if (Provider.Control is SWF.TextBoxBase)
63
				if (Provider.Control is SWF.TextBoxBase)
64
					return (SWF.TextBoxBase)Provider.Control;
64
					return (SWF.TextBoxBase)Provider.Control;
65
				else if (Provider.Control is SWF.UpDownBase)
65
				else if (Provider.Control is SWF.UpDownBase)
66
					return ((SWF.UpDownBase)Provider.Control).txtView;
66
					return ((SWF.UpDownBase)Provider.Control).InvokeSync (c => c.txtView);
67
				else
67
				else
68
					throw new Exception ("TextBoxBase: Unknown type: " + Provider.Control);
68
					throw new Exception ("TextBoxBase: Unknown type: " + Provider.Control);
69
			}
69
			}
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Events/TextBox/TextPatternTextSelectionChangedEvent.cs (-2 / +2 lines)
Lines 73-79 namespace Mono.UIAutomation.Winforms.Events.TextBox Link Here
73
		private void OnSelectionChangedEvent (object sender, 
73
		private void OnSelectionChangedEvent (object sender, 
74
		                                    EventArgs args)
74
		                                    EventArgs args)
75
		{
75
		{
76
			SWF.Document document = TextBoxBase.Document;
76
			SWF.Document document = TextBoxBase.InvokeSync (c => c.Document);
77
			if (!selectionVisible && !document.selection_visible)
77
			if (!selectionVisible && !document.selection_visible)
78
				return;
78
				return;
79
			if (document.selection_visible != selectionVisible || document.selection_start != selectionStart || document.selection_end != selectionEnd) {
79
			if (document.selection_visible != selectionVisible || document.selection_start != selectionStart || document.selection_end != selectionEnd) {
Lines 89-95 namespace Mono.UIAutomation.Winforms.Events.TextBox Link Here
89
				if (Provider.Control is SWF.TextBoxBase)
89
				if (Provider.Control is SWF.TextBoxBase)
90
					return (SWF.TextBoxBase)Provider.Control;
90
					return (SWF.TextBoxBase)Provider.Control;
91
				else if (Provider.Control is SWF.UpDownBase)
91
				else if (Provider.Control is SWF.UpDownBase)
92
					return ((SWF.UpDownBase)Provider.Control).txtView;
92
					return ((SWF.UpDownBase)Provider.Control).InvokeSync (c => c.txtView);
93
				else
93
				else
94
					throw new Exception ("TextBoxBase: Unknown type: " + Provider.Control);
94
					throw new Exception ("TextBoxBase: Unknown type: " + Provider.Control);
95
			}
95
			}
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.Navigation/ParentNavigation.cs (-6 / +6 lines)
Lines 163-197 namespace Mono.UIAutomation.Winforms.Navigation Link Here
163
163
164
				
164
				
165
				if (args.RaiseEvent == true) {
165
				if (args.RaiseEvent == true) {
166
					Helper.DelegateQueue.Get ().Enqueue (delegate {
166
//					Helper.DelegateQueue.Get ().Enqueue (delegate {
167
					Helper.RaiseStructureChangedEvent (StructureChangeType.ChildAdded, 
167
					Helper.RaiseStructureChangedEvent (StructureChangeType.ChildAdded, 
168
					                                   args.ChildProvider);
168
					                                   args.ChildProvider);
169
					Helper.RaiseStructureChangedEvent (StructureChangeType.ChildrenInvalidated,
169
					Helper.RaiseStructureChangedEvent (StructureChangeType.ChildrenInvalidated,
170
					                                   (FragmentControlProvider) sender);
170
					                                   (FragmentControlProvider) sender);
171
					});
171
//					});
172
				}
172
				}
173
			} else if (args.ChangeType == StructureChangeType.ChildRemoved) {
173
			} else if (args.ChangeType == StructureChangeType.ChildRemoved) {
174
				Remove (args.ChildProvider.Navigation);
174
				Remove (args.ChildProvider.Navigation);
175
	
175
	
176
				if (args.RaiseEvent == true) {
176
				if (args.RaiseEvent == true) {
177
					Helper.DelegateQueue.Get ().Enqueue (delegate {
177
//					Helper.DelegateQueue.Get ().Enqueue (delegate {
178
					Helper.RaiseStructureChangedEvent (StructureChangeType.ChildRemoved, 
178
					Helper.RaiseStructureChangedEvent (StructureChangeType.ChildRemoved, 
179
					                                   args.ChildProvider);
179
					                                   args.ChildProvider);
180
					Helper.RaiseStructureChangedEvent (StructureChangeType.ChildrenInvalidated,
180
					Helper.RaiseStructureChangedEvent (StructureChangeType.ChildrenInvalidated,
181
					                                   (FragmentControlProvider) sender);
181
					                                   (FragmentControlProvider) sender);
182
					});
182
//					});
183
				}
183
				}
184
			} else if (args.ChangeType == StructureChangeType.ChildrenReordered) {
184
			} else if (args.ChangeType == StructureChangeType.ChildrenReordered) {
185
				chain.Clear ();
185
				chain.Clear ();
186
				
186
				
187
				//TODO: Is this the event to generate?
187
				//TODO: Is this the event to generate?
188
				if (args.RaiseEvent == true) {
188
				if (args.RaiseEvent == true) {
189
					Helper.DelegateQueue.Get ().Enqueue (delegate {
189
//					Helper.DelegateQueue.Get ().Enqueue (delegate {
190
					Helper.RaiseStructureChangedEvent (StructureChangeType.ChildrenBulkRemoved, 
190
					Helper.RaiseStructureChangedEvent (StructureChangeType.ChildrenBulkRemoved, 
191
					                                   (FragmentControlProvider) sender);
191
					                                   (FragmentControlProvider) sender);
192
					Helper.RaiseStructureChangedEvent (StructureChangeType.ChildrenInvalidated,
192
					Helper.RaiseStructureChangedEvent (StructureChangeType.ChildrenInvalidated,
193
					                                   (FragmentControlProvider) sender);
193
					                                   (FragmentControlProvider) sender);
194
					});
194
//					});
195
				}
195
				}
196
			}
196
			}
197
		}
197
		}
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms.mdp (-3 / +10 lines)
Lines 1-4 Link Here
1
<Project name="Mono.UIAutomation.Winforms" fileversion="2.0" language="C#" UseParentDirectoryAsNamespace="True" DefaultNamespace="Mono.UIAutomation.Winforms" clr-version="Net_2_0" targetFramework="3.5" ctype="DotNetProject">
1
<Project name="Mono.UIAutomation.Winforms" fileversion="2.0" language="C#" DefaultNamespace="Mono.UIAutomation.Winforms" UseParentDirectoryAsNamespace="True" clr-version="Net_2_0" targetFramework="3.5" ctype="DotNetProject">
2
  <Configurations active="Debug">
2
  <Configurations active="Debug">
3
    <Configuration name="Debug" ctype="DotNetProjectConfiguration">
3
    <Configuration name="Debug" ctype="DotNetProjectConfiguration">
4
      <Output directory="bin/Debug" signAssembly="True" assemblyKeyFile="../mono-uia.snk" assembly="UIAutomationWinforms" />
4
      <Output directory="bin/Debug" signAssembly="True" assemblyKeyFile="../mono-uia.snk" assembly="UIAutomationWinforms" />
Lines 23-29 Link Here
23
    <File name="Mono.UIAutomation.Winforms/RadioButtonProvider.cs" subtype="Code" buildaction="Compile" />
23
    <File name="Mono.UIAutomation.Winforms/RadioButtonProvider.cs" subtype="Code" buildaction="Compile" />
24
    <File name="Mono.UIAutomation.Winforms/LabelProvider.cs" subtype="Code" buildaction="Compile" />
24
    <File name="Mono.UIAutomation.Winforms/LabelProvider.cs" subtype="Code" buildaction="Compile" />
25
    <File name="Mono.UIAutomation.Winforms/TextBoxProvider.cs" subtype="Code" buildaction="Compile" />
25
    <File name="Mono.UIAutomation.Winforms/TextBoxProvider.cs" subtype="Code" buildaction="Compile" />
26
    <File name="Mono.UIAutomation.Winforms/Helper.cs" subtype="Code" buildaction="Compile" />
27
    <File name="Mono.UIAutomation.Winforms/LinkLabelProvider.cs" subtype="Code" buildaction="Compile" />
26
    <File name="Mono.UIAutomation.Winforms/LinkLabelProvider.cs" subtype="Code" buildaction="Compile" />
28
    <File name="Mono.UIAutomation.Winforms.Events/AutomationHasKeyboardFocusPropertyEvent.cs" subtype="Code" buildaction="Compile" />
27
    <File name="Mono.UIAutomation.Winforms.Events/AutomationHasKeyboardFocusPropertyEvent.cs" subtype="Code" buildaction="Compile" />
29
    <File name="Mono.UIAutomation.Winforms.Events/AutomationBoundingRectanglePropertyEvent.cs" subtype="Code" buildaction="Compile" />
28
    <File name="Mono.UIAutomation.Winforms.Events/AutomationBoundingRectanglePropertyEvent.cs" subtype="Code" buildaction="Compile" />
Lines 567-572 Link Here
567
    <File name="Mono.UIAutomation.Winforms.Events/DataGridView/DataItemChildHasKeyboardFocusPropertyEvent.cs" subtype="Code" buildaction="Compile" />
566
    <File name="Mono.UIAutomation.Winforms.Events/DataGridView/DataItemChildHasKeyboardFocusPropertyEvent.cs" subtype="Code" buildaction="Compile" />
568
    <File name="Mono.UIAutomation.Winforms.Behaviors/DataGrid/DataItemEditSelectionItemProviderBehavior.cs" subtype="Code" buildaction="Compile" />
567
    <File name="Mono.UIAutomation.Winforms.Behaviors/DataGrid/DataItemEditSelectionItemProviderBehavior.cs" subtype="Code" buildaction="Compile" />
569
    <File name="Mono.UIAutomation.Winforms.Events/DataGrid/DataItemEditSelectionItemPatternIsSelectedEvent.cs" subtype="Code" buildaction="Compile" />
568
    <File name="Mono.UIAutomation.Winforms.Events/DataGrid/DataItemEditSelectionItemPatternIsSelectedEvent.cs" subtype="Code" buildaction="Compile" />
569
    <File name="Mono.UIAutomation.Winforms.Behaviors/ListView/ListItemInvokeProviderBehavior.cs" subtype="Code" buildaction="Compile" />
570
    <File name="Mono.UIAutomation.Winforms.Behaviors/ToolStripButton/ToggleProviderBehavior.cs" subtype="Code" buildaction="Compile" />
571
    <File name="Mono.UIAutomation.Winforms.Events/DateTimePicker/CheckboxAutomationHasKeyboardFocusPropertyEvent.cs" subtype="Code" buildaction="Compile" />
572
    <File name="Mono.UIAutomation.Winforms.Events/DateTimePicker/PartAutomationHasKeyboardFocusPropertyEvent.cs" subtype="Code" buildaction="Compile" />
573
    <File name="Mono.UIAutomation.Winforms.Events/MonthCalendar/AutomationNamePropertyEvent.cs" subtype="Code" buildaction="Compile" />
574
    <File name="Mono.UIAutomation.Winforms.Events/PopupButton/AutomationHasKeyboardFocusPropertyEvent.cs" subtype="Code" buildaction="Compile" />
575
    <File name="Mono.UIAutomation.Winforms.Events/ToolStripButton/TogglePatternToggleStateEvent.cs" subtype="Code" buildaction="Compile" />
576
    <File name="Mono.UIAutomation.Winforms/Helper.cs" subtype="Code" buildaction="Compile" />
570
  </Contents>
577
  </Contents>
571
  <References>
578
  <References>
572
    <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
579
    <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
Lines 578-587 Link Here
578
    <ProjectReference type="Gac" localcopy="True" refto="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
585
    <ProjectReference type="Gac" localcopy="True" refto="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
579
    <ProjectReference type="Gac" localcopy="True" refto="UIAutomationTypes, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
586
    <ProjectReference type="Gac" localcopy="True" refto="UIAutomationTypes, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
580
    <ProjectReference type="Gac" localcopy="True" refto="UIAutomationProvider, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
587
    <ProjectReference type="Gac" localcopy="True" refto="UIAutomationProvider, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
588
    <ProjectReference type="Gac" localcopy="True" refto="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
581
    <ProjectReference type="Gac" localcopy="True" refto="glib-sharp, Version=2.14.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
589
    <ProjectReference type="Gac" localcopy="True" refto="glib-sharp, Version=2.14.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
582
    <ProjectReference type="Gac" localcopy="True" refto="atk-sharp, Version=2.14.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
590
    <ProjectReference type="Gac" localcopy="True" refto="atk-sharp, Version=2.14.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
583
    <ProjectReference type="Gac" localcopy="True" refto="Mono.WebBrowser, Version=0.5.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
591
    <ProjectReference type="Gac" localcopy="True" refto="Mono.WebBrowser, Version=0.5.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
584
    <ProjectReference type="Gac" localcopy="True" refto="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
585
  </References>
592
  </References>
586
  <MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="True" RelativeMakefileName="Makefile.am" IsAutotoolsProject="True" RelativeConfigureInPath="..">
593
  <MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="True" RelativeMakefileName="Makefile.am" IsAutotoolsProject="True" RelativeConfigureInPath="..">
587
    <BuildFilesVar Sync="True" Name="FILES" />
594
    <BuildFilesVar Sync="True" Name="FILES" />
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms/BalloonWindowProvider.cs (-2 / +1 lines)
Lines 75-82 namespace Mono.UIAutomation.Winforms Link Here
75
		protected override object GetProviderPropertyValue (int propertyId)
75
		protected override object GetProviderPropertyValue (int propertyId)
76
		{
76
		{
77
			if (propertyId == AutomationElementIdentifiers.HelpTextProperty.Id)
77
			if (propertyId == AutomationElementIdentifiers.HelpTextProperty.Id)
78
				return Helper.SynchronizedGet<NotifyIcon.BalloonWindow, string> (balloon,
78
				return balloon.InvokeSync (c => c.AccessibleDescription ?? c.Title);
79
				                                                                 s => balloon.AccessibleDescription ?? balloon.Title);
80
			else if (propertyId == AutomationElementIdentifiers.IsNotifyIconProperty.Id)
79
			else if (propertyId == AutomationElementIdentifiers.IsNotifyIconProperty.Id)
81
				return true;
80
				return true;
82
			else
81
			else
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms/CheckedListBoxProvider.cs (-3 / +2 lines)
Lines 52-58 namespace Mono.UIAutomation.Winforms Link Here
52
		{
52
		{
53
			if (ContainsItem (item) == true) {
53
			if (ContainsItem (item) == true) {
54
				SWF.CheckedListBox checkedListBox = (SWF.CheckedListBox) Control;
54
				SWF.CheckedListBox checkedListBox = (SWF.CheckedListBox) Control;
55
				Helper.SynchronizedSet (checkedListBox, delegate {
55
				checkedListBox.InvokeSync (delegate {
56
					bool chcked = checkedListBox.GetItemChecked (item.Index);
56
					bool chcked = checkedListBox.GetItemChecked (item.Index);
57
					checkedListBox.SetItemChecked (item.Index, !chcked);
57
					checkedListBox.SetItemChecked (item.Index, !chcked);
58
				});
58
				});
Lines 65-72 namespace Mono.UIAutomation.Winforms Link Here
65
				SWF.CheckedListBox checkedListBox = (SWF.CheckedListBox) Control;	
65
				SWF.CheckedListBox checkedListBox = (SWF.CheckedListBox) Control;	
66
				
66
				
67
				SWF.CheckState state 
67
				SWF.CheckState state 
68
					= Helper.SynchronizedGet<SWF.CheckedListBox, SWF.CheckState> (checkedListBox,
68
					= checkedListBox.InvokeSync (c => c.GetItemCheckState (item.Index));
69
					                                                              s => checkedListBox.GetItemCheckState (item.Index));
70
				switch (state) {
69
				switch (state) {
71
					case SWF.CheckState.Checked:
70
					case SWF.CheckState.Checked:
72
						return ToggleState.On;
71
						return ToggleState.On;
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms/ComboBoxProvider.cs (-60 / +43 lines)
Lines 79-86 namespace Mono.UIAutomation.Winforms Link Here
79
			else if (propertyId == AEIds.LocalizedControlTypeProperty.Id)
79
			else if (propertyId == AEIds.LocalizedControlTypeProperty.Id)
80
				return Catalog.GetString ("combo box");
80
				return Catalog.GetString ("combo box");
81
			else if (propertyId == AEIds.HasKeyboardFocusProperty.Id
81
			else if (propertyId == AEIds.HasKeyboardFocusProperty.Id
82
			         && Helper.SynchronizedGet<SWF.ComboBox, bool> (comboboxControl, 
82
			         && comboboxControl.InvokeSync (b => b.DropDownStyle == SWF.ComboBoxStyle.DropDown))
83
			                                                        b => comboboxControl.DropDownStyle == SWF.ComboBoxStyle.DropDown))
84
				return false;
83
				return false;
85
			else
84
			else
86
				return base.GetProviderPropertyValue (propertyId);
85
				return base.GetProviderPropertyValue (propertyId);
Lines 108-116 namespace Mono.UIAutomation.Winforms Link Here
108
		
107
		
109
		public override IRawElementProviderFragment GetFocus ()
108
		public override IRawElementProviderFragment GetFocus ()
110
		{
109
		{
111
			return Helper.SynchronizedGet<SWF.ComboBox, IRawElementProviderFragment> (comboboxControl,
110
			return comboboxControl.InvokeSync (c => listboxProvider.GetItemProviderFrom (listboxProvider, c.SelectedItem));
112
			                                                                          v => listboxProvider.GetItemProviderFrom (listboxProvider,
113
			                                                                                                                    comboboxControl.SelectedItem));
114
		}		
111
		}		
115
		
112
		
116
		public override IRawElementProviderFragment ElementProviderFromPoint (double x, double y)
113
		public override IRawElementProviderFragment ElementProviderFromPoint (double x, double y)
Lines 162-169 namespace Mono.UIAutomation.Winforms Link Here
162
		private void UpdateBehaviors (bool updateAssociatedChildren) 
159
		private void UpdateBehaviors (bool updateAssociatedChildren) 
163
		{
160
		{
164
			SWF.ComboBoxStyle style 
161
			SWF.ComboBoxStyle style 
165
				= Helper.SynchronizedGet<SWF.ComboBox, SWF.ComboBoxStyle> (comboboxControl,
162
				= comboboxControl.InvokeSync (c => c.DropDownStyle);
166
				                                                           s => comboboxControl.DropDownStyle);
167
			
163
			
168
			if (style == SWF.ComboBoxStyle.Simple) {
164
			if (style == SWF.ComboBoxStyle.Simple) {
169
				SetBehavior (ExpandCollapsePatternIdentifiers.Pattern, 
165
				SetBehavior (ExpandCollapsePatternIdentifiers.Pattern, 
Lines 305-312 namespace Mono.UIAutomation.Winforms Link Here
305
					else
301
					else
306
						return Helper.GetControlScreenBounds (listboxControl.Bounds, listboxControl);
302
						return Helper.GetControlScreenBounds (listboxControl.Bounds, listboxControl);
307
				} else if (propertyId == AutomationElementIdentifiers.IsOffscreenProperty.Id) {
303
				} else if (propertyId == AutomationElementIdentifiers.IsOffscreenProperty.Id) {
308
					if (Helper.SynchronizedGet<SWF.ComboBox, SWF.ComboBoxStyle> (comboboxControl,
304
					if (comboboxControl.InvokeSync (s => s.DropDownStyle)
309
					                                                             s => comboboxControl.DropDownStyle)
310
					    == SWF.ComboBoxStyle.Simple)
305
					    == SWF.ComboBoxStyle.Simple)
311
						return false;
306
						return false;
312
					
307
					
Lines 319-383 namespace Mono.UIAutomation.Winforms Link Here
319
314
320
			public override int SelectedItemsCount {
315
			public override int SelectedItemsCount {
321
				get {
316
				get {
322
					return Helper.SynchronizedGet<SWF.ComboBox, int> (comboboxControl,
317
					return comboboxControl.InvokeSync (c => c.SelectedIndex == -1 ? 0 : 1);
323
					                                                   b => comboboxControl.SelectedIndex == -1 ? 0 : 1);
324
				}
318
				}
325
			}
319
			}
326
			
320
			
327
			public override int ItemsCount {
321
			public override int ItemsCount {
328
				get {
322
				get {
329
					return Helper.SynchronizedGet<SWF.ComboBox, int> (comboboxControl,
323
					return comboboxControl.InvokeSync (c => c.Items.Count);
330
					                                                   i => comboboxControl.Items.Count);
331
				}
324
				}
332
			}
325
			}
333
326
334
			public override int IndexOfObjectItem (object objectItem)
327
			public override int IndexOfObjectItem (object objectItem)
335
			{
328
			{
336
				return Helper.SynchronizedGet<SWF.ComboBox, int> (comboboxControl,
329
				return comboboxControl.InvokeSync (c => c.Items.IndexOf (objectItem));
337
				                                                  v => comboboxControl.Items.IndexOf (objectItem));
338
			}	
330
			}	
339
331
340
			public override IRawElementProviderSimple[] GetSelectedItems ()
332
			public override IRawElementProviderSimple[] GetSelectedItems ()
341
			{
333
			{
342
				return Helper.SynchronizedGet<SWF.ComboBox, IRawElementProviderSimple[]> (comboboxControl,
334
				if (comboboxControl == null)
343
				                                                                          delegate {
335
					return new IRawElementProviderSimple [0];
344
					if (comboboxControl == null || comboboxControl.SelectedIndex == -1)
336
				return comboboxControl.InvokeSync (c => {
337
					if (c.SelectedIndex == -1)
345
						return new IRawElementProviderSimple [0];
338
						return new IRawElementProviderSimple [0];
346
					else
339
					else
347
						return new IRawElementProviderSimple [] { GetItemProviderFrom (this,
340
						return new IRawElementProviderSimple [] { GetItemProviderFrom (this,
348
						                                                               comboboxControl.SelectedItem) };
341
						                                                               c.SelectedItem) };
349
				});
342
				});
350
			}
343
			}
351
344
352
			public override void SelectItem (ListItemProvider item)
345
			public override void SelectItem (ListItemProvider item)
353
			{
346
			{
354
				if (ContainsItem (item) == true) {
347
				if (ContainsItem (item) == true) {
355
					Helper.SynchronizedSet (comboboxControl, delegate {
348
					comboboxControl.InvokeSync (delegate {
356
						comboboxControl.SelectedIndex = item.Index;
349
						comboboxControl.SelectedIndex = item.Index;
350
						// Raise SelectionChangeCommitted event
351
						// on the ComboBox. Since we are simulating
352
						// a user interacting with the control,
353
						// this event is expected.
354
						//
355
						// NOTE: This is a protected method that
356
						//       is a part of the documented
357
						//       API for SWF.ComboBox.
358
						MethodInfo onSelectionChangeCommitted =
359
							comboboxControl.GetType ().GetMethod ("OnSelectionChangeCommitted",
360
							                                      BindingFlags.NonPublic | BindingFlags.Instance);
361
						if (onSelectionChangeCommitted != null) {
362
							onSelectionChangeCommitted.Invoke (comboboxControl,
363
								                                   new object [] {EventArgs.Empty});
364
						}
357
					});
365
					});
358
359
					// Raise SelectionChangeCommitted event
360
					// on the ComboBox. Since we are simulating
361
					// a user interacting with the control,
362
					// this event is expected.
363
					//
364
					// NOTE: This is a protected method that
365
					//       is a part of the documented
366
					//       API for SWF.ComboBox.
367
					MethodInfo onSelectionChangeCommitted =
368
						comboboxControl.GetType ().GetMethod ("OnSelectionChangeCommitted",
369
						                                      BindingFlags.NonPublic | BindingFlags.Instance);
370
					if (onSelectionChangeCommitted != null) {
371
						onSelectionChangeCommitted.Invoke (comboboxControl,
372
							                                   new object [] {EventArgs.Empty});
373
					}
374
				}
366
				}
375
			}
367
			}
376
	
368
	
377
			public override void UnselectItem (ListItemProvider item)
369
			public override void UnselectItem (ListItemProvider item)
378
			{
370
			{
379
				if (ContainsItem (item) == true)
371
				if (ContainsItem (item) == true)
380
					Helper.SynchronizedSet (comboboxControl, delegate {
372
					comboboxControl.InvokeSync (delegate {
381
						comboboxControl.SelectedIndex = -1;
373
						comboboxControl.SelectedIndex = -1;
382
					});
374
					});
383
			}
375
			}
Lines 387-396 namespace Mono.UIAutomation.Winforms Link Here
387
				if (!ContainsItem (item))
379
				if (!ContainsItem (item))
388
					return false;
380
					return false;
389
				else
381
				else
390
					return Helper.SynchronizedGet<SWF.ComboBox, bool> (comboboxControl,
382
					return comboboxControl.InvokeSync (c => {
391
					                                                   delegate {
383
						return item.Index == c.SelectedIndex; });
392
						return item.Index == comboboxControl.SelectedIndex; });
393
//					                                                   v => item.Index == v.SelectedIndex);
394
			}
384
			}
395
385
396
			public override void InitializeChildControlStructure ()
386
			public override void InitializeChildControlStructure ()
Lines 400-407 namespace Mono.UIAutomation.Winforms Link Here
400
				comboboxControl.Items.UIACollectionChanged += OnCollectionChanged;
390
				comboboxControl.Items.UIACollectionChanged += OnCollectionChanged;
401
391
402
				foreach (object objectItem 
392
				foreach (object objectItem 
403
				         in Helper.SynchronizedGet<SWF.ComboBox, SWF.ComboBox.ObjectCollection> (comboboxControl, 
393
				         in comboboxControl.InvokeSync (c => c.Items)) {
404
				                                                                                 i => comboboxControl.Items)) {
405
					ListItemProvider item = GetItemProviderFrom (this, objectItem);
394
					ListItemProvider item = GetItemProviderFrom (this, objectItem);
406
					AddChildProvider (item);
395
					AddChildProvider (item);
407
				}
396
				}
Lines 424-431 namespace Mono.UIAutomation.Winforms Link Here
424
			                                             int propertyId)
413
			                                             int propertyId)
425
			{
414
			{
426
				if (propertyId == AutomationElementIdentifiers.NameProperty.Id)
415
				if (propertyId == AutomationElementIdentifiers.NameProperty.Id)
427
					return Helper.SynchronizedGet<SWF.ComboBox, string> (comboboxControl,
416
					return comboboxControl.InvokeSync (c => c.GetItemText (item.ObjectItem));
428
					                                                     v => comboboxControl.GetItemText (item.ObjectItem));
429
				int topItem = -1;
417
				int topItem = -1;
430
				if (ListBoxControl != null)
418
				if (ListBoxControl != null)
431
					topItem = ListBoxControl.UIATopItem;
419
					topItem = ListBoxControl.UIATopItem;
Lines 433-440 namespace Mono.UIAutomation.Winforms Link Here
433
				if (ContainsItem (item) == false)
421
				if (ContainsItem (item) == false)
434
					return null;
422
					return null;
435
				else if (propertyId == AutomationElementIdentifiers.HasKeyboardFocusProperty.Id)
423
				else if (propertyId == AutomationElementIdentifiers.HasKeyboardFocusProperty.Id)
436
					return Helper.SynchronizedGet<SWF.ComboBox, bool> (comboboxControl,
424
					return comboboxControl.InvokeSync (b => b.Focused && item.Index == b.SelectedIndex);
437
					                                                   b => comboboxControl.Focused && item.Index == comboboxControl.SelectedIndex);
438
				else if (propertyId == AutomationElementIdentifiers.BoundingRectangleProperty.Id) {
425
				else if (propertyId == AutomationElementIdentifiers.BoundingRectangleProperty.Id) {
439
					//FIXME: We need to improve this
426
					//FIXME: We need to improve this
440
					int index = item.Index;
427
					int index = item.Index;
Lines 442-457 namespace Mono.UIAutomation.Winforms Link Here
442
					System.Drawing.Rectangle bounds = System.Drawing.Rectangle.Empty;
429
					System.Drawing.Rectangle bounds = System.Drawing.Rectangle.Empty;
443
430
444
					if (ListBoxControl == null)
431
					if (ListBoxControl == null)
445
						bounds = Helper.SynchronizedGet<SWF.ComboBox, System.Drawing.Rectangle> (comboboxControl, 
432
						bounds = comboboxControl.InvokeSync (c => c.Bounds);
446
						                                                                         b => comboboxControl.Bounds);
447
					else
433
					else
448
						bounds = Helper.SynchronizedGet<SWF.ComboBox.ComboListBox, System.Drawing.Rectangle> (ListBoxControl, 
434
						bounds = ListBoxControl.InvokeSync (c => c.Bounds);
449
						                                                                          b => ListBoxControl.Bounds);
450
435
451
					int itemHeight = Helper.SynchronizedGet<SWF.ComboBox, int> (comboboxControl, 
436
					int itemHeight = comboboxControl.InvokeSync (c => c.GetItemHeight (0));// TODO: always true?
452
					                                                            i => comboboxControl.GetItemHeight (0));// TODO: always true?
437
					rectangle.Height = comboboxControl.InvokeSync (c => c.GetItemHeight (index));
453
					rectangle.Height = Helper.SynchronizedGet<SWF.ComboBox, int> (comboboxControl,
454
					                                                              i => comboboxControl.GetItemHeight (index));
455
					rectangle.Width = bounds.Width;
438
					rectangle.Width = bounds.Width;
456
					rectangle.X = bounds.X;
439
					rectangle.X = bounds.X;
457
					rectangle.Y = bounds.Y + (index * itemHeight) - (topItem * itemHeight);// decreaseY;
440
					rectangle.Y = bounds.Y + (index * itemHeight) - (topItem * itemHeight);// decreaseY;
Lines 461-476 namespace Mono.UIAutomation.Winforms Link Here
461
					else
444
					else
462
						return Helper.GetControlScreenBounds (rectangle, ListBoxControl);
445
						return Helper.GetControlScreenBounds (rectangle, ListBoxControl);
463
				} else if (propertyId == AutomationElementIdentifiers.IsOffscreenProperty.Id) {
446
				} else if (propertyId == AutomationElementIdentifiers.IsOffscreenProperty.Id) {
464
					return Helper.SynchronizedGet<SWF.ComboBox, bool> (comboboxControl, delegate {
447
					return comboboxControl.InvokeSync (c => {
465
						if (comboboxControl.SelectedIndex == item.Index)
448
						if (c.SelectedIndex == item.Index)
466
							return false;
449
							return false;
467
						
450
						
468
						if (topItem == -1 || !ListBoxControl.Visible)
451
						if (topItem == -1 || !ListBoxControl.Visible)
469
							return !(comboboxControl.SelectedIndex == item.Index);
452
							return !(c.SelectedIndex == item.Index);
470
	
453
	
471
						int lastItem = ListBoxControl.UIALastItem;				
454
						int lastItem = ListBoxControl.UIALastItem;				
472
						if ((item.Index >= topItem && item.Index < lastItem) 
455
						if ((item.Index >= topItem && item.Index < lastItem) 
473
						    || (item.Index == lastItem && comboboxControl.Items.Count == lastItem + 1))
456
						    || (item.Index == lastItem && c.Items.Count == lastItem + 1))
474
							return false;
457
							return false;
475
						else
458
						else
476
						return true;
459
						return true;
Lines 630-636 namespace Mono.UIAutomation.Winforms Link Here
630
					// This control cannot be selected, but
613
					// This control cannot be selected, but
631
					// it can still be keyboard focused, so
614
					// it can still be keyboard focused, so
632
					// we override it manually.
615
					// we override it manually.
633
					return Control.CanFocus;
616
					return Control.InvokeSync (c => c.CanFocus);
634
				}
617
				}
635
618
636
				return base.GetProviderPropertyValue (propertyId);
619
				return base.GetProviderPropertyValue (propertyId);
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms/FormListener.cs (-8 lines)
Lines 63-69 namespace Mono.UIAutomation.Winforms Link Here
63
					Helper.RaiseStructureChangedEvent (StructureChangeType.ChildRemoved,
63
					Helper.RaiseStructureChangedEvent (StructureChangeType.ChildRemoved,
64
					                                   provider);
64
					                                   provider);
65
				}
65
				}
66
				Helper.DelegateQueue.Get ().Quit ();
67
			};
66
			};
68
			
67
			
69
			// FIXME: FormAdded is fired too frequently (such as
68
			// FIXME: FormAdded is fired too frequently (such as
Lines 88-95 namespace Mono.UIAutomation.Winforms Link Here
88
			if (formProviders.ContainsKey (f))
87
			if (formProviders.ContainsKey (f))
89
				return;
88
				return;
90
89
91
//			Helper.SynchronizedSet (f, delegate {
92
93
			FormProvider provider = (FormProvider)
90
			FormProvider provider = (FormProvider)
94
				ProviderFactory.GetProvider (f, true);
91
				ProviderFactory.GetProvider (f, true);
95
92
Lines 107-126 namespace Mono.UIAutomation.Winforms Link Here
107
				provider.Navigation = NavigationFactory.CreateNavigation (provider);
104
				provider.Navigation = NavigationFactory.CreateNavigation (provider);
108
				provider.Navigation.Initialize ();
105
				provider.Navigation.Initialize ();
109
106
110
				Helper.DelegateQueue.Get ().Enqueue (delegate {
111
				
112
				// TODO: Fill in rest of eventargs
107
				// TODO: Fill in rest of eventargs
113
				Helper.RaiseStructureChangedEvent (StructureChangeType.ChildAdded,
108
				Helper.RaiseStructureChangedEvent (StructureChangeType.ChildAdded,
114
				                                   provider);
109
				                                   provider);
115
				provider.InitializeChildControlStructure ();
110
				provider.InitializeChildControlStructure ();
116
				});
117
			} else {
111
			} else {
118
				Console.WriteLine ("is child dialog..: {0}", Helper.DelegateQueue.Get ().Count);
119
				FormProvider ownerProvider 
112
				FormProvider ownerProvider 
120
					= (FormProvider) ProviderFactory.FindProvider (f.Owner);
113
					= (FormProvider) ProviderFactory.FindProvider (f.Owner);
121
				ownerProvider.AddChildProvider (provider);
114
				ownerProvider.AddChildProvider (provider);
122
			}
115
			}
123
//			});
124
		}
116
		}
125
		
117
		
126
#endregion
118
#endregion
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms/FormProvider.cs (-11 / +7 lines)
Lines 59-65 namespace Mono.UIAutomation.Winforms Link Here
59
			
59
			
60
			// We keep a copy because we can't reference "form" after 
60
			// We keep a copy because we can't reference "form" after 
61
			// Disposed (used in Close()) called by WindowPatternWindowClosedEvent.
61
			// Disposed (used in Close()) called by WindowPatternWindowClosedEvent.
62
			owner = Helper.SynchronizedGet<Form, Form> (form, o => form.Owner);
62
			owner = form.InvokeSync (c => c.Owner);
63
			alreadyClosed = false;
63
			alreadyClosed = false;
64
		}
64
		}
65
		
65
		
Lines 153-164 namespace Mono.UIAutomation.Winforms Link Here
153
		
153
		
154
		public override IRawElementProviderFragment ElementProviderFromPoint (double x, double y)
154
		public override IRawElementProviderFragment ElementProviderFromPoint (double x, double y)
155
		{
155
		{
156
			if (Helper.SynchronizedGet<Form, bool> (form, 
156
			if (form.InvokeSync (c => x > c.Width || y > c.Height))
157
			                                        b => x > form.Width || y > form.Height))
158
				return null;
157
				return null;
159
			
158
			
160
			Control child = Helper.SynchronizedGet<Form, Control> (form,
159
			Control child 
161
			                                                       c => form.GetChildAtPoint (new Point ((int) x, (int) y)));
160
				= form.InvokeSync (c => c.GetChildAtPoint (new Point ((int) x, (int) y)));
162
			
161
			
163
			if (child != null) {
162
			if (child != null) {
164
				Log.Debug (child.ToString ());
163
				Log.Debug (child.ToString ());
Lines 179-187 namespace Mono.UIAutomation.Winforms Link Here
179
		
178
		
180
		public override IRawElementProviderFragment GetFocus ()
179
		public override IRawElementProviderFragment GetFocus ()
181
		{
180
		{
182
			foreach (Control control 
181
			foreach (Control control in form.InvokeSync (f => f.Controls)) {
183
			         in Helper.SynchronizedGet<Form, Control.ControlCollection> (form, f => f.Controls)) {
182
				if (control.InvokeSync (c => c.Focused)) {
184
				if (control.Focused) {
185
					// TODO: Necessary to delve into child control
183
					// TODO: Necessary to delve into child control
186
					// for focused element?
184
					// for focused element?
187
					
185
					
Lines 209-218 namespace Mono.UIAutomation.Winforms Link Here
209
				alreadyClosed = true;
207
				alreadyClosed = true;
210
208
211
				if (owner == null) {
209
				if (owner == null) {
212
					Helper.DelegateQueue.Get ().Enqueue (delegate {
213
					Helper.RaiseStructureChangedEvent (StructureChangeType.ChildRemoved,
210
					Helper.RaiseStructureChangedEvent (StructureChangeType.ChildRemoved,
214
					                                   this);
211
					                                   this);
215
					});
216
				} else {
212
				} else {
217
					FormProvider ownerProvider 
213
					FormProvider ownerProvider 
218
						= ProviderFactory.FindProvider (owner) as FormProvider;
214
						= ProviderFactory.FindProvider (owner) as FormProvider;
Lines 224-230 namespace Mono.UIAutomation.Winforms Link Here
224
220
225
		private void SetupMainMenuProvider ()
221
		private void SetupMainMenuProvider ()
226
		{
222
		{
227
			MainMenu mainMenu = Helper.SynchronizedGet<Form, MainMenu> (form, m => form.Menu);
223
			MainMenu mainMenu = form.InvokeSync (f => f.Menu);
228
			
224
			
229
			if (mainMenu != null) {
225
			if (mainMenu != null) {
230
				mainMenuProvider = (MainMenuProvider)
226
				mainMenuProvider = (MainMenuProvider)
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms/FragmentControlProvider.cs (-16 / +16 lines)
Lines 66-80 namespace Mono.UIAutomation.Winforms Link Here
66
			children = new List<FragmentControlProvider> ();
66
			children = new List<FragmentControlProvider> ();
67
			componentChildren = new List<Component> ();
67
			componentChildren = new List<Component> ();
68
68
69
//			if (Control != null) {
69
			if (Control != null) {
70
//				Control.ContextMenuChanged += HandleContextMenuChanged;
70
				Control.ContextMenuChanged += HandleContextMenuChanged;
71
//				Control.ContextMenuStripChanged += HandleContextMenuStripChanged;
71
				Control.ContextMenuStripChanged += HandleContextMenuStripChanged;
72
//
72
73
//				HandleContextMenuChanged (null, EventArgs.Empty);
73
				HandleContextMenuChanged (null, EventArgs.Empty);
74
//				HandleContextMenuStripChanged (null, EventArgs.Empty);
74
				HandleContextMenuStripChanged (null, EventArgs.Empty);
75
//
75
76
//				visible = Helper.SynchronizedGet<SWF.Control, bool> (Control, v => Control.Visible);
76
				visible = Control.InvokeSync (c => c.Visible);
77
//			}
77
			}
78
		}
78
		}
79
79
80
		void HandleContextMenuStripChanged (object sender, EventArgs e)
80
		void HandleContextMenuStripChanged (object sender, EventArgs e)
Lines 83-89 namespace Mono.UIAutomation.Winforms Link Here
83
				contextMenuStrip.Opened -= HandleContextMenuStripOpened;
83
				contextMenuStrip.Opened -= HandleContextMenuStripOpened;
84
				contextMenuStrip.Closed -= HandleContextMenuStripClosed;
84
				contextMenuStrip.Closed -= HandleContextMenuStripClosed;
85
			}
85
			}
86
			contextMenuStrip = Helper.SynchronizedGet<SWF.Control, SWF.ContextMenuStrip> (Control, m => Control.ContextMenuStrip);
86
			contextMenuStrip = Control.InvokeSync (c => c.ContextMenuStrip);
87
87
88
			if (contextMenuStrip != null) {
88
			if (contextMenuStrip != null) {
89
				contextMenuStrip.Opened += HandleContextMenuStripOpened;
89
				contextMenuStrip.Opened += HandleContextMenuStripOpened;
Lines 116-122 namespace Mono.UIAutomation.Winforms Link Here
116
				contextMenu.Popup -= HandleContextMenuPopup;
116
				contextMenu.Popup -= HandleContextMenuPopup;
117
				contextMenu.Collapse -= HandleContextMenuCollapse;
117
				contextMenu.Collapse -= HandleContextMenuCollapse;
118
			}
118
			}
119
			contextMenu = Helper.SynchronizedGet<SWF.Control, SWF.ContextMenu> (Control, c => c.ContextMenu);
119
			contextMenu = Control.InvokeSync (c => c.ContextMenu);
120
120
121
			if (contextMenu != null) {
121
			if (contextMenu != null) {
122
				contextMenu.Popup += HandleContextMenuPopup;
122
				contextMenu.Popup += HandleContextMenuPopup;
Lines 271-277 namespace Mono.UIAutomation.Winforms Link Here
271
				HandleContextMenuChanged (null, EventArgs.Empty);
271
				HandleContextMenuChanged (null, EventArgs.Empty);
272
				HandleContextMenuStripChanged (null, EventArgs.Empty);
272
				HandleContextMenuStripChanged (null, EventArgs.Empty);
273
273
274
				visible = Helper.SynchronizedGet<SWF.Control, bool> (Control, v => Control.Visible);
274
				visible = Control.InvokeSync (c => c.Visible);
275
			}
275
			}
276
		}
276
		}
277
277
Lines 291-297 namespace Mono.UIAutomation.Winforms Link Here
291
				Control.ControlAdded += OnControlAdded;
291
				Control.ControlAdded += OnControlAdded;
292
				Control.ControlRemoved += OnControlRemoved;
292
				Control.ControlRemoved += OnControlRemoved;
293
				
293
				
294
				foreach (SWF.Control childControl in Control.Controls)
294
				foreach (SWF.Control childControl in Control.InvokeSync (c => c.Controls))
295
					HandleComponentAdded (childControl);
295
					HandleComponentAdded (childControl);
296
296
297
				Control.VisibleChanged += OnControlVisibleChanged;
297
				Control.VisibleChanged += OnControlVisibleChanged;
Lines 349-355 namespace Mono.UIAutomation.Winforms Link Here
349
		
349
		
350
		private void OnControlVisibleChanged (object sender, EventArgs args)
350
		private void OnControlVisibleChanged (object sender, EventArgs args)
351
		{
351
		{
352
			bool isVisible = Helper.SynchronizedGet<SWF.Control, bool> (Control, v => v.Visible);
352
			bool isVisible = Control.InvokeSync (c => c.Visible);
353
			
353
			
354
			if (visible == isVisible)
354
			if (visible == isVisible)
355
				return;
355
				return;
Lines 479-485 namespace Mono.UIAutomation.Winforms Link Here
479
		{
479
		{
480
			SWF.Control control = null;
480
			SWF.Control control = null;
481
			if ((control = component as SWF.Control) != null)
481
			if ((control = component as SWF.Control) != null)
482
				return control.Visible;
482
				return control.InvokeSync (c => c.Visible);
483
			else // Component based providers will need to override this method
483
			else // Component based providers will need to override this method
484
				return false;
484
				return false;
485
		}
485
		}
Lines 539-545 namespace Mono.UIAutomation.Winforms Link Here
539
		public virtual void SetFocus ()
539
		public virtual void SetFocus ()
540
		{
540
		{
541
			if (Control != null)
541
			if (Control != null)
542
				Helper.SynchronizedSet (Control, delegate { Control.Focus (); });
542
				Control.InvokeSync (delegate { Control.Focus (); });
543
		}
543
		}
544
544
545
		#endregion
545
		#endregion
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms/Helper.cs (-209 / +81 lines)
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 74-95 namespace Mono.UIAutomation.Winforms Link Here
74
			if (control == null)
74
			if (control == null)
75
				return Rect.Empty;
75
				return Rect.Empty;
76
			else {
76
			else {
77
//				Console.WriteLine ("Helper.GetControlScreenBounds");
77
//				SWF.Control c = control;
78
//				return Helper.SynchronizedGet<SWF.Control, Rect> (control, delegate {
78
				return control.InvokeSync (c => {
79
				if (!control.Visible)
79
					if (!c.Visible)
80
					return Rect.Empty;
80
						return Rect.Empty;
81
				else if (controlIsParent)
81
					else if (controlIsParent)
82
					return Helper.RectangleToRect (control.RectangleToScreen (bounds));
82
						return Helper.RectangleToRect (c.RectangleToScreen (bounds));
83
				else if (control.Parent == null || control.TopLevelControl == null)
83
					else if (c.Parent == null || c.TopLevelControl == null)
84
					return Helper.RectangleToRect (bounds);
84
						return Helper.RectangleToRect (bounds);
85
				else {
85
					else {
86
					if (control.FindForm () == control.Parent)
86
						if (c.FindForm () == c.Parent)
87
						return Helper.RectangleToRect (control.TopLevelControl.RectangleToScreen (bounds));
87
							return Helper.RectangleToRect (c.TopLevelControl.RectangleToScreen (bounds));
88
					else
88
						else
89
						return Helper.RectangleToRect (control.Parent.RectangleToScreen (bounds));
89
							return Helper.RectangleToRect (c.Parent.RectangleToScreen (bounds));
90
				}
90
					}
91
//				});
91
				});
92
		}
92
			}
93
		}
93
		}
94
94
95
		internal static Rect GetToolStripItemScreenBounds (SWF.ToolStripItem item)
95
		internal static Rect GetToolStripItemScreenBounds (SWF.ToolStripItem item)
Lines 102-109 namespace Mono.UIAutomation.Winforms Link Here
102
			if (item.Owner == null)
102
			if (item.Owner == null)
103
				return item.Bounds;
103
				return item.Bounds;
104
			else
104
			else
105
				//return Helper.SynchronizedGet<SWF.ToolStrip, System.Drawing.Rectangle> (item.Owner, v => item.Owner.RectangleToScreen (item.Bounds));
105
				return item.Owner.InvokeSync (c => c.RectangleToScreen (item.Bounds));
106
				return item.Owner.RectangleToScreen (item.Bounds);
107
		}
106
		}
108
107
109
		internal static object GetClickablePoint (SimpleControlProvider provider)
108
		internal static object GetClickablePoint (SimpleControlProvider provider)
Lines 160-167 namespace Mono.UIAutomation.Winforms Link Here
160
		                                          Rectangle headerBounds,
159
		                                          Rectangle headerBounds,
161
		                                          IScrollBehaviorObserver observer)
160
		                                          IScrollBehaviorObserver observer)
162
		{
161
		{
163
			Rectangle listViewRectangle = Helper.SynchronizedGet<SWF.Control, Rectangle> (containerControl, 
162
			Rectangle listViewRectangle = containerControl.InvokeSync (c => c.Bounds);
164
			                                                                              b => containerControl.Bounds);
165
			if (visibleHeader) {
163
			if (visibleHeader) {
166
				listViewRectangle.Y += headerBounds.Height;
164
				listViewRectangle.Y += headerBounds.Height;
167
				listViewRectangle.Height -= headerBounds.Height;
165
				listViewRectangle.Height -= headerBounds.Height;
Lines 171-181 namespace Mono.UIAutomation.Winforms Link Here
171
			if (observer.VerticalScrollBar.Visible)
169
			if (observer.VerticalScrollBar.Visible)
172
				listViewRectangle.Width -= observer.VerticalScrollBar.Width;
170
				listViewRectangle.Width -= observer.VerticalScrollBar.Width;
173
			
171
			
174
			SWF.Control parent 
172
			SWF.Control parent = containerControl.InvokeSync (c => c.Parent);
175
				= Helper.SynchronizedGet<SWF.Control, SWF.Control> (containerControl, p => containerControl.Parent);
176
			Rect screen
173
			Rect screen
177
				= Helper.SynchronizedGet<SWF.Control, Rect> (parent,
174
				= parent.InvokeSync (c => Helper.RectangleToRect (c.RectangleToScreen (listViewRectangle)));
178
				                                             r => Helper.RectangleToRect (parent.RectangleToScreen (listViewRectangle)));
179
			return !itemBounds.IntersectsWith (screen);
175
			return !itemBounds.IntersectsWith (screen);
180
		}
176
		}
181
177
Lines 199-212 namespace Mono.UIAutomation.Winforms Link Here
199
			int imageY;
195
			int imageY;
200
			int imageWidth;
196
			int imageWidth;
201
			int imageHeight;
197
			int imageHeight;
202
			int width = Helper.SynchronizedGet<SWF.ButtonBase, int> (buttonBase, w => buttonBase.Width);
198
			int width = buttonBase.InvokeSync (c => c.Width);
203
			int height = Helper.SynchronizedGet<SWF.ButtonBase, int> (buttonBase, h => buttonBase.Height);
199
			int height = buttonBase.InvokeSync (c => c.Height);
204
200
205
			image = Helper.SynchronizedGet<SWF.ButtonBase, Image> (buttonBase, delegate {
201
			image = buttonBase.InvokeSync (c => {
206
				if (buttonBase.ImageIndex != -1)
202
				if (c.ImageIndex != -1)
207
					return buttonBase.ImageList.Images [buttonBase.ImageIndex];
203
					return c.ImageList.Images [c.ImageIndex];
208
				else
204
				else
209
					return buttonBase.Image;
205
					return c.Image;
210
			});
206
			});
211
			
207
			
212
			if (image == null)
208
			if (image == null)
Lines 215-221 namespace Mono.UIAutomation.Winforms Link Here
215
			imageWidth = image.Width;
211
			imageWidth = image.Width;
216
			imageHeight = image.Height;
212
			imageHeight = image.Height;
217
		
213
		
218
			switch (Helper.SynchronizedGet<SWF.ButtonBase, ContentAlignment> (buttonBase, i => buttonBase.ImageAlign)) {
214
			switch (buttonBase.InvokeSync (c => c.ImageAlign)) {
219
				case ContentAlignment.TopLeft: {
215
				case ContentAlignment.TopLeft: {
220
					imageX = 5;
216
					imageX = 5;
221
					imageY = 5;
217
					imageY = 5;
Lines 402-414 namespace Mono.UIAutomation.Winforms Link Here
402
				else
398
				else
403
					runtimeId = provider.GetRuntimeId ();
399
					runtimeId = provider.GetRuntimeId ();
404
400
405
//				System.Threading.ThreadPool.QueueUserWorkItem (v => {
401
				StructureChangedEventArgs invalidatedArgs 
406
//				DelegateQueue.Get ().Enqueue (delegate {
402
					= new StructureChangedEventArgs (type, runtimeId);
407
					StructureChangedEventArgs invalidatedArgs 
403
				AutomationInteropProvider.RaiseStructureChangedEvent (provider, 
408
						= new StructureChangedEventArgs (type, runtimeId);
404
				                                                      invalidatedArgs);
409
					AutomationInteropProvider.RaiseStructureChangedEvent (provider, 
410
					                                                      invalidatedArgs);
411
//				});
412
			}
405
			}
413
		}
406
		}
414
		
407
		
Lines 471-661 namespace Mono.UIAutomation.Winforms Link Here
471
			return s;
464
			return s;
472
		}
465
		}
473
466
474
		private static Thread invokeThread;
475
		private static object invokeThreadLock = new object ();
476
//		private static object lockObj = new object ();
477
		
478
		private static Thread InvokeThread {
479
			// FIXME: Remove getter
480
			get {
481
				lock (invokeThreadLock) {
482
					return invokeThread;
483
				}
484
			}
485
			
486
			set {
487
				lock (invokeThreadLock) {
488
					invokeThread = Thread.CurrentThread;
489
				}
490
			}
491
		}
492
493
		internal static Return SynchronizedGet<Subject, Return> (Subject subject, Func<Subject, Return> verb)
467
		internal static Return SynchronizedGet<Subject, Return> (Subject subject, Func<Subject, Return> verb)
494
			where Subject : SWF.Control	
468
			where Subject : SWF.Control
495
		{			
469
		{
496
			lock (lockObject) {
497
				// If is being used already in a different thread
498
				if (Interlocked.CompareExchange (ref Counter, 1, 1) == 1
499
				    && (InvokeThread != null && InvokeThread != Thread.CurrentThread))  {
500
					Console.WriteLine ("ya esta siendo usado...");
501
					Monitor.Wait (lockObject);
502
					InvokeThread = null;
503
				}
504
			}
505
			
506
			if (subject.InvokeRequired && subject.IsHandleCreated) {
470
			if (subject.InvokeRequired && subject.IsHandleCreated) {
507
				return (Return) subject.Invoke (new Func<Subject, Func<Subject, Return>, Return> (SynchronizedGet<Subject, Return>), 
471
//				return (Return) subject.Invoke (new Func<Subject, Func<Subject, Return>, Return> (SynchronizedGet<Subject, Return>),
508
				                                new object [] { subject, verb });
472
//				                                 new object [] { subject, verb });
509
			} else { 
473
				return (Return) subject.Invoke (verb, subject);
510
				InvokeThread = Thread.CurrentThread;
474
			} else {
511
				int oldValue = Interlocked.Exchange (ref Counter, 1);
475
				return verb (subject);
512
				
513
				
514
				if (oldValue != 1) {
515
					Console.WriteLine ("GET unlocing thread");
516
					Interlocked.Exchange (ref Counter, 0);
517
					
518
					lock (lockObject) {
519
						Monitor.Pulse (lockObject);
520
					}
521
					
522
					lock (Helper.DelegateQueue.Lock) {
523
						Monitor.Pulse (Helper.DelegateQueue.Lock);
524
					}
525
				}
526
				
527
				Return v = verb (subject);
528
529
				return v;
530
			}
476
			}
531
		}
477
		}
532
478
533
		internal static int Counter = 0;
479
		internal static int Counter = 0;
534
		static object lockObject = new object ();
535
//		static object lockObjectMonitor = new object ()
536
480
537
		internal static void SynchronizedSet (SWF.Control subject, Action<SWF.Control> verb)
481
		internal static void SynchronizedSet (SWF.Control subject, Action<SWF.Control> verb)
538
		{
482
		{
539
			lock (lockObject) {
540
				// If is being used, wait
541
				if (Interlocked.CompareExchange (ref Counter, 1, 1) == 1
542
				    && (InvokeThread != null && InvokeThread != Thread.CurrentThread))  {
543
					Console.WriteLine ("SET ya esta siendo usado...");
544
					Monitor.Wait (lockObject);
545
				}
546
			}
547
			
548
			if (subject.InvokeRequired && subject.IsHandleCreated) {
483
			if (subject.InvokeRequired && subject.IsHandleCreated) {
549
				subject.BeginInvoke (new Action<SWF.Control, Action<SWF.Control>> (SynchronizedSet), 
484
				subject.BeginInvoke (new Action<SWF.Control, Action<SWF.Control>> (SynchronizedSet), 
550
				                     new object [] { subject, verb });
485
				                new object [] { subject, verb });
551
			} else {
486
			} else {
552
				InvokeThread = Thread.CurrentThread;
553
				int oldValue = Interlocked.Exchange (ref Counter, 1);
554
				
555
				
556
				if (oldValue != 1) { // We are being called by Set/Get
557
					Console.WriteLine ("SET unlocing thread");
558
					Interlocked.Exchange (ref Counter, 0);
559
					
560
					lock (lockObject) {
561
						Monitor.Pulse (lockObject);
562
					}
563
					
564
					lock (Helper.DelegateQueue.Lock) {
565
						Monitor.Pulse (Helper.DelegateQueue.Lock);
566
					}
567
				
568
				}
569
	
570
				verb (subject);
487
				verb (subject);
571
				
572
			}
488
			}
573
		}
489
		}
574
575
		internal class DelegateQueue
576
		{
577
			public static DelegateQueue Get ()
578
			{
579
				if (consumer == null)
580
					consumer = new DelegateQueue ();
581
				
582
				return consumer;
583
			}
584
585
			public void Enqueue (QueueDelegate value)
586
			{
587
				lock (lockObj) {
588
					queue.Enqueue (value);
589
				}
590
			}
591
			
592
			public int Count {
593
				get {
594
					lock (lockObj) {
595
						return queue.Count;
596
					}
597
				}
598
			}
599
600
			public QueueDelegate Dequeue ()
601
			{
602
				lock (lockObj) {
603
					if (queue.Count == 0)
604
						return null;
605
					else
606
						return queue.Dequeue ();
607
				}
608
			}
609
			
610
			private DelegateQueue ()
611
			{
612
				queue = new System.Collections.Generic.Queue<QueueDelegate> ();
613
				threadConsumer = new Thread (new ThreadStart (Consume));
614
				threadConsumer.Name = "AIPConsumer";
615
				threadConsumer.Start ();
616
			}
617
			
618
			public void Quit ()
619
			{
620
				lock (lockObj) {
621
					Console.WriteLine ("Not proceseed events: {0}", queue.Count);
622
					close = true;
623
					lock (DelegateQueue.Lock) {
624
						Monitor.Pulse (DelegateQueue.Lock);
625
					}
626
				}
627
			}
628
629
			private void Consume ()
630
			{
631
				while (!close) {
632
					QueueDelegate action = Dequeue ();
633
					if (action == null || Interlocked.CompareExchange (ref Helper.Counter, 0, 0) != 0) {
634
						lock (DelegateQueue.Lock) {
635
							Console.WriteLine ("waiting...: {0}", action == null);
636
							Monitor.Wait (DelegateQueue.Lock);
637
							if (close)
638
								break;
639
							continue;
640
						}
641
					}
642
					Console.WriteLine ("Raising action!");
643
					action ();
644
				}
645
			}
646
			
647
			private bool close = false;
648
649
			public delegate void QueueDelegate ();
650
651
			public static readonly object Lock = new object (); 
652
653
			private object lockObj = new object ();
654
			private static DelegateQueue consumer;
655
			
656
			private Thread threadConsumer;
657
			private System.Collections.Generic.Queue<QueueDelegate> queue;
658
		}
659
		
490
		
660
		#endregion
491
		#endregion
661
		
492
		
Lines 703-706 namespace Mono.UIAutomation.Winforms Link Here
703
534
704
		#endregion
535
		#endregion
705
	}
536
	}
537
538
	internal static class InvokeRequiredExtensionControl
539
	{	
540
		public static TResult InvokeSync<TControl, TResult> (this TControl control,
541
		                                                       Func<TControl, TResult> func)
542
			where TControl : SWF.Control
543
		{
544
			// This happens when a Winforms event raises an AutomationEvent
545
			// that raises an Atk event that needs to request Winforms data :-)
546
			if (AlreadyInvoked)
547
				return (TResult) func (control);
548
			
549
			if (control.InvokeRequired && control.IsHandleCreated) {
550
				if (Interlocked.CompareExchange (ref alreadyInvoked, 1, 0) == 1) {
551
					TResult result = (TResult) control.Invoke (func, control);
552
					Interlocked.CompareExchange (ref alreadyInvoked, 0, 1);
553
					return result;
554
				} else
555
					return (TResult) func (control);
556
			} else
557
				return (TResult) func (control);
558
		}
559
		
560
		public static void InvokeSync<TControl> (this TControl control, 
561
		                                            Action<TControl> action)
562
			where TControl : SWF.Control
563
		{
564
			// We don't care about AlreadyInvoked since we are not 
565
			// returning a value.
566
			if (control.InvokeRequired && control.IsHandleCreated)
567
				control.BeginInvoke (action, control);
568
			else
569
				action (control);
570
		}
571
572
		private static bool AlreadyInvoked {
573
			get { return Interlocked.CompareExchange (ref alreadyInvoked, 0, 0) == 1; }
574
		}
575
		
576
		private static int alreadyInvoked = 0;
577
	}
706
}
578
}
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms/ListBoxProvider.cs (-37 / +30 lines)
Lines 57-71 namespace Mono.UIAutomation.Winforms Link Here
57
57
58
		protected override ScrollBar HorizontalScrollBar { 
58
		protected override ScrollBar HorizontalScrollBar { 
59
			get { 
59
			get { 
60
				return Helper.SynchronizedGet<ListBox, ScrollBar> (listboxControl, 
60
				return listboxControl.InvokeSync (c => c.UIAHScrollBar); 
61
				                                                   s => listboxControl.UIAHScrollBar); 
62
			}
61
			}
63
		}
62
		}
64
63
65
		protected override ScrollBar VerticalScrollBar { 
64
		protected override ScrollBar VerticalScrollBar { 
66
			get { 
65
			get { 
67
				return Helper.SynchronizedGet<ListBox, ScrollBar> (listboxControl,
66
				return listboxControl.InvokeSync (c => c.UIAVScrollBar); 
68
				                                                   s => listboxControl.UIAVScrollBar); 
69
			}
67
			}
70
		}
68
		}
71
69
Lines 94-104 namespace Mono.UIAutomation.Winforms Link Here
94
			else if (propertyId == AutomationElementIdentifiers.LocalizedControlTypeProperty.Id)
92
			else if (propertyId == AutomationElementIdentifiers.LocalizedControlTypeProperty.Id)
95
				return Catalog.GetString ("list");
93
				return Catalog.GetString ("list");
96
			else if (propertyId == AutomationElementIdentifiers.NameProperty.Id) {
94
			else if (propertyId == AutomationElementIdentifiers.NameProperty.Id) {
97
				return Helper.SynchronizedGet<ListBox, string> (listboxControl, delegate {
95
				return listboxControl.InvokeSync (c => {
98
					if (string.IsNullOrEmpty (listboxControl.AccessibleName))
96
					if (string.IsNullOrEmpty (c.AccessibleName))
99
						return Helper.StripAmpersands (listboxControl.Text);
97
						return Helper.StripAmpersands (c.Text);
100
					else
98
					else
101
						return listboxControl.AccessibleName;
99
						return c.AccessibleName;
102
				});
100
				});
103
			} else
101
			} else
104
				return base.GetProviderPropertyValue (propertyId);
102
				return base.GetProviderPropertyValue (propertyId);
Lines 121-133 namespace Mono.UIAutomation.Winforms Link Here
121
		
119
		
122
		public override IRawElementProviderFragment GetFocus ()
120
		public override IRawElementProviderFragment GetFocus ()
123
		{
121
		{
124
			return Helper.SynchronizedGet<ListBox, IRawElementProviderFragment> (listboxControl,
122
			return listboxControl.InvokeSync (c => GetItemProviderFrom (this, c.Items [c.FocusedItem]));
125
			                                                                     c => GetItemProviderFrom (this, listboxControl.Items [listboxControl.FocusedItem]));
126
		}
123
		}
127
		
124
		
128
		public override void FocusItem (object objectItem)
125
		public override void FocusItem (object objectItem)
129
		{
126
		{
130
			Helper.SynchronizedSet (listboxControl, delegate {
127
			listboxControl.InvokeSync (delegate {
131
				listboxControl.FocusedItem = listboxControl.Items.IndexOf (objectItem);
128
				listboxControl.FocusedItem = listboxControl.Items.IndexOf (objectItem);
132
			});
129
			});
133
		}
130
		}
Lines 136-142 namespace Mono.UIAutomation.Winforms Link Here
136
		{
133
		{
137
			base.InitializeChildControlStructure ();
134
			base.InitializeChildControlStructure ();
138
135
139
			Helper.SynchronizedSet (listboxControl, delegate {
136
			listboxControl.InvokeSync (delegate {
140
				listboxControl.Items.UIACollectionChanged += OnCollectionChanged;
137
				listboxControl.Items.UIACollectionChanged += OnCollectionChanged;
141
				
138
				
142
				foreach (object objectItem in listboxControl.Items) {
139
				foreach (object objectItem in listboxControl.Items) {
Lines 150-156 namespace Mono.UIAutomation.Winforms Link Here
150
		{
147
		{
151
			base.FinalizeChildControlStructure ();
148
			base.FinalizeChildControlStructure ();
152
149
153
			Helper.SynchronizedSet (listboxControl, delegate {
150
			listboxControl.InvokeSync (delegate {
154
				listboxControl.Items.UIACollectionChanged -= OnCollectionChanged;
151
				listboxControl.Items.UIACollectionChanged -= OnCollectionChanged;
155
			});
152
			});
156
		}
153
		}
Lines 163-191 namespace Mono.UIAutomation.Winforms Link Here
163
		                                             int propertyId)
160
		                                             int propertyId)
164
		{
161
		{
165
			if (propertyId == AutomationElementIdentifiers.NameProperty.Id)
162
			if (propertyId == AutomationElementIdentifiers.NameProperty.Id)
166
				return Helper.SynchronizedGet<ListBox, string> (listboxControl, 
163
				return listboxControl.InvokeSync (s => s.GetItemText (item.ObjectItem));
167
				                                                s => listboxControl.GetItemText (item.ObjectItem));
168
			
164
			
169
			if (ContainsItem (item) == false)
165
			if (ContainsItem (item) == false)
170
				return null;
166
				return null;
171
167
172
			if (propertyId == AutomationElementIdentifiers.HasKeyboardFocusProperty.Id)
168
			if (propertyId == AutomationElementIdentifiers.HasKeyboardFocusProperty.Id)
173
				return Helper.SynchronizedGet<ListBox, bool> (listboxControl, 
169
				return listboxControl.InvokeSync (s => s.Focused 
174
				                                              b => listboxControl.Focused 
170
				                                  && item.Index == s.FocusedItem);
175
				                                              && item.Index == listboxControl.FocusedItem);
176
			else if (propertyId == AutomationElementIdentifiers.BoundingRectangleProperty.Id) {
171
			else if (propertyId == AutomationElementIdentifiers.BoundingRectangleProperty.Id) {
177
				return Helper.SynchronizedGet<ListBox, Rect> (listboxControl, delegate {
172
				return listboxControl.InvokeSync (c => {
178
					System.Drawing.Rectangle itemRec = System.Drawing.Rectangle.Empty;
173
					System.Drawing.Rectangle itemRec = System.Drawing.Rectangle.Empty;
179
					System.Drawing.Rectangle rectangle = listboxControl.Bounds;
174
					System.Drawing.Rectangle rectangle = c.Bounds;
180
	
175
	
181
					itemRec = listboxControl.GetItemRectangle (item.Index);
176
					itemRec = c.GetItemRectangle (item.Index);
182
					itemRec.X += rectangle.X;
177
					itemRec.X += rectangle.X;
183
					itemRec.Y += rectangle.Y;
178
					itemRec.Y += rectangle.Y;
184
					
179
					
185
					if (listboxControl.FindForm () == listboxControl.Parent)
180
					if (c.FindForm () == c.Parent)
186
						itemRec = listboxControl.TopLevelControl.RectangleToScreen (itemRec);
181
						itemRec = c.TopLevelControl.RectangleToScreen (itemRec);
187
					else
182
					else
188
						itemRec = listboxControl.Parent.RectangleToScreen (itemRec);
183
						itemRec = c.Parent.RectangleToScreen (itemRec);
189
		
184
		
190
					return Helper.RectangleToRect (itemRec);
185
					return Helper.RectangleToRect (itemRec);
191
				});
186
				});
Lines 204-219 namespace Mono.UIAutomation.Winforms Link Here
204
		#region ListProvider: Specializations
199
		#region ListProvider: Specializations
205
		
200
		
206
		public override int SelectedItemsCount {
201
		public override int SelectedItemsCount {
207
			get { return Helper.SynchronizedGet<ListBox, int> (listboxControl, c => listboxControl.SelectedItems.Count); }
202
			get { return listboxControl.InvokeSync (c => c.SelectedItems.Count); }
208
		}
203
		}
209
		
204
		
210
		public override int ItemsCount {
205
		public override int ItemsCount {
211
			get { return Helper.SynchronizedGet<ListBox, int> (listboxControl, c => listboxControl.Items.Count); }
206
			get { return listboxControl.InvokeSync (c => c.Items.Count); }
212
		}
207
		}
213
208
214
		public override int IndexOfObjectItem (object objectItem)
209
		public override int IndexOfObjectItem (object objectItem)
215
		{
210
		{
216
			return Helper.SynchronizedGet<ListBox, int> (listboxControl, c => listboxControl.Items.IndexOf (objectItem));
211
			return listboxControl.InvokeSync (c => c.Items.IndexOf (objectItem));
217
		}
212
		}
218
		
213
		
219
		public override IRawElementProviderSimple[] GetSelectedItems ()
214
		public override IRawElementProviderSimple[] GetSelectedItems ()
Lines 221-234 namespace Mono.UIAutomation.Winforms Link Here
221
			ListItemProvider []items;
216
			ListItemProvider []items;
222
217
223
			if (listboxControl == null 
218
			if (listboxControl == null 
224
			    || Helper.SynchronizedGet<ListBox, bool> (listboxControl, 
219
			    || listboxControl.InvokeSync (c => c.SelectedIndices.Count == 0))
225
			                                              c => listboxControl.SelectedIndices.Count == 0))
226
				return new ListItemProvider [0];
220
				return new ListItemProvider [0];
227
221
228
			return Helper.SynchronizedGet<ListBox, ListItemProvider[]> (listboxControl, delegate {
222
			return listboxControl.InvokeSync (c => {
229
				items = new ListItemProvider [listboxControl.SelectedIndices.Count];		
223
				items = new ListItemProvider [c.SelectedIndices.Count];		
230
				for (int index = 0; index < items.Length; index++) 
224
				for (int index = 0; index < items.Length; index++) 
231
					items [index] = GetItemProviderFrom (this, listboxControl.Items [listboxControl.SelectedIndices [index]]);
225
					items [index] = GetItemProviderFrom (this, c.Items [c.SelectedIndices [index]]);
232
				
226
				
233
				return items;
227
				return items;
234
			});
228
			});
Lines 236-257 namespace Mono.UIAutomation.Winforms Link Here
236
		
230
		
237
		public override void SelectItem (ListItemProvider item)
231
		public override void SelectItem (ListItemProvider item)
238
		{
232
		{
239
			Helper.SynchronizedSet (listboxControl, delegate {
233
			listboxControl.InvokeSync (delegate {
240
				listboxControl.SetSelected (item.Index, true);
234
				listboxControl.SetSelected (item.Index, true);
241
			});
235
			});
242
		}
236
		}
243
237
244
		public override void UnselectItem (ListItemProvider item)
238
		public override void UnselectItem (ListItemProvider item)
245
		{
239
		{
246
			Helper.SynchronizedSet (listboxControl, delegate {
240
			listboxControl.InvokeSync (delegate {
247
				listboxControl.SetSelected (item.Index, false);
241
				listboxControl.SetSelected (item.Index, false);
248
			});
242
			});
249
		}
243
		}
250
		
244
		
251
		public override bool IsItemSelected (ListItemProvider item)
245
		public override bool IsItemSelected (ListItemProvider item)
252
		{
246
		{
253
			return Helper.SynchronizedGet<ListBox, bool> (listboxControl, 
247
			return listboxControl.InvokeSync (b => b.SelectedIndices.Contains (item.Index));
254
			                                              b => listboxControl.SelectedIndices.Contains (item.Index));
255
		}
248
		}
256
249
257
		public override IConnectable GetListItemEventRealization (ProviderEventType eventType, 
250
		public override IConnectable GetListItemEventRealization (ProviderEventType eventType, 
Lines 270-276 namespace Mono.UIAutomation.Winforms Link Here
270
		public override void ScrollItemIntoView (ListItemProvider item)
263
		public override void ScrollItemIntoView (ListItemProvider item)
271
		{
264
		{
272
			if (ContainsItem (item) == true)
265
			if (ContainsItem (item) == true)
273
				Helper.SynchronizedSet (listboxControl, delegate {
266
				listboxControl.InvokeSync (delegate {
274
					listboxControl.TopIndex = item.Index;
267
					listboxControl.TopIndex = item.Index;
275
				});
268
				});
276
		}
269
		}
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms/ListViewProvider.cs (-121 / +86 lines)
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
					});
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms/MenuStripProvider.cs (-2 / +1 lines)
Lines 54-61 namespace Mono.UIAutomation.Winforms Link Here
54
			else if (propertyId == AEIds.LocalizedControlTypeProperty.Id)
54
			else if (propertyId == AEIds.LocalizedControlTypeProperty.Id)
55
				return Catalog.GetString ("menu bar");
55
				return Catalog.GetString ("menu bar");
56
			else if (propertyId == AEIds.OrientationProperty.Id) {
56
			else if (propertyId == AEIds.OrientationProperty.Id) {
57
				switch (Helper.SynchronizedGet<MenuStrip, Orientation> (menu, 
57
				switch (menu.InvokeSync (o => menu.Orientation)) {
58
				                                                        o => menu.Orientation)) {
59
				case Orientation.Vertical:
58
				case Orientation.Vertical:
60
					return OrientationType.Vertical;
59
					return OrientationType.Vertical;
61
				case Orientation.Horizontal:
60
				case Orientation.Horizontal:
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms/PanelProvider.cs (-1 / +1 lines)
Lines 38-44 namespace Mono.UIAutomation.Winforms Link Here
38
		}
38
		}
39
39
40
		public override Component Container  {
40
		public override Component Container  {
41
			get { return Control.Parent; }
41
			get { return Control.InvokeSync (c => c.Parent); }
42
		}
42
		}
43
43
44
	}
44
	}
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms/ScrollBehaviorObserver.cs (-2 / +2 lines)
Lines 58-71 namespace Mono.UIAutomation.Winforms Link Here
58
		public bool HasHorizontalScrollbar {
58
		public bool HasHorizontalScrollbar {
59
			get {
59
			get {
60
				return HorizontalScrollBar != null 
60
				return HorizontalScrollBar != null 
61
					&& HorizontalScrollBar.Visible && HorizontalScrollBar.Enabled; 
61
					&& HorizontalScrollBar.InvokeSync (c => c.Visible && c.Enabled); 
62
			}
62
			}
63
		}
63
		}
64
		
64
		
65
		public bool HasVerticalScrollbar {
65
		public bool HasVerticalScrollbar {
66
			get { 
66
			get { 
67
				return VerticalScrollBar != null 
67
				return VerticalScrollBar != null 
68
					&& VerticalScrollBar.Visible && VerticalScrollBar.Enabled; 
68
					&& VerticalScrollBar.InvokeSync (c => c.Visible && c.Enabled); 
69
			}
69
			}
70
		}
70
		}
71
	
71
	
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms/ScrollableControlProvider.cs (-7 / +9 lines)
Lines 59-76 namespace Mono.UIAutomation.Winforms Link Here
59
59
60
#region FragmentRootControlProvider Implementation
60
#region FragmentRootControlProvider Implementation
61
		public override Component Container {
61
		public override Component Container {
62
			get { return Control.Parent; }
62
			get { return Control.InvokeSync (c => c.Parent); }
63
		}
63
		}
64
64
65
		public override void InitializeChildControlStructure ()
65
		public override void InitializeChildControlStructure ()
66
		{
66
		{
67
			base.InitializeChildControlStructure ();
67
			base.InitializeChildControlStructure ();
68
68
69
			observer = new ScrollBehaviorObserver (
69
			scrollableControl.InvokeSync (delegate {
70
				this, scrollableControl.hscrollbar,
70
				observer = new ScrollBehaviorObserver (
71
				scrollableControl.vscrollbar);
71
					this, scrollableControl.hscrollbar,
72
			observer.ScrollPatternSupportChanged += OnScrollPatternSupportChanged;
72
					scrollableControl.vscrollbar);
73
			observer.Initialize ();
73
				observer.ScrollPatternSupportChanged += OnScrollPatternSupportChanged;
74
				observer.Initialize ();
75
			});
74
			UpdateScrollBehavior ();
76
			UpdateScrollBehavior ();
75
		}
77
		}
76
78
Lines 78-84 namespace Mono.UIAutomation.Winforms Link Here
78
		{
80
		{
79
			// Override Pane's IsKeyboardFocusableProperty
81
			// Override Pane's IsKeyboardFocusableProperty
80
			if (propertyId == AutomationElementIdentifiers.IsKeyboardFocusableProperty.Id)
82
			if (propertyId == AutomationElementIdentifiers.IsKeyboardFocusableProperty.Id)
81
				return Control.CanFocus && Control.CanSelect;
83
				return Control.InvokeSync (c => c.CanFocus && c.CanSelect);
82
84
83
			return base.GetProviderPropertyValue (propertyId);
85
			return base.GetProviderPropertyValue (propertyId);
84
		}
86
		}
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms/SimpleControlProvider.cs (-14 / +18 lines)
Lines 76-82 namespace Mono.UIAutomation.Winforms Link Here
76
		#region Public Properties
76
		#region Public Properties
77
		
77
		
78
		public virtual Component Container {
78
		public virtual Component Container {
79
			get { return control != null ? control.Parent : null; }
79
			get { return control != null ? control.InvokeSync (c => c.Parent) : null; }
80
		}
80
		}
81
81
82
		public Component Component {
82
		public Component Component {
Lines 209-220 namespace Mono.UIAutomation.Winforms Link Here
209
		protected virtual System.Drawing.Rectangle ScreenBounds
209
		protected virtual System.Drawing.Rectangle ScreenBounds
210
		{
210
		{
211
			get {
211
			get {
212
				if (Control == null || !Control.Visible)
212
				if (Control == null)
213
					return System.Drawing.Rectangle.Empty;
213
					return System.Drawing.Rectangle.Empty;
214
214
215
				return Helper.RectToRectangle (
215
				return Control.InvokeSync (c => {
216
					Helper.GetControlScreenBounds (Control.Bounds, Control)
216
					if (!c.Visible)
217
				);
217
						return System.Drawing.Rectangle.Empty;
218
219
					return Helper.RectToRectangle (Helper.GetControlScreenBounds (c.Bounds, c));
220
				});
218
			}
221
			}
219
		}
222
		}
220
223
Lines 281-287 namespace Mono.UIAutomation.Winforms Link Here
281
			if (Control == null)
284
			if (Control == null)
282
				return null;
285
				return null;
283
			else if (propertyId == AutomationElementIdentifiers.IsEnabledProperty.Id)
286
			else if (propertyId == AutomationElementIdentifiers.IsEnabledProperty.Id)
284
				return Control.Enabled;
287
				return Control.InvokeSync (c => c.Enabled);
285
			else if (propertyId == AutomationElementIdentifiers.NameProperty.Id) {
288
			else if (propertyId == AutomationElementIdentifiers.NameProperty.Id) {
286
				if (!string.IsNullOrEmpty (Control.AccessibleName)) 
289
				if (!string.IsNullOrEmpty (Control.AccessibleName)) 
287
					return Control.AccessibleName;
290
					return Control.AccessibleName;
Lines 296-302 namespace Mono.UIAutomation.Winforms Link Here
296
					if (controlType == ControlType.Edit.Id || controlType == ControlType.Document.Id)
299
					if (controlType == ControlType.Edit.Id || controlType == ControlType.Document.Id)
297
						return string.Empty;
300
						return string.Empty;
298
					else
301
					else
299
						return Helper.StripAmpersands (Control.Text);
302
						return Helper.StripAmpersands (Control.InvokeSync (c => c.Text));
300
				} else
303
				} else
301
					return label.GetPropertyValue (AutomationElementIdentifiers.NameProperty.Id);
304
					return label.GetPropertyValue (AutomationElementIdentifiers.NameProperty.Id);
302
			} else if (propertyId == AutomationElementIdentifiers.LabeledByProperty.Id) {
305
			} else if (propertyId == AutomationElementIdentifiers.LabeledByProperty.Id) {
Lines 326-334 namespace Mono.UIAutomation.Winforms Link Here
326
				return closestLabel;
329
				return closestLabel;
327
				
330
				
328
			} else if (propertyId == AutomationElementIdentifiers.IsKeyboardFocusableProperty.Id)
331
			} else if (propertyId == AutomationElementIdentifiers.IsKeyboardFocusableProperty.Id)
329
				return Control.CanFocus && Control.CanSelect;
332
				return Control.InvokeSync (c => c.CanFocus && c.CanSelect);
330
			else if (propertyId == AutomationElementIdentifiers.HasKeyboardFocusProperty.Id)
333
			else if (propertyId == AutomationElementIdentifiers.HasKeyboardFocusProperty.Id)
331
				return Control.Focused;
334
				return Control.InvokeSync (c => c.Focused);
332
			else if (propertyId == AutomationElementIdentifiers.ClickablePointProperty.Id)
335
			else if (propertyId == AutomationElementIdentifiers.ClickablePointProperty.Id)
333
				return Helper.GetClickablePoint (this);
336
				return Helper.GetClickablePoint (this);
334
			else if (propertyId == AutomationElementIdentifiers.HelpTextProperty.Id) {
337
			else if (propertyId == AutomationElementIdentifiers.HelpTextProperty.Id) {
Lines 337-347 namespace Mono.UIAutomation.Winforms Link Here
337
				else
340
				else
338
					return ToolTip.GetToolTip (Control);
341
					return ToolTip.GetToolTip (Control);
339
			} else if (propertyId == AutomationElementIdentifiers.AccessKeyProperty.Id) {
342
			} else if (propertyId == AutomationElementIdentifiers.AccessKeyProperty.Id) {
340
				if (!Control.Text.Contains ("&"))
343
				string text = Control.InvokeSync (c => c.Text);
344
				if (!text.Contains ("&"))
341
					return null;
345
					return null;
342
				else {
346
				else {
343
					int index = Control.Text.LastIndexOf ('&') + 1;
347
					int index = text.LastIndexOf ('&') + 1;
344
					return "Alt+" + Control.Text.Substring (index, 1);
348
					return "Alt+" + text.Substring (index, 1);
345
				}
349
				}
346
			} else
350
			} else
347
				return null;
351
				return null;
Lines 390-399 namespace Mono.UIAutomation.Winforms Link Here
390
		public virtual IRawElementProviderSimple HostRawElementProvider {
394
		public virtual IRawElementProviderSimple HostRawElementProvider {
391
			get {
395
			get {
392
				// TODO: Address for Components (*Strip*)
396
				// TODO: Address for Components (*Strip*)
393
				if (Control == null || Control.TopLevelControl == null)
397
				if (Control == null || Control.InvokeSync (c => c.TopLevelControl == null))
394
					return null;
398
					return null;
395
				else
399
				else
396
					return AutomationInteropProvider.HostProviderFromHandle (Control.TopLevelControl.Handle);
400
					return AutomationInteropProvider.HostProviderFromHandle (Control.InvokeSync (c => c.TopLevelControl.Handle));
397
			}
401
			}
398
		}
402
		}
399
		
403
		
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms/SplitContainerProvider.cs (-3 / +6 lines)
Lines 95-103 namespace Mono.UIAutomation.Winforms Link Here
95
				return ControlType.Pane.Id;
95
				return ControlType.Pane.Id;
96
			else if (propertyId == AutomationElementIdentifiers.LocalizedControlTypeProperty.Id)
96
			else if (propertyId == AutomationElementIdentifiers.LocalizedControlTypeProperty.Id)
97
				return Catalog.GetString ("pane");
97
				return Catalog.GetString ("pane");
98
				else if (propertyId == AutomationElementIdentifiers.OrientationProperty.Id)
98
			else if (propertyId == AutomationElementIdentifiers.OrientationProperty.Id) {
99
					return ((SplitContainer)Control).Orientation == Orientation.Vertical? OrientationType.Vertical: OrientationType.Horizontal;
99
				if (((SplitContainer)Control).InvokeSync (c => c.Orientation) == Orientation.Vertical)
100
			else
100
					return OrientationType.Vertical;
101
				else
102
					return OrientationType.Horizontal;
103
			} else
101
				return base.GetProviderPropertyValue (propertyId);
104
				return base.GetProviderPropertyValue (propertyId);
102
		}
105
		}
103
		
106
		
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms/StatusBarProvider.cs (-11 / +13 lines)
Lines 112-130 namespace Mono.UIAutomation.Winforms Link Here
112
		
112
		
113
		public StatusBarPanelProvider GetPanelProvider (int index)
113
		public StatusBarPanelProvider GetPanelProvider (int index)
114
		{
114
		{
115
			StatusBarPanelProvider panel = null;
115
			return statusBar.InvokeSync (p => {
116
			
116
				StatusBarPanelProvider panel = null;
117
			if (index < 0 || index >= statusBar.Panels.Count)
117
				
118
				return null;
118
				if (index < 0 || index >= p.Panels.Count)
119
			else if (index >= panels.Count) {
119
					return null;
120
				for (int loop = panels.Count - 1; loop < index; ++loop) {
120
				else if (index >= panels.Count) {
121
					panel = new StatusBarPanelProvider (statusBar.Panels [index]);
121
					for (int loop = panels.Count - 1; loop < index; ++loop) {
122
					panels.Add (panel);
122
						panel = new StatusBarPanelProvider (p.Panels [index]);
123
					panel.Initialize ();
123
						panels.Add (panel);
124
						panel.Initialize ();
125
					}
124
				}
126
				}
125
			}
127
				return panels [index];
128
			});
126
			
129
			
127
			return panels [index];
128
		}
130
		}
129
		
131
		
130
		public StatusBarPanelProvider RemovePanelAt (int index)
132
		public StatusBarPanelProvider RemovePanelAt (int index)
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms/TabControlProvider.cs (-16 / +6 lines)
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
//	Brad Taylor <brad@getcoded.net>
23
//	Brad Taylor <brad@getcoded.net>
Lines 66-74 namespace Mono.UIAutomation.Winforms Link Here
66
			else if (propertyId == AEIds.LocalizedControlTypeProperty.Id)
66
			else if (propertyId == AEIds.LocalizedControlTypeProperty.Id)
67
				return Catalog.GetString ("tab");
67
				return Catalog.GetString ("tab");
68
			else if (propertyId == AEIds.OrientationProperty.Id) {
68
			else if (propertyId == AEIds.OrientationProperty.Id) {
69
				TabAlignment align = Helper.SynchronizedGet<TabControl, TabAlignment> (
69
				TabAlignment align = control.InvokeSync (c => c.Alignment);
70
					control, c => c.Alignment
71
				);
72
				return (align == TabAlignment.Top || align == TabAlignment.Bottom)
70
				return (align == TabAlignment.Top || align == TabAlignment.Bottom)
73
				       ? Orientation.Horizontal : Orientation.Vertical;
71
				       ? Orientation.Horizontal : Orientation.Vertical;
74
			}
72
			}
Lines 87-104 namespace Mono.UIAutomation.Winforms Link Here
87
#endregion
85
#endregion
88
86
89
		internal bool HasSelection {
87
		internal bool HasSelection {
90
			get {
88
			get { return control.InvokeSync (c => c.SelectedIndex > -1); }
91
				return Helper.SynchronizedGet<TabControl, bool> (
92
					control, c => c.SelectedIndex > -1
93
				);
94
			}
95
		}
89
		}
96
90
97
		internal TabPageProvider GetSelectedTab ()
91
		internal TabPageProvider GetSelectedTab ()
98
		{
92
		{
99
			TabPage page = Helper.SynchronizedGet<TabControl, TabPage> (
93
			TabPage page = control.InvokeSync (c => c.SelectedTab);
100
				control, c => c.SelectedTab
101
			);
102
94
103
			if (page == null)
95
			if (page == null)
104
				return null;
96
				return null;
Lines 108-123 namespace Mono.UIAutomation.Winforms Link Here
108
100
109
		internal void SelectItem (TabPageProvider tabPage)
101
		internal void SelectItem (TabPageProvider tabPage)
110
		{
102
		{
111
			Helper.SynchronizedSet (control, delegate {
103
			control.InvokeSync (delegate {
112
				control.SelectedTab = (TabPage) tabPage.Control;
104
				control.SelectedTab = (TabPage) tabPage.Control;
113
			});
105
			});
114
		}
106
		}
115
107
116
		internal bool IsItemSelected (TabPageProvider tabPage)
108
		internal bool IsItemSelected (TabPageProvider tabPage)
117
		{
109
		{
118
			return Helper.SynchronizedGet<TabControl, bool> (
110
			return control.InvokeSync (c => c.SelectedTab == (TabPage) tabPage.Control);
119
				control, c => c.SelectedTab == (TabPage) tabPage.Control
120
			);
121
		}
111
		}
122
		
112
		
123
#region Private Fields
113
#region Private Fields
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms/TabPageProvider.cs (-4 / +3 lines)
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
//	Brad Taylor <brad@getcoded.net>
23
//	Brad Taylor <brad@getcoded.net>
Lines 56-63 namespace Mono.UIAutomation.Winforms Link Here
56
				// want this control's visiblity managed by the
56
				// want this control's visiblity managed by the
57
				// TabControl, as tab pages are on-screen even
57
				// TabControl, as tab pages are on-screen even
58
				// if they report Visible = false.
58
				// if they report Visible = false.
59
				return Helper.SynchronizedGet<Control, System.Windows.Rect> (Control,
59
				return Control.InvokeSync (v => Helper.RectangleToRect (
60
					v => Helper.RectangleToRect (
61
						v.Parent.RectangleToScreen (tabPage.TabBounds)));
60
						v.Parent.RectangleToScreen (tabPage.TabBounds)));
62
			}
61
			}
63
62
Lines 71-77 namespace Mono.UIAutomation.Winforms Link Here
71
			// seems to keep a TabPages' children visible even if
70
			// seems to keep a TabPages' children visible even if
72
			// the TabPage isn't.  This is to model Vista's
71
			// the TabPage isn't.  This is to model Vista's
73
			// behavior.
72
			// behavior.
74
			return Helper.SynchronizedGet<Control, bool> (Control, c => c.Visible);
73
			return Control.InvokeSync (c => c.Visible);
75
		}
74
		}
76
75
77
		internal TabControlProvider TabControlProvider {
76
		internal TabControlProvider TabControlProvider {
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms/TextBoxProvider.cs (-15 / +17 lines)
Lines 85-93 namespace Mono.UIAutomation.Winforms Link Here
85
		protected override object GetProviderPropertyValue (int propertyId)
85
		protected override object GetProviderPropertyValue (int propertyId)
86
		{
86
		{
87
			if (propertyId == AutomationElementIdentifiers.ControlTypeProperty.Id)
87
			if (propertyId == AutomationElementIdentifiers.ControlTypeProperty.Id)
88
				return textboxbase.Multiline == true ? ControlType.Document.Id : ControlType.Edit.Id;
88
				return textboxbase.InvokeSync (c => c.Multiline) ? ControlType.Document.Id : ControlType.Edit.Id;
89
			else if (propertyId == AutomationElementIdentifiers.LocalizedControlTypeProperty.Id)
89
			else if (propertyId == AutomationElementIdentifiers.LocalizedControlTypeProperty.Id)
90
				return textboxbase.Multiline == true ? Catalog.GetString ("document")
90
				return textboxbase.InvokeSync (c => c.Multiline) ? Catalog.GetString ("document")
91
				                                     : Catalog.GetString ("edit");
91
				                                     : Catalog.GetString ("edit");
92
			else 
92
			else 
93
				return base.GetProviderPropertyValue (propertyId);
93
				return base.GetProviderPropertyValue (propertyId);
Lines 159-177 namespace Mono.UIAutomation.Winforms Link Here
159
		
159
		
160
		internal int MaxLength {
160
		internal int MaxLength {
161
			get {
161
			get {
162
				if (textboxbase is TextBox) {
162
				return textboxbase.InvokeSync (c => {
163
					return ((TextBox) textboxbase).MaxLength;
163
					if (textboxbase is TextBox) {
164
				} else if (textboxbase is RichTextBox) {
164
						return ((TextBox) c).MaxLength;
165
					return ((RichTextBox) textboxbase).MaxLength;
165
					} else if (textboxbase is RichTextBox) {
166
				} else if (textboxbase is MaskedTextBox) {
166
						return ((RichTextBox) c).MaxLength;
167
					// Length of the mask, removing mask modifiers
167
					} else if (textboxbase is MaskedTextBox) {
168
					MaskedTextBox mtb = (MaskedTextBox) textboxbase;
168
						// Length of the mask, removing mask modifiers
169
					if (mtb.MaskedTextProvider != null)
169
						MaskedTextBox mtb = (MaskedTextBox) c;
170
						return mtb.MaskedTextProvider.Length;
170
						if (mtb.MaskedTextProvider != null)
171
					else
171
							return mtb.MaskedTextProvider.Length;
172
						return mtb.Mask.Length;
172
						else
173
				}
173
							return mtb.Mask.Length;
174
				return 0;
174
					}
175
					return 0;
176
				});
175
			}
177
			}
176
		}
178
		}
177
179
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms/ToolBarProvider.cs (-12 / +16 lines)
Lines 107-127 namespace Mono.UIAutomation.Winforms Link Here
107
		public ToolBarButtonProvider RemoveButtonAt (int index)
107
		public ToolBarButtonProvider RemoveButtonAt (int index)
108
		{
108
		{
109
			ToolBarButtonProvider button = null;
109
			ToolBarButtonProvider button = null;
110
			
110
111
			if (index < toolBar.Buttons.Count) {
111
			return toolBar.InvokeSync (t => {
112
				button = (ToolBarButtonProvider)
112
				if (index < t.Buttons.Count) {
113
					ProviderFactory.GetProvider (toolBar.Buttons [index]);
113
					button = (ToolBarButtonProvider)
114
				ProviderFactory.ReleaseProvider (toolBar.Buttons [index]);
114
						ProviderFactory.GetProvider (t.Buttons [index]);
115
			}
115
					ProviderFactory.ReleaseProvider (t.Buttons [index]);
116
			
116
				}
117
			return button;
117
				
118
				return button;
119
			});
118
		}
120
		}
119
		
121
		
120
		public void ClearButtonsCollection ()
122
		public void ClearButtonsCollection ()
121
		{
123
		{
122
			while (toolBar.Buttons.Count > 0) {
124
			toolBar.InvokeSync (delegate {
123
				RemoveButtonAt (toolBar.Buttons.Count - 1);
125
				while (toolBar.Buttons.Count > 0) {
124
			}
126
					RemoveButtonAt (toolBar.Buttons.Count - 1);
127
				}
128
			});
125
		}
129
		}
126
		
130
		
127
		#endregion
131
		#endregion
Lines 134-140 namespace Mono.UIAutomation.Winforms Link Here
134
		{
138
		{
135
			if (e.Action == CollectionChangeAction.Add) {
139
			if (e.Action == CollectionChangeAction.Add) {
136
				ToolBarButtonProvider button = (ToolBarButtonProvider)
140
				ToolBarButtonProvider button = (ToolBarButtonProvider)
137
					ProviderFactory.GetProvider (toolBar.Buttons [(int) e.Element]);
141
					ProviderFactory.GetProvider (toolBar.InvokeSync (c => c.Buttons [(int) e.Element]));
138
				AddChildProvider (button);
142
				AddChildProvider (button);
139
			} else if (e.Action == CollectionChangeAction.Remove) {
143
			} else if (e.Action == CollectionChangeAction.Remove) {
140
				ToolBarButtonProvider button = RemoveButtonAt ((int) e.Element);
144
				ToolBarButtonProvider button = RemoveButtonAt ((int) e.Element);
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms/ToolStripButtonProvider.cs (-3 / +1 lines)
Lines 55-63 namespace Mono.UIAutomation.Winforms Link Here
55
55
56
		protected override object GetProviderPropertyValue (int propertyId)
56
		protected override object GetProviderPropertyValue (int propertyId)
57
		{
57
		{
58
			bool checkOnClick = Helper.SynchronizedGet<ToolStrip, bool> (
58
			bool checkOnClick = Owner.InvokeSync (t => button.CheckOnClick);
59
				Owner, t => button.CheckOnClick
60
			);
61
59
62
			if (propertyId == AEIds.ControlTypeProperty.Id)
60
			if (propertyId == AEIds.ControlTypeProperty.Id)
63
				return checkOnClick ? ControlType.CheckBox.Id : ControlType.Button.Id;
61
				return checkOnClick ? ControlType.CheckBox.Id : ControlType.Button.Id;
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms/ToolStripItemProvider.cs (-1 / +4 lines)
Lines 107-113 namespace Mono.UIAutomation.Winforms Link Here
107
107
108
		public override void SetFocus ()
108
		public override void SetFocus ()
109
		{
109
		{
110
			item.Select ();
110
			if (item.Owner != null)
111
				item.Owner.InvokeSync (delegate { item.Select (); });
112
			else
113
				item.Select ();
111
		}
114
		}
112
115
113
	}
116
	}
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms/ToolStripProvider.cs (-1 / +1 lines)
Lines 59-65 namespace Mono.UIAutomation.Winforms Link Here
59
			else if (propertyId == AEIds.LabeledByProperty.Id)
59
			else if (propertyId == AEIds.LabeledByProperty.Id)
60
				return null;
60
				return null;
61
			else if (propertyId == AEIds.NameProperty.Id)
61
			else if (propertyId == AEIds.NameProperty.Id)
62
				return Helper.StripAmpersands (strip.Text);
62
				return Helper.StripAmpersands (strip.InvokeSync (s => s.Text));
63
			else if (propertyId == AEIds.IsContentElementProperty.Id)
63
			else if (propertyId == AEIds.IsContentElementProperty.Id)
64
				return true;
64
				return true;
65
			else
65
			else
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms/ToolTipBaseProvider.cs (-4 / +4 lines)
Lines 104-110 namespace Mono.UIAutomation.Winforms Link Here
104
			if (AutomationInteropProvider.ClientsAreListening == true) {					
104
			if (AutomationInteropProvider.ClientsAreListening == true) {					
105
				message = GetTextFromControl (control);
105
				message = GetTextFromControl (control);
106
106
107
				Helper.DelegateQueue.Get ().Enqueue (delegate {
107
//				Helper.DelegateQueue.Get ().Enqueue (delegate {
108
				
108
				
109
				//TODO: We need deeper tests in Vista because MS is generating both events
109
				//TODO: We need deeper tests in Vista because MS is generating both events
110
				Helper.RaiseStructureChangedEvent (StructureChangeType.ChildAdded,
110
				Helper.RaiseStructureChangedEvent (StructureChangeType.ChildAdded,
Lines 116-122 namespace Mono.UIAutomation.Winforms Link Here
116
				                                                this, 
116
				                                                this, 
117
				                                                eventArgs);
117
				                                                eventArgs);
118
118
119
				});
119
//				});
120
			}
120
			}
121
		}
121
		}
122
		
122
		
Lines 125-131 namespace Mono.UIAutomation.Winforms Link Here
125
			if (AutomationInteropProvider.ClientsAreListening == true) {
125
			if (AutomationInteropProvider.ClientsAreListening == true) {
126
				message = GetTextFromControl (control);
126
				message = GetTextFromControl (control);
127
127
128
				Helper.DelegateQueue.Get ().Enqueue (delegate {
128
//				Helper.DelegateQueue.Get ().Enqueue (delegate {
129
				
129
				
130
				//TODO: We need deeper tests in Vista because MS is generating both events
130
				//TODO: We need deeper tests in Vista because MS is generating both events
131
				Helper.RaiseStructureChangedEvent (StructureChangeType.ChildRemoved,
131
				Helper.RaiseStructureChangedEvent (StructureChangeType.ChildRemoved,
Lines 136-142 namespace Mono.UIAutomation.Winforms Link Here
136
				AutomationInteropProvider.RaiseAutomationEvent (AutomationElementIdentifiers.ToolTipClosedEvent,
136
				AutomationInteropProvider.RaiseAutomationEvent (AutomationElementIdentifiers.ToolTipClosedEvent,
137
				                                                this, 
137
				                                                this, 
138
				                                                eventArgs);
138
				                                                eventArgs);
139
				});
139
//				});
140
			}
140
			}
141
		}
141
		}
142
142
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms/TrackBarProvider.cs (-4 / +6 lines)
Lines 84-93 namespace Mono.UIAutomation.Winforms Link Here
84
				return Catalog.GetString ("slider");
84
				return Catalog.GetString ("slider");
85
			else if (propertyId == AutomationElementIdentifiers.IsContentElementProperty.Id)
85
			else if (propertyId == AutomationElementIdentifiers.IsContentElementProperty.Id)
86
				return true;
86
				return true;
87
			else if (propertyId == AutomationElementIdentifiers.OrientationProperty.Id)
87
			else if (propertyId == AutomationElementIdentifiers.OrientationProperty.Id) {
88
				return trackBar.Orientation == Orientation.Horizontal
88
				if (trackBar.InvokeSync (c => c.Orientation == Orientation.Horizontal))
89
					? OrientationType.Horizontal : OrientationType.Vertical;
89
					return OrientationType.Horizontal;
90
			else
90
				else
91
					return OrientationType.Vertical;
92
			} else
91
				return base.GetProviderPropertyValue (propertyId);
93
				return base.GetProviderPropertyValue (propertyId);
92
		}
94
		}
93
95
(-)a/UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms/TreeViewProvider.cs (-1 / +1 lines)
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
//	Sandy Armstrong <sanfordarmstrong@gmail.com>
23
//	Sandy Armstrong <sanfordarmstrong@gmail.com>
(-)a/UIAutomationWinforms/UIAutomationWinformsTests/Makefile.am (+1 lines)
Lines 66-71 FILES = \ Link Here
66
	DateTimePickerProviderTest.cs \
66
	DateTimePickerProviderTest.cs \
67
	DomainUpDownProviderTest.cs \
67
	DomainUpDownProviderTest.cs \
68
	ErrorProviderTest.cs \
68
	ErrorProviderTest.cs \
69
	FormProviderTest.cs \
69
	GroupBoxProviderTest.cs \
70
	GroupBoxProviderTest.cs \
70
	HelpProviderTest.cs \
71
	HelpProviderTest.cs \
71
	LabelProviderTest.cs \
72
	LabelProviderTest.cs \
(-)a/UIAutomationWinforms/UIAutomationWinformsTests/UIAutomationWinformsTests.mdp (-1 / +1 lines)
Lines 66-72 Link Here
66
    <File name="DateTimePickerProviderTest.cs" subtype="Code" buildaction="Compile" />
66
    <File name="DateTimePickerProviderTest.cs" subtype="Code" buildaction="Compile" />
67
    <File name="ToolStripButtonProviderTest.cs" subtype="Code" buildaction="Compile" />
67
    <File name="ToolStripButtonProviderTest.cs" subtype="Code" buildaction="Compile" />
68
    <File name="PopupButtonPanelTest.cs" subtype="Code" buildaction="Compile" />
68
    <File name="PopupButtonPanelTest.cs" subtype="Code" buildaction="Compile" />
69
    <File name="FormProviderTest.cs" subtype="Code" buildaction="Nothing" />
69
    <File name="FormProviderTest.cs" subtype="Code" buildaction="Compile" />
70
    <File name="MainMenuProviderTest.cs" subtype="Code" buildaction="Compile" />
70
    <File name="MainMenuProviderTest.cs" subtype="Code" buildaction="Compile" />
71
    <File name="MenuItemProviderTest.cs" subtype="Code" buildaction="Compile" />
71
    <File name="MenuItemProviderTest.cs" subtype="Code" buildaction="Compile" />
72
    <File name="DataGridProviderTest.cs" subtype="Code" buildaction="Compile" />
72
    <File name="DataGridProviderTest.cs" subtype="Code" buildaction="Compile" />

Return to bug 494034