diff --git a/Plugins/Wox.Plugin.Doc/Main.cs b/Plugins/Wox.Plugin.Doc/Main.cs index e437bc4a92..e482d5c769 100644 --- a/Plugins/Wox.Plugin.Doc/Main.cs +++ b/Plugins/Wox.Plugin.Doc/Main.cs @@ -23,53 +23,36 @@ namespace Wox.Plugin.Doc List results = new List(); if (query.ActionParameters.Count == 0) { - results.Add(new Result() - { - Title = "Current supported docs:" - }); results.AddRange(docs.Select(o => new Result() { - Title = o.Name.Replace(".docset", ""), + Title = o.Name.Replace(".docset", "").Replace(" ",""), IcoPath = o.IconPath }).ToList()); return results; } - foreach (Doc doc in docs) + if (query.ActionParameters.Count >= 2) { - results.AddRange(QuerySqllite(doc, query.ActionParameters[0])); + Doc firstOrDefault = docs.FirstOrDefault(o => o.Name.Replace(".docset", "").Replace(" ","").ToLower() == query.ActionParameters[0]); + if (firstOrDefault != null) + { + results.AddRange(QuerySqllite(firstOrDefault, query.ActionParameters[1])); + } } + else + { + foreach (Doc doc in docs) + { + results.AddRange(QuerySqllite(doc, query.ActionParameters[0])); + } + } + return results; } public void Init(PluginInitContext context) { - - //todo:move to common place - var otherCompanyDlls = new DirectoryInfo(context.PluginMetadata.PluginDirecotry).GetFiles("*.dll"); - AppDomain.CurrentDomain.AssemblyResolve += (sender, args) => - { - var dll = otherCompanyDlls.FirstOrDefault(fi => - { - try - { - Assembly assembly = Assembly.LoadFile(fi.FullName); - return assembly.FullName == args.Name; - } - catch - { - return false; - } - }); - if (dll == null) - { - return null; - } - - return Assembly.LoadFile(dll.FullName); - }; - docsetBasePath = context.PluginMetadata.PluginDirecotry + @"Docset"; if (!Directory.Exists(docsetBasePath)) Directory.CreateDirectory(docsetBasePath); @@ -110,7 +93,6 @@ namespace Wox.Plugin.Doc } } } - } return imagePath; } diff --git a/Plugins/Wox.Plugin.Doc/README.md b/Plugins/Wox.Plugin.Doc/README.md new file mode 100644 index 0000000000..fa721944c3 --- /dev/null +++ b/Plugins/Wox.Plugin.Doc/README.md @@ -0,0 +1,5 @@ +How to use? + +1. Docset download link:[http://kapeli.com/docset_links](http://kapeli.com/docset_links) +2. Unzip doc zip into "Plugins\Doc\Docset\{docname}" +3. Restart Wox \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Doc/Wox.Plugin.Doc.csproj b/Plugins/Wox.Plugin.Doc/Wox.Plugin.Doc.csproj index f53a63ad8a..9376906653 100644 --- a/Plugins/Wox.Plugin.Doc/Wox.Plugin.Doc.csproj +++ b/Plugins/Wox.Plugin.Doc/Wox.Plugin.Doc.csproj @@ -83,6 +83,7 @@ Always + @@ -101,7 +102,7 @@ - xcopy /Y /E $(TargetDir)*.* $(SolutionDir)Wox\bin\Debug\Plugins\Doc\ + xcopy /Y /E $(TargetDir)*.* $(SolutionDir)Wox\bin\Debug\Plugins\$(ProjectName)\ + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.DotnetPluginTest/packages.config b/Plugins/Wox.Plugin.DotnetPluginTest/packages.config new file mode 100644 index 0000000000..3a7903bb6b --- /dev/null +++ b/Plugins/Wox.Plugin.DotnetPluginTest/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.DotnetPluginTest/plugin.ini b/Plugins/Wox.Plugin.DotnetPluginTest/plugin.ini new file mode 100644 index 0000000000..a598232fed --- /dev/null +++ b/Plugins/Wox.Plugin.DotnetPluginTest/plugin.ini @@ -0,0 +1,8 @@ +[plugin] +ActionKeyword = ts +Name = dotnet test +Author = qianlifeng +Version = 0.1 +Language = csharp +Description = test +ExecuteFile = Wox.Plugin.DotnetPluginTest.dll diff --git a/Plugins/Wox.Plugin.Everything/Wox.Plugin.Everything.csproj b/Plugins/Wox.Plugin.Everything/Wox.Plugin.Everything.csproj index 1ec9d2a66b..bd9b27beb2 100644 --- a/Plugins/Wox.Plugin.Everything/Wox.Plugin.Everything.csproj +++ b/Plugins/Wox.Plugin.Everything/Wox.Plugin.Everything.csproj @@ -16,7 +16,7 @@ true full false - ..\..\Wox\bin\Debug\Plugins\Everything\ + bin\Debug\ DEBUG;TRACE prompt 4 @@ -81,10 +81,9 @@ - xcopy /Y $(TargetDir)$(TargetFileName) $(SolutionDir)Wox\bin\Debug\Plugins\Everything\ -xcopy /Y $(TargetDir)plugin.ini $(SolutionDir)Wox\bin\Debug\Plugins\Everything\ -xcopy /Y $(ProjectDir)x86\Everything.dll $(SolutionDir)Wox\bin\Debug\Plugins\Everything\x86\ -xcopy /Y $(ProjectDir)x64\Everything.dll $(SolutionDir)Wox\bin\Debug\Plugins\Everything\x64\ + xcopy /Y /E $(TargetDir)*.* $(SolutionDir)Wox\bin\Debug\Plugins\$(ProjectName)\ +xcopy /Y $(ProjectDir)x86\Everything.dll $(SolutionDir)Wox\bin\Debug\Plugins\$(ProjectName)\x86\ +xcopy /Y $(ProjectDir)x64\Everything.dll $(SolutionDir)Wox\bin\Debug\Plugins\$(ProjectName)\x64\ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Wox/ResultPanel.xaml.cs b/Wox/ResultPanel.xaml.cs index 118f8923e8..eb9d3f1b7a 100644 --- a/Wox/ResultPanel.xaml.cs +++ b/Wox/ResultPanel.xaml.cs @@ -1,8 +1,10 @@ -using System.Collections.Generic; -using System.Linq; +using System; +using System.Collections.Generic; +using System.Diagnostics; using System.Windows; using System.Windows.Controls; using Wox.Helper; +using Wox.Infrastructure; using Wox.Plugin; namespace Wox @@ -11,70 +13,37 @@ namespace Wox { public bool Dirty { get; set; } - public delegate void ResultItemsChanged(); - - public event ResultItemsChanged resultItemChangedEvent; - - protected virtual void OnResultItemChangedEvent() - { - ResultItemsChanged handler = resultItemChangedEvent; - if (handler != null) handler(); - } - public void AddResults(List results) { - if (results.Count == 0) return; - if (Dirty) { Dirty = false; - pnlContainer.Children.Clear(); + lbResults.Items.Clear(); } - - for (int i = 0; i < results.Count; i++) + foreach (var result in results) { - Result result = results[i]; - if (!CheckExisted(result)) - { - ResultItem control = new ResultItem(result); - pnlContainer.Children.Insert(GetInsertLocation(result.Score), control); - } + int position = GetInsertLocation(result.Score); + lbResults.Items.Insert(position, result); } - + gridContainer.Margin = lbResults.Items.Count > 0 ? new Thickness { Top = 8 } : new Thickness { Top = 0 }; SelectFirst(); - pnlContainer.UpdateLayout(); - - double resultItemHeight = 0; - if (pnlContainer.Children.Count > 0) - { - var resultItem = pnlContainer.Children[0] as ResultItem; - if (resultItem != null) - resultItemHeight = resultItem.ActualHeight; - } - pnlContainer.Height = pnlContainer.Children.Count * resultItemHeight; - OnResultItemChangedEvent(); - } - - private bool CheckExisted(Result result) - { - return pnlContainer.Children.Cast().Any(child => child.Result.Equals(result)); } private int GetInsertLocation(int currentScore) { - int location = pnlContainer.Children.Count; - if (pnlContainer.Children.Count == 0) return 0; - if (currentScore > ((ResultItem)pnlContainer.Children[0]).Result.Score) return 0; + int location = lbResults.Items.Count; + if (lbResults.Items.Count == 0) return 0; + if (currentScore > ((Result)lbResults.Items[0]).Score) return 0; - for (int index = 1; index < pnlContainer.Children.Count; index++) + for (int index = 1; index < lbResults.Items.Count; index++) { - ResultItem next = pnlContainer.Children[index] as ResultItem; - ResultItem prev = pnlContainer.Children[index - 1] as ResultItem; + Result next = lbResults.Items[index] as Result; + Result prev = lbResults.Items[index - 1] as Result; if (next != null && prev != null) { - if ((currentScore >= next.Result.Score && currentScore <= prev.Result.Score)) + if ((currentScore >= next.Score && currentScore <= prev.Score)) { - if (currentScore == next.Result.Score) + if (currentScore == next.Score) { location = index + 1; } @@ -89,40 +58,10 @@ namespace Wox return location; } - public int GetCurrentResultCount() - { - return pnlContainer.Children.Count; - } - - public int GetCurrentSelectedResultIndex() - { - for (int i = 0; i < pnlContainer.Children.Count; i++) - { - var resultItemControl = pnlContainer.Children[i] as ResultItem; - if (resultItemControl != null && resultItemControl.Selected) - { - return i; - } - } - return -1; - } - - public void UnSelectAll() - { - for (int i = 0; i < pnlContainer.Children.Count; i++) - { - var resultItemControl = pnlContainer.Children[i] as ResultItem; - if (resultItemControl != null && resultItemControl.Selected) - { - resultItemControl.Selected = false; - } - } - } - public void SelectNext() { - int index = GetCurrentSelectedResultIndex(); - if (index == pnlContainer.Children.Count - 1) + int index = lbResults.SelectedIndex; + if (index == lbResults.Items.Count - 1) { index = -1; } @@ -131,98 +70,33 @@ namespace Wox public void SelectPrev() { - int index = GetCurrentSelectedResultIndex(); + int index = lbResults.SelectedIndex; if (index == 0) { - index = pnlContainer.Children.Count; + index = lbResults.Items.Count; } Select(index - 1); } - private void Select(int index) - { - if (pnlContainer.Children.Count > 0) - { - int oldIndex = GetCurrentSelectedResultIndex(); - - UnSelectAll(); - var resultItemControl = pnlContainer.Children[index] as ResultItem; - if (resultItemControl != null) - { - resultItemControl.Selected = true; - - double scrollPosition = 0; - Point newItemBottomPoint = resultItemControl.TranslatePoint(new Point(0, resultItemControl.ActualHeight), pnlContainer); - scrollPosition = newItemBottomPoint.Y; - if (index == 0) - { - sv.ScrollToTop(); - return; - } - if (index == pnlContainer.Children.Count - 1) - { - sv.ScrollToBottom(); - return; - } - - if (index < oldIndex) - { - //move up and old item is at the top of the scroll view - var scrollPostionY = sv.VerticalOffset - sv.VerticalOffset%resultItemControl.ActualHeight + - resultItemControl.ActualHeight; - if (newItemBottomPoint.Y - scrollPostionY == 0) - { - scrollPosition = sv.VerticalOffset - resultItemControl.ActualHeight; - } - else - { - return; - } - } - else - { - //move down and old item is at the bottom of scroll view - double scrollPostionY = (sv.ActualHeight + sv.VerticalOffset) - (sv.ActualHeight + sv.VerticalOffset)%resultItemControl.ActualHeight; - if (scrollPostionY == newItemBottomPoint.Y - resultItemControl.ActualHeight) - { - scrollPosition = newItemBottomPoint.Y - sv.ActualHeight; - } - else - { - return; - } - } - - sv.ScrollToVerticalOffset(scrollPosition); - } - } - } - - public void SelectFirst() + private void SelectFirst() { Select(0); } + private void Select(int index) + { + if (index >= 0 && index < lbResults.Items.Count) + { + lbResults.SelectedItem = lbResults.Items.GetItemAt(index); + } + } + public Result AcceptSelect() { - int index = GetCurrentSelectedResultIndex(); + int index = lbResults.SelectedIndex; if (index < 0) return null; - var resultItemControl = pnlContainer.Children[index] as ResultItem; - if (resultItemControl != null) - { - if (resultItemControl.Result.Action != null) - { - resultItemControl.Result.Action(new ActionContext() - { - SpecialKeyState = new KeyboardListener().CheckModifiers() - }); - } - - return resultItemControl.Result; - } - - return null; + return lbResults.Items[index] as Result; } public ResultPanel() @@ -232,9 +106,16 @@ namespace Wox public void Clear() { - pnlContainer.Children.Clear(); - pnlContainer.Height = 0; - OnResultItemChangedEvent(); + lbResults.Items.Clear(); + gridContainer.Margin = new Thickness { Top = 0 }; + } + + private void lbResults_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + if (e.AddedItems.Count > 0) + { + lbResults.ScrollIntoView(e.AddedItems[0]); + } } } } \ No newline at end of file diff --git a/Wox/SettingWindow.xaml b/Wox/SettingWindow.xaml index d8cc3f69ca..5c3c5f390b 100644 --- a/Wox/SettingWindow.xaml +++ b/Wox/SettingWindow.xaml @@ -1,6 +1,7 @@  + + + + + + + + + + Wox Hotkey: + + + + Custom Plugin Hotkey: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + diff --git a/Wox/SettingWindow.xaml.cs b/Wox/SettingWindow.xaml.cs index f704e05924..e2999dbd47 100644 --- a/Wox/SettingWindow.xaml.cs +++ b/Wox/SettingWindow.xaml.cs @@ -19,7 +19,7 @@ namespace Wox { public partial class SettingWidow : Window { - private MainWindow mainWindow; + public MainWindow MainWindow; public SettingWidow() { @@ -28,9 +28,17 @@ namespace Wox public SettingWidow(MainWindow mainWindow) { - this.mainWindow = mainWindow; + this.MainWindow = mainWindow; InitializeComponent(); Loaded += Setting_Loaded; + } + + + + private void Setting_Loaded(object sender, RoutedEventArgs ev) + { + ctlHotkey.OnHotkeyChanged += ctlHotkey_OnHotkeyChanged; + ctlHotkey.SetHotkey(CommonStorage.Instance.UserSetting.Hotkey, false); cbReplaceWinR.Checked += (o, e) => { CommonStorage.Instance.UserSetting.ReplaceWinR = true; @@ -41,10 +49,7 @@ namespace Wox CommonStorage.Instance.UserSetting.ReplaceWinR = false; CommonStorage.Instance.Save(); }; - } - private void Setting_Loaded(object sender, RoutedEventArgs e) - { foreach (string theme in LoadAvailableThemes()) { string themeName = theme.Substring(theme.LastIndexOf('\\') + 1).Replace(".xaml", ""); @@ -54,6 +59,7 @@ namespace Wox themeComboBox.SelectedItem = CommonStorage.Instance.UserSetting.Theme; cbReplaceWinR.IsChecked = CommonStorage.Instance.UserSetting.ReplaceWinR; webSearchView.ItemsSource = CommonStorage.Instance.UserSetting.WebSearches; + lvCustomHotkey.ItemsSource = CommonStorage.Instance.UserSetting.CustomPluginHotkeys; cbStartWithWindows.IsChecked = CommonStorage.Instance.UserSetting.StartWoxOnSystemStartup; } @@ -71,7 +77,7 @@ namespace Wox private void ThemeComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) { string themeName = themeComboBox.SelectedItem.ToString(); - mainWindow.SetTheme(themeName); + MainWindow.SetTheme(themeName); CommonStorage.Instance.UserSetting.Theme = themeName; CommonStorage.Instance.Save(); } @@ -79,7 +85,7 @@ namespace Wox private void btnAddWebSearch_OnClick(object sender, RoutedEventArgs e) { WebSearchSetting webSearch = new WebSearchSetting(this); - webSearch.Show(); + webSearch.ShowDialog(); } private void btnDeleteWebSearch_OnClick(object sender, RoutedEventArgs e) @@ -104,8 +110,8 @@ namespace Wox if (seletedWebSearch != null) { WebSearchSetting webSearch = new WebSearchSetting(this); - webSearch.Show(); webSearch.UpdateItem(seletedWebSearch); + webSearch.ShowDialog(); } else { @@ -159,6 +165,74 @@ namespace Wox } } + void ctlHotkey_OnHotkeyChanged(object sender, System.EventArgs e) + { + if (ctlHotkey.CurrentHotkeyAvailable) + { + MainWindow.SetHotkey(ctlHotkey.CurrentHotkey.ToString(), delegate + { + if (!MainWindow.IsVisible) + { + MainWindow.ShowApp(); + } + else + { + MainWindow.HideApp(); + } + }); + MainWindow.RemoveHotkey(CommonStorage.Instance.UserSetting.Hotkey); + CommonStorage.Instance.UserSetting.Hotkey = ctlHotkey.CurrentHotkey.ToString(); + CommonStorage.Instance.Save(); + } + } + + #region Custom Plugin Hotkey + + private void BtnDeleteCustomHotkey_OnClick(object sender, RoutedEventArgs e) + { + CustomPluginHotkey item = lvCustomHotkey.SelectedItem as CustomPluginHotkey; + if (item != null && + MessageBox.Show("Are your sure to delete " + item.Hotkey + " plugin hotkey?","Delete Custom Plugin Hotkey", + MessageBoxButton.YesNo) == MessageBoxResult.Yes) + { + CommonStorage.Instance.UserSetting.CustomPluginHotkeys.Remove(item); + lvCustomHotkey.Items.Refresh(); + CommonStorage.Instance.Save(); + MainWindow.RemoveHotkey(item.Hotkey); + } + else + { + MessageBox.Show("Please select an item"); + } + } + + private void BtnEditCustomHotkey_OnClick(object sender, RoutedEventArgs e) + { + CustomPluginHotkey item = lvCustomHotkey.SelectedItem as CustomPluginHotkey; + if (item != null) + { + CustomPluginHotkeySetting window = new CustomPluginHotkeySetting(this); + window.UpdateItem(item); + window.ShowDialog(); + } + else + { + MessageBox.Show("Please select an item"); + } + } + + private void BtnAddCustomeHotkey_OnClick(object sender, RoutedEventArgs e) + { + new CustomPluginHotkeySetting(this).ShowDialog(); + } + + public void ReloadCustomPluginHotkeyView() + { + lvCustomHotkey.Items.Refresh(); + } + + #endregion + } } diff --git a/Wox/StringNullOrEmptyToVisibilityConverter.cs b/Wox/StringNullOrEmptyToVisibilityConverter.cs new file mode 100644 index 0000000000..8ed4b71c86 --- /dev/null +++ b/Wox/StringNullOrEmptyToVisibilityConverter.cs @@ -0,0 +1,26 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Wox +{ + public class StringNullOrEmptyToVisibilityConverter : MarkupExtension, IValueConverter + { + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return string.IsNullOrEmpty(value as string) ? Visibility.Collapsed : Visibility.Visible; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + } +} \ No newline at end of file diff --git a/Wox/Themes/Default.xaml b/Wox/Themes/Default.xaml index 33e17dd46f..61447daf51 100644 --- a/Wox/Themes/Default.xaml +++ b/Wox/Themes/Default.xaml @@ -30,16 +30,35 @@ - - + + #4F6180 + + diff --git a/Wox/Themes/Light.xaml b/Wox/Themes/Light.xaml index 3fc48c9873..28c8f9f914 100644 --- a/Wox/Themes/Light.xaml +++ b/Wox/Themes/Light.xaml @@ -23,32 +23,42 @@ + - + + #543BFD + + @@ -123,4 +133,4 @@ - + \ No newline at end of file diff --git a/Wox/Wox.csproj b/Wox/Wox.csproj index 25fc11a8de..1e2dfba0ab 100644 --- a/Wox/Wox.csproj +++ b/Wox/Wox.csproj @@ -89,6 +89,12 @@ ..\packages\Newtonsoft.Json.5.0.8\lib\net35\Newtonsoft.Json.dll + + ..\packages\NHotkey.1.1.0.0\lib\NHotkey.dll + + + ..\packages\NHotkey.Wpf.1.1.0.0\lib\NHotkey.Wpf.dll + @@ -119,12 +125,18 @@ + + CustomPluginHotkeySetting.xaml + - - + + + HotkeyControl.xaml + + Msg.xaml @@ -137,15 +149,21 @@ ResultPanel.xaml - - ResultItem.xaml - SettingWindow.xaml + WebSearchSetting.xaml + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + MSBuild:Compile Designer @@ -166,10 +184,6 @@ Designer MSBuild:Compile - - Designer - MSBuild:Compile - Designer MSBuild:Compile diff --git a/Wox/packages.config b/Wox/packages.config index edde682830..2e5ba2b823 100644 --- a/Wox/packages.config +++ b/Wox/packages.config @@ -3,5 +3,7 @@ + + \ No newline at end of file