Skip to content

Commit 4b66021

Browse files
committed
implemented manual refresh in ParserStateCommandBar
1 parent a7c13a1 commit 4b66021

File tree

13 files changed

+153
-23
lines changed

13 files changed

+153
-23
lines changed

RetailCoder.VBE/App.cs

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ public App(VBE vbe, IMessageBox messageBox,
6161
_hook.KeyPressed += _hook_KeyPressed;
6262
_configService.SettingsChanged += _configService_SettingsChanged;
6363
_parser.State.StateChanged += Parser_StateChanged;
64+
_stateBar.Refresh += _stateBar_Refresh;
65+
}
66+
67+
private void _stateBar_Refresh(object sender, EventArgs e)
68+
{
69+
Task.Run(() => ParseAll());
6470
}
6571

6672
private void Parser_StateChanged(object sender, EventArgs e)
@@ -113,26 +119,28 @@ public void Startup()
113119

114120
Task.Delay(1000).ContinueWith(t =>
115121
{
116-
var components = _vbe.VBProjects.Cast<VBProject>()
117-
.SelectMany(project => project.VBComponents.Cast<VBComponent>());
122+
ParseAll();
123+
});
118124

119-
var result = Parallel.ForEach(components, async component =>
120-
{
121-
await ParseComponentAsync(component, false);
122-
});
125+
_hook.Attach();
126+
}
127+
128+
private void ParseAll()
129+
{
130+
var components = _vbe.VBProjects.Cast<VBProject>()
131+
.SelectMany(project => project.VBComponents.Cast<VBComponent>());
132+
133+
var result = Parallel.ForEach(components, async component => { await ParseComponentAsync(component, false); });
123134

124-
if (result.IsCompleted)
135+
if (result.IsCompleted)
136+
{
137+
using (var tokenSource = new CancellationTokenSource())
125138
{
126-
using (var tokenSource = new CancellationTokenSource())
127-
{
128-
_parser.Resolve(tokenSource.Token);
129-
}
139+
_parser.Resolve(tokenSource.Token);
130140
}
131-
});
132-
133-
_hook.Attach();
141+
}
134142
}
135-
143+
136144
private void CleanReloadConfig()
137145
{
138146
LoadConfig();

RetailCoder.VBE/Properties/Resources.Designer.cs

Lines changed: 50 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

RetailCoder.VBE/Properties/Resources.resx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,4 +364,19 @@
364364
<data name="disk" type="System.Resources.ResXFileRef, System.Windows.Forms">
365365
<value>..\Resources\disk.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
366366
</data>
367+
<data name="arrow_circle_double_mask" type="System.Resources.ResXFileRef, System.Windows.Forms">
368+
<value>..\resources\arrow_circle_double_mask.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
369+
</data>
370+
<data name="balloon_ellipsis" type="System.Resources.ResXFileRef, System.Windows.Forms">
371+
<value>..\resources\balloon_ellipsis.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
372+
</data>
373+
<data name="balloon_mask" type="System.Resources.ResXFileRef, System.Windows.Forms">
374+
<value>..\resources\balloon_mask.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
375+
</data>
376+
<data name="balloon_prohibition" type="System.Resources.ResXFileRef, System.Windows.Forms">
377+
<value>..\resources\balloon_prohibition.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
378+
</data>
379+
<data name="balloon_smiley" type="System.Resources.ResXFileRef, System.Windows.Forms">
380+
<value>..\resources\balloon_smiley.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
381+
</data>
367382
</root>
Binary file not shown.
1.3 KB
Binary file not shown.
1.3 KB
Binary file not shown.
Binary file not shown.
1.3 KB
Binary file not shown.

RetailCoder.VBE/Rubberduck.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,11 @@
10031003
<Resource Include="Resources\flask_exclamation_mask.png" />
10041004
<Resource Include="Resources\flask_mask.png" />
10051005
<Resource Include="Resources\disk.png" />
1006+
<Content Include="Resources\arrow_circle_double_mask.bmp" />
1007+
<Content Include="Resources\balloon_ellipsis.bmp" />
1008+
<Content Include="Resources\balloon_mask.bmp" />
1009+
<Content Include="Resources\balloon_prohibition.bmp" />
1010+
<Content Include="Resources\balloon_smiley.bmp" />
10061011
<Content Include="Resources\Microsoft\Mask\AllLoadedTests_8644_24.bmp" />
10071012
<Content Include="Resources\Microsoft\Mask\ExtractMethod_6786_32.bmp" />
10081013
<Content Include="Resources\Microsoft\Mask\FindSymbol_6263_32.bmp" />

RetailCoder.VBE/UI/Command/MenuItems/ParentMenus/ParentMenuItemBase.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Diagnostics;
44
using System.Drawing;
55
using System.Linq;
6+
using System.Runtime.InteropServices;
67
using System.Windows.Forms;
78
using Microsoft.Office.Core;
89
using Rubberduck.Parsing.VBA;
@@ -149,8 +150,15 @@ public static void SetButtonImage(CommandBarButton button, Image image, Image ma
149150
return;
150151
}
151152

152-
button.Picture = AxHostConverter.ImageToPictureDisp(image);
153-
button.Mask = AxHostConverter.ImageToPictureDisp(mask);
153+
try
154+
{
155+
button.Picture = AxHostConverter.ImageToPictureDisp(image);
156+
button.Mask = AxHostConverter.ImageToPictureDisp(mask);
157+
}
158+
catch (COMException exception)
159+
{
160+
Debug.Print("Button image could not be set for button [" + button.Caption + "]\n" + exception);
161+
}
154162
}
155163

156164
private class AxHostConverter : AxHost

0 commit comments

Comments
 (0)