Skip to content

Commit

Permalink
Cross-platform support (for #17)
Browse files Browse the repository at this point in the history
  • Loading branch information
chelh committed Apr 19, 2017
1 parent f44ac8e commit 7aee51c
Show file tree
Hide file tree
Showing 46 changed files with 596 additions and 315 deletions.
4 changes: 2 additions & 2 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
The following license applies to all of `VBA Sync Tool.exe` except these
statically-linked third-party libraries:
The following license applies to all of `VBASync.exe` and `VBASync.WPF.dll`
except these statically-linked third-party libraries:

* DiffPlex (modified by me for use with VBA)
* OpenMCDF
Expand Down
90 changes: 47 additions & 43 deletions LICENSE.rtf

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions MakeInstaller.iss
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#define MyAppName "VBA Sync Tool"
#define MyAppVersion "1.3.1"
#define MyAppVersion "2.0.0"
#define MyAppPublisher "Chelsea Hughes"
#define MyAppURL "https://github.com/chelh/VBASync"
#define MyAppExeName "VBA Sync Tool.exe"
#define MyAppExeName "VBASync.exe"

[Setup]
AppId={{FCE92422-DABC-447E-8DC4-504C206D2784}
Expand All @@ -27,7 +27,8 @@ Name: "en"; MessagesFile: "compiler:Default.isl"
Name: "fr"; MessagesFile: "compiler:Languages\French.isl"

[Files]
Source: "src\VBASync\bin\Release\VBA Sync Tool.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "src\VBASync\bin\Release\VBASync.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "src\VBASync.WPF\bin\Release\VBASync.WPF.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "src\VBACompressionCodec.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "LICENSE.rtf"; DestDir: "{app}"; Flags: ignoreversion
Source: "3RDPARTY\*"; DestDir: "{app}\3RDPARTY"; Flags: ignoreversion
Expand Down
4 changes: 2 additions & 2 deletions MakePortable.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set version=1.3.1
set version=2.0.0
set pathTo7Zip=%ProgramFiles%\7-Zip\

"%pathTo7Zip%7z.exe" a "dist\Portable VBA Sync Tool %version%.zip" "3RDPARTY\*" "LICENSE.rtf" ".\src\VBACompressionCodec.dll" ".\src\VBASync\bin\Release\VBA Sync Tool.exe" ".\src\VBASync.ini"
"%pathTo7Zip%7z.exe" a "dist\Portable VBA Sync Tool %version%.zip" "3RDPARTY\*" "LICENSE.rtf" ".\src\VBACompressionCodec.dll" ".\src\VBASync\bin\Release\VBASync.exe" ".\src\VBASync.WPF\bin\Release\VBASync.WPF.dll" ".\src\VBASync.ini"
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ the VBA code. This gives it several advantages:
as any other module.
* Supports Excel 97-2003, Excel 2007+, Word 97-2003, Word 2007+,
PowerPoint 2007+, and Outlook files.
* Compatible with every platform supported by the .Net Framework.

## Using
VBA Sync Tool has two modes: **Extract** mode extracts modules
Expand Down Expand Up @@ -56,11 +57,11 @@ You can also specify settings on the command-line via switches:

Switch | Meaning
------ | ------
`/X` | Extract VBA from Office file (default)
`/P` | Publish VBA to Office file
`/F <file>` | Specify Office file
`/D <dir>` | Specify version-control directory
`/R` | Do the selected action, then immediately exit
`-x` | Extract VBA from Office file (default)
`-p` | Publish VBA to Office file
`-f <file>` | Specify Office file
`-d <dir>` | Specify version-control directory
`-r` | Do the selected action, then immediately exit

Any other parameter passed to VBA Sync Tool will be read and parsed as a session `.ini` file.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:l10n="clr-namespace:VBASync.Localization"
xmlns:l10n="clr-namespace:VBASync.Localization;assembly=VBASync"
xmlns:local="clr-namespace:VBASync.WPF"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="{x:Static l10n:VBASyncResources.AWTitle}"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ public ModuleTypeToIconConverter() : base(
(v, t, p, c) => {
switch ((ModuleType)v) {
case ModuleType.Class:
return "pack://application:,,,/WPF/Icons/ClassIcon.png";
return "Icons/ClassIcon.png";
case ModuleType.Standard:
return "pack://application:,,,/WPF/Icons/ModuleIcon.png";
return "Icons/ModuleIcon.png";
case ModuleType.Form:
return "pack://application:,,,/WPF/Icons/FormIcon.png";
return "Icons/FormIcon.png";
case ModuleType.Ini:
return "pack://application:,,,/WPF/Icons/ProjectIcon.png";
return "Icons/ProjectIcon.png";
default:
return "pack://application:,,,/WPF/Icons/DocIcon.png";
return "Icons/DocIcon.png";
}
}) {
}
Expand Down
11 changes: 11 additions & 0 deletions src/VBASync.WPF/FodyWeavers.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Weavers>
<Costura IncludeDebugSymbols="false">
<ExcludeAssemblies>
ICSharpCode.SharpZipLib
OpenMcdf
VbaCompressionCodec
VBASync
</ExcludeAssemblies>
</Costura>
</Weavers>
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace VBASync.WPF
{
internal class MainViewModel : ViewModelBase
{
private Model.ActiveSession _activeSession;
private SessionViewModel _session;
private SettingsViewModel _settings;

Expand All @@ -24,10 +25,16 @@ internal MainViewModel()
public WpfCommand OpenRecentCommand { get; }
public BindingList<string> RecentFiles { get; }

public Model.ActiveSession ActiveSession => _activeSession;

public SessionViewModel Session
{
get => _session;
set => SetField(ref _session, value, nameof(Session));
set
{
SetField(ref _session, value, nameof(Session));
RefreshActiveSession();
}
}

public SettingsViewModel Settings
Expand Down Expand Up @@ -98,5 +105,11 @@ private void LoadRecent(string index)
MessageBoxButton.OK, MessageBoxImage.Error);
}
}

public void RefreshActiveSession()
{
_activeSession?.Dispose();
_activeSession = new Model.ActiveSession(_session);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:l10n="clr-namespace:VBASync.Localization"
xmlns:l10n="clr-namespace:VBASync.Localization;assembly=VBASync"
xmlns:local="clr-namespace:VBASync.WPF"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Name="ThisWindow"
Expand All @@ -18,6 +18,27 @@
Icon="Icons/VBA Sync Simple.ico"
Loaded="Window_Loaded"
mc:Ignorable="d">
<Window.Resources>
<Style x:Key="Level1" TargetType="{x:Type FrameworkElement}">
<Setter Property="Margin" Value="4,8,0,0" />
</Style>
<Style x:Key="Level1Close" TargetType="{x:Type FrameworkElement}">
<Setter Property="Margin" Value="4,4,0,0" />
</Style>
<Style x:Key="Level1VeryClose" TargetType="{x:Type FrameworkElement}">
<Setter Property="Margin" Value="4,2,0,0" />
</Style>
<Style x:Key="Level1Solid" TargetType="{x:Type FrameworkElement}">
<Setter Property="Margin" Value="4,0,0,0" />
</Style>
<Style x:Key="Level2" TargetType="{x:Type FrameworkElement}">
<Setter Property="Margin" Value="20,4,0,0" />
</Style>
<Style x:Key="ExpanderChild" TargetType="{x:Type FrameworkElement}">
<Setter Property="Margin" Value="16,4,0,0" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
</Style>
</Window.Resources>
<DockPanel>
<Menu Margin="4" DockPanel.Dock="Top">
<MenuItem Header="{x:Static l10n:VBASyncResources.MWFileMenu}">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Ookii.Dialogs.Wpf;
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
Expand All @@ -17,16 +16,33 @@ internal partial class MainWindow {
internal const int CopyrightYear = 2017;
internal const string SupportUrl = "https://github.com/chelh/VBASync";

internal static readonly Version Version = new Version(1, 3, 1);
internal static readonly Version Version = new Version(2, 0, 0);

private readonly MainViewModel _vm;

private bool _doUpdateIncludeAll = true;
private VbaFolder _evf;

public MainWindow(MainViewModel vm) {
public MainWindow(Model.Startup startup) {
InitializeComponent();
DataContext = _vm = vm;

DataContext = _vm = new MainViewModel
{
Session = new SessionViewModel
{
Action = startup.Action,
AutoRun = startup.AutoRun,
FilePath = startup.FilePath,
FolderPath = startup.FolderPath
},
Settings = new SettingsViewModel
{
DiffTool = startup.DiffTool,
DiffToolParameters = startup.DiffToolParameters,
Language = startup.Language,
Portable = startup.Portable
}
};

DataContextChanged += (s, e) => QuietRefreshIfInputsOk();
_vm.Session.PropertyChanged += (s, e) =>
{
Expand All @@ -53,56 +69,16 @@ private void AboutMenu_Click(object sender, RoutedEventArgs e)
private void ApplyButton_Click(object sender, RoutedEventArgs e)
{
FixQuotesEnclosingPaths();
var vm = ChangesGrid.DataContext as ChangesViewModel;
if (vm == null) {

var changes = ChangesGrid.DataContext as ChangesViewModel;
var committedChanges = changes?.Where(p => p.Commit).ToList();
if (committedChanges == null || committedChanges.Count == 0)
{
return;
}
if (Session.Action == ActionType.Extract) {
foreach (var p in vm.Where(p => p.Commit).ToArray()) {
var fileName = p.ModuleName + ModuleProcessing.ExtensionFromType(p.ModuleType);
switch (p.ChangeType) {
case ChangeType.DeleteFile:
File.Delete(Path.Combine(Session.FolderPath, fileName));
if (p.ModuleType == ModuleType.Form) {
File.Delete(Path.Combine(Session.FolderPath, p.ModuleName + ".frx"));
}
break;
case ChangeType.ChangeFormControls:
File.Copy(Path.Combine(_evf.FolderPath, p.ModuleName + ".frx"), Path.Combine(Session.FolderPath, p.ModuleName + ".frx"), true);
break;
default:
File.Copy(Path.Combine(_evf.FolderPath, fileName), Path.Combine(Session.FolderPath, fileName), true);
if (p.ChangeType == ChangeType.AddFile && p.ModuleType == ModuleType.Form) {
File.Copy(Path.Combine(_evf.FolderPath, p.ModuleName + ".frx"), Path.Combine(Session.FolderPath, p.ModuleName + ".frx"), true);
}
break;
}
vm.Remove(p);
}
} else {
foreach (var p in vm.Where(p => p.Commit).ToArray()) {
var fileName = p.ModuleName + ModuleProcessing.ExtensionFromType(p.ModuleType);
switch (p.ChangeType) {
case ChangeType.DeleteFile:
File.Delete(Path.Combine(_evf.FolderPath, fileName));
if (p.ModuleType == ModuleType.Form) {
File.Delete(Path.Combine(_evf.FolderPath, p.ModuleName + ".frx"));
}
break;
case ChangeType.ChangeFormControls:
File.Copy(Path.Combine(Session.FolderPath, p.ModuleName + ".frx"), Path.Combine(_evf.FolderPath, p.ModuleName + ".frx"), true);
break;
default:
File.Copy(Path.Combine(Session.FolderPath, fileName), Path.Combine(_evf.FolderPath, fileName), true);
if (p.ChangeType == ChangeType.AddFile && p.ModuleType == ModuleType.Form) {
File.Copy(Path.Combine(Session.FolderPath, p.ModuleName + ".frx"), Path.Combine(_evf.FolderPath, p.ModuleName + ".frx"), true);
}
break;
}
vm.Remove(p);
}
_evf.Write(Session.FilePath);
}

_vm.ActiveSession.Apply(committedChanges, p => changes.Remove(p));

UpdateIncludeAllBox();
}

Expand All @@ -117,9 +93,9 @@ private void ChangesGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
string newPath;
if (Session.Action == ActionType.Extract) {
oldPath = Path.Combine(Session.FolderPath, fileName);
newPath = Path.Combine(_evf.FolderPath, fileName);
newPath = Path.Combine(_vm.ActiveSession.FolderPath, fileName);
} else {
oldPath = Path.Combine(_evf.FolderPath, fileName);
oldPath = Path.Combine(_vm.ActiveSession.FolderPath, fileName);
newPath = Path.Combine(Session.FolderPath, fileName);
}
if (sel.ChangeType == ChangeType.ChangeFormControls) {
Expand Down Expand Up @@ -216,19 +192,12 @@ private void RefreshButton_Click(object sender, RoutedEventArgs e) {
return;
}
FixQuotesEnclosingPaths();
var folderModules = Lib.GetFolderModules(Session.FolderPath);
_evf?.Dispose();
_evf = new VbaFolder();
_evf.Read(Session.FilePath, folderModules.ToDictionary(kvp => kvp.Key, kvp => kvp.Value.Item1));
var changes = Lib.GetModulePatches(Session, _evf.FolderPath, folderModules, _evf.ModuleTexts.ToList()).ToList();
var projChange = Lib.GetProjectPatch(Session, _evf.FolderPath);
if (projChange != null) {
changes.Add(projChange);
}
var cvm = new ChangesViewModel(changes);
ChangesGrid.DataContext = cvm;
foreach (var ch in cvm) {
ch.CommitChanged += (s2, e2) => UpdateIncludeAllBox();
_vm.RefreshActiveSession();

var changes = new ChangesViewModel(_vm.ActiveSession.GetPatches());
ChangesGrid.DataContext = changes;
foreach (var p in changes) {
p.CommitChanged += (s2, e2) => UpdateIncludeAllBox();
}
UpdateIncludeAllBox();
}
Expand Down Expand Up @@ -295,7 +264,7 @@ private void UpdateIncludeAllBox() {
}

private void Window_Closed(object sender, EventArgs e) {
_evf?.Dispose();
_vm.ActiveSession?.Dispose();

string lastSessionPath;
if (_vm.Settings.Portable)
Expand Down
6 changes: 6 additions & 0 deletions src/VBASync.WPF/Packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Costura.Fody" version="1.3.3.0" targetFramework="net40" developmentDependency="true" />
<package id="Fody" version="1.29.4" targetFramework="net40" developmentDependency="true" />
<package id="Ookii.Dialogs" version="1.0" targetFramework="net40" />
</packages>
8 changes: 8 additions & 0 deletions src/VBASync.WPF/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using System.Reflection;

[assembly: AssemblyTitle("VBA Sync WPF")]
[assembly: AssemblyDescription("Cross-platform tool to synchronize an Office VBA file with a version-controlled folder")]
[assembly: AssemblyProduct("VBA Sync Tool")]
[assembly: AssemblyCopyright("Copyright © 2017 Chelsea Hughes")]

[assembly: AssemblyVersion("2.0.0")]
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,35 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:l10n="clr-namespace:VBASync.Localization"
xmlns:lib="clr-namespace:VBASync.Model"
xmlns:l10n="clr-namespace:VBASync.Localization;assembly=VBASync"
xmlns:lib="clr-namespace:VBASync.Model;assembly=VBASync"
xmlns:local="clr-namespace:VBASync.WPF"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="300"
d:DesignWidth="300"
x:ClassModifier="internal"
mc:Ignorable="d">
<UserControl.Resources>
<Style x:Key="Level1" TargetType="{x:Type FrameworkElement}">
<Setter Property="Margin" Value="4,8,0,0" />
</Style>
<Style x:Key="Level1Close" TargetType="{x:Type FrameworkElement}">
<Setter Property="Margin" Value="4,4,0,0" />
</Style>
<Style x:Key="Level1VeryClose" TargetType="{x:Type FrameworkElement}">
<Setter Property="Margin" Value="4,2,0,0" />
</Style>
<Style x:Key="Level1Solid" TargetType="{x:Type FrameworkElement}">
<Setter Property="Margin" Value="4,0,0,0" />
</Style>
<Style x:Key="Level2" TargetType="{x:Type FrameworkElement}">
<Setter Property="Margin" Value="20,4,0,0" />
</Style>
<Style x:Key="ExpanderChild" TargetType="{x:Type FrameworkElement}">
<Setter Property="Margin" Value="16,4,0,0" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
</Style>
</UserControl.Resources>
<StackPanel>
<Label
Padding="0"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 7aee51c

Please sign in to comment.