diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..c5f084d6 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "publish/VstoAddinInstaller"] + path = publish/VstoAddinInstaller + url = git@github.com:bovender/VstoAddinInstaller.git diff --git a/README.md b/README.md index 7fb85660..1738cac6 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,10 @@ XL Toolbox NG (Next Generation) =============================== -The XL Toolbox NG source code is written in (mostly) C# with Visual Studio -Professional 2013 and target for the .NET framework 4.0. - -For more information about this project, see . +For more information about this project, see . -This project uses the Git source code management system. You can find the -repository at . +The XL Toolbox NG source code is written in (mostly) C# with Visual Studio +Professional 2013 and targeted for the .NET framework 4.0. Building the Debug configuration @@ -112,7 +109,7 @@ License ------- Daniel's XL Toolbox NG - Copyright (C) 2014-2015 Daniel Kraus + Copyright (C) 2014-2016 Daniel Kraus , Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/Tests/Properties/AssemblyInfo.cs b/Tests/Properties/AssemblyInfo.cs index eea3222c..ed20c0f1 100755 --- a/Tests/Properties/AssemblyInfo.cs +++ b/Tests/Properties/AssemblyInfo.cs @@ -49,5 +49,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("7.0.0.19")] -[assembly: AssemblyFileVersion("7.0.0.19")] +[assembly: AssemblyVersion("7.0.0.20")] +[assembly: AssemblyFileVersion("7.0.0.20")] diff --git a/VERSION b/VERSION index 5844d366..26e307cd 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ -7.0.0-alpha.19 -7.0.0.19 +7.0.0-beta.1 +7.0.0.20 diff --git a/XLToolbox/Command.cs b/XLToolbox/Command.cs index cd20447a..3c37818f 100755 --- a/XLToolbox/Command.cs +++ b/XLToolbox/Command.cs @@ -39,5 +39,35 @@ public enum Command SaveCsvWithParams, SaveCsvRange, SaveCsvRangeWithParams, + OpenFromCell, + CopyPageSetup, + SelectAllShapes, + Anova1Way, + AnovaRepeat, + Anova2Way, + FormulaBuilder, + SelectionAssistant, + LinearRegression, + Correlation, + TransposeWizard, + MultiHisto, + Allocate, + LastErrorBars, + AutomaticErrorBars, + InteractiveErrorBars, + ChartDesign, + MoveDataSeriesLeft, + MoveDataSeriesRight, + Annotate, + SpreadScatter, + SeriesToFront, + SeriesForward, + SeriesBackward, + SeriesToBack, + AddSeries, + CopyChart, + PointChart, + Watermark, + Prefs, } } diff --git a/XLToolbox/Csv/CsvExportViewModel.cs b/XLToolbox/Csv/CsvExportViewModel.cs index bce943f3..c746b74d 100755 --- a/XLToolbox/Csv/CsvExportViewModel.cs +++ b/XLToolbox/Csv/CsvExportViewModel.cs @@ -188,9 +188,9 @@ public override object RevealModelObject() private void DoChooseFileName() { WorkbookStorage.Store store = new WorkbookStorage.Store(); + string defaultPath = Excel.ViewModels.Instance.Default.ActivePath; ChooseExportFileNameMessage.Send( - new FileNameMessageContent( - store.Get("csv_path", Excel.ViewModels.Instance.Default.ActiveWorkbook.Path), + new FileNameMessageContent(store.Get("csv_path", defaultPath), "CSV files|*.csv;*.txt;*.dat|All files|*.*"), ConfirmChooseFileName); } diff --git a/XLToolbox/Csv/CsvImportViewModel.cs b/XLToolbox/Csv/CsvImportViewModel.cs index 81953ded..ba2868b4 100755 --- a/XLToolbox/Csv/CsvImportViewModel.cs +++ b/XLToolbox/Csv/CsvImportViewModel.cs @@ -155,7 +155,7 @@ private void DoChooseFileName() WorkbookStorage.Store store = new WorkbookStorage.Store(); ChooseImportFileNameMessage.Send( new FileNameMessageContent( - store.Get("csv_path", Excel.ViewModels.Instance.Default.ActiveWorkbook.Path), + store.Get("csv_path", Excel.ViewModels.Instance.Default.ActivePath), "CSV files|*.csv;*.txt;*.dat|All files|*.*"), ConfirmChooseFileName); } diff --git a/XLToolbox/Dispatcher.cs b/XLToolbox/Dispatcher.cs index 6fb37dd8..50194250 100755 --- a/XLToolbox/Dispatcher.cs +++ b/XLToolbox/Dispatcher.cs @@ -71,6 +71,37 @@ public static void Execute(Command cmd) case Command.SaveCsvWithParams: SaveCsvWithSettings(); break; case Command.SaveCsvRange: SaveCsvRange(); break; case Command.SaveCsvRangeWithParams: SaveCsvRangeWithSettings(); break; + case Command.Anova1Way: Anova1Way(); break; + case Command.Anova2Way: Anova2Way(); break; + case Command.AnovaRepeat: LastAnova(); break; + case Command.AutomaticErrorBars: ErrorBarsAutomatic(); break; + case Command.InteractiveErrorBars: ErrorBarsInteractive(); break; + case Command.LastErrorBars: LastErrorBars(); break; + case Command.OpenFromCell: + case Command.CopyPageSetup: + case Command.SelectAllShapes: + case Command.FormulaBuilder: + case Command.SelectionAssistant: + case Command.LinearRegression: + case Command.Correlation: + case Command.TransposeWizard: + case Command.MultiHisto: + case Command.Allocate: + case Command.ChartDesign: + case Command.MoveDataSeriesLeft: + case Command.MoveDataSeriesRight: + case Command.Annotate: + case Command.SpreadScatter: + case Command.SeriesToFront: + case Command.SeriesForward: + case Command.SeriesBackward: + case Command.SeriesToBack: + case Command.AddSeries: + case Command.CopyChart: + case Command.PointChart: + case Command.Watermark: + case Command.Prefs: + Legacy.LegacyToolbox.Default.RunCommand(cmd); break; default: throw new NotImplementedException("Don't know what to do with " + cmd.ToString()); } @@ -239,6 +270,48 @@ static void SaveCsvRangeWithSettings() } } + static void Anova1Way() + { + Properties.Settings.Default.LastAnova = 1; + Properties.Settings.Default.Save(); + Legacy.LegacyToolbox.Default.RunCommand(Command.Anova1Way); + } + + static void Anova2Way() + { + Properties.Settings.Default.LastAnova = 2; + Properties.Settings.Default.Save(); + Legacy.LegacyToolbox.Default.RunCommand(Command.Anova2Way); + } + + static void LastAnova() + { + Command c = Properties.Settings.Default.LastAnova == 2 ? + Command.Anova2Way : Command.Anova1Way; + Legacy.LegacyToolbox.Default.RunCommand(c); + } + + static void ErrorBarsAutomatic() + { + Properties.Settings.Default.LastErrorBars = 1; + Properties.Settings.Default.Save(); + Legacy.LegacyToolbox.Default.RunCommand(Command.AutomaticErrorBars); + } + + static void ErrorBarsInteractive() + { + Properties.Settings.Default.LastErrorBars = 2; + Properties.Settings.Default.Save(); + Legacy.LegacyToolbox.Default.RunCommand(Command.InteractiveErrorBars); + } + + static void LastErrorBars() + { + Command c = Properties.Settings.Default.LastErrorBars == 2 ? + Command.InteractiveErrorBars : Command.AutomaticErrorBars; + Legacy.LegacyToolbox.Default.RunCommand(c); + } + #endregion #region Private helper methods diff --git a/XLToolbox/Excel/ViewModels/Instance.cs b/XLToolbox/Excel/ViewModels/Instance.cs index 39686b76..30cc8f87 100755 --- a/XLToolbox/Excel/ViewModels/Instance.cs +++ b/XLToolbox/Excel/ViewModels/Instance.cs @@ -149,6 +149,25 @@ public Workbook ActiveWorkbook } } + /// + /// Returns the active path. This is either the path + /// of the active workbook, or the current working + /// directory. + /// + /// + /// If a workbook is opened as in Protected View and + /// is the only open workbook, Application.ActiveWorkbook + /// will be null. Therefore this helper property was + /// invented. + /// + public string ActivePath + { + get + { + return ActiveWorkbook == null ? System.IO.Directory.GetCurrentDirectory() : ActiveWorkbook.Path; + } + } + /// /// Gets the Excel version and build number in a human-friendly form. /// diff --git a/XLToolbox/Legacy/LegacyToolbox.cs b/XLToolbox/Legacy/LegacyToolbox.cs new file mode 100755 index 00000000..7ab6f140 --- /dev/null +++ b/XLToolbox/Legacy/LegacyToolbox.cs @@ -0,0 +1,204 @@ +using Bovender.Mvvm.Actions; +/* LegacyToolbox.cs + * part of Daniel's XL Toolbox NG + * + * Copyright 2014-2016 Daniel Kraus + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +using System; +using System.IO; +using System.Threading.Tasks; +using XLToolbox.Excel.ViewModels; + +namespace XLToolbox.Legacy +{ + public class LegacyToolbox + { + private const string ADDIN_RESOURCE_NAME = "XLToolbox.Legacy.xltb-legacy-addin.xlam"; + + #region Static methods + + /// + /// Detects if a .XLAM or .XLA version of the XL Toolbox is installed, + /// and if so, issues a notice to the user and deactivates the VBA add-in. + /// + public static void DeactivateObsoleteVbaAddin() + { + foreach (Microsoft.Office.Interop.Excel.AddIn addin in Instance.Default.Application.AddIns) + { + if (addin.Name.StartsWith("Daniels XL Toolbox.xla") && addin.Installed) + { + NotificationAction a = new NotificationAction(); + a.Message = Strings.LegacyToolboxDetectedMessage; + a.Caption = Strings.LegacyToolboxDetectedCaption; + a.OkButtonLabel = Strings.OK; + a.Invoke(); + addin.Installed = false; + break; + } + } + } + + #endregion + + #region Singleton + + public static LegacyToolbox Default + { + get { return _lazy.Value; } + } + + #endregion + + #region Constructor + + private LegacyToolbox() { } + + #endregion + + #region Public command method + + public void RunCommand(Command command) + { + Microsoft.Office.Interop.Excel.Application app = Instance.Default.Application; + switch (command) + { + case Command.OpenFromCell: + app.Run("RunOpenFromCell"); + break; + case Command.CopyPageSetup: + app.Run("RunCopyPageSetup"); + break; + case Command.SelectAllShapes: + app.Run("RunSelectAllShapes"); + break; + case Command.Anova1Way: + app.Run("RunANOVA"); + break; + case Command.Anova2Way: + app.Run("RunANOVA2Way"); + break; + case Command.FormulaBuilder: + app.Run("RunFormulaBuilder"); + break; + case Command.SelectionAssistant: + app.Run("RunSelectionAssistant"); + break; + case Command.LinearRegression: + app.Run("RunLinearRegression"); + break; + case Command.Correlation: + app.Run("RunCorrelation"); + break; + case Command.TransposeWizard: + app.Run("RunTransposeWizard"); + break; + case Command.MultiHisto: + app.Run("RunMultiHistogram"); + break; + case Command.Allocate: + app.Run("RunGroupAllocation"); + break; + case Command.AutomaticErrorBars: + app.Run("RunErrorBarsAuto"); + break; + case Command.InteractiveErrorBars: + app.Run("RunErrorBarsInteractive"); + break; + case Command.ChartDesign: + app.Run("RunChartDesign"); + break; + case Command.MoveDataSeriesLeft: + app.Run("RunMoveDataSeriesLeft"); + break; + case Command.MoveDataSeriesRight: + app.Run("RunMoveDataSeriesRight"); + break; + case Command.Annotate: + app.Run("RunChartAnnotation"); + break; + case Command.SpreadScatter: + app.Run("RunSpreadScatter"); + break; + case Command.SeriesToFront: + app.Run("RunSeriesToFront"); + break; + case Command.SeriesForward: + app.Run("RunSeriesForward"); + break; + case Command.SeriesBackward: + app.Run("RunSeriesBackward"); + break; + case Command.SeriesToBack: + app.Run("RunSeriesToBack"); + break; + case Command.AddSeries: + app.Run("RunAddSeries"); + break; + case Command.CopyChart: + app.Run("RunCopyChart"); + break; + case Command.PointChart: + app.Run("RunPointChart"); + break; + case Command.Watermark: + app.Run("RuneWatermark"); + break; + case Command.Prefs: + app.Run("RunPreferences"); + break; + default: + throw new InvalidOperationException("Unknown legacy command " + command.ToString()); + } + } + + #endregion + + #region Private methods + + /// + /// Loads the legacy .xlam file if it has not been loaded yet. + /// + private static void LoadAddinIfNeeded() + { + Stream resourceStream = typeof(LegacyToolbox).Assembly + .GetManifestResourceStream(ADDIN_RESOURCE_NAME); + if (resourceStream == null) + { + throw new IOException("Unable to open resource stream " + ADDIN_RESOURCE_NAME); + } + string tempDir = Path.GetTempPath(); + string addinFile = Path.Combine(tempDir, ADDIN_RESOURCE_NAME); + Stream tempStream = File.Create(addinFile); + resourceStream.CopyTo(tempStream); + tempStream.Close(); + resourceStream.Close(); + Instance.Default.Application.Workbooks.Open(addinFile); + } + + #endregion + + #region Private static fields + + private static Lazy _lazy = new Lazy( + () => + { + LoadAddinIfNeeded(); + return new LegacyToolbox(); + } + ); + + #endregion + } +} diff --git a/XLToolbox/Legacy/xltb-legacy-addin.xlam b/XLToolbox/Legacy/xltb-legacy-addin.xlam new file mode 100644 index 00000000..e88216c1 Binary files /dev/null and b/XLToolbox/Legacy/xltb-legacy-addin.xlam differ diff --git a/XLToolbox/Properties/AssemblyInfo.cs b/XLToolbox/Properties/AssemblyInfo.cs index 7a272267..a7869d1f 100755 --- a/XLToolbox/Properties/AssemblyInfo.cs +++ b/XLToolbox/Properties/AssemblyInfo.cs @@ -49,5 +49,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("7.0.0.19")] -[assembly: AssemblyFileVersion("7.0.0.19")] +[assembly: AssemblyVersion("7.0.0.20")] +[assembly: AssemblyFileVersion("7.0.0.20")] diff --git a/XLToolbox/Properties/Settings.Designer.cs b/XLToolbox/Properties/Settings.Designer.cs index c1aa5702..e5f490d6 100755 --- a/XLToolbox/Properties/Settings.Designer.cs +++ b/XLToolbox/Properties/Settings.Designer.cs @@ -177,5 +177,29 @@ public bool WindowManagerAlwaysOnTop { this["CsvExport"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("0")] + public int LastAnova { + get { + return ((int)(this["LastAnova"])); + } + set { + this["LastAnova"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("0")] + public int LastErrorBars { + get { + return ((int)(this["LastErrorBars"])); + } + set { + this["LastErrorBars"] = value; + } + } } } diff --git a/XLToolbox/Properties/Settings.settings b/XLToolbox/Properties/Settings.settings index 4ec4969d..6538107a 100755 --- a/XLToolbox/Properties/Settings.settings +++ b/XLToolbox/Properties/Settings.settings @@ -47,5 +47,11 @@ + + 0 + + + 0 + \ No newline at end of file diff --git a/XLToolbox/Strings.Designer.cs b/XLToolbox/Strings.Designer.cs index 1c80ff59..43d0e232 100755 --- a/XLToolbox/Strings.Designer.cs +++ b/XLToolbox/Strings.Designer.cs @@ -762,6 +762,24 @@ public static string Layout { } } + /// + /// Looks up a localized string similar to Obsolete XL Toolbox version found. + /// + public static string LegacyToolboxDetectedCaption { + get { + return ResourceManager.GetString("LegacyToolboxDetectedCaption", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to An obsolete version of the XL Toolbox was found. It will be deactivated now. You can use old XL Toolbox commands in the new, Next-Generation version. You may want to uninstall the old version from your system using "Add/Remove Software".. + /// + public static string LegacyToolboxDetectedMessage { + get { + return ResourceManager.GetString("LegacyToolboxDetectedMessage", resourceCulture); + } + } + /// /// Looks up a localized string similar to License. /// diff --git a/XLToolbox/Strings.resx b/XLToolbox/Strings.resx index 94e5c24f..16217acf 100755 --- a/XLToolbox/Strings.resx +++ b/XLToolbox/Strings.resx @@ -627,4 +627,10 @@ You may want to try again. Hint: Use \t to separate fields by tabs. + + Obsolete XL Toolbox version found + + + An obsolete version of the XL Toolbox was found. It will be deactivated now. You can use old XL Toolbox commands in the new, Next-Generation version. You may want to uninstall the old version from your system using "Add/Remove Software". + \ No newline at end of file diff --git a/XLToolbox/XLToolbox.csproj b/XLToolbox/XLToolbox.csproj index 9bd8c1f4..dc29c7ce 100755 --- a/XLToolbox/XLToolbox.csproj +++ b/XLToolbox/XLToolbox.csproj @@ -160,6 +160,7 @@ + @@ -239,6 +240,7 @@ + SettingsSingleFileGenerator diff --git a/XLToolbox/app.config b/XLToolbox/app.config index e0b7ce47..73af9df3 100755 --- a/XLToolbox/app.config +++ b/XLToolbox/app.config @@ -72,6 +72,12 @@ True + + 0 + + + 0 + \ No newline at end of file diff --git a/XLToolboxForExcel/Properties/AssemblyInfo.cs b/XLToolboxForExcel/Properties/AssemblyInfo.cs index edb7b311..f806b9ef 100755 --- a/XLToolboxForExcel/Properties/AssemblyInfo.cs +++ b/XLToolboxForExcel/Properties/AssemblyInfo.cs @@ -51,7 +51,7 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("7.0.0.19")] -[assembly: AssemblyFileVersion("7.0.0.19")] +[assembly: AssemblyVersion("7.0.0.20")] +[assembly: AssemblyFileVersion("7.0.0.20")] [assembly: NeutralResourcesLanguageAttribute("en-US")] diff --git a/XLToolboxForExcel/Ribbon.cs b/XLToolboxForExcel/Ribbon.cs index d88d790e..94d4ad93 100755 --- a/XLToolboxForExcel/Ribbon.cs +++ b/XLToolboxForExcel/Ribbon.cs @@ -74,7 +74,37 @@ public Ribbon() { "ButtonSaveCsv", Command.SaveCsv }, { "ButtonSaveCsvWithParams", Command.SaveCsvWithParams }, { "ButtonSaveCsvRange", Command.SaveCsvRange }, - { "ButtonSaveCsvRangeWithParams", Command.SaveCsvRangeWithParams}, + { "ButtonSaveCsvRangeWithParams", Command.SaveCsvRangeWithParams }, + { "ButtonOpenFromCell", Command.OpenFromCell }, + { "ButtonCopyPageSetup", Command.CopyPageSetup }, + { "ButtonSelectAllShapes", Command.SelectAllShapes }, + { "ButtonAnova1Way", Command.Anova1Way }, + { "ButtonRepeatAnova", Command.AnovaRepeat }, + { "ButtonAnova2Way", Command.Anova2Way }, + { "ButtonFormulaBuilder", Command.FormulaBuilder }, + { "ButtonSelectionAssistant", Command.SelectionAssistant }, + { "ButtonLinearRegression", Command.LinearRegression }, + { "ButtonCorrelation", Command.Correlation }, + { "ButtonTransposeWizard", Command.TransposeWizard }, + { "ButtonMultiHisto", Command.MultiHisto }, + { "ButtonAllocate", Command.Allocate }, + { "ButtonLastErrorBars", Command.LastErrorBars }, + { "ButtonAutomaticErrorBars", Command.AutomaticErrorBars }, + { "ButtonInteractiveErrorBars", Command.InteractiveErrorBars }, + { "ButtonChartDesign", Command.ChartDesign }, + { "ButtonMoveDataSeriesLeft", Command.MoveDataSeriesLeft }, + { "ButtonMoveDataSeriesRight", Command.MoveDataSeriesRight }, + { "ButtonAnnotate", Command.Annotate }, + { "ButtonSpreadScatter", Command.SpreadScatter }, + { "ButtonSeriesToFront", Command.SeriesToFront }, + { "ButtonSeriesForward", Command.SeriesForward }, + { "ButtonSeriesBackward", Command.SeriesBackward }, + { "ButtonSeriesToBack", Command.SeriesToBack }, + { "ButtonAddSeries", Command.AddSeries }, + { "ButtonCopyChart", Command.CopyChart }, + { "ButtonPointChart", Command.PointChart }, + { "ButtonWatermark", Command.Watermark }, + { "ButtonPrefs", Command.Prefs }, }; XLToolbox.Versioning.UpdaterViewModel.Instance.PropertyChanged += UpdaterViewModel_PropertyChanged; diff --git a/XLToolboxForExcel/Ribbon.xml b/XLToolboxForExcel/Ribbon.xml index 8b2fdad3..564e4ad7 100755 --- a/XLToolboxForExcel/Ribbon.xml +++ b/XLToolboxForExcel/Ribbon.xml @@ -25,6 +25,17 @@