Remove unused updater and command line arguments

This commit is contained in:
bao-qian
2016-05-08 22:13:23 +01:00
parent d06fb83fee
commit e88e912c3c
20 changed files with 10 additions and 642 deletions

View File

@@ -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();
}
}
}
}

View File

@@ -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();
}
}
}

View File

@@ -1,10 +0,0 @@
using System.Collections.Generic;
namespace Wox.CommandArgs
{
interface ICommandArg
{
string Command { get; }
void Execute(IList<string> args);
}
}

View File

@@ -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);
}
}
}
}

View File

@@ -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();
}
}
}

View File

@@ -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();
}
}
}
}

View File

@@ -7,7 +7,6 @@ using System.Windows.Media.Animation;
using System.Windows.Controls;
using Wox.Core.Plugin;
using Wox.Core.Resource;
using Wox.Core.Updater;
using Wox.Core.UserSettings;
using Wox.Helper;
using Wox.Infrastructure.Hotkey;
@@ -47,8 +46,6 @@ namespace Wox
private void OnLoaded(object sender, RoutedEventArgs _)
{
CheckUpdate();
InitProgressbarAnimation();
WindowIntelopHelper.DisableControlBox(this);
@@ -110,27 +107,6 @@ namespace Wox
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()
{
var da = new DoubleAnimation(ProgressBar.X2, ActualWidth + 100, new Duration(new TimeSpan(0, 0, 0, 0, 1600)));

View File

@@ -7,7 +7,6 @@ using System.Windows;
using System.Windows.Input;
using Wox.Core.Plugin;
using Wox.Core.Resource;
using Wox.Core.Updater;
using Wox.Core.UserSettings;
using Wox.Helper;
using Wox.Infrastructure;
@@ -64,7 +63,6 @@ namespace Wox.ViewModel
// happlebao todo temp fix for instance code logic
HttpProxy.Instance.Settings = _settings;
UpdaterManager.Instance.Settings = _settings;
InternationalizationManager.Instance.Settings = _settings;
InternationalizationManager.Instance.ChangeLanguage(_settings.Language);
ThemeManager.Instance.Settings = _settings;

View File

@@ -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>

View File

@@ -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();
}
}
}