mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 03:07:04 +02:00
ReSharper: remove redundant code
This commit is contained in:
@@ -59,11 +59,11 @@ namespace Wox.Plugin.CMD
|
||||
!results.Any(p => o.Equals(p.Title, StringComparison.OrdinalIgnoreCase)) &&
|
||||
!results.Any(p => o.Equals(p.Title, StringComparison.OrdinalIgnoreCase))).ToList();
|
||||
autocomplete.Sort();
|
||||
results.AddRange(autocomplete.ConvertAll(m => new Result()
|
||||
results.AddRange(autocomplete.ConvertAll(m => new Result
|
||||
{
|
||||
Title = m,
|
||||
IcoPath = "Images/cmd.png",
|
||||
Action = (c) =>
|
||||
Action = c =>
|
||||
{
|
||||
ExecuteCMD(m);
|
||||
return true;
|
||||
@@ -96,7 +96,7 @@ namespace Wox.Plugin.CMD
|
||||
Title = m.Key,
|
||||
SubTitle = string.Format(context.API.GetTranslation("wox_plugin_cmd_cmd_has_been_executed_times"), m.Value),
|
||||
IcoPath = "Images/cmd.png",
|
||||
Action = (c) =>
|
||||
Action = c =>
|
||||
{
|
||||
ExecuteCMD(m.Key);
|
||||
return true;
|
||||
@@ -115,7 +115,7 @@ namespace Wox.Plugin.CMD
|
||||
Score = 5000,
|
||||
SubTitle = context.API.GetTranslation("wox_plugin_cmd_execute_through_shell"),
|
||||
IcoPath = "Images/cmd.png",
|
||||
Action = (c) =>
|
||||
Action = c =>
|
||||
{
|
||||
ExecuteCMD(cmd);
|
||||
return true;
|
||||
@@ -133,7 +133,7 @@ namespace Wox.Plugin.CMD
|
||||
Title = m.Key,
|
||||
SubTitle = string.Format(context.API.GetTranslation("wox_plugin_cmd_cmd_has_been_executed_times"), m.Value),
|
||||
IcoPath = "Images/cmd.png",
|
||||
Action = (c) =>
|
||||
Action = c =>
|
||||
{
|
||||
ExecuteCMD(m.Key);
|
||||
return true;
|
||||
@@ -219,9 +219,9 @@ namespace Wox.Plugin.CMD
|
||||
|
||||
public List<Result> LoadContextMenus(Result selectedResult)
|
||||
{
|
||||
return new List<Result>()
|
||||
{
|
||||
new Result()
|
||||
return new List<Result>
|
||||
{
|
||||
new Result
|
||||
{
|
||||
Title = context.API.GetTranslation("wox_plugin_cmd_run_as_administrator"),
|
||||
Action = c =>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows;
|
||||
using YAMP;
|
||||
@@ -18,7 +19,7 @@ namespace Wox.Plugin.Caculator
|
||||
@"[ei]|[0-9]|[\+\-\*\/\^\., ""]|[\(\)\|\!\[\]]" +
|
||||
@")+$", RegexOptions.Compiled);
|
||||
private static Regex regBrackets = new Regex(@"[\(\)\[\]]", RegexOptions.Compiled);
|
||||
private static ParseContext yampContext = null;
|
||||
private static ParseContext yampContext;
|
||||
private PluginInitContext context { get; set; }
|
||||
|
||||
static Calculator()
|
||||
@@ -39,19 +40,21 @@ namespace Wox.Plugin.Caculator
|
||||
var result = yampContext.Run(query.Search);
|
||||
if (result.Output != null && !string.IsNullOrEmpty(result.Result))
|
||||
{
|
||||
return new List<Result>() { new Result() {
|
||||
return new List<Result>
|
||||
{ new Result
|
||||
{
|
||||
Title = result.Result,
|
||||
IcoPath = "Images/calculator.png",
|
||||
Score = 300,
|
||||
SubTitle = "Copy this number to the clipboard",
|
||||
Action = (c) =>
|
||||
Action = c =>
|
||||
{
|
||||
try
|
||||
{
|
||||
Clipboard.SetText(result.Result);
|
||||
return true;
|
||||
}
|
||||
catch (System.Runtime.InteropServices.ExternalException e)
|
||||
catch (ExternalException e)
|
||||
{
|
||||
MessageBox.Show("Copy failed, please try later");
|
||||
return false;
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Wox.Plugin.ControlPanel
|
||||
var fuzzyMather = FuzzyMatcher.Create(myQuery);
|
||||
if (MatchProgram(item, fuzzyMather))
|
||||
{
|
||||
results.Add(new Result()
|
||||
results.Add(new Result
|
||||
{
|
||||
Title = item.LocalizedString,
|
||||
SubTitle = item.InfoTip,
|
||||
|
||||
@@ -123,7 +123,7 @@ namespace Wox.Plugin.ControlPanel
|
||||
|
||||
if (currentKey.GetValue("LocalizedString") != null)
|
||||
{
|
||||
localizedStringRaw = currentKey.GetValue("LocalizedString").ToString().Split(new string[] { ",-" }, StringSplitOptions.None);
|
||||
localizedStringRaw = currentKey.GetValue("LocalizedString").ToString().Split(new[] { ",-" }, StringSplitOptions.None);
|
||||
|
||||
if (localizedStringRaw.Length > 1)
|
||||
{
|
||||
@@ -184,7 +184,7 @@ namespace Wox.Plugin.ControlPanel
|
||||
|
||||
if (currentKey.GetValue("InfoTip") != null)
|
||||
{
|
||||
infoTipRaw = currentKey.GetValue("InfoTip").ToString().Split(new string[] { ",-" }, StringSplitOptions.None);
|
||||
infoTipRaw = currentKey.GetValue("InfoTip").ToString().Split(new[] { ",-" }, StringSplitOptions.None);
|
||||
|
||||
if (infoTipRaw.Length == 2)
|
||||
{
|
||||
@@ -229,7 +229,7 @@ namespace Wox.Plugin.ControlPanel
|
||||
{
|
||||
if (currentKey.OpenSubKey("DefaultIcon").GetValue(null) != null)
|
||||
{
|
||||
iconString = new List<string>(currentKey.OpenSubKey("DefaultIcon").GetValue(null).ToString().Split(new char[] { ',' }, 2));
|
||||
iconString = new List<string>(currentKey.OpenSubKey("DefaultIcon").GetValue(null).ToString().Split(new[] { ',' }, 2));
|
||||
if (iconString[0][0] == '@')
|
||||
{
|
||||
iconString[0] = iconString[0].Substring(1);
|
||||
@@ -247,7 +247,7 @@ namespace Wox.Plugin.ControlPanel
|
||||
if (iconPtr == IntPtr.Zero)
|
||||
{
|
||||
defaultIconPtr = IntPtr.Zero;
|
||||
EnumResourceNamesWithID(dataFilePointer, GROUP_ICON, new EnumResNameDelegate(EnumRes), IntPtr.Zero); //Iterate through resources.
|
||||
EnumResourceNamesWithID(dataFilePointer, GROUP_ICON, EnumRes, IntPtr.Zero); //Iterate through resources.
|
||||
|
||||
iconPtr = LoadImage(dataFilePointer, defaultIconPtr, 1, iconSize, iconSize, 0);
|
||||
}
|
||||
@@ -312,16 +312,16 @@ namespace Wox.Plugin.ControlPanel
|
||||
|
||||
private static uint GET_RESOURCE_ID(IntPtr value)
|
||||
{
|
||||
if (IS_INTRESOURCE(value) == true)
|
||||
if (IS_INTRESOURCE(value))
|
||||
return (uint)value;
|
||||
throw new System.NotSupportedException("value is not an ID!");
|
||||
throw new NotSupportedException("value is not an ID!");
|
||||
}
|
||||
|
||||
private static string GET_RESOURCE_NAME(IntPtr value)
|
||||
{
|
||||
if (IS_INTRESOURCE(value) == true)
|
||||
if (IS_INTRESOURCE(value))
|
||||
return value.ToString();
|
||||
return Marshal.PtrToStringUni((IntPtr)value);
|
||||
return Marshal.PtrToStringUni(value);
|
||||
}
|
||||
|
||||
private static bool EnumRes(IntPtr hModule, IntPtr lpszType, IntPtr lpszName, IntPtr lParam)
|
||||
|
||||
@@ -233,7 +233,7 @@ namespace Wox.Plugin.Everything.Everything
|
||||
{
|
||||
Everything_GetResultFullPathName(idx, buffer, bufferSize);
|
||||
|
||||
var result = new SearchResult() { FullPath = buffer.ToString() };
|
||||
var result = new SearchResult { FullPath = buffer.ToString() };
|
||||
if (Everything_IsFolderResult(idx))
|
||||
result.Type = ResultType.Folder;
|
||||
else if (Everything_IsFileResult(idx))
|
||||
|
||||
@@ -4,7 +4,9 @@ using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.ServiceProcess;
|
||||
using System.Windows;
|
||||
using Wox.Plugin.Everything.Everything;
|
||||
|
||||
namespace Wox.Plugin.Everything
|
||||
@@ -13,8 +15,8 @@ namespace Wox.Plugin.Everything
|
||||
{
|
||||
PluginInitContext context;
|
||||
EverythingAPI api = new EverythingAPI();
|
||||
private static List<string> imageExts = new List<string>() { ".png", ".jpg", ".jpeg", ".gif", ".bmp", ".tiff", ".ico" };
|
||||
private static List<string> executableExts = new List<string>() { ".exe" };
|
||||
private static List<string> imageExts = new List<string> { ".png", ".jpg", ".jpeg", ".gif", ".bmp", ".tiff", ".ico" };
|
||||
private static List<string> executableExts = new List<string> { ".exe" };
|
||||
|
||||
public List<Result> Query(Query query)
|
||||
{
|
||||
@@ -34,7 +36,7 @@ namespace Wox.Plugin.Everything
|
||||
r.Title = "Uninstall Everything";
|
||||
r.SubTitle = "You need to uninstall everything service if you can not move/delete wox folder";
|
||||
r.IcoPath = "Images\\find.png";
|
||||
r.Action = (c) =>
|
||||
r.Action = c =>
|
||||
{
|
||||
UnInstallEverything();
|
||||
return true;
|
||||
@@ -53,7 +55,7 @@ namespace Wox.Plugin.Everything
|
||||
r.Title = Path.GetFileName(path);
|
||||
r.SubTitle = path;
|
||||
r.IcoPath = GetIconPath(s);
|
||||
r.Action = (c) =>
|
||||
r.Action = c =>
|
||||
{
|
||||
context.API.HideApp();
|
||||
Process.Start(new ProcessStartInfo
|
||||
@@ -70,7 +72,7 @@ namespace Wox.Plugin.Everything
|
||||
catch (IPCErrorException)
|
||||
{
|
||||
StartEverything();
|
||||
results.Add(new Result()
|
||||
results.Add(new Result
|
||||
{
|
||||
Title = context.API.GetTranslation("wox_plugin_everything_is_not_running"),
|
||||
IcoPath = "Images\\warning.png"
|
||||
@@ -78,13 +80,13 @@ namespace Wox.Plugin.Everything
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
results.Add(new Result()
|
||||
results.Add(new Result
|
||||
{
|
||||
Title = context.API.GetTranslation("wox_plugin_everything_query_error"),
|
||||
SubTitle = e.Message,
|
||||
Action = _ =>
|
||||
{
|
||||
System.Windows.Clipboard.SetText(e.Message + "\r\n" + e.StackTrace);
|
||||
Clipboard.SetText(e.Message + "\r\n" + e.StackTrace);
|
||||
context.API.ShowMsg(context.API.GetTranslation("wox_plugin_everything_copied"), null, string.Empty);
|
||||
return false;
|
||||
},
|
||||
@@ -120,13 +122,13 @@ namespace Wox.Plugin.Everything
|
||||
return "Images\\file.png";
|
||||
}
|
||||
|
||||
[System.Runtime.InteropServices.DllImport("kernel32.dll")]
|
||||
[DllImport("kernel32.dll")]
|
||||
private static extern int LoadLibrary(string name);
|
||||
|
||||
private List<ContextMenu> GetDefaultContextMenu()
|
||||
{
|
||||
List<ContextMenu> defaultContextMenus = new List<ContextMenu>();
|
||||
ContextMenu openFolderContextMenu = new ContextMenu()
|
||||
ContextMenu openFolderContextMenu = new ContextMenu
|
||||
{
|
||||
Name = context.API.GetTranslation("wox_plugin_everything_open_containing_folder"),
|
||||
Command = "explorer.exe",
|
||||
@@ -282,7 +284,7 @@ namespace Wox.Plugin.Everything
|
||||
foreach (ContextMenu contextMenu in availableContextMenus)
|
||||
{
|
||||
var menu = contextMenu;
|
||||
contextMenus.Add(new Result()
|
||||
contextMenus.Add(new Result
|
||||
{
|
||||
Title = contextMenu.Name,
|
||||
Action = _ =>
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Wox.Plugin.Folder
|
||||
|
||||
public string Nickname
|
||||
{
|
||||
get { return Path.Split(new char[] { System.IO.Path.DirectorySeparatorChar }, StringSplitOptions.None).Last(); }
|
||||
get { return Path.Split(new[] { System.IO.Path.DirectorySeparatorChar }, StringSplitOptions.None).Last(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Wox.Plugin.Folder
|
||||
{
|
||||
List<Result> contextMenus = new List<Result>();
|
||||
string folderPath = ((FolderLink) targetResult.ContextData).Path;
|
||||
contextMenus.Add(new Result()
|
||||
contextMenus.Add(new Result
|
||||
{
|
||||
Title = "Copy to this folder",
|
||||
IcoPath = "Images/copy.png",
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using DataFormats = System.Windows.DataFormats;
|
||||
using DragDropEffects = System.Windows.DragDropEffects;
|
||||
using DragEventArgs = System.Windows.DragEventArgs;
|
||||
using MessageBox = System.Windows.MessageBox;
|
||||
using UserControl = System.Windows.Controls.UserControl;
|
||||
|
||||
@@ -66,10 +70,10 @@ namespace Wox.Plugin.Folder
|
||||
|
||||
private void btnAdd_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog();
|
||||
if (folderBrowserDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
||||
var folderBrowserDialog = new FolderBrowserDialog();
|
||||
if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
var newFolder = new FolderLink()
|
||||
var newFolder = new FolderLink
|
||||
{
|
||||
Path = folderBrowserDialog.SelectedPath
|
||||
};
|
||||
@@ -86,9 +90,9 @@ namespace Wox.Plugin.Folder
|
||||
lbxFolders.Items.Refresh();
|
||||
}
|
||||
|
||||
private void lbxFolders_Drop(object sender, System.Windows.DragEventArgs e)
|
||||
private void lbxFolders_Drop(object sender, DragEventArgs e)
|
||||
{
|
||||
string[] files = (string[])e.Data.GetData(System.Windows.DataFormats.FileDrop);
|
||||
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
|
||||
|
||||
if (files != null && files.Count() > 0)
|
||||
{
|
||||
@@ -99,9 +103,9 @@ namespace Wox.Plugin.Folder
|
||||
|
||||
foreach (string s in files)
|
||||
{
|
||||
if (System.IO.Directory.Exists(s) == true)
|
||||
if (Directory.Exists(s))
|
||||
{
|
||||
var newFolder = new FolderLink()
|
||||
var newFolder = new FolderLink
|
||||
{
|
||||
Path = s
|
||||
};
|
||||
@@ -115,15 +119,15 @@ namespace Wox.Plugin.Folder
|
||||
}
|
||||
}
|
||||
|
||||
private void lbxFolders_DragEnter(object sender, System.Windows.DragEventArgs e)
|
||||
private void lbxFolders_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(System.Windows.DataFormats.FileDrop))
|
||||
if (e.Data.GetDataPresent(DataFormats.FileDrop))
|
||||
{
|
||||
e.Effects = System.Windows.DragDropEffects.Link;
|
||||
e.Effects = DragDropEffects.Link;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effects = System.Windows.DragDropEffects.None;
|
||||
e.Effects = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,11 +25,11 @@ namespace Wox.Plugin.PluginIndicator
|
||||
SubTitle = $"Activate {metadata.Name} plugin",
|
||||
Score = 100,
|
||||
IcoPath = metadata.FullIcoPath,
|
||||
Action = (c) =>
|
||||
Action = c =>
|
||||
{
|
||||
context.API.ChangeQuery($"{keyword}{Plugin.Query.TermSeperater}");
|
||||
return false;
|
||||
},
|
||||
}
|
||||
};
|
||||
return results.ToList();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Wox.Plugin.Program
|
||||
{
|
||||
@@ -16,51 +17,51 @@ namespace Wox.Plugin.Program
|
||||
|
||||
public AddProgramSource(ProgramSource edit) : this()
|
||||
{
|
||||
this._editing = edit;
|
||||
this.Directory.Text = this._editing.Location;
|
||||
this.MaxDepth.Text = this._editing.MaxDepth.ToString();
|
||||
this.Suffixes.Text = this._editing.Suffixes;
|
||||
_editing = edit;
|
||||
Directory.Text = _editing.Location;
|
||||
MaxDepth.Text = _editing.MaxDepth.ToString();
|
||||
Suffixes.Text = _editing.Suffixes;
|
||||
}
|
||||
|
||||
private void BrowseButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var dialog = new System.Windows.Forms.FolderBrowserDialog();
|
||||
System.Windows.Forms.DialogResult result = dialog.ShowDialog();
|
||||
var dialog = new FolderBrowserDialog();
|
||||
DialogResult result = dialog.ShowDialog();
|
||||
if (result == System.Windows.Forms.DialogResult.OK)
|
||||
{
|
||||
this.Directory.Text = dialog.SelectedPath;
|
||||
Directory.Text = dialog.SelectedPath;
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonAdd_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
int max;
|
||||
if(!int.TryParse(this.MaxDepth.Text, out max))
|
||||
if(!int.TryParse(MaxDepth.Text, out max))
|
||||
{
|
||||
max = -1;
|
||||
}
|
||||
|
||||
if(this._editing == null)
|
||||
if(_editing == null)
|
||||
{
|
||||
ProgramStorage.Instance.ProgramSources.Add(new ProgramSource()
|
||||
ProgramStorage.Instance.ProgramSources.Add(new ProgramSource
|
||||
{
|
||||
Location = this.Directory.Text,
|
||||
Location = Directory.Text,
|
||||
MaxDepth = max,
|
||||
Suffixes = this.Suffixes.Text,
|
||||
Suffixes = Suffixes.Text,
|
||||
Type = "FileSystemProgramSource",
|
||||
Enabled = true
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
this._editing.Location = this.Directory.Text;
|
||||
this._editing.MaxDepth = max;
|
||||
this._editing.Suffixes = this.Suffixes.Text;
|
||||
_editing.Location = Directory.Text;
|
||||
_editing.MaxDepth = max;
|
||||
_editing.Suffixes = Suffixes.Text;
|
||||
}
|
||||
|
||||
ProgramStorage.Instance.Save();
|
||||
this.DialogResult = true;
|
||||
this.Close();
|
||||
DialogResult = true;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Wox.Plugin.Program
|
||||
{
|
||||
internal class FileChangeWatcher
|
||||
{
|
||||
private static bool isIndexing = false;
|
||||
private static bool isIndexing;
|
||||
private static List<string> watchedPath = new List<string>();
|
||||
|
||||
public static void AddWatch(string path, bool includingSubDirectory = true)
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Wox.Plugin.Program
|
||||
|
||||
protected Program CreateEntry(string file)
|
||||
{
|
||||
var p = new Program()
|
||||
var p = new Program
|
||||
{
|
||||
Title = Path.GetFileNameWithoutExtension(file),
|
||||
IcoPath = file,
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using Wox.Infrastructure;
|
||||
|
||||
namespace Wox.Plugin.Program
|
||||
@@ -6,7 +8,7 @@ namespace Wox.Plugin.Program
|
||||
[Serializable]
|
||||
public class Program
|
||||
{
|
||||
private static readonly global::System.Text.RegularExpressions.Regex AbbrRegexp = new global::System.Text.RegularExpressions.Regex("[^A-Z0-9]", global::System.Text.RegularExpressions.RegexOptions.Compiled);
|
||||
private static readonly Regex AbbrRegexp = new Regex("[^A-Z0-9]", RegexOptions.Compiled);
|
||||
private string m_Title;
|
||||
public string Title
|
||||
{
|
||||
@@ -19,7 +21,7 @@ namespace Wox.Plugin.Program
|
||||
m_Title = value;
|
||||
string pinyin = m_Title.Unidecode();
|
||||
PinyinTitle = pinyin;
|
||||
AbbrTitle = AbbrRegexp.Replace(global::System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(pinyin), "");
|
||||
AbbrTitle = AbbrRegexp.Replace(Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(pinyin), "");
|
||||
if (AbbrTitle.Length < 2) AbbrTitle = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
@@ -31,9 +31,9 @@ namespace Wox.Plugin.Program
|
||||
programSourceView.Items.Refresh();
|
||||
ThreadPool.QueueUserWorkItem(t =>
|
||||
{
|
||||
Dispatcher.Invoke(new Action(() => { indexingPanel.Visibility = Visibility.Visible; }));
|
||||
Dispatcher.Invoke(() => { indexingPanel.Visibility = Visibility.Visible; });
|
||||
Programs.IndexPrograms();
|
||||
Dispatcher.Invoke(new Action(() => { indexingPanel.Visibility = Visibility.Hidden; }));
|
||||
Dispatcher.Invoke(() => { indexingPanel.Visibility = Visibility.Hidden; });
|
||||
});
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace Wox.Plugin.Program
|
||||
var add = new AddProgramSource();
|
||||
if(add.ShowDialog() ?? false)
|
||||
{
|
||||
this.ReIndexing();
|
||||
ReIndexing();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace Wox.Plugin.Program
|
||||
var add = new AddProgramSource(selectedProgramSource);
|
||||
if (add.ShowDialog() ?? false)
|
||||
{
|
||||
this.ReIndexing();
|
||||
ReIndexing();
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -116,9 +116,9 @@ namespace Wox.Plugin.Program
|
||||
{
|
||||
foreach (string s in files)
|
||||
{
|
||||
if (System.IO.Directory.Exists(s) == true)
|
||||
if (Directory.Exists(s))
|
||||
{
|
||||
ProgramStorage.Instance.ProgramSources.Add(new ProgramSource()
|
||||
ProgramStorage.Instance.ProgramSources.Add(new ProgramSource
|
||||
{
|
||||
Location = s,
|
||||
Type = "FileSystemProgramSource",
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Wox.Plugin.Program
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return (this.Type ?? "") + ":" + this.Location ?? "";
|
||||
return (Type ?? "") + ":" + Location ?? "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using Microsoft.Win32;
|
||||
using Wox.Infrastructure.Logger;
|
||||
|
||||
namespace Wox.Plugin.Program.ProgramSources
|
||||
{
|
||||
[Serializable]
|
||||
[System.ComponentModel.Browsable(false)]
|
||||
[Browsable(false)]
|
||||
public class AppPathsProgramSource : AbstractProgramSource
|
||||
{
|
||||
public AppPathsProgramSource()
|
||||
@@ -28,7 +31,7 @@ namespace Wox.Plugin.Program.ProgramSources
|
||||
|
||||
private void ReadAppPaths(string rootpath, List<Program> list)
|
||||
{
|
||||
using (var root = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(rootpath))
|
||||
using (var root = Registry.LocalMachine.OpenSubKey(rootpath))
|
||||
{
|
||||
if (root == null) return;
|
||||
foreach (var item in root.GetSubKeyNames())
|
||||
@@ -49,7 +52,7 @@ namespace Wox.Plugin.Program.ProgramSources
|
||||
path = path.Substring(begin + 1, path.Length - 2);
|
||||
}
|
||||
|
||||
if (!System.IO.File.Exists(path)) continue;
|
||||
if (!File.Exists(path)) continue;
|
||||
var entry = CreateEntry(path);
|
||||
entry.ExecuteName = item;
|
||||
list.Add(entry);
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace Wox.Plugin.Program.ProgramSources
|
||||
{
|
||||
[Serializable]
|
||||
[global::System.ComponentModel.Browsable(false)]
|
||||
[Browsable(false)]
|
||||
public class CommonStartMenuProgramSource : FileSystemProgramSource
|
||||
{
|
||||
[DllImport("shell32.dll")]
|
||||
@@ -28,7 +29,7 @@ namespace Wox.Plugin.Program.ProgramSources
|
||||
public CommonStartMenuProgramSource(ProgramSource source)
|
||||
: this()
|
||||
{
|
||||
this.BonusPoints = source.BonusPoints;
|
||||
BonusPoints = source.BonusPoints;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Wox.Plugin.Program.ProgramSources
|
||||
public FileSystemProgramSource(ProgramSource source)
|
||||
: this(source.Location, source.MaxDepth, source.Suffixes)
|
||||
{
|
||||
this.BonusPoints = source.BonusPoints;
|
||||
BonusPoints = source.BonusPoints;
|
||||
}
|
||||
|
||||
public override List<Program> LoadPrograms()
|
||||
@@ -78,7 +78,7 @@ namespace Wox.Plugin.Program.ProgramSources
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return typeof(FileSystemProgramSource).Name + ":" + this.baseDirectory;
|
||||
return typeof(FileSystemProgramSource).Name + ":" + baseDirectory;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Wox.Plugin.Program.ProgramSources
|
||||
{
|
||||
[Serializable]
|
||||
[global::System.ComponentModel.Browsable(false)]
|
||||
[Browsable(false)]
|
||||
public class UserStartMenuProgramSource : FileSystemProgramSource
|
||||
{
|
||||
public UserStartMenuProgramSource()
|
||||
@@ -14,7 +15,7 @@ namespace Wox.Plugin.Program.ProgramSources
|
||||
public UserStartMenuProgramSource(ProgramSource source)
|
||||
: this()
|
||||
{
|
||||
this.BonusPoints = source.BonusPoints;
|
||||
BonusPoints = source.BonusPoints;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using Wox.Infrastructure;
|
||||
using Wox.Infrastructure.Logger;
|
||||
using Wox.Plugin.Program.ProgramSources;
|
||||
@@ -17,11 +18,12 @@ namespace Wox.Plugin.Program
|
||||
private static object lockObject = new object();
|
||||
private static List<Program> programs = new List<Program>();
|
||||
private static List<IProgramSource> sources = new List<IProgramSource>();
|
||||
private static Dictionary<string, Type> SourceTypes = new Dictionary<string, Type>() {
|
||||
private static Dictionary<string, Type> SourceTypes = new Dictionary<string, Type>
|
||||
{
|
||||
{"FileSystemProgramSource", typeof(FileSystemProgramSource)},
|
||||
{"CommonStartMenuProgramSource", typeof(CommonStartMenuProgramSource)},
|
||||
{"UserStartMenuProgramSource", typeof(UserStartMenuProgramSource)},
|
||||
{"AppPathsProgramSource", typeof(AppPathsProgramSource)},
|
||||
{"AppPathsProgramSource", typeof(AppPathsProgramSource)}
|
||||
};
|
||||
private PluginInitContext context;
|
||||
|
||||
@@ -32,14 +34,14 @@ namespace Wox.Plugin.Program
|
||||
var results = programs.Where(p => MatchProgram(p, fuzzyMather)).
|
||||
Select(ScoreFilter).
|
||||
OrderByDescending(p => p.Score)
|
||||
.Select(c => new Result()
|
||||
.Select(c => new Result
|
||||
{
|
||||
Title = c.Title,
|
||||
SubTitle = c.ExecutePath,
|
||||
IcoPath = c.IcoPath,
|
||||
Score = c.Score,
|
||||
ContextData = c,
|
||||
Action = (e) =>
|
||||
Action = e =>
|
||||
{
|
||||
context.API.HideApp();
|
||||
Process.Start(c.ExecutePath);
|
||||
@@ -128,19 +130,19 @@ namespace Wox.Plugin.Program
|
||||
private static List<ProgramSource> LoadDeaultProgramSources()
|
||||
{
|
||||
var list = new List<ProgramSource>();
|
||||
list.Add(new ProgramSource()
|
||||
list.Add(new ProgramSource
|
||||
{
|
||||
BonusPoints = 0,
|
||||
Enabled = ProgramStorage.Instance.EnableStartMenuSource,
|
||||
Type = "CommonStartMenuProgramSource"
|
||||
});
|
||||
list.Add(new ProgramSource()
|
||||
list.Add(new ProgramSource
|
||||
{
|
||||
BonusPoints = 0,
|
||||
Enabled = ProgramStorage.Instance.EnableStartMenuSource,
|
||||
Type = "UserStartMenuProgramSource"
|
||||
});
|
||||
list.Add(new ProgramSource()
|
||||
list.Add(new ProgramSource
|
||||
{
|
||||
BonusPoints = -10,
|
||||
Enabled = ProgramStorage.Instance.EnableRegistrySource,
|
||||
@@ -166,7 +168,7 @@ namespace Wox.Plugin.Program
|
||||
|
||||
#region ISettingProvider Members
|
||||
|
||||
public System.Windows.Controls.Control CreateSettingPanel()
|
||||
public Control CreateSettingPanel()
|
||||
{
|
||||
return new ProgramSetting(context);
|
||||
}
|
||||
@@ -190,9 +192,9 @@ namespace Wox.Plugin.Program
|
||||
public List<Result> LoadContextMenus(Result selectedResult)
|
||||
{
|
||||
Program p = selectedResult.ContextData as Program;
|
||||
List<Result> contextMenus = new List<Result>()
|
||||
List<Result> contextMenus = new List<Result>
|
||||
{
|
||||
new Result()
|
||||
new Result
|
||||
{
|
||||
Title = context.API.GetTranslation("wox_plugin_program_run_as_administrator"),
|
||||
Action = _ =>
|
||||
@@ -207,7 +209,7 @@ namespace Wox.Plugin.Program
|
||||
},
|
||||
IcoPath = "Images/cmd.png"
|
||||
},
|
||||
new Result()
|
||||
new Result
|
||||
{
|
||||
Title = context.API.GetTranslation("wox_plugin_program_open_containing_folder"),
|
||||
Action = _ =>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Markup;
|
||||
|
||||
@@ -6,13 +7,13 @@ namespace Wox.Plugin.Program
|
||||
{
|
||||
public class StringEmptyConverter : MarkupExtension, IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return string.IsNullOrEmpty((string)value) ? parameter : value;
|
||||
}
|
||||
|
||||
public object ConvertBack(
|
||||
object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
@@ -76,14 +76,14 @@ namespace Wox.Plugin.Sys
|
||||
|
||||
private void LoadCommands()
|
||||
{
|
||||
availableResults.AddRange(new Result[]
|
||||
availableResults.AddRange(new[]
|
||||
{
|
||||
new Result
|
||||
{
|
||||
Title = "Shutdown",
|
||||
SubTitle = context.API.GetTranslation("wox_plugin_sys_shutdown_computer"),
|
||||
IcoPath = "Images\\exit.png",
|
||||
Action = (c) =>
|
||||
Action = c =>
|
||||
{
|
||||
var reuslt = MessageBox.Show("Are you sure you want to shut the computer down?",
|
||||
"Shutdown Computer?", MessageBoxButton.YesNo, MessageBoxImage.Warning);
|
||||
@@ -99,7 +99,7 @@ namespace Wox.Plugin.Sys
|
||||
Title = "Restart",
|
||||
SubTitle = context.API.GetTranslation("wox_plugin_sys_restart_computer"),
|
||||
IcoPath = "Images\\restartcomp.png",
|
||||
Action = (c) =>
|
||||
Action = c =>
|
||||
{
|
||||
var result = MessageBox.Show("Are you sure you want to restart the computer?",
|
||||
"Restart Computer?", MessageBoxButton.YesNo, MessageBoxImage.Warning);
|
||||
@@ -115,14 +115,14 @@ namespace Wox.Plugin.Sys
|
||||
Title = "Log off",
|
||||
SubTitle = context.API.GetTranslation("wox_plugin_sys_log_off"),
|
||||
IcoPath = "Images\\logoff.png",
|
||||
Action = (c) => ExitWindowsEx(EWX_LOGOFF, 0)
|
||||
Action = c => ExitWindowsEx(EWX_LOGOFF, 0)
|
||||
},
|
||||
new Result
|
||||
{
|
||||
Title = "Lock",
|
||||
SubTitle = context.API.GetTranslation("wox_plugin_sys_lock"),
|
||||
IcoPath = "Images\\lock.png",
|
||||
Action = (c) =>
|
||||
Action = c =>
|
||||
{
|
||||
LockWorkStation();
|
||||
return true;
|
||||
@@ -133,14 +133,14 @@ namespace Wox.Plugin.Sys
|
||||
Title = "Sleep",
|
||||
SubTitle = context.API.GetTranslation("wox_plugin_sys_sleep"),
|
||||
IcoPath = "Images\\sleep.png",
|
||||
Action = (c) => FormsApplication.SetSuspendState(PowerState.Suspend, false, false)
|
||||
Action = c => FormsApplication.SetSuspendState(PowerState.Suspend, false, false)
|
||||
},
|
||||
new Result
|
||||
{
|
||||
Title = "Empty Recycle Bin",
|
||||
SubTitle = context.API.GetTranslation("wox_plugin_sys_emptyrecyclebin"),
|
||||
IcoPath = "Images\\recyclebin.png",
|
||||
Action = (c) =>
|
||||
Action = c =>
|
||||
{
|
||||
// http://www.pinvoke.net/default.aspx/shell32/SHEmptyRecycleBin.html
|
||||
// 0 for nothing
|
||||
@@ -160,7 +160,7 @@ namespace Wox.Plugin.Sys
|
||||
Title = "Exit",
|
||||
SubTitle = context.API.GetTranslation("wox_plugin_sys_exit"),
|
||||
IcoPath = "Images\\app.png",
|
||||
Action = (c) =>
|
||||
Action = c =>
|
||||
{
|
||||
context.API.CloseApp();
|
||||
return true;
|
||||
@@ -171,7 +171,7 @@ namespace Wox.Plugin.Sys
|
||||
Title = "Restart Wox",
|
||||
SubTitle = context.API.GetTranslation("wox_plugin_sys_restart"),
|
||||
IcoPath = "Images\\restart.png",
|
||||
Action = (c) =>
|
||||
Action = c =>
|
||||
{
|
||||
context.API.RestarApp();
|
||||
return false;
|
||||
@@ -182,7 +182,7 @@ namespace Wox.Plugin.Sys
|
||||
Title = "Settings",
|
||||
SubTitle = context.API.GetTranslation("wox_plugin_sys_setting"),
|
||||
IcoPath = "Images\\app.png",
|
||||
Action = (c) =>
|
||||
Action = c =>
|
||||
{
|
||||
context.API.OpenSettingDialog();
|
||||
return true;
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Wox.Plugin.Sys
|
||||
|
||||
foreach (var Result in Results)
|
||||
{
|
||||
this.lbxCommands.Items.Add(Result);
|
||||
lbxCommands.Items.Add(Result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace Wox.Plugin.WebSearch
|
||||
MessageBox.Show(exception.Message);
|
||||
return;
|
||||
}
|
||||
WebSearchStorage.Instance.WebSearches.Add(new WebSearch()
|
||||
WebSearchStorage.Instance.WebSearches.Add(new WebSearch
|
||||
{
|
||||
ActionKeyword = newActionKeyword,
|
||||
Enabled = cbEnable.IsChecked ?? false,
|
||||
|
||||
@@ -29,10 +29,10 @@ namespace Wox.Plugin.WebSearch
|
||||
? Visibility.Visible
|
||||
: Visibility.Collapsed;
|
||||
|
||||
List<ComboBoxItem> items = new List<ComboBoxItem>()
|
||||
List<ComboBoxItem> items = new List<ComboBoxItem>
|
||||
{
|
||||
new ComboBoxItem() {Content = "Google"},
|
||||
new ComboBoxItem() {Content = "Baidu"},
|
||||
new ComboBoxItem {Content = "Google"},
|
||||
new ComboBoxItem {Content = "Baidu"}
|
||||
};
|
||||
ComboBoxItem selected = items.FirstOrDefault(o => o.Content.ToString() == WebSearchStorage.Instance.WebSearchSuggestionSource);
|
||||
if (selected == null)
|
||||
|
||||
Reference in New Issue
Block a user