Skip to content

Commit 82e537d

Browse files
committed
Revert "Add infrastructure for focus events."
This reverts commit 58876a5.
1 parent cd5c7c8 commit 82e537d

File tree

10 files changed

+122
-279
lines changed

10 files changed

+122
-279
lines changed

RetailCoder.VBE/UI/DockableToolwindowPresenter.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
using System;
2+
using System.Configuration;
23
using System.Runtime.InteropServices;
34
using System.Windows.Forms;
45
using NLog;
56
using Rubberduck.Settings;
67
using Rubberduck.SettingsProvider;
7-
using Rubberduck.VBEditor.Extensions;
88
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
99

1010
namespace Rubberduck.UI
@@ -55,7 +55,7 @@ private IWindow CreateToolWindow(IDockableUserControl control)
5555
{
5656
var info = _vbe.Windows.CreateToolWindow(_addin, _DockableWindowHost.RegisteredProgId, control.Caption, control.ClassId);
5757
_userControlObject = info.UserControl;
58-
toolWindow = info.ToolWindow;
58+
toolWindow = info.ToolWindow;
5959
}
6060
catch (COMException exception)
6161
{
@@ -77,9 +77,6 @@ private IWindow CreateToolWindow(IDockableUserControl control)
7777

7878
EnsureMinimumWindowSize(toolWindow);
7979

80-
//Get the hwnd here - otherwise, FindWindowEx won't find it (because it's hidden).
81-
toolWindow.RealHwnd = toolWindow.ToHwnd();
82-
8380
toolWindow.IsVisible = _settings != null && _settings.IsWindowVisible(this);
8481

8582
userControlHost.AddUserControl(control as UserControl, new IntPtr(_vbe.MainWindow.HWnd));

Rubberduck.VBEEditor/Extensions/IDEExtensions.cs

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using Rubberduck.VBEditor.Application;
66
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
77
using Rubberduck.VBEditor.SafeComWrappers.MSForms;
8+
using Exception = System.Exception;
89

910
namespace Rubberduck.VBEditor.Extensions
1011
{
@@ -204,4 +205,100 @@ public static bool HostSupportsUnitTests(this IVBE vbe)
204205
return false;
205206
}
206207
}
208+
209+
public static class VBProjectExtensions
210+
{
211+
/// <summary>
212+
/// Imports all source code files from target directory into project.
213+
/// </summary>
214+
/// <remarks>
215+
/// Only files with extensions "cls", "bas, "frm", and "doccls" are imported.
216+
/// It is the callers responsibility to remove any existing components prior to importing.
217+
/// </remarks>
218+
/// <param name="project"></param>
219+
/// <param name="filePath">Directory path containing the source files.</param>
220+
public static void ImportDocumentTypeSourceFiles(this IVBProject project, string filePath)
221+
{
222+
var dirInfo = new DirectoryInfo(filePath);
223+
224+
var files = dirInfo.EnumerateFiles()
225+
.Where(f => f.Extension == ComponentTypeExtensions.DocClassExtension);
226+
foreach (var file in files)
227+
{
228+
try
229+
{
230+
project.VBComponents.ImportSourceFile(file.FullName);
231+
}
232+
catch (IndexOutOfRangeException) { } // component didn't exist
233+
}
234+
}
235+
236+
public static void LoadAllComponents(this IVBProject project, string filePath)
237+
{
238+
var dirInfo = new DirectoryInfo(filePath);
239+
240+
var files = dirInfo.EnumerateFiles()
241+
.Where(f => f.Extension == ComponentTypeExtensions.StandardExtension ||
242+
f.Extension == ComponentTypeExtensions.ClassExtension ||
243+
f.Extension == ComponentTypeExtensions.DocClassExtension ||
244+
f.Extension == ComponentTypeExtensions.FormExtension
245+
)
246+
.ToList();
247+
248+
var exceptions = new List<Exception>();
249+
250+
foreach (var component in project.VBComponents)
251+
{
252+
try
253+
{
254+
var name = component.Name;
255+
project.VBComponents.RemoveSafely(component);
256+
257+
var file = files.SingleOrDefault(f => f.Name == name + f.Extension);
258+
if (file != null)
259+
{
260+
try
261+
{
262+
project.VBComponents.ImportSourceFile(file.FullName);
263+
}
264+
catch (IndexOutOfRangeException)
265+
{
266+
exceptions.Add(new IndexOutOfRangeException(string.Format(VBEEditorText.NonexistentComponentErrorText, Path.GetFileNameWithoutExtension(file.FullName))));
267+
}
268+
}
269+
}
270+
catch (Exception ex)
271+
{
272+
exceptions.Add(ex);
273+
}
274+
}
275+
276+
foreach (var file in files)
277+
{
278+
try
279+
{
280+
if (project.VBComponents.All(v => v.Name + file.Extension != file.Name))
281+
{
282+
try
283+
{
284+
project.VBComponents.ImportSourceFile(file.FullName);
285+
}
286+
catch (IndexOutOfRangeException)
287+
{
288+
exceptions.Add(new IndexOutOfRangeException(string.Format(VBEEditorText.NonexistentComponentErrorText, Path.GetFileNameWithoutExtension(file.FullName))));
289+
}
290+
}
291+
}
292+
catch (Exception ex)
293+
{
294+
exceptions.Add(ex);
295+
}
296+
}
297+
298+
if (exceptions.Count != 0)
299+
{
300+
throw new AggregateException(string.Empty, exceptions);
301+
}
302+
}
303+
}
207304
}
Lines changed: 1 addition & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,104 +1,3 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.IO;
4-
using System.Linq;
5-
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
6-
7-
namespace Rubberduck.VBEditor.Extensions
1+
namespace Rubberduck.VBEditor.Extensions
82
{
9-
public static class VBProjectExtensions
10-
{
11-
/// <summary>
12-
/// Imports all source code files from target directory into project.
13-
/// </summary>
14-
/// <remarks>
15-
/// Only files with extensions "cls", "bas, "frm", and "doccls" are imported.
16-
/// It is the callers responsibility to remove any existing components prior to importing.
17-
/// </remarks>
18-
/// <param name="project"></param>
19-
/// <param name="filePath">Directory path containing the source files.</param>
20-
public static void ImportDocumentTypeSourceFiles(this IVBProject project, string filePath)
21-
{
22-
var dirInfo = new DirectoryInfo(filePath);
23-
24-
var files = dirInfo.EnumerateFiles()
25-
.Where(f => f.Extension == ComponentTypeExtensions.DocClassExtension);
26-
foreach (var file in files)
27-
{
28-
try
29-
{
30-
project.VBComponents.ImportSourceFile(file.FullName);
31-
}
32-
catch (IndexOutOfRangeException) { } // component didn't exist
33-
}
34-
}
35-
36-
public static void LoadAllComponents(this IVBProject project, string filePath)
37-
{
38-
var dirInfo = new DirectoryInfo(filePath);
39-
40-
var files = dirInfo.EnumerateFiles()
41-
.Where(f => f.Extension == ComponentTypeExtensions.StandardExtension ||
42-
f.Extension == ComponentTypeExtensions.ClassExtension ||
43-
f.Extension == ComponentTypeExtensions.DocClassExtension ||
44-
f.Extension == ComponentTypeExtensions.FormExtension
45-
)
46-
.ToList();
47-
48-
var exceptions = new List<Exception>();
49-
50-
foreach (var component in project.VBComponents)
51-
{
52-
try
53-
{
54-
var name = component.Name;
55-
project.VBComponents.RemoveSafely(component);
56-
57-
var file = files.SingleOrDefault(f => f.Name == name + f.Extension);
58-
if (file != null)
59-
{
60-
try
61-
{
62-
project.VBComponents.ImportSourceFile(file.FullName);
63-
}
64-
catch (IndexOutOfRangeException)
65-
{
66-
exceptions.Add(new IndexOutOfRangeException(string.Format(VBEEditorText.NonexistentComponentErrorText, Path.GetFileNameWithoutExtension(file.FullName))));
67-
}
68-
}
69-
}
70-
catch (Exception ex)
71-
{
72-
exceptions.Add(ex);
73-
}
74-
}
75-
76-
foreach (var file in files)
77-
{
78-
try
79-
{
80-
if (project.VBComponents.All(v => v.Name + file.Extension != file.Name))
81-
{
82-
try
83-
{
84-
project.VBComponents.ImportSourceFile(file.FullName);
85-
}
86-
catch (IndexOutOfRangeException)
87-
{
88-
exceptions.Add(new IndexOutOfRangeException(string.Format(VBEEditorText.NonexistentComponentErrorText, Path.GetFileNameWithoutExtension(file.FullName))));
89-
}
90-
}
91-
}
92-
catch (Exception ex)
93-
{
94-
exceptions.Add(ex);
95-
}
96-
}
97-
98-
if (exceptions.Count != 0)
99-
{
100-
throw new AggregateException(string.Empty, exceptions);
101-
}
102-
}
103-
}
1043
}

Rubberduck.VBEEditor/Extensions/WindowExtensions.cs

Lines changed: 0 additions & 69 deletions
This file was deleted.

Rubberduck.VBEEditor/NativeMethods.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,6 @@ public static class NativeMethods
3939
[DllImport("user32", ExactSpelling = true, CharSet = CharSet.Unicode)]
4040
internal static extern int EnumChildWindows(IntPtr parentWindowHandle, EnumChildWindowsDelegate lpEnumFunction, IntPtr lParam);
4141

42-
/// <param name="parentHandle"> Handle of the parent window. IntPtr.Zero is the desktop. </param>
43-
/// <param name="childAfter"> The child window to begin searching after. </param>
44-
/// <param name="lclassName"> The window class name (optional). </param>
45-
/// <param name="windowTitle"> The window caption (optional). </param>
46-
/// <returns> An IntPtr to the found windows hWnd, IntPtr.Zero if no match is found. </returns>
47-
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
48-
public static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string lclassName, string windowTitle);
49-
5042
/// <summary> Gets window text. </summary>
5143
///
5244
/// <param name="hWnd"> The window handle. </param>

Rubberduck.VBEEditor/Rubberduck.VBEditor.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@
127127
<Compile Include="Events\ProjectEventArgs.cs" />
128128
<Compile Include="Events\ProjectRenamedEventArgs.cs" />
129129
<Compile Include="Extensions\MSAccessComponentTypeExtensions.cs" />
130-
<Compile Include="Extensions\WindowExtensions.cs" />
131130
<Compile Include="Native\WinEvents.cs" />
132131
<Compile Include="SafeComWrappers\Abstract\ISafeComWrapper.cs" />
133132
<Compile Include="SafeComWrappers\Abstract\IVBComponentsEventsSink.cs" />

Rubberduck.VBEEditor/SafeComWrappers/Abstract/IWindow.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ namespace Rubberduck.VBEditor.SafeComWrappers.Abstract
55
{
66
public interface IWindow : ISafeComWrapper, IEquatable<IWindow>
77
{
8-
IntPtr RealHwnd { get; set; }
98
int HWnd { get; }
109
string Caption { get; }
1110
bool IsVisible { get; set; }

Rubberduck.VBEEditor/SafeComWrappers/VB6/Window.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ public Window(VB.Window window)
1212
{
1313
}
1414

15-
public IntPtr RealHwnd { get; set; }
16-
1715
public int HWnd
1816
{
1917
get { return IsWrappingNullReference ? 0 : Target.HWnd; }

0 commit comments

Comments
 (0)