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

(-)a/UIAutomation/UIAutomationClient/System.Windows.Automation/AutomationElement.cs (-1 / +9 lines)
Lines 455-461 namespace System.Windows.Automation Link Here
455
#region Public Static Methods
455
#region Public Static Methods
456
		public static AutomationElement FromHandle (IntPtr hwnd)
456
		public static AutomationElement FromHandle (IntPtr hwnd)
457
		{
457
		{
458
			throw new NotImplementedException ();
458
			AutomationElement element = null;
459
			foreach (var source in SourceManager.GetAutomationSources ()) {
460
				var sourceElement = source.GetElementFromHandle (hwnd);
461
				if (sourceElement != null) {
462
					element = SourceManager.GetOrCreateAutomationElement (sourceElement);
463
					break;
464
				}
465
			}
466
			return element;
459
		}
467
		}
460
468
461
		public static AutomationElement FromLocalProvider (IRawElementProviderSimple localImpl)
469
		public static AutomationElement FromLocalProvider (IRawElementProviderSimple localImpl)
(-)a/UIAutomation/UIAutomationSource/Mono.UIAutomation.Source/IAutomationSource.cs (+2 lines)
Lines 34-39 namespace Mono.UIAutomation.Source Link Here
34
		void Initialize ();
34
		void Initialize ();
35
35
36
		IElement [] GetRootElements ();
36
		IElement [] GetRootElements ();
37
		
38
		IElement GetElementFromHandle (IntPtr handle);
37
39
38
		bool IsAccessibilityEnabled { get; }
40
		bool IsAccessibilityEnabled { get; }
39
41
(-)a/UIAutomationWinforms/UIAutomationWinformsClientTests/DataGridApplication/DataGridApplication.csproj (-12 / +4 lines)
Lines 1-5 Link Here
1
<?xml version="1.0" encoding="utf-8"?>
1
<?xml version="1.0" encoding="utf-8"?>
2
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
3
  <PropertyGroup>
3
  <PropertyGroup>
4
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
5
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Lines 12-19 Link Here
12
    <AssemblyName>datagrid</AssemblyName>
12
    <AssemblyName>datagrid</AssemblyName>
13
    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
13
    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
14
    <FileAlignment>512</FileAlignment>
14
    <FileAlignment>512</FileAlignment>
15
    <StartupObject>
16
    </StartupObject>
17
  </PropertyGroup>
15
  </PropertyGroup>
18
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
19
    <DebugSymbols>true</DebugSymbols>
17
    <DebugSymbols>true</DebugSymbols>
Lines 44-50 Link Here
44
      <RequiredTargetFramework>3.5</RequiredTargetFramework>
42
      <RequiredTargetFramework>3.5</RequiredTargetFramework>
45
    </Reference>
43
    </Reference>
46
    <Reference Include="System.Data" />
44
    <Reference Include="System.Data" />
47
    <Reference Include="System.Deployment" />
48
    <Reference Include="System.Drawing" />
45
    <Reference Include="System.Drawing" />
49
    <Reference Include="System.Windows.Forms" />
46
    <Reference Include="System.Windows.Forms" />
50
    <Reference Include="System.Xml" />
47
    <Reference Include="System.Xml" />
Lines 63-84 Link Here
63
      <SubType>Designer</SubType>
60
      <SubType>Designer</SubType>
64
    </EmbeddedResource>
61
    </EmbeddedResource>
65
    <EmbeddedResource Include="Properties\Resources.resx">
62
    <EmbeddedResource Include="Properties\Resources.resx">
66
      <Generator>ResXFileCodeGenerator</Generator>
67
      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
68
      <SubType>Designer</SubType>
63
      <SubType>Designer</SubType>
64
      <Generator>ResXFileCodeGenerator</Generator>
69
    </EmbeddedResource>
65
    </EmbeddedResource>
70
    <Compile Include="Properties\Resources.Designer.cs">
66
    <Compile Include="Properties\Resources.Designer.cs">
71
      <AutoGen>True</AutoGen>
72
      <DependentUpon>Resources.resx</DependentUpon>
67
      <DependentUpon>Resources.resx</DependentUpon>
73
    </Compile>
68
    </Compile>
74
    <None Include="Properties\Settings.settings">
69
    <None Include="Properties\Settings.settings">
75
      <Generator>SettingsSingleFileGenerator</Generator>
70
      <Generator>SettingsSingleFileGenerator</Generator>
76
      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
77
    </None>
71
    </None>
78
    <Compile Include="Properties\Settings.Designer.cs">
72
    <Compile Include="Properties\Settings.Designer.cs">
79
      <AutoGen>True</AutoGen>
80
      <DependentUpon>Settings.settings</DependentUpon>
73
      <DependentUpon>Settings.settings</DependentUpon>
81
      <DesignTimeSharedInput>True</DesignTimeSharedInput>
82
    </Compile>
74
    </Compile>
83
  </ItemGroup>
75
  </ItemGroup>
84
  <ItemGroup>
76
  <ItemGroup>
Lines 87-93 Link Here
87
      <Name>DataGridAssembly</Name>
79
      <Name>DataGridAssembly</Name>
88
    </ProjectReference>
80
    </ProjectReference>
89
  </ItemGroup>
81
  </ItemGroup>
90
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
82
  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
91
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
83
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
92
       Other similar extension points exist, see Microsoft.Common.targets.
84
       Other similar extension points exist, see Microsoft.Common.targets.
93
  <Target Name="BeforeBuild">
85
  <Target Name="BeforeBuild">
(-)a/UIAutomationWinforms/UIAutomationWinformsClientTests/HelpProviderTest.cs (-2 / +2 lines)
Lines 1-4 Link Here
1
// Permission is hereby granted, free of charge, to any person obtaining 
1
// Permission is hereby granted, free of charge, to any person obtaining 
2
// a copy of this software and associated documentation files (the 
2
// a copy of this software and associated documentation files (the 
3
// "Software"), to deal in the Software without restriction, including 
3
// "Software"), to deal in the Software without restriction, including 
4
// without limitation the rights to use, copy, modify, merge, publish, 
4
// without limitation the rights to use, copy, modify, merge, publish, 
Lines 68-74 namespace MonoTests.Mono.UIAutomation.Winforms.Client Link Here
68
        }
68
        }
69
69
70
		[Test]
70
		[Test]
71
		[RequiresSTA]
71
		//[RequiresSTA]
72
		public void PatternsTest ()
72
		public void PatternsTest ()
73
		{
73
		{
74
			form.Show ();
74
			form.Show ();
(-)a/UIAutomationWinforms/UIAutomationWinformsClientTests/UIAutomationWinformsClientTests.csproj (-9 / +4 lines)
Lines 1-5 Link Here
1
<?xml version="1.0" encoding="utf-8"?>
1
<?xml version="1.0" encoding="utf-8"?>
2
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
3
  <PropertyGroup>
3
  <PropertyGroup>
4
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
5
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Lines 12-19 Link Here
12
    <AssemblyName>UIAutomationWinformsClientTests</AssemblyName>
12
    <AssemblyName>UIAutomationWinformsClientTests</AssemblyName>
13
    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
13
    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
14
    <FileAlignment>512</FileAlignment>
14
    <FileAlignment>512</FileAlignment>
15
    <StartupObject>
16
    </StartupObject>
17
  </PropertyGroup>
15
  </PropertyGroup>
18
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
19
    <DebugSymbols>true</DebugSymbols>
17
    <DebugSymbols>true</DebugSymbols>
Lines 33-42 Link Here
33
    <WarningLevel>4</WarningLevel>
31
    <WarningLevel>4</WarningLevel>
34
  </PropertyGroup>
32
  </PropertyGroup>
35
  <ItemGroup>
33
  <ItemGroup>
36
    <Reference Include="nunit.framework, Version=2.5.0.8332, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77">
37
      <SpecificVersion>False</SpecificVersion>
38
      <HintPath>..\..\..\..\..\..\..\Program Files\NUnit 2.5\bin\net-1.1\framework\nunit.framework.dll</HintPath>
39
    </Reference>
40
    <Reference Include="System" />
34
    <Reference Include="System" />
41
    <Reference Include="System.Data" />
35
    <Reference Include="System.Data" />
42
    <Reference Include="System.Drawing" />
36
    <Reference Include="System.Drawing" />
Lines 54-59 Link Here
54
    <Reference Include="UIAutomationTypes">
48
    <Reference Include="UIAutomationTypes">
55
      <RequiredTargetFramework>3.0</RequiredTargetFramework>
49
      <RequiredTargetFramework>3.0</RequiredTargetFramework>
56
    </Reference>
50
    </Reference>
51
    <Reference Include="nunit.framework, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77" />
57
  </ItemGroup>
52
  </ItemGroup>
58
  <ItemGroup>
53
  <ItemGroup>
59
    <Compile Include="BaseTest.cs" />
54
    <Compile Include="BaseTest.cs" />
Lines 95-101 Link Here
95
      <Name>DataGridAssembly</Name>
90
      <Name>DataGridAssembly</Name>
96
    </ProjectReference>
91
    </ProjectReference>
97
  </ItemGroup>
92
  </ItemGroup>
98
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
93
  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
99
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
94
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
100
       Other similar extension points exist, see Microsoft.Common.targets.
95
       Other similar extension points exist, see Microsoft.Common.targets.
101
  <Target Name="BeforeBuild">
96
  <Target Name="BeforeBuild">
(-)a/UiaDbus/UiaDbus/Interfaces/IApplication.cs (+2 lines)
Lines 37-42 namespace Mono.UIAutomation.UiaDbus.Interfaces Link Here
37
	public interface IApplication
37
	public interface IApplication
38
	{
38
	{
39
		string [] GetRootElementPaths ();
39
		string [] GetRootElementPaths ();
40
		
41
		string GetElementPathFromHandle (int handle);
40
42
41
		void AddAutomationEventHandler (int eventId, int [] elementRuntimeId, TreeScope scope, int handlerId);
43
		void AddAutomationEventHandler (int eventId, int [] elementRuntimeId, TreeScope scope, int handlerId);
42
		void AddAutomationPropertyChangedEventHandler (int [] elementRuntimeId, TreeScope scope, int handlerId, int[] properties);
44
		void AddAutomationPropertyChangedEventHandler (int [] elementRuntimeId, TreeScope scope, int handlerId, int[] properties);
(-)a/UiaDbus/UiaDbusBridge/Application.cs (+10 lines)
Lines 219-224 namespace Mono.UIAutomation.UiaDbusBridge Link Here
219
			return paths;
219
			return paths;
220
		}
220
		}
221
221
222
		public string GetElementPathFromHandle (int handle)
223
		{
224
			// TODO: Can we assume int is always correct?
225
			var element = AutomationBridge.Instance.FindWrapperByHandle (handle);
226
			if (element != null)
227
				return element.Path;
228
			return string.Empty;
229
		}
230
222
		public void AddAutomationEventHandler (int eventId, int [] elementRuntimeId,
231
		public void AddAutomationEventHandler (int eventId, int [] elementRuntimeId,
223
		                                TreeScope scope, int handlerId)
232
		                                TreeScope scope, int handlerId)
224
		{
233
		{
Lines 313-318 namespace Mono.UIAutomation.UiaDbusBridge Link Here
313
			RemoveEventHandlersByMask (handlerIdMask, structureEventHandlers);
322
			RemoveEventHandlersByMask (handlerIdMask, structureEventHandlers);
314
		}
323
		}
315
324
325
316
		public event Mono.UIAutomation.UiaDbus.Interfaces.AutomationEventHandler
326
		public event Mono.UIAutomation.UiaDbus.Interfaces.AutomationEventHandler
317
			AutomationEvent;
327
			AutomationEvent;
318
		public event Mono.UIAutomation.UiaDbus.Interfaces.AutomationPropertyChangedHandler
328
		public event Mono.UIAutomation.UiaDbus.Interfaces.AutomationPropertyChangedHandler
(-)a/UiaDbus/UiaDbusBridge/AutomationBridge.cs (+10 lines)
Lines 271-276 namespace Mono.UIAutomation.UiaDbusBridge Link Here
271
				return wrapper;
271
				return wrapper;
272
			return null;
272
			return null;
273
		}
273
		}
274
		
275
		internal ProviderElementWrapper FindWrapperByHandle (int handle)
276
		{
277
			IRawElementProviderSimple provider = null;
278
			pointerProviderMapping.TryGetValue (new IntPtr (handle),
279
			                                    out provider);
280
			if (provider != null)
281
				return FindWrapperByPovider (provider);
282
			return null;
283
		}
274
284
275
		#endregion
285
		#endregion
276
286
(-)a/UiaDbus/UiaDbusSource/UiaDbusAutomationSource.cs (-6 / +16 lines)
Lines 136-141 namespace Mono.UIAutomation.UiaDbusSource Link Here
136
			Log.Info ("UiaDbusAutomationSource: GetRootElements count will be: " + dbusElements.Count);
136
			Log.Info ("UiaDbusAutomationSource: GetRootElements count will be: " + dbusElements.Count);
137
			return dbusElements.ToArray ();
137
			return dbusElements.ToArray ();
138
		}
138
		}
139
		
140
		public IElement GetElementFromHandle (IntPtr handle)
141
		{
142
			foreach (var appPair in GetUiaApplications ()) {
143
				string path = appPair.Value.GetElementPathFromHandle (handle.ToInt32 ());
144
				if (!string.IsNullOrEmpty (path))
145
					return GetOrCreateElement (appPair.Key, path);
146
			}
147
			return null;
148
		}
139
149
140
		public void AddAutomationEventHandler (AutomationEvent eventId,
150
		public void AddAutomationEventHandler (AutomationEvent eventId,
141
		                                       IElement element,
151
		                                       IElement element,
Lines 294-300 namespace Mono.UIAutomation.UiaDbusSource Link Here
294
304
295
		public void RemoveAllEventHandlers ()
305
		public void RemoveAllEventHandlers ()
296
		{
306
		{
297
			foreach (DCI.IApplication app in GetUiaApplications ())
307
			foreach (DCI.IApplication app in GetUiaApplications ().Values)
298
				app.RemoveAllEventHandlers (EventHandlerManager.ClientPrefix);
308
				app.RemoveAllEventHandlers (EventHandlerManager.ClientPrefix);
299
		}
309
		}
300
310
Lines 367-376 namespace Mono.UIAutomation.UiaDbusSource Link Here
367
			return candidateBusNames;
377
			return candidateBusNames;
368
		}
378
		}
369
379
370
		private DCI.IApplication [] GetUiaApplications ()
380
		private Dictionary<string, DCI.IApplication> GetUiaApplications ()
371
		{
381
		{
372
			List<DCI.IApplication> dbusApps =
382
			Dictionary<string, DCI.IApplication> dbusApps =
373
				new List<DCI.IApplication> ();
383
				new Dictionary<string, DCI.IApplication> ();
374
384
375
			foreach (string busName in GetUiaDbusNames ()) {
385
			foreach (string busName in GetUiaDbusNames ()) {
376
				DCI.IApplication app =
386
				DCI.IApplication app =
Lines 378-387 namespace Mono.UIAutomation.UiaDbusSource Link Here
378
					                                         new ObjectPath (DC.Constants.ApplicationPath));
388
					                                         new ObjectPath (DC.Constants.ApplicationPath));
379
				if (app == null)
389
				if (app == null)
380
					continue;
390
					continue;
381
				dbusApps.Add (app);
391
				dbusApps [busName] = app;
382
			}
392
			}
383
393
384
			return dbusApps.ToArray ();
394
			return dbusApps;
385
		}
395
		}
386
396
387
		private UiaDbusElement CreateElement (DCI.IAutomationElement dbusElement, string busName, string elementPath)
397
		private UiaDbusElement CreateElement (DCI.IAutomationElement dbusElement, string busName, string elementPath)

Return to bug 489387