Skip to content

Commit d2d5e16

Browse files
committed
Introduced a wrapper for Microsoft.Vbe.Interop.Forms.UserForm.
1 parent 323f0ba commit d2d5e16

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

Rubberduck.VBEEditor/Rubberduck.VBEditor.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@
139139
<Compile Include="Events\VBENativeServices.cs" />
140140
<Compile Include="Events\WindowChangedEventArgs.cs" />
141141
<Compile Include="Extensions\MSAccessComponentTypeExtensions.cs" />
142+
<Compile Include="SafeComWrappers\Office.Core\Abstract\IUserForm.cs" />
142143
<Compile Include="SafeComWrappers\Abstract\ISafeComWrapper.cs" />
143144
<Compile Include="SafeComWrappers\DispatcherEventArgs.cs" />
144145
<Compile Include="SafeComWrappers\MSAccessComponentType.cs" />
@@ -196,6 +197,7 @@
196197
<Compile Include="SafeComWrappers\VBA\AddIn.cs" />
197198
<Compile Include="SafeComWrappers\VBA\AddIns.cs" />
198199
<Compile Include="SafeComWrappers\VBA\Application.cs" />
200+
<Compile Include="SafeComWrappers\VBA\UserForm.cs" />
199201
<Compile Include="SafeComWrappers\VBA\CodeModule.cs" />
200202
<Compile Include="SafeComWrappers\VBA\CodePane.cs" />
201203
<Compile Include="SafeComWrappers\VBA\CodePanes.cs" />
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace Rubberduck.VBEditor.SafeComWrappers.Office.Core.Abstract
2+
{
3+
public interface IUserForm
4+
{
5+
IControls Controls { get; }
6+
IControls Selected { get; }
7+
}
8+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
2+
using Rubberduck.VBEditor.SafeComWrappers.Office.Core.Abstract;
3+
4+
namespace Rubberduck.VBEditor.SafeComWrappers.VBA
5+
{
6+
public class UserForm : SafeComWrapper<Microsoft.Vbe.Interop.Forms.UserForm>, IUserForm
7+
{
8+
public UserForm(Microsoft.Vbe.Interop.Forms.UserForm target, bool rewrapping = false)
9+
: base(target, rewrapping)
10+
{
11+
}
12+
13+
public IControls Controls => new Controls(Target.Controls);
14+
15+
public IControls Selected => new Controls(Target.Selected);
16+
17+
public override bool Equals(ISafeComWrapper<Microsoft.Vbe.Interop.Forms.UserForm> other)
18+
{
19+
return IsEqualIfNull(other) || (other != null && ReferenceEquals(other.Target, Target));
20+
}
21+
22+
public bool Equals(IUserForm other)
23+
{
24+
return Equals(other as SafeComWrapper<Microsoft.Vbe.Interop.Forms.UserForm>);
25+
}
26+
27+
public override int GetHashCode()
28+
{
29+
return IsWrappingNullReference ? 0 : Target.GetHashCode();
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)