Skip to content

Commit

Permalink
Merge pull request #27 from rubberduck-vba/next
Browse files Browse the repository at this point in the history
sync with merged PR's in main repo
  • Loading branch information
retailcoder committed Feb 10, 2016
2 parents 3f74508 + 0588974 commit 086a890
Show file tree
Hide file tree
Showing 242 changed files with 26,292 additions and 16,224 deletions.
65 changes: 22 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![Rubberduck](http://i.stack.imgur.com/taIMg.png)
![Rubberduck](http://i.stack.imgur.com/vmqXM.png)

| Branch | Build Status |
|------------|--------------|
Expand All @@ -12,37 +12,38 @@

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.

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).
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).

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

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

---

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

If you're a C# developer looking for a fun project to contribute to, feel free to fork the project and
[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!

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!
[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!

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

There is additonal information about [building the project in our wiki][install].

[chat]:http://chat.stackexchange.com/rooms/14929/vba
[chat]:http://chat.stackexchange.com/rooms/14929
[helpwanted]:https://github.com/rubberduck-vba/Rubberduck/labels/help-wanted
[install]:https://github.com/rubberduck-vba/Rubberduck/wiki/Building-&-Installation
[branch]:https://github.com/rubberduck-vba/Rubberduck/issues/288

---

#[Installing](https://github.com/rubberduck-vba/Rubberduck/wiki/Installing)

This section was moved to a dedicated wiki page.

---

#License

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

Copyright (C) 2014-2015 Mathieu Guindon & Christopher McClellan
Copyright (C) 2014-2016 Mathieu Guindon & Christopher McClellan

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

---

#Installation

Visit our releases page, [download the installer](https://github.com/rubberduck-vba/Rubberduck/releases/latest), and run the Setup.exe.

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.

##System Requirements

- Windows Vista or more recent (tested on Win7 and Win8.1)
- .Net Framework 4.5
- Microsoft Office 97-2003 or higher

Please feel free to test it on other versions and [submit any bugs on our issue tracker](https://github.com/rubberduck-vba/Rubberduck/issues).

**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/).

---

#Attributions

##Software & Libraries
Expand Down Expand Up @@ -105,16 +88,6 @@ LibGit2Sharp is the library that has allowed us to integrate Git right into the
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).

###[Smart Indenter](http://www.oaltd.co.uk/Indenter/)

**What is Smart Indenter?**

> *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.*
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.

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.

##Icons

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

> 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.
For more information, please see the EULAs in the [./Resources/Microsoft/ directory](https://github.com/rubberduck-vba/Rubberduck/tree/master/RetailCoder.VBE/Resources/Microsoft).
For more information, please see the EULAs in the [./Resources/Microsoft/ directory](https://github.com/retailcoder/Rubberduck/tree/master/RetailCoder.VBE/Resources/Microsoft).

* [Visual Studio 2013 Image Library EULA](https://github.com/retailcoder/Rubberduck/blob/master/RetailCoder.VBE/Resources/Microsoft/Visual%20Studio%202013%20Image%20Library%20EULA.rtf)
* [Visual Studio 2012 Image Library EULA](https://github.com/retailcoder/Rubberduck/blob/master/RetailCoder.VBE/Resources/Microsoft/Visual%20Studio%202012%20Image%20Library%20EULA.rtf)

###[WPF Localization Using RESX Files](http://www.codeproject.com/Articles/35159/WPF-Localization-Using-RESX-Files)

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)!

* [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)
* [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)
> Licensed under [The Code Project Open License](http://www.codeproject.com/info/cpol10.aspx).
5 changes: 4 additions & 1 deletion RetailCoder.VBE/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using Rubberduck.UI.Command.MenuItems;
using Rubberduck.UI.ParserErrors;
using Rubberduck.VBEditor.Extensions;
using Infralution.Localization.Wpf;

namespace Rubberduck
{
Expand Down Expand Up @@ -64,6 +65,8 @@ public class App : IDisposable
_configService.SettingsChanged += _configService_SettingsChanged;
_parser.State.StateChanged += Parser_StateChanged;
_stateBar.Refresh += _stateBar_Refresh;

UiDispatcher.Initialize();
}

private Keys _firstStepHotKey;
Expand Down Expand Up @@ -187,7 +190,7 @@ private void LoadConfig()
var currentCulture = RubberduckUI.Culture;
try
{
RubberduckUI.Culture = CultureInfo.GetCultureInfo(_config.UserSettings.LanguageSetting.Code);
CultureManager.UICulture = CultureInfo.GetCultureInfo(_config.UserSettings.LanguageSetting.Code);
_appMenus.Localize();
}
catch (CultureNotFoundException exception)
Expand Down
34 changes: 12 additions & 22 deletions RetailCoder.VBE/AutoSave/AutoSave.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Timers;
Expand All @@ -10,20 +11,9 @@ public class AutoSave : IDisposable
{
private readonly VBE _vbe;
private readonly IAutoSaveSettings _settings;
// ReSharper disable once InconsistentNaming
private readonly Timer _timer = new Timer();

public bool IsEnabled
{
get { return _timer.Enabled; }
set { _timer.Enabled = value; }
}

public double TimerDelay
{
get { return _timer.Interval; }
set { _timer.Interval = value; }
}
private const int VbeSaveCommandId = 3;

public AutoSave(VBE vbe, IAutoSaveSettings settings)
{
Expand All @@ -38,15 +28,16 @@ public AutoSave(VBE vbe, IAutoSaveSettings settings)
_timer.Elapsed += _timer_Elapsed;
}

void _settings_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
private void _settings_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == "IsEnabled")
{
_timer.Enabled = _settings.IsEnabled;
}
if (e.PropertyName == "TimerDelay")
switch (e.PropertyName)
{
_timer.Interval = _settings.TimerDelay;
case "IsEnabled":
_timer.Enabled = _settings.IsEnabled;
break;
case "TimerDelay":
_timer.Interval = _settings.TimerDelay;
break;
}
}

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

_vbe.CommandBars.FindControl(Id: 3).Execute();
_vbe.CommandBars.FindControl(Id: VbeSaveCommandId).Execute();
}
}

Expand Down
2 changes: 1 addition & 1 deletion RetailCoder.VBE/AutoSave/AutoSaveSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public interface IAutoSaveSettings : INotifyPropertyChanged

public class AutoSaveSettings : IAutoSaveSettings
{
public AutoSaveSettings(bool isEnabled = true, int timerDelay = 600000)
public AutoSaveSettings(bool isEnabled = false, int timerDelay = 600000)
{
IsEnabled = isEnabled;
TimerDelay = timerDelay;
Expand Down
10 changes: 10 additions & 0 deletions RetailCoder.VBE/Common/DeclarationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,16 @@ public static IEnumerable<Declaration> FindEventHandlers(this IEnumerable<Declar
&& declaration.IdentifierName.StartsWith(control.IdentifierName + "_"));
}

public static IEnumerable<Declaration> FindBuiltInEventHandlers(this IEnumerable<Declaration> declarations)
{
var handlerNames = declarations.Where(declaration => declaration.IsBuiltIn && declaration.DeclarationType == DeclarationType.Event)
.Select(e => e.ParentDeclaration.IdentifierName + "_" + e.IdentifierName);

return declarations.Where(declaration => !declaration.IsBuiltIn
&& declaration.DeclarationType == DeclarationType.Procedure
&& handlerNames.Contains(declaration.IdentifierName));
}

/// <summary>
/// Gets the <see cref="Declaration"/> of the specified <see cref="type"/>,
/// at the specified <see cref="selection"/>.
Expand Down
4 changes: 2 additions & 2 deletions RetailCoder.VBE/Common/WinAPI/POINT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ public struct POINT

public POINT(int x, int y)
{
this.X = x;
this.Y = y;
X = x;
Y = y;
}

public POINT(System.Drawing.Point pt) : this(pt.X, pt.Y) { }
Expand Down
31 changes: 31 additions & 0 deletions RetailCoder.VBE/Controls/GroupingGrid/GroupingGrid.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<DataGrid x:Class="Rubberduck.Controls.GroupingGrid"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Rubberduck.Controls"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<DataGrid.Resources>
<Style x:Key="GroupHeaderStyle" TargetType="{x:Type GroupItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Expander Background="WhiteSmoke" Foreground="Black" Header="{Binding Name}" IsExpanded="True">
<ItemsPresenter></ItemsPresenter>
</Expander>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</DataGrid.Resources>
<DataGrid.GroupStyle>
<GroupStyle ContainerStyle="{StaticResource GroupHeaderStyle}">
<GroupStyle.Panel>
<ItemsPanelTemplate>
<DataGridRowsPresenter></DataGridRowsPresenter>
</ItemsPanelTemplate>
</GroupStyle.Panel>
</GroupStyle>
</DataGrid.GroupStyle>
</DataGrid>
34 changes: 34 additions & 0 deletions RetailCoder.VBE/Controls/GroupingGrid/GroupingGrid.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Rubberduck.Controls
{
public partial class GroupingGrid
{
public static readonly DependencyProperty IsExpandedProperty =
DependencyProperty.Register("IsExpanded", typeof(bool), typeof(GroupingGrid));

public bool IsExpanded
{
get { return (bool)GetValue(IsExpandedProperty); }
set { SetValue(IsExpandedProperty, value); }
}

public GroupingGrid()
{
InitializeComponent();
}
}
}
22 changes: 20 additions & 2 deletions RetailCoder.VBE/Extension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
using Ninject.Extensions.Factory;
using Rubberduck.Root;
using Rubberduck.UI;
using System.Reflection;
using System.IO;

namespace Rubberduck
{
Expand Down Expand Up @@ -36,20 +38,36 @@ public void OnConnection(object Application, ext_ConnectMode ConnectMode, object
{
try
{
AppDomain currentDomain = AppDomain.CurrentDomain;
currentDomain.AssemblyResolve += LoadFromSameFolder;

_kernel.Load(new RubberduckModule(_kernel, (VBE)Application, (AddIn)AddInInst));
_kernel.Load(new UI.SourceControl.SourceControlBindings());
_kernel.Load(new CommandBarsModule(_kernel));

var app = _kernel.Get<App>();
app.Startup();
}
catch (Exception exception)
{
System.Windows.Forms.MessageBox.Show(exception.ToString(), RubberduckUI.RubberduckLoadFailure, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

Assembly LoadFromSameFolder(object sender, ResolveEventArgs args)
{
string folderPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string assemblyPath = Path.Combine(folderPath, new AssemblyName(args.Name).Name + ".dll");
if (!File.Exists(assemblyPath))
{
return null;
}
Assembly assembly = Assembly.LoadFrom(assemblyPath);
return assembly;
}

public void OnStartupComplete(ref Array custom)
{
var app = _kernel.Get<App>();
app.Startup();
}

public void OnDisconnection(ext_DisconnectMode RemoveMode, ref Array custom)
Expand Down

0 comments on commit 086a890

Please sign in to comment.