Skip to content

Commit 56cc4be

Browse files
authored
Merge pull request #2475 from comintern/next
Reverts WinEvents, closes #2474
2 parents a703527 + 43560f8 commit 56cc4be

File tree

11 files changed

+103
-516
lines changed

11 files changed

+103
-516
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.

0 commit comments

Comments
 (0)