diff --git a/Wox.Core/Configuration/IPortable.cs b/Wox.Core/Configuration/IPortable.cs
new file mode 100644
index 000000000..e92db779a
--- /dev/null
+++ b/Wox.Core/Configuration/IPortable.cs
@@ -0,0 +1,13 @@
+
+namespace Wox.Core.Configuration
+{
+ public interface IPortable
+ {
+ void EnablePortableMode();
+ void DisablePortableMode();
+ void RemoveShortcuts();
+ void RemoveUninstallerEntry();
+ bool IsPortableModeEnabled();
+ void MoveUserDataFolder(string fromLocation, string toLocation);
+ }
+}
\ No newline at end of file
diff --git a/Wox.Core/Configuration/Portable.cs b/Wox.Core/Configuration/Portable.cs
new file mode 100644
index 000000000..92f6fac2d
--- /dev/null
+++ b/Wox.Core/Configuration/Portable.cs
@@ -0,0 +1,68 @@
+using Squirrel;
+using System;
+using Wox.Infrastructure;
+
+namespace Wox.Core.Configuration
+{
+ public class Portable : IPortable
+ {
+ private string applicationName;
+ private string exeName;
+ private string rootAppDirectory;
+ private UpdateManager portabilityUpdater;
+
+ public Portable()
+ {
+ applicationName = Constant.Wox;
+ exeName = applicationName + ".exe";
+ rootAppDirectory = Constant.RootDirectory;
+ portabilityUpdater = new UpdateManager(string.Empty, applicationName, rootAppDirectory);
+ }
+
+ public void DisablePortableMode()
+ {
+ throw new NotImplementedException();
+ }
+
+ public void EnablePortableMode()
+ {
+ try
+ {
+ RemoveShortcuts();
+ RemoveUninstallerEntry();
+ }
+ catch (Exception e)
+ {
+ //log and update error message to output above locations where shortcuts may not have been removed
+#if DEBUG
+ throw;
+#else
+ throw;// PRODUCTION LOGGING AND CONTINUE
+
+#endif
+ }
+ }
+
+ public bool IsPortableModeEnabled()
+ {
+ throw new NotImplementedException();
+ }
+
+ public void RemoveShortcuts()
+ {
+ portabilityUpdater.RemoveShortcutsForExecutable(exeName, ShortcutLocation.StartMenu);
+ portabilityUpdater.RemoveShortcutsForExecutable(exeName, ShortcutLocation.Desktop);
+ portabilityUpdater.RemoveShortcutsForExecutable(exeName, ShortcutLocation.Startup);
+ }
+
+ public void RemoveUninstallerEntry()
+ {
+ portabilityUpdater.RemoveUninstallerRegistryEntry();
+ }
+
+ public void MoveUserDataFolder(string fromLocation, string toLocation)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/Wox.Core/Wox.Core.csproj b/Wox.Core/Wox.Core.csproj
index c1758fdb3..b3d0adc8b 100644
--- a/Wox.Core/Wox.Core.csproj
+++ b/Wox.Core/Wox.Core.csproj
@@ -51,6 +51,8 @@
Properties\SolutionAssemblyInfo.cs
+
+
diff --git a/Wox.Infrastructure/Wox.cs b/Wox.Infrastructure/Wox.cs
index 396ee0bb1..61e2b411f 100644
--- a/Wox.Infrastructure/Wox.cs
+++ b/Wox.Infrastructure/Wox.cs
@@ -25,6 +25,8 @@ namespace Wox.Infrastructure
private static readonly Assembly Assembly = Assembly.GetExecutingAssembly();
public static readonly string ProgramDirectory = Directory.GetParent(Assembly.Location.NonNull()).ToString();
+ private static readonly string ApplicationDirectory = Directory.GetParent(ProgramDirectory).ToString();
+ public static readonly string RootDirectory = Directory.GetParent(ApplicationDirectory).ToString();
public static readonly string ExecutablePath = Path.Combine(ProgramDirectory, Wox + ".exe");
public static readonly string DataDirectory = DetermineDataDirectory();
public static readonly string PluginsDirectory = Path.Combine(DataDirectory, Plugins);
diff --git a/Wox/App.xaml.cs b/Wox/App.xaml.cs
index 0fc1e8c95..96c2858af 100644
--- a/Wox/App.xaml.cs
+++ b/Wox/App.xaml.cs
@@ -4,6 +4,7 @@ using System.Threading.Tasks;
using System.Timers;
using System.Windows;
using Wox.Core;
+using Wox.Core.Configuration;
using Wox.Core.Plugin;
using Wox.Core.Resource;
using Wox.Helper;
@@ -26,6 +27,7 @@ namespace Wox
private MainViewModel _mainVM;
private SettingWindowViewModel _settingsVM;
private readonly Updater _updater = new Updater(Wox.Properties.Settings.Default.GithubRepo);
+ private readonly Portable _portable = new Portable();
private readonly Alphabet _alphabet = new Alphabet();
private StringMatcher _stringMatcher;
@@ -53,7 +55,7 @@ namespace Wox
ImageLoader.Initialize();
- _settingsVM = new SettingWindowViewModel(_updater);
+ _settingsVM = new SettingWindowViewModel(_updater, _portable);
_settings = _settingsVM.Settings;
_alphabet.Initialize(_settings);
diff --git a/Wox/ViewModel/SettingWindowViewModel.cs b/Wox/ViewModel/SettingWindowViewModel.cs
index 923e456b0..b827130b1 100644
--- a/Wox/ViewModel/SettingWindowViewModel.cs
+++ b/Wox/ViewModel/SettingWindowViewModel.cs
@@ -8,6 +8,7 @@ using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using Wox.Core;
+using Wox.Core.Configuration;
using Wox.Core.Plugin;
using Wox.Core.Resource;
using Wox.Helper;
@@ -22,11 +23,13 @@ namespace Wox.ViewModel
public class SettingWindowViewModel : BaseModel
{
private readonly Updater _updater;
+ private readonly IPortable _portable;
private readonly WoxJsonStorage _storage;
- public SettingWindowViewModel(Updater updater)
+ public SettingWindowViewModel(Updater updater, IPortable portable)
{
_updater = updater;
+ _portable = portable;
_storage = new WoxJsonStorage();
Settings = _storage.Load();
Settings.PropertyChanged += (s, e) =>
@@ -47,6 +50,11 @@ namespace Wox.ViewModel
await _updater.UpdateApp();
}
+ public void EnablePortableMode()
+ {
+ _portable.EnablePortableMode();
+ }
+
public void Save()
{
_storage.Save();