mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 20:27:36 +02:00
Remove unused updater and command line arguments
This commit is contained in:
@@ -1,16 +0,0 @@
|
|||||||
namespace Wox.Core.Updater
|
|
||||||
{
|
|
||||||
public class Release
|
|
||||||
{
|
|
||||||
public string version { get; set; }
|
|
||||||
public string download_link { get; set; }
|
|
||||||
public string download_link1 { get; set; }
|
|
||||||
public string download_link2 { get; set; }
|
|
||||||
public string description { get; set; }
|
|
||||||
|
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,95 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Wox.Infrastructure.Exception;
|
|
||||||
|
|
||||||
namespace Wox.Core.Updater
|
|
||||||
{
|
|
||||||
public class SemanticVersion : IComparable
|
|
||||||
{
|
|
||||||
public int MAJOR { get; set; }
|
|
||||||
public int MINOR { get; set; }
|
|
||||||
public int PATCH { get; set; }
|
|
||||||
|
|
||||||
public SemanticVersion(Version version)
|
|
||||||
{
|
|
||||||
MAJOR = version.Major;
|
|
||||||
MINOR = version.Minor;
|
|
||||||
PATCH = version.Build;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SemanticVersion(int major, int minor, int patch)
|
|
||||||
{
|
|
||||||
MAJOR = major;
|
|
||||||
MINOR = minor;
|
|
||||||
PATCH = patch;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SemanticVersion(string version)
|
|
||||||
{
|
|
||||||
var strings = version.Split('.');
|
|
||||||
if (strings.Length != 3)
|
|
||||||
{
|
|
||||||
throw new WoxException("Invalid semantic version");
|
|
||||||
}
|
|
||||||
MAJOR = int.Parse(strings[0]);
|
|
||||||
MINOR = int.Parse(strings[1]);
|
|
||||||
PATCH = int.Parse(strings[2]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool operator >(SemanticVersion v1, SemanticVersion v2)
|
|
||||||
{
|
|
||||||
return v1.CompareTo(v2) > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool operator <(SemanticVersion v1, SemanticVersion v2)
|
|
||||||
{
|
|
||||||
return v1.CompareTo(v2) < 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool operator ==(SemanticVersion v1, SemanticVersion v2)
|
|
||||||
{
|
|
||||||
if (ReferenceEquals(v1, null))
|
|
||||||
{
|
|
||||||
return ReferenceEquals(v2, null);
|
|
||||||
}
|
|
||||||
if (ReferenceEquals(v2, null))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return v1.Equals(v2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool operator !=(SemanticVersion v1, SemanticVersion v2)
|
|
||||||
{
|
|
||||||
return !(v1 == v2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
return string.Format("{0}.{1}.{2}", MAJOR, MINOR, PATCH);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool Equals(object version)
|
|
||||||
{
|
|
||||||
var v2 = (SemanticVersion)version;
|
|
||||||
return MAJOR == v2.MAJOR && MINOR == v2.MINOR && PATCH == v2.PATCH;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int CompareTo(object version)
|
|
||||||
{
|
|
||||||
var v2 = (SemanticVersion)version;
|
|
||||||
if (MAJOR == v2.MAJOR)
|
|
||||||
{
|
|
||||||
if (MINOR == v2.MINOR)
|
|
||||||
{
|
|
||||||
if (PATCH == v2.PATCH)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return PATCH - v2.PATCH;
|
|
||||||
}
|
|
||||||
return MINOR - v2.MINOR;
|
|
||||||
}
|
|
||||||
return MAJOR - v2.MAJOR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,182 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using NAppUpdate.Framework;
|
|
||||||
using NAppUpdate.Framework.Common;
|
|
||||||
using NAppUpdate.Framework.Sources;
|
|
||||||
using NAppUpdate.Framework.Tasks;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Wox.Core.Resource;
|
|
||||||
using Wox.Core.UserSettings;
|
|
||||||
using Wox.Infrastructure.Http;
|
|
||||||
using Wox.Infrastructure.Logger;
|
|
||||||
|
|
||||||
namespace Wox.Core.Updater
|
|
||||||
{
|
|
||||||
public class UpdaterManager
|
|
||||||
{
|
|
||||||
private static UpdaterManager instance;
|
|
||||||
private const string VersionCheckURL = "http://api.getwox.com/release/latest/";
|
|
||||||
private const string UpdateFeedURL = "http://upgrade.getwox.com/update.xml";
|
|
||||||
//private const string UpdateFeedURL = "http://127.0.0.1:8888/update.xml";
|
|
||||||
private static SemanticVersion currentVersion;
|
|
||||||
public UserSettings.Settings Settings { get; set; }
|
|
||||||
|
|
||||||
public event EventHandler PrepareUpdateReady;
|
|
||||||
public event EventHandler UpdateError;
|
|
||||||
|
|
||||||
public Release NewRelease { get; set; }
|
|
||||||
|
|
||||||
public static UpdaterManager Instance
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (instance == null)
|
|
||||||
{
|
|
||||||
instance = new UpdaterManager();
|
|
||||||
}
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private UpdaterManager()
|
|
||||||
{
|
|
||||||
UpdateManager.Instance.UpdateSource = GetUpdateSource();
|
|
||||||
}
|
|
||||||
|
|
||||||
public SemanticVersion CurrentVersion
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (currentVersion == null)
|
|
||||||
{
|
|
||||||
currentVersion = new SemanticVersion(Assembly.GetExecutingAssembly().GetName().Version);
|
|
||||||
}
|
|
||||||
return currentVersion;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool IsNewerThanCurrent(Release release)
|
|
||||||
{
|
|
||||||
if (release == null) return false;
|
|
||||||
|
|
||||||
return new SemanticVersion(release.version) > CurrentVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<string> GetAvailableUpdateFiles()
|
|
||||||
{
|
|
||||||
List<string> files = new List<string>();
|
|
||||||
foreach (var task in UpdateManager.Instance.Tasks)
|
|
||||||
{
|
|
||||||
if (task is FileUpdateTask)
|
|
||||||
{
|
|
||||||
files.Add(((FileUpdateTask)task).LocalPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return files;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CheckUpdate()
|
|
||||||
{
|
|
||||||
Task.Run(() =>
|
|
||||||
{
|
|
||||||
string json = HttpRequest.Get(VersionCheckURL, HttpProxy.Instance);
|
|
||||||
if (!string.IsNullOrEmpty(json))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
NewRelease = JsonConvert.DeserializeObject<Release>(json);
|
|
||||||
if (IsNewerThanCurrent(NewRelease) && !Settings.DontPromptUpdateMsg)
|
|
||||||
{
|
|
||||||
StartUpdate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Log.Error(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void StartUpdate()
|
|
||||||
{
|
|
||||||
UpdateManager updManager = UpdateManager.Instance;
|
|
||||||
updManager.BeginCheckForUpdates(asyncResult =>
|
|
||||||
{
|
|
||||||
if (asyncResult.IsCompleted)
|
|
||||||
{
|
|
||||||
// still need to check for caught exceptions if any and rethrow
|
|
||||||
try
|
|
||||||
{
|
|
||||||
((UpdateProcessAsyncResult)asyncResult).EndInvoke();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
updManager.CleanUp();
|
|
||||||
Log.Error(e);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// No updates were found, or an error has occured. We might want to check that...
|
|
||||||
if (updManager.UpdatesAvailable == 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
updManager.BeginPrepareUpdates(result =>
|
|
||||||
{
|
|
||||||
((UpdateProcessAsyncResult)result).EndInvoke();
|
|
||||||
OnPrepareUpdateReady();
|
|
||||||
}, null);
|
|
||||||
}, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CleanUp()
|
|
||||||
{
|
|
||||||
UpdateManager.Instance.CleanUp();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ApplyUpdates()
|
|
||||||
{
|
|
||||||
// ApplyUpdates is a synchronous method by design. Make sure to save all user work before calling
|
|
||||||
// it as it might restart your application
|
|
||||||
// get out of the way so the console window isn't obstructed
|
|
||||||
try
|
|
||||||
{
|
|
||||||
UpdateManager.Instance.ApplyUpdates(true, Settings.EnableUpdateLog, false);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
string updateError = InternationalizationManager.Instance.GetTranslation("update_wox_update_error");
|
|
||||||
Log.Error(e);
|
|
||||||
MessageBox.Show(updateError);
|
|
||||||
OnUpdateError();
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdateManager.Instance.CleanUp();
|
|
||||||
}
|
|
||||||
|
|
||||||
private IUpdateSource GetUpdateSource()
|
|
||||||
{
|
|
||||||
var source = new WoxUpdateSource(UpdateFeedURL, HttpRequest.GetWebProxy(HttpProxy.Instance));
|
|
||||||
return source;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void OnPrepareUpdateReady()
|
|
||||||
{
|
|
||||||
var handler = PrepareUpdateReady;
|
|
||||||
if (handler != null) handler(this, EventArgs.Empty);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void OnUpdateError()
|
|
||||||
{
|
|
||||||
var handler = UpdateError;
|
|
||||||
if (handler != null) handler(this, EventArgs.Empty);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
using System.Net;
|
|
||||||
using NAppUpdate.Framework.Common;
|
|
||||||
using NAppUpdate.Framework.Sources;
|
|
||||||
using NAppUpdate.Framework.Utils;
|
|
||||||
|
|
||||||
namespace Wox.Core.Updater
|
|
||||||
{
|
|
||||||
internal class WoxUpdateSource : IUpdateSource
|
|
||||||
{
|
|
||||||
public IWebProxy Proxy { get; set; }
|
|
||||||
|
|
||||||
public string FeedUrl { get; set; }
|
|
||||||
|
|
||||||
public WoxUpdateSource(string feedUrl,IWebProxy proxy)
|
|
||||||
{
|
|
||||||
FeedUrl = feedUrl;
|
|
||||||
Proxy = proxy;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void TryResolvingHost()
|
|
||||||
{
|
|
||||||
Uri uri = new Uri(FeedUrl);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Dns.GetHostEntry(uri.Host);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
throw new WebException(string.Format("Failed to resolve {0}. Check your connectivity.", uri.Host), WebExceptionStatus.ConnectFailure);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string GetUpdatesFeed()
|
|
||||||
{
|
|
||||||
TryResolvingHost();
|
|
||||||
string str = string.Empty;
|
|
||||||
WebRequest webRequest = WebRequest.Create(FeedUrl);
|
|
||||||
webRequest.Method = "GET";
|
|
||||||
webRequest.Proxy = Proxy;
|
|
||||||
using (WebResponse response = webRequest.GetResponse())
|
|
||||||
{
|
|
||||||
Stream responseStream = response.GetResponseStream();
|
|
||||||
if (responseStream != null)
|
|
||||||
{
|
|
||||||
using (StreamReader streamReader = new StreamReader(responseStream, true))
|
|
||||||
str = streamReader.ReadToEnd();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool GetData(string url, string baseUrl, Action<UpdateProgressInfo> onProgress, ref string tempLocation)
|
|
||||||
{
|
|
||||||
if (!string.IsNullOrEmpty(baseUrl) && !baseUrl.EndsWith("/"))
|
|
||||||
baseUrl += "/";
|
|
||||||
FileDownloader fileDownloader = !Uri.IsWellFormedUriString(url, UriKind.Absolute) ? (!Uri.IsWellFormedUriString(baseUrl, UriKind.Absolute) ? (string.IsNullOrEmpty(baseUrl) ? new FileDownloader(url) : new FileDownloader(new Uri(new Uri(baseUrl), url))) : new FileDownloader(new Uri(new Uri(baseUrl, UriKind.Absolute), url))) : new FileDownloader(url);
|
|
||||||
fileDownloader.Proxy = Proxy;
|
|
||||||
if (string.IsNullOrEmpty(tempLocation) || !Directory.Exists(Path.GetDirectoryName(tempLocation)))
|
|
||||||
tempLocation = Path.GetTempFileName();
|
|
||||||
return fileDownloader.DownloadToFile(tempLocation, onProgress);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -67,9 +67,6 @@
|
|||||||
<Compile Include="APIServer.cs" />
|
<Compile Include="APIServer.cs" />
|
||||||
<Compile Include="Plugin\ExecutablePlugin.cs" />
|
<Compile Include="Plugin\ExecutablePlugin.cs" />
|
||||||
<Compile Include="Plugin\PluginsLoader.cs" />
|
<Compile Include="Plugin\PluginsLoader.cs" />
|
||||||
<Compile Include="Updater\Release.cs" />
|
|
||||||
<Compile Include="Updater\UpdaterManager.cs" />
|
|
||||||
<Compile Include="Updater\WoxUpdateSource.cs" />
|
|
||||||
<Compile Include="UserSettings\HttpProxy.cs" />
|
<Compile Include="UserSettings\HttpProxy.cs" />
|
||||||
<Compile Include="Resource\AvailableLanguages.cs" />
|
<Compile Include="Resource\AvailableLanguages.cs" />
|
||||||
<Compile Include="Resource\Internationalization.cs" />
|
<Compile Include="Resource\Internationalization.cs" />
|
||||||
@@ -90,7 +87,6 @@
|
|||||||
<Compile Include="UserSettings\PluginSettings.cs" />
|
<Compile Include="UserSettings\PluginSettings.cs" />
|
||||||
<Compile Include="UserSettings\PluginHotkey.cs" />
|
<Compile Include="UserSettings\PluginHotkey.cs" />
|
||||||
<Compile Include="UserSettings\Settings.cs" />
|
<Compile Include="UserSettings\Settings.cs" />
|
||||||
<Compile Include="Updater\SemanticVersion.cs" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ using System.Windows;
|
|||||||
using System.Windows.Documents;
|
using System.Windows.Documents;
|
||||||
using Exceptionless;
|
using Exceptionless;
|
||||||
using Wox.Core.Resource;
|
using Wox.Core.Resource;
|
||||||
using Wox.Core.Updater;
|
using Wox.Infrastructure;
|
||||||
|
|
||||||
namespace Wox.CrashReporter
|
namespace Wox.CrashReporter
|
||||||
{
|
{
|
||||||
@@ -23,7 +23,7 @@ namespace Wox.CrashReporter
|
|||||||
private void SetException(Exception exception)
|
private void SetException(Exception exception)
|
||||||
{
|
{
|
||||||
tbSummary.AppendText(exception.Message);
|
tbSummary.AppendText(exception.Message);
|
||||||
tbVersion.Text = UpdaterManager.Instance.CurrentVersion.ToString();
|
tbVersion.Text = Infrastructure.Wox.Version;
|
||||||
tbDatetime.Text = DateTime.Now.ToString();
|
tbDatetime.Text = DateTime.Now.ToString();
|
||||||
tbStackTrace.AppendText(exception.StackTrace);
|
tbStackTrace.AppendText(exception.StackTrace);
|
||||||
tbSource.Text = exception.Source;
|
tbSource.Text = exception.Source;
|
||||||
|
|||||||
@@ -78,6 +78,10 @@
|
|||||||
<Project>{B749F0DB-8E75-47DB-9E5E-265D16D0C0D2}</Project>
|
<Project>{B749F0DB-8E75-47DB-9E5E-265D16D0C0D2}</Project>
|
||||||
<Name>Wox.Core</Name>
|
<Name>Wox.Core</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\Wox.Infrastructure\Wox.Infrastructure.csproj">
|
||||||
|
<Project>{4fd29318-a8ab-4d8f-aa47-60bc241b8da3}</Project>
|
||||||
|
<Name>Wox.Infrastructure</Name>
|
||||||
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Resource Include="Images\crash_warning.png">
|
<Resource Include="Images\crash_warning.png">
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
@@ -10,11 +11,13 @@ namespace Wox.Infrastructure
|
|||||||
public const string Plugins = "Plugins";
|
public const string Plugins = "Plugins";
|
||||||
public const string Settings = "Settings";
|
public const string Settings = "Settings";
|
||||||
|
|
||||||
public static readonly string ProgramPath = Directory.GetParent(Assembly.GetExecutingAssembly().Location).ToString();
|
private static readonly Assembly Assembly = Assembly.GetExecutingAssembly();
|
||||||
|
public static readonly string ProgramPath = Directory.GetParent(Assembly.Location).ToString();
|
||||||
public static readonly string DataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Name);
|
public static readonly string DataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Name);
|
||||||
public static readonly string UserDirectory = Path.Combine(DataPath, Plugins);
|
public static readonly string UserDirectory = Path.Combine(DataPath, Plugins);
|
||||||
public static readonly string PreinstalledDirectory = Path.Combine(ProgramPath, Plugins);
|
public static readonly string PreinstalledDirectory = Path.Combine(ProgramPath, Plugins);
|
||||||
public static readonly string SettingsPath = Path.Combine(DataPath, Settings);
|
public static readonly string SettingsPath = Path.Combine(DataPath, Settings);
|
||||||
public const string Github = "https://github.com/Wox-launcher/Wox";
|
public const string Github = "https://github.com/Wox-launcher/Wox";
|
||||||
|
public static readonly string Version = FileVersionInfo.GetVersionInfo(Assembly.Location).ProductVersion;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
using NUnit.Framework;
|
|
||||||
using Wox.Core.Updater;
|
|
||||||
|
|
||||||
namespace Wox.Test
|
|
||||||
{
|
|
||||||
[TestFixture]
|
|
||||||
public class SemanticVersionTest
|
|
||||||
{
|
|
||||||
[Test]
|
|
||||||
public void CompareTest()
|
|
||||||
{
|
|
||||||
SemanticVersion v1 = new SemanticVersion(1, 1, 0);
|
|
||||||
SemanticVersion v2 = new SemanticVersion(1, 2, 0);
|
|
||||||
SemanticVersion v3 = new SemanticVersion(1, 1, 0);
|
|
||||||
SemanticVersion v4 = new SemanticVersion("1.1.0");
|
|
||||||
Assert.IsTrue(v1 < v2);
|
|
||||||
Assert.IsTrue(v2 > v1);
|
|
||||||
Assert.IsTrue(v1 == v3);
|
|
||||||
Assert.IsTrue(v1.Equals(v3));
|
|
||||||
Assert.IsTrue(v1 == v4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -52,7 +52,6 @@
|
|||||||
<Compile Include="Plugins\PluginInitTest.cs" />
|
<Compile Include="Plugins\PluginInitTest.cs" />
|
||||||
<Compile Include="QueryTest.cs" />
|
<Compile Include="QueryTest.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="SemanticVersionTest.cs" />
|
|
||||||
<Compile Include="UrlPluginTest.cs" />
|
<Compile Include="UrlPluginTest.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
|
||||||
using Wox.Helper;
|
|
||||||
|
|
||||||
namespace Wox.CommandArgs
|
|
||||||
{
|
|
||||||
internal static class CommandArgsFactory
|
|
||||||
{
|
|
||||||
private static List<ICommandArg> commandArgs;
|
|
||||||
|
|
||||||
static CommandArgsFactory()
|
|
||||||
{
|
|
||||||
var type = typeof(ICommandArg);
|
|
||||||
commandArgs = Assembly.GetExecutingAssembly()
|
|
||||||
.GetTypes()
|
|
||||||
.Where(p => type.IsAssignableFrom(p) && !p.IsInterface)
|
|
||||||
.Select(t => Activator.CreateInstance(t) as ICommandArg).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void Execute(IList<string> args)
|
|
||||||
{
|
|
||||||
// todo restart command line args?
|
|
||||||
//if (args.Count > 0 && args[0] != SingleInstance<App>.Restart)
|
|
||||||
if (args.Count > 0)
|
|
||||||
{
|
|
||||||
string command = args[0];
|
|
||||||
ICommandArg cmd = commandArgs.FirstOrDefault(o => o.Command.ToLower() == command);
|
|
||||||
if (cmd != null)
|
|
||||||
{
|
|
||||||
args.RemoveAt(0); //remove command itself
|
|
||||||
cmd.Execute(args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
App.API.ShowApp();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace Wox.CommandArgs
|
|
||||||
{
|
|
||||||
public class HideStartCommandArg : ICommandArg
|
|
||||||
{
|
|
||||||
public string Command
|
|
||||||
{
|
|
||||||
get { return "hidestart"; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Execute(IList<string> args)
|
|
||||||
{
|
|
||||||
//App.Window.ShowApp();
|
|
||||||
//App.Window.HideApp();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace Wox.CommandArgs
|
|
||||||
{
|
|
||||||
interface ICommandArg
|
|
||||||
{
|
|
||||||
string Command { get; }
|
|
||||||
void Execute(IList<string> args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Windows;
|
|
||||||
using Wox.Core.Plugin;
|
|
||||||
|
|
||||||
namespace Wox.CommandArgs
|
|
||||||
{
|
|
||||||
public class InstallPluginCommandArg : ICommandArg
|
|
||||||
{
|
|
||||||
public string Command
|
|
||||||
{
|
|
||||||
get { return "installplugin"; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Execute(IList<string> args)
|
|
||||||
{
|
|
||||||
if (args.Count > 0)
|
|
||||||
{
|
|
||||||
var path = args[0];
|
|
||||||
if (!File.Exists(path))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Plugin " + path + " didn't exist");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
PluginManager.InstallPlugin(path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace Wox.CommandArgs
|
|
||||||
{
|
|
||||||
public class QueryCommandArg : ICommandArg
|
|
||||||
{
|
|
||||||
public string Command
|
|
||||||
{
|
|
||||||
get { return "query"; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Execute(IList<string> args)
|
|
||||||
{
|
|
||||||
Console.WriteLine("test");
|
|
||||||
if (args.Count > 0)
|
|
||||||
{
|
|
||||||
string query = args[0];
|
|
||||||
App.API.ChangeQuery(query);
|
|
||||||
}
|
|
||||||
App.API.ShowApp();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace Wox.CommandArgs
|
|
||||||
{
|
|
||||||
public class ToggleCommandArg:ICommandArg
|
|
||||||
{
|
|
||||||
public string Command
|
|
||||||
{
|
|
||||||
get { return "toggle"; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Execute(IList<string> args)
|
|
||||||
{
|
|
||||||
if (App.Window.IsVisible)
|
|
||||||
{
|
|
||||||
App.API.HideApp();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
App.API.ShowApp();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -7,7 +7,6 @@ using System.Windows.Media.Animation;
|
|||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using Wox.Core.Plugin;
|
using Wox.Core.Plugin;
|
||||||
using Wox.Core.Resource;
|
using Wox.Core.Resource;
|
||||||
using Wox.Core.Updater;
|
|
||||||
using Wox.Core.UserSettings;
|
using Wox.Core.UserSettings;
|
||||||
using Wox.Helper;
|
using Wox.Helper;
|
||||||
using Wox.Infrastructure.Hotkey;
|
using Wox.Infrastructure.Hotkey;
|
||||||
@@ -47,8 +46,6 @@ namespace Wox
|
|||||||
|
|
||||||
private void OnLoaded(object sender, RoutedEventArgs _)
|
private void OnLoaded(object sender, RoutedEventArgs _)
|
||||||
{
|
{
|
||||||
CheckUpdate();
|
|
||||||
|
|
||||||
InitProgressbarAnimation();
|
InitProgressbarAnimation();
|
||||||
WindowIntelopHelper.DisableControlBox(this);
|
WindowIntelopHelper.DisableControlBox(this);
|
||||||
|
|
||||||
@@ -110,27 +107,6 @@ namespace Wox
|
|||||||
return top;
|
return top;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CheckUpdate()
|
|
||||||
{
|
|
||||||
UpdaterManager.Instance.PrepareUpdateReady += OnPrepareUpdateReady;
|
|
||||||
UpdaterManager.Instance.UpdateError += OnUpdateError;
|
|
||||||
UpdaterManager.Instance.CheckUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnUpdateError(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
string updateError = InternationalizationManager.Instance.GetTranslation("update_wox_update_error");
|
|
||||||
MessageBox.Show(updateError);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnPrepareUpdateReady(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Dispatcher.Invoke(() =>
|
|
||||||
{
|
|
||||||
new WoxUpdate().ShowDialog();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void InitProgressbarAnimation()
|
private void InitProgressbarAnimation()
|
||||||
{
|
{
|
||||||
var da = new DoubleAnimation(ProgressBar.X2, ActualWidth + 100, new Duration(new TimeSpan(0, 0, 0, 0, 1600)));
|
var da = new DoubleAnimation(ProgressBar.X2, ActualWidth + 100, new Duration(new TimeSpan(0, 0, 0, 0, 1600)));
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ using System.Windows;
|
|||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using Wox.Core.Plugin;
|
using Wox.Core.Plugin;
|
||||||
using Wox.Core.Resource;
|
using Wox.Core.Resource;
|
||||||
using Wox.Core.Updater;
|
|
||||||
using Wox.Core.UserSettings;
|
using Wox.Core.UserSettings;
|
||||||
using Wox.Helper;
|
using Wox.Helper;
|
||||||
using Wox.Infrastructure;
|
using Wox.Infrastructure;
|
||||||
@@ -64,7 +63,6 @@ namespace Wox.ViewModel
|
|||||||
|
|
||||||
// happlebao todo temp fix for instance code logic
|
// happlebao todo temp fix for instance code logic
|
||||||
HttpProxy.Instance.Settings = _settings;
|
HttpProxy.Instance.Settings = _settings;
|
||||||
UpdaterManager.Instance.Settings = _settings;
|
|
||||||
InternationalizationManager.Instance.Settings = _settings;
|
InternationalizationManager.Instance.Settings = _settings;
|
||||||
InternationalizationManager.Instance.ChangeLanguage(_settings.Language);
|
InternationalizationManager.Instance.ChangeLanguage(_settings.Language);
|
||||||
ThemeManager.Instance.Settings = _settings;
|
ThemeManager.Instance.Settings = _settings;
|
||||||
|
|||||||
@@ -1,46 +0,0 @@
|
|||||||
<Window x:Class="Wox.WoxUpdate"
|
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
||||||
Icon="Images/app.png"
|
|
||||||
Topmost="True"
|
|
||||||
ResizeMode="NoResize"
|
|
||||||
WindowStartupLocation="CenterScreen"
|
|
||||||
Title="{DynamicResource update_wox_update}" Height="400" Width="600">
|
|
||||||
<Grid>
|
|
||||||
<Grid.ColumnDefinitions>
|
|
||||||
<ColumnDefinition Width="100" />
|
|
||||||
<ColumnDefinition />
|
|
||||||
</Grid.ColumnDefinitions>
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="80" />
|
|
||||||
<RowDefinition />
|
|
||||||
<RowDefinition Height="50" />
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<Image Source="Images/update.png" Width="64" />
|
|
||||||
<TextBlock x:Name="tbNewVersionAvailable" Grid.Column="1" Grid.Row="0" VerticalAlignment="Center" FontSize="20"
|
|
||||||
Text="{DynamicResource update_wox_update_new_version_available}" />
|
|
||||||
<TabControl Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2">
|
|
||||||
<TabItem Header="{DynamicResource update_wox_update_upadte_description}">
|
|
||||||
<WebBrowser x:Name="wbDetails" Grid.Row="1" />
|
|
||||||
</TabItem>
|
|
||||||
<TabItem Header="{DynamicResource update_wox_update_files}">
|
|
||||||
<Grid>
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="30" />
|
|
||||||
<RowDefinition />
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<TextBlock Grid.Row="0" Padding="8" Text="{DynamicResource update_wox_update_upadte_files}" />
|
|
||||||
<ListBox x:Name="lbUpdatedFiles" Grid.Row="1" />
|
|
||||||
</Grid>
|
|
||||||
</TabItem>
|
|
||||||
</TabControl>
|
|
||||||
<StackPanel Grid.Column="1" Grid.Row="4" HorizontalAlignment="Right" Orientation="Horizontal">
|
|
||||||
<TextBlock Foreground="Gray" TextAlignment="Center" Margin="0 0 10 0" VerticalAlignment="Center"
|
|
||||||
Text="{DynamicResource update_wox_update_restart_wox_tip}" />
|
|
||||||
<Button x:Name="btnUpdate" Padding="8 3" Margin="8" Click="btnUpdate_Click"
|
|
||||||
Content="{DynamicResource update_wox_update}" />
|
|
||||||
<Button x:Name="btnCancel" Padding="8 3" Margin="8" Click="btnCancel_Click"
|
|
||||||
Content="{DynamicResource update_wox_update_cancel}" />
|
|
||||||
</StackPanel>
|
|
||||||
</Grid>
|
|
||||||
</Window>
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
using System.Windows;
|
|
||||||
using MarkdownSharp;
|
|
||||||
using Wox.Core.Resource;
|
|
||||||
using Wox.Core.Updater;
|
|
||||||
|
|
||||||
namespace Wox
|
|
||||||
{
|
|
||||||
public partial class WoxUpdate : Window
|
|
||||||
{
|
|
||||||
public WoxUpdate()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
|
|
||||||
string newVersionAvailable = string.Format(
|
|
||||||
InternationalizationManager.Instance.GetTranslation("update_wox_update_new_version_available"),
|
|
||||||
UpdaterManager.Instance.NewRelease);
|
|
||||||
tbNewVersionAvailable.Text = newVersionAvailable;
|
|
||||||
Markdown markdown = new Markdown();
|
|
||||||
wbDetails.NavigateToString(markdown.Transform(UpdaterManager.Instance.NewRelease.description));
|
|
||||||
lbUpdatedFiles.ItemsSource = UpdaterManager.Instance.GetAvailableUpdateFiles();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void btnUpdate_Click(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
UpdaterManager.Instance.ApplyUpdates();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void btnCancel_Click(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
UpdaterManager.Instance.CleanUp();
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user