Skip to content

Commit 086a890

Browse files
committed
Merge pull request #27 from rubberduck-vba/next
sync with merged PR's in main repo
2 parents 3f74508 + 0588974 commit 086a890

File tree

242 files changed

+26292
-16224
lines changed

Some content is hidden

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

242 files changed

+26292
-16224
lines changed

README.md

Lines changed: 22 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
![Rubberduck](http://i.stack.imgur.com/taIMg.png)
1+
![Rubberduck](http://i.stack.imgur.com/vmqXM.png)
22

33
| Branch | Build Status |
44
|------------|--------------|
@@ -12,37 +12,38 @@
1212

1313
Rubberduck is a COM Add-In for the VBA IDE that makes VBA development even more enjoyable, by extending the Visual Basic Editor (VBE) with menus, toolbars and toolwindows that enable things we didn't even think were possible when we first started this project.
1414

15-
If you're learning VBA, Rubberduck can help you avoid a few common beginner mistakes, and can probably show you a trick or two - even if you're only ever writing *macros*. If you're a more advanced programmer, you will appreciate the richness of [Rubberduck's feature set](https://github.com/rubberduck-vba/Rubberduck/wiki/Features).
15+
If you're learning VBA, Rubberduck can help you avoid a few common beginner mistakes, and can probably show you a trick or two - even if you're only ever writing *macros*. If you're a more advanced programmer, you will appreciate the richness of [Rubberduck's feature set](https://github.com/retailcoder/Rubberduck/wiki/Features).
1616

1717
[**Follow us on Twitter!**](https://twitter.com/rubberduckvba)
1818

19-
[**Rubberduck Wiki**](https://github.com/rubberduck-vba/Rubberduck/wiki)
19+
[**Rubberduck Wiki**](https://github.com/retailcoder/Rubberduck/wiki)
2020

2121
---
2222

23-
#Contributing
23+
#[Contributing](https://github.com/rubberduck-vba/Rubberduck/wiki/Contributing)
2424

2525
If you're a C# developer looking for a fun project to contribute to, feel free to fork the project and
26-
[come meet the devs in Code Review's "VBA" chatroom][chat] - we'll be happy to answer your questions and help you help us take the VBE into the 21st century!
27-
28-
Some issues are tagged with [help-wanted][helpwanted], but that doesn't mean we can't use some help with anything else in the project - if this project interests you, we want to hear from you!
26+
[come meet the devs in Code Review's "VBA Rubberducking" chatroom][chat] - we'll be happy to answer your questions and help you help us!
2927

3028
We follow a [development branch workflow][branch], so please submit any Pull Requests to the `next` branch.
3129

32-
There is additonal information about [building the project in our wiki][install].
33-
34-
[chat]:http://chat.stackexchange.com/rooms/14929/vba
30+
[chat]:http://chat.stackexchange.com/rooms/14929
3531
[helpwanted]:https://github.com/rubberduck-vba/Rubberduck/labels/help-wanted
36-
[install]:https://github.com/rubberduck-vba/Rubberduck/wiki/Building-&-Installation
3732
[branch]:https://github.com/rubberduck-vba/Rubberduck/issues/288
3833

3934
---
4035

36+
#[Installing](https://github.com/rubberduck-vba/Rubberduck/wiki/Installing)
37+
38+
This section was moved to a dedicated wiki page.
39+
40+
---
41+
4142
#License
4243

4344
Rubberduck is a COM add-in for the VBA IDE (VBE).
4445

45-
Copyright (C) 2014-2015 Mathieu Guindon & Christopher McClellan
46+
Copyright (C) 2014-2016 Mathieu Guindon & Christopher McClellan
4647

4748
This program is free software: you can redistribute it and/or modify
4849
it under the terms of the GNU General Public License as published by
@@ -59,24 +60,6 @@ along with this program. If not, see http://www.gnu.org/licenses/.
5960

6061
---
6162

62-
#Installation
63-
64-
Visit our releases page, [download the installer](https://github.com/rubberduck-vba/Rubberduck/releases/latest), and run the Setup.exe.
65-
66-
If you're **upgrading** from version 1.0, you will need to completely uninstall it before installing the newest release. This isn't necessary when upgrading from newer versions. Also, be sure to back up the `rubberduck.config` file in the `\AppData\Roaming\Rubberduck\` directory prior to installation.
67-
68-
##System Requirements
69-
70-
- Windows Vista or more recent (tested on Win7 and Win8.1)
71-
- .Net Framework 4.5
72-
- Microsoft Office 97-2003 or higher
73-
74-
Please feel free to test it on other versions and [submit any bugs on our issue tracker](https://github.com/rubberduck-vba/Rubberduck/issues).
75-
76-
**Note:** The 1.2 installer doesn't work for 64 bit versions of office. You can find the [work around here](https://rubberduckvba.wordpress.com/2015/03/11/64-bit-rubberduck-a-work-around-until-release-1-21-soon/).
77-
78-
---
79-
8063
#Attributions
8164

8265
##Software & Libraries
@@ -105,16 +88,6 @@ LibGit2Sharp is the library that has allowed us to integrate Git right into the
10588
10689
Which basically means it's a reimplementation of Git in C. It also [happens to be the technology Microsoft uses for their own Git integration with Visual Studio](http://www.hanselman.com/blog/GitSupportForVisualStudioGitTFSAndVSPutIntoContext.aspx).
10790

108-
###[Smart Indenter](http://www.oaltd.co.uk/Indenter/)
109-
110-
**What is Smart Indenter?**
111-
112-
> *The Smart Indenter is a utility to tidy up VBA code by rebuilding the indentation of each line. Most developers naturally indent code within control structures, such as For...Next, If...End If, etc. Many developers also indent all the code within a procedure, to ease identification of line labels, error handling blocks etc. From that point on, there is much more variety in indenting styles, ranging from how to treat declaration lines to handling end-of-line comments.*
113-
114-
The Rubberduck project was graciously offered the source code for this formidable tool by Stephen Bullen and Rob Bovey. We've translated the VB6 source code to C# and embedded a managed indenting API that Rubberduck calls into, while decoupling the indenter logic from the Windows Registry so we could store indenter options together with the Rubberduck settings, and configure the indenter from Rubberduck's options dialog.
115-
116-
If you're already using Smart Indenter, Rubberduck's options dialog allow importing the settings from the registry. If we did our part well, you can uninstall Smart Indenter after installing Rubberduck 2.0, and still benefit from the smartest indenting tool available for VBA.
117-
11891
##Icons
11992

12093
We didn't come up with these icons ourselves! Here's who did what:
@@ -133,7 +106,13 @@ Icons in the `./Resources/Microsoft/` directory are licensed under Microsoft's S
133106

134107
> You have a right to Use and Distribute these files. This means that you are free to copy and use these images in documents and projects that you create, but you may not modify them in anyway.
135108
136-
For more information, please see the EULAs in the [./Resources/Microsoft/ directory](https://github.com/rubberduck-vba/Rubberduck/tree/master/RetailCoder.VBE/Resources/Microsoft).
109+
For more information, please see the EULAs in the [./Resources/Microsoft/ directory](https://github.com/retailcoder/Rubberduck/tree/master/RetailCoder.VBE/Resources/Microsoft).
110+
111+
* [Visual Studio 2013 Image Library EULA](https://github.com/retailcoder/Rubberduck/blob/master/RetailCoder.VBE/Resources/Microsoft/Visual%20Studio%202013%20Image%20Library%20EULA.rtf)
112+
* [Visual Studio 2012 Image Library EULA](https://github.com/retailcoder/Rubberduck/blob/master/RetailCoder.VBE/Resources/Microsoft/Visual%20Studio%202012%20Image%20Library%20EULA.rtf)
113+
114+
###[WPF Localization Using RESX Files](http://www.codeproject.com/Articles/35159/WPF-Localization-Using-RESX-Files)
115+
116+
This library makes localizing WPF applications at runtime using resx files a breeze. Thank you [Grant Frisken](http://www.codeproject.com/script/Membership/View.aspx?mid=1079060)!
137117

138-
* [Visual Studio 2013 Image Library EULA](https://github.com/rubberduck-vba/Rubberduck/blob/master/RetailCoder.VBE/Resources/Microsoft/Visual%20Studio%202013%20Image%20Library%20EULA.rtf)
139-
* [Visual Studio 2012 Image Library EULA](https://github.com/rubberduck-vba/Rubberduck/blob/master/RetailCoder.VBE/Resources/Microsoft/Visual%20Studio%202012%20Image%20Library%20EULA.rtf)
118+
> Licensed under [The Code Project Open License](http://www.codeproject.com/info/cpol10.aspx).

RetailCoder.VBE/App.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using Rubberduck.UI.Command.MenuItems;
1717
using Rubberduck.UI.ParserErrors;
1818
using Rubberduck.VBEditor.Extensions;
19+
using Infralution.Localization.Wpf;
1920

2021
namespace Rubberduck
2122
{
@@ -64,6 +65,8 @@ public App(VBE vbe, IMessageBox messageBox,
6465
_configService.SettingsChanged += _configService_SettingsChanged;
6566
_parser.State.StateChanged += Parser_StateChanged;
6667
_stateBar.Refresh += _stateBar_Refresh;
68+
69+
UiDispatcher.Initialize();
6770
}
6871

6972
private Keys _firstStepHotKey;
@@ -187,7 +190,7 @@ private void LoadConfig()
187190
var currentCulture = RubberduckUI.Culture;
188191
try
189192
{
190-
RubberduckUI.Culture = CultureInfo.GetCultureInfo(_config.UserSettings.LanguageSetting.Code);
193+
CultureManager.UICulture = CultureInfo.GetCultureInfo(_config.UserSettings.LanguageSetting.Code);
191194
_appMenus.Localize();
192195
}
193196
catch (CultureNotFoundException exception)

RetailCoder.VBE/AutoSave/AutoSave.cs

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.ComponentModel;
23
using System.IO;
34
using System.Linq;
45
using System.Timers;
@@ -10,20 +11,9 @@ public class AutoSave : IDisposable
1011
{
1112
private readonly VBE _vbe;
1213
private readonly IAutoSaveSettings _settings;
13-
// ReSharper disable once InconsistentNaming
1414
private readonly Timer _timer = new Timer();
1515

16-
public bool IsEnabled
17-
{
18-
get { return _timer.Enabled; }
19-
set { _timer.Enabled = value; }
20-
}
21-
22-
public double TimerDelay
23-
{
24-
get { return _timer.Interval; }
25-
set { _timer.Interval = value; }
26-
}
16+
private const int VbeSaveCommandId = 3;
2717

2818
public AutoSave(VBE vbe, IAutoSaveSettings settings)
2919
{
@@ -38,15 +28,16 @@ public AutoSave(VBE vbe, IAutoSaveSettings settings)
3828
_timer.Elapsed += _timer_Elapsed;
3929
}
4030

41-
void _settings_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
31+
private void _settings_PropertyChanged(object sender, PropertyChangedEventArgs e)
4232
{
43-
if (e.PropertyName == "IsEnabled")
44-
{
45-
_timer.Enabled = _settings.IsEnabled;
46-
}
47-
if (e.PropertyName == "TimerDelay")
33+
switch (e.PropertyName)
4834
{
49-
_timer.Interval = _settings.TimerDelay;
35+
case "IsEnabled":
36+
_timer.Enabled = _settings.IsEnabled;
37+
break;
38+
case "TimerDelay":
39+
_timer.Interval = _settings.TimerDelay;
40+
break;
5041
}
5142
}
5243

@@ -56,16 +47,15 @@ private void _timer_Elapsed(object sender, ElapsedEventArgs e)
5647
{
5748
try
5849
{
59-
// iterate to find if a file exists for each open project
60-
// I do hope the compiler doesn't optimize this out
50+
// note: VBProject.FileName getter throws IOException if unsaved
6151
_vbe.VBProjects.OfType<VBProject>().Select(p => p.FileName).ToList();
6252
}
6353
catch (DirectoryNotFoundException)
6454
{
6555
return;
6656
}
6757

68-
_vbe.CommandBars.FindControl(Id: 3).Execute();
58+
_vbe.CommandBars.FindControl(Id: VbeSaveCommandId).Execute();
6959
}
7060
}
7161

RetailCoder.VBE/AutoSave/AutoSaveSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public interface IAutoSaveSettings : INotifyPropertyChanged
1212

1313
public class AutoSaveSettings : IAutoSaveSettings
1414
{
15-
public AutoSaveSettings(bool isEnabled = true, int timerDelay = 600000)
15+
public AutoSaveSettings(bool isEnabled = false, int timerDelay = 600000)
1616
{
1717
IsEnabled = isEnabled;
1818
TimerDelay = timerDelay;

RetailCoder.VBE/Common/DeclarationExtensions.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,16 @@ public static IEnumerable<Declaration> FindEventHandlers(this IEnumerable<Declar
216216
&& declaration.IdentifierName.StartsWith(control.IdentifierName + "_"));
217217
}
218218

219+
public static IEnumerable<Declaration> FindBuiltInEventHandlers(this IEnumerable<Declaration> declarations)
220+
{
221+
var handlerNames = declarations.Where(declaration => declaration.IsBuiltIn && declaration.DeclarationType == DeclarationType.Event)
222+
.Select(e => e.ParentDeclaration.IdentifierName + "_" + e.IdentifierName);
223+
224+
return declarations.Where(declaration => !declaration.IsBuiltIn
225+
&& declaration.DeclarationType == DeclarationType.Procedure
226+
&& handlerNames.Contains(declaration.IdentifierName));
227+
}
228+
219229
/// <summary>
220230
/// Gets the <see cref="Declaration"/> of the specified <see cref="type"/>,
221231
/// at the specified <see cref="selection"/>.

RetailCoder.VBE/Common/WinAPI/POINT.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ public struct POINT
1010

1111
public POINT(int x, int y)
1212
{
13-
this.X = x;
14-
this.Y = y;
13+
X = x;
14+
Y = y;
1515
}
1616

1717
public POINT(System.Drawing.Point pt) : this(pt.X, pt.Y) { }
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<DataGrid x:Class="Rubberduck.Controls.GroupingGrid"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:local="clr-namespace:Rubberduck.Controls"
7+
mc:Ignorable="d"
8+
d:DesignHeight="300" d:DesignWidth="300">
9+
<DataGrid.Resources>
10+
<Style x:Key="GroupHeaderStyle" TargetType="{x:Type GroupItem}">
11+
<Setter Property="Template">
12+
<Setter.Value>
13+
<ControlTemplate>
14+
<Expander Background="WhiteSmoke" Foreground="Black" Header="{Binding Name}" IsExpanded="True">
15+
<ItemsPresenter></ItemsPresenter>
16+
</Expander>
17+
</ControlTemplate>
18+
</Setter.Value>
19+
</Setter>
20+
</Style>
21+
</DataGrid.Resources>
22+
<DataGrid.GroupStyle>
23+
<GroupStyle ContainerStyle="{StaticResource GroupHeaderStyle}">
24+
<GroupStyle.Panel>
25+
<ItemsPanelTemplate>
26+
<DataGridRowsPresenter></DataGridRowsPresenter>
27+
</ItemsPanelTemplate>
28+
</GroupStyle.Panel>
29+
</GroupStyle>
30+
</DataGrid.GroupStyle>
31+
</DataGrid>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Windows;
7+
using System.Windows.Controls;
8+
using System.Windows.Data;
9+
using System.Windows.Documents;
10+
using System.Windows.Input;
11+
using System.Windows.Media;
12+
using System.Windows.Media.Imaging;
13+
using System.Windows.Navigation;
14+
using System.Windows.Shapes;
15+
16+
namespace Rubberduck.Controls
17+
{
18+
public partial class GroupingGrid
19+
{
20+
public static readonly DependencyProperty IsExpandedProperty =
21+
DependencyProperty.Register("IsExpanded", typeof(bool), typeof(GroupingGrid));
22+
23+
public bool IsExpanded
24+
{
25+
get { return (bool)GetValue(IsExpandedProperty); }
26+
set { SetValue(IsExpandedProperty, value); }
27+
}
28+
29+
public GroupingGrid()
30+
{
31+
InitializeComponent();
32+
}
33+
}
34+
}

RetailCoder.VBE/Extension.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
using Ninject.Extensions.Factory;
99
using Rubberduck.Root;
1010
using Rubberduck.UI;
11+
using System.Reflection;
12+
using System.IO;
1113

1214
namespace Rubberduck
1315
{
@@ -36,20 +38,36 @@ public void OnConnection(object Application, ext_ConnectMode ConnectMode, object
3638
{
3739
try
3840
{
41+
AppDomain currentDomain = AppDomain.CurrentDomain;
42+
currentDomain.AssemblyResolve += LoadFromSameFolder;
43+
3944
_kernel.Load(new RubberduckModule(_kernel, (VBE)Application, (AddIn)AddInInst));
4045
_kernel.Load(new UI.SourceControl.SourceControlBindings());
4146
_kernel.Load(new CommandBarsModule(_kernel));
47+
48+
var app = _kernel.Get<App>();
49+
app.Startup();
4250
}
4351
catch (Exception exception)
4452
{
4553
System.Windows.Forms.MessageBox.Show(exception.ToString(), RubberduckUI.RubberduckLoadFailure, MessageBoxButtons.OK, MessageBoxIcon.Error);
4654
}
4755
}
4856

57+
Assembly LoadFromSameFolder(object sender, ResolveEventArgs args)
58+
{
59+
string folderPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
60+
string assemblyPath = Path.Combine(folderPath, new AssemblyName(args.Name).Name + ".dll");
61+
if (!File.Exists(assemblyPath))
62+
{
63+
return null;
64+
}
65+
Assembly assembly = Assembly.LoadFrom(assemblyPath);
66+
return assembly;
67+
}
68+
4969
public void OnStartupComplete(ref Array custom)
5070
{
51-
var app = _kernel.Get<App>();
52-
app.Startup();
5371
}
5472

5573
public void OnDisconnection(ext_DisconnectMode RemoveMode, ref Array custom)

0 commit comments

Comments
 (0)