Skip to content

Commit ed9ea21

Browse files
committed
Include Rubberduck.Resources, fix remaining Compilation Problems
1 parent cd8ab5a commit ed9ea21

File tree

44 files changed

+305
-74
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+305
-74
lines changed
Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Windows.Media.Imaging;
5+
using Rubberduck.Parsing.Symbols;
6+
7+
namespace Rubberduck.Common
8+
{
9+
public class DeclarationIconCache
10+
{
11+
private static readonly IDictionary<Tuple<DeclarationType, Accessibility>, BitmapImage> Images;
12+
13+
static DeclarationIconCache()
14+
{
15+
var types = Enum.GetValues(typeof (DeclarationType)).Cast<DeclarationType>();
16+
var accessibilities = Enum.GetValues(typeof (Accessibility)).Cast<Accessibility>();
17+
18+
Images = types.SelectMany(t => accessibilities.Select(a => Tuple.Create(t, a)))
19+
.ToDictionary(key => key, key => new BitmapImage(GetIconUri(key.Item1, key.Item2)));
20+
}
21+
22+
public BitmapImage this[Declaration declaration]
23+
{
24+
get
25+
{
26+
var key = Tuple.Create(declaration.DeclarationType, declaration.Accessibility);
27+
return Images[key];
28+
}
29+
}
30+
31+
private static Uri GetIconUri(DeclarationType declarationType, Accessibility accessibility)
32+
{
33+
const string baseUri = @"../Rubberduck.Resources/Icons/Fugue/";
34+
35+
string path;
36+
switch (declarationType)
37+
{
38+
case DeclarationType.ProceduralModule:
39+
path = "ObjectModule.png";
40+
break;
41+
42+
case DeclarationType.Document | DeclarationType.ClassModule:
43+
path = "Document.png";
44+
break;
45+
46+
case DeclarationType.UserForm | DeclarationType.ClassModule | DeclarationType.Control:
47+
path = "ProjectForm.png";
48+
break;
49+
50+
case DeclarationType.ClassModule | DeclarationType.ProceduralModule:
51+
path = "ObjectClass.png";
52+
break;
53+
54+
case DeclarationType.Procedure | DeclarationType.Member:
55+
case DeclarationType.Function | DeclarationType.Member:
56+
if (accessibility == Accessibility.Private)
57+
{
58+
path = "ObjectMethodPrivate.png";
59+
break;
60+
}
61+
if (accessibility == Accessibility.Friend)
62+
{
63+
path = "ObjectMethodFriend.png";
64+
break;
65+
}
66+
67+
path = "ObjectMethod.png";
68+
break;
69+
70+
case DeclarationType.PropertyGet | DeclarationType.Property | DeclarationType.Function:
71+
case DeclarationType.PropertyLet | DeclarationType.Property | DeclarationType.Procedure:
72+
case DeclarationType.PropertySet | DeclarationType.Property | DeclarationType.Procedure:
73+
if (accessibility == Accessibility.Private)
74+
{
75+
path = "ObjectPropertiesPrivate.png";
76+
break;
77+
}
78+
if (accessibility == Accessibility.Friend)
79+
{
80+
path = "ObjectPropertiesFriend.png";
81+
break;
82+
}
83+
84+
path = "ObjectProperties.png";
85+
break;
86+
87+
case DeclarationType.Parameter:
88+
path = "ObjectFieldShortcut.png";
89+
break;
90+
91+
case DeclarationType.Variable:
92+
if (accessibility == Accessibility.Private)
93+
{
94+
path = "ObjectFieldPrivate.png";
95+
break;
96+
}
97+
if (accessibility == Accessibility.Friend)
98+
{
99+
path = "ObjectFieldFriend.png";
100+
break;
101+
}
102+
103+
path = "ObjectField.png";
104+
break;
105+
106+
case DeclarationType.Constant:
107+
if (accessibility == Accessibility.Private)
108+
{
109+
path = "ObjectConstantPrivate.png";
110+
break;
111+
}
112+
if (accessibility == Accessibility.Friend)
113+
{
114+
path = "ObjectConstantFriend.png";
115+
break;
116+
}
117+
118+
path = "ObjectConstant.png";
119+
break;
120+
121+
case DeclarationType.Enumeration:
122+
if (accessibility == Accessibility.Private)
123+
{
124+
path = "ObjectEnumPrivate.png";
125+
break;
126+
}
127+
if (accessibility == Accessibility.Friend)
128+
{
129+
path = "ObjectEnumFriend.png";
130+
break;
131+
}
132+
133+
path = "ObjectEnum.png";
134+
break;
135+
136+
case DeclarationType.EnumerationMember:
137+
path = "ObjectEnumItem.png";
138+
break;
139+
140+
case DeclarationType.Event:
141+
if (accessibility == Accessibility.Private)
142+
{
143+
path = "ObjectEventPrivate.png";
144+
break;
145+
}
146+
if (accessibility == Accessibility.Friend)
147+
{
148+
path = "ObjectEventFriend.png";
149+
break;
150+
}
151+
152+
path = "ObjectEvent.png";
153+
break;
154+
155+
case DeclarationType.UserDefinedType:
156+
if (accessibility == Accessibility.Private)
157+
{
158+
path = "ObjectValueTypePrivate.png";
159+
break;
160+
}
161+
if (accessibility == Accessibility.Friend)
162+
{
163+
path = "ObjectValueTypeFriend.png";
164+
break;
165+
}
166+
167+
path = "ObjectValueType.png";
168+
break;
169+
170+
case DeclarationType.UserDefinedTypeMember:
171+
path = "ObjectField.png";
172+
break;
173+
174+
case DeclarationType.LibraryProcedure | DeclarationType.Procedure:
175+
case DeclarationType.LibraryFunction | DeclarationType.Function:
176+
path = "ObjectMethodShortcut.png";
177+
break;
178+
179+
case DeclarationType.LineLabel:
180+
path = "ObjectConstantShortcut.png";
181+
break;
182+
183+
case DeclarationType.Project:
184+
path = "ObjectLibrary.png";
185+
break;
186+
187+
default:
188+
path = "ObjectStructure.png";
189+
break;
190+
}
191+
192+
return new Uri(baseUri + path, UriKind.Relative);
193+
}
194+
195+
}
196+
}

Rubberduck.Core/Rubberduck.Core.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@
297297
<Compile Include="App.cs" />
298298
<Compile Include="AppMenu.cs" />
299299
<Compile Include="Common\ApplicationConstants.cs" />
300+
<Compile Include="Common\DeclarationIconCache.cs" />
300301
<Compile Include="Common\ExportFormatter.cs" />
301302
<Compile Include="Common\ClipboardWriter.cs" />
302303
<Compile Include="Common\HookEventArgs.cs" />
@@ -753,7 +754,6 @@
753754
<DependentUpon>SimpleListControl.cs</DependentUpon>
754755
</Compile>
755756
<Compile Include="UI\IdentifierReferences\IdentifierReferencesListDockablePresenter.cs" />
756-
</Compile>
757757
<Compile Include="UI\FileBrowserDialogFactory.cs" />
758758
<Compile Include="UI\Controls\INavigateSelection.cs" />
759759
<Compile Include="UI\Splash.cs">
@@ -878,7 +878,6 @@
878878
<EmbeddedResource Include="UI\SimpleListControl.resx">
879879
<DependentUpon>SimpleListControl.cs</DependentUpon>
880880
</EmbeddedResource>
881-
</EmbeddedResource>
882881
<EmbeddedResource Include="UI\Splash.resx">
883882
<DependentUpon>Splash.cs</DependentUpon>
884883
</EmbeddedResource>

Rubberduck.Core/UI/CodeExplorer/Commands/RemoveCommand.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Linq;
44
using System.Windows.Forms;
55
using NLog;
6+
using Rubberduck.Interaction;
67
using Rubberduck.Navigation.CodeExplorer;
78
using Rubberduck.UI.Command;
89
using Rubberduck.VBEditor.ComManagement;
@@ -55,15 +56,14 @@ protected override bool EvaluateCanExecute(object parameter)
5556
protected override void OnExecute(object parameter)
5657
{
5758
var message = string.Format("Do you want to export '{0}' before removing?", ((CodeExplorerComponentViewModel)parameter).Name);
58-
var result = _messageBox.Show(message, "Rubberduck Export Prompt", MessageBoxButtons.YesNoCancel,
59-
MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
59+
var result = _messageBox.Confirm(message, "Rubberduck Export Prompt", true);
6060

61-
if (result == DialogResult.Cancel)
61+
if (!result.HasValue)
6262
{
6363
return;
6464
}
6565

66-
if (result == DialogResult.Yes && !ExportFile((CodeExplorerComponentViewModel)parameter))
66+
if (result.Value && !ExportFile((CodeExplorerComponentViewModel)parameter))
6767
{
6868
return;
6969
}

Rubberduck.Core/UI/CodeExplorer/Commands/RenameCommand.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using NLog;
3+
using Rubberduck.Interaction;
34
using Rubberduck.Navigation.CodeExplorer;
45
using Rubberduck.Parsing.VBA;
56
using Rubberduck.Refactorings.Rename;

Rubberduck.Core/UI/Command/AddTestModuleCommand.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Linq;
33
using System.Runtime.InteropServices;
44
using NLog;
5+
using Rubberduck.Interaction;
56
using Rubberduck.Parsing.VBA;
67
using Rubberduck.Settings;
78
using Rubberduck.UnitTesting;

Rubberduck.Core/UI/Command/FindAllImplementationsCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Runtime.InteropServices;
5-
using System.Windows.Forms;
65
using NLog;
76
using Rubberduck.Common;
7+
using Rubberduck.Interaction;
88
using Rubberduck.Parsing.Grammar;
99
using Rubberduck.Parsing.Symbols;
1010
using Rubberduck.Parsing.UIContext;

Rubberduck.Core/UI/Command/FindAllReferencesCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using System;
22
using System.Linq;
33
using System.Runtime.InteropServices;
4-
using System.Windows.Forms;
54
using NLog;
5+
using Rubberduck.Interaction;
66
using Rubberduck.Parsing.Symbols;
77
using Rubberduck.Parsing.UIContext;
88
using Rubberduck.Parsing.VBA;

Rubberduck.Core/UI/Command/Refactorings/CodePaneRefactorRenameCommand.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Runtime.InteropServices;
2+
using Rubberduck.Interaction;
23
using Rubberduck.Parsing.Symbols;
34
using Rubberduck.Parsing.VBA;
45
using Rubberduck.Refactorings.Rename;

Rubberduck.Core/UI/Command/Refactorings/FormDesignerRefactorRenameCommand.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Linq;
22
using System.Runtime.InteropServices;
3+
using Rubberduck.Interaction;
34
using Rubberduck.Parsing.Symbols;
45
using Rubberduck.Parsing.VBA;
56
using Rubberduck.Refactorings.Rename;

Rubberduck.Core/UI/Command/Refactorings/ProjectExplorerRefactorRenameCommand.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Linq;
22
using System.Runtime.InteropServices;
3+
using Rubberduck.Interaction;
34
using Rubberduck.Parsing.Symbols;
45
using Rubberduck.Parsing.VBA;
56
using Rubberduck.Refactorings.Rename;

0 commit comments

Comments
 (0)