protected virtual void Execute(bool openDirectoryOnly, IQuickWindow quickWindow) { string arg = quickWindow.GetArgument(); if (arg == null) { return; } string[] splits = arg.Split(new char[] { ' ', '\t', '\r', '\n' }, 2); string path = splits[0]; if (openDirectoryOnly) { string tmpPath = Path.GetDirectoryName(path); if (!Directory.Exists(tmpPath)) { tmpPath = MatchCommonShortcutPath(path); if (tmpPath != null) { tmpPath = Path.GetDirectoryName(tmpPath); if (!Directory.Exists(tmpPath)) { return; } path = tmpPath; } } } string shellarg = splits.Length > 1 ? splits[1] : null; Process.Start(path, shellarg ?? ""); }
public override bool GetIcon(IQuickWindow quickWindow, out System.Windows.Media.ImageSource icon) { try { if (Directory.Exists(m_fullpath)) { icon = GetRoot().DefaultFolderIcon; } else { string dest = m_fullpath; if (!Path.IsPathRooted(m_fullpath)) { dest = MatchCommonShortcutPath(m_fullpath); } var tmp = Icon.ExtractAssociatedIcon(dest); //获得主线程图标 icon = tmp.ToBitmapSource(); } return(true); } catch { } icon = null; return(false); }
public void KeyDown(IQuickWindow quickWindow, KeyEventArgs e) { switch (e.Key) { case Key.Tab: TabKeyPressed = true; CompletePathInTextbox(quickWindow, e); return; case Key.LeftShift: case Key.RightShift: case Key.LeftCtrl: case Key.RightCtrl: case Key.LeftAlt: case Key.RightAlt: break; case Key.Enter: // Ctrl+Enter 打开文件夹 if (e.KeyboardDevice.Modifiers == ModifierKeys.Control) { OpenDirectory(quickWindow); } break; } }
public void TextChanged(IQuickWindow quickWindow, TextChangedEventArgs e) { var arg = quickWindow.GetArgument(); if (arg == null) { GetCache().ClearCache(); quickWindow.ResetMethods(); return; } CalcResult(quickWindow); QuickCalcItemType[] types = { QuickCalcItemType.ToDecimal, QuickCalcItemType.ToHex, QuickCalcItemType.ToBinary, }; List <QuickCalcItem> calcItemList = new List <QuickCalcItem>(); foreach (var type in types) { QuickCalcItem item = new QuickCalcItem(GetRoot(), type); calcItemList.Add(item); } if (calcItemList.Count > 0) { quickWindow.ReplaceMethods(calcItemList.ToArray()); } }
private bool Query(IQuickWindow quickWindow) { bool bInited = TestEverything(quickWindow); if (!bInited) { CurrentDescriptionType = DescriptionType.NotInited; quickWindow.Refresh(0); return(false); } QuickEverything.Everything_Reset(); QuickEverything.Everything_SetMax(MAX_FILE_NUMBER_IN_ONE_QUERY); QuickEverything.Everything_SetOffset(GetPage() * MAX_FILE_NUMBER_IN_ONE_QUERY); string arg = quickWindow.GetArgument(); if (arg == null) { return(false); } //改善易用性,将/视为\ arg = arg.Replace('/', '\\'); SearchOption option = SearchOption.File; string a = arg.Trim().ToLower(); if (a.StartsWith("folder:")) { option = SearchOption.Folder; } else if (a.StartsWith("all:")) { option = SearchOption.All; } string realQueryText = arg; if (option == SearchOption.File) { realQueryText = "file:" + arg; } else if (option == SearchOption.Folder) { realQueryText = "folder:" + arg; } QuickEverything.Everything_SetSearchW(realQueryText); QuickEverything.Everything_QueryW(true); int count = QuickEverything.Everything_GetNumResults(); EVERYTHING_RESULT result = (EVERYTHING_RESULT)QuickEverything.Everything_GetLastError(); if (result == EVERYTHING_RESULT.EVERYTHING_OK && count > 0) { ReplaceMethods(quickWindow, count); return(true); } CurrentDescriptionType = DescriptionType.NoResult; return(false); }
private void QueryOnTick(object sender, EventArgs e) { DispatcherTimer timer = (DispatcherTimer)sender; IQuickWindow quickWindow = (IQuickWindow)timer.Tag; AsyncQuery(quickWindow); timer.Stop(); }
public virtual string GetDescription(IQuickWindow quickWindow) { if (!GetCache().HasCache()) { return("输入算式进行计算,回车粘贴到剪贴板"); } return(GetCache().GetValue().ToString()); }
public virtual void KeyDown(IQuickWindow quickWindow, System.Windows.Input.KeyEventArgs e) { if (quickWindow != null && m_everythingExePath == null) { m_everythingExePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, quickWindow.GetPluginsPath(), "3rdparty/everything/everything.exe"); } }
public override void Invoke(object sender, IQuickWindow quickWindow) { if (m_directoryOpenedToogle) { m_directoryOpenedToogle = false; return; } Execute(false); }
private void AsyncQuery(IQuickWindow quickWindow) { quickWindow.AsyncInvoke( () => { Query(quickWindow); quickWindow.Refresh(0); } ); }
public static IHostBuilder UseWindow <T>(this IHostBuilder builder) where T : IQuickWindow { builder.ConfigureService(services => { IServiceCollection pool = services.GetService(typeof(IServiceCollection)) as IServiceCollection; IQuickWindow window = services.CreateInstance <T>(); pool.Add(ServiceDescriptor.Singleton <IQuickWindow>(window)); }); return(builder); }
public virtual DispatcherTimer GetTimer(IQuickWindow quickWindow) { if (m_timer == null) { m_timer = new DispatcherTimer(DispatcherPriority.Normal); m_timer.Interval = TimeSpan.FromMilliseconds(COUNT_DOWN_TIMEOUT); m_timer.Tick += QueryOnTick; m_timer.Tag = quickWindow; } return(m_timer); }
public void PageDown(IQuickWindow quickWindow) { try { m_method.PageDown(quickWindow); } catch (Exception ex) { QuickVitality.UpdateVitality("error in plugin method", m_method.GetName(), "invoking: PageDown() and caused " + ex.Message + Environment.NewLine + ex.StackTrace); } }
public Host(IServiceProvider services, IServiceCollection pool, IAppBuilder appBuilder, ITerminationNotifier terminationNotifier, ITray tray, IHotKey hotkey, IQuickWindow window) { this.services = services; this.pool = pool; this.appBuilder = appBuilder; this.terminationNotifier = terminationNotifier; this.tray = tray; this.hotkey = hotkey; this.window = window; actions = new ObservableCollection <ActionBase>(); }
public void TextChanged(IQuickWindow quickWindow, System.Windows.Controls.TextChangedEventArgs e) { try { m_method.TextChanged(quickWindow, e); } catch (Exception ex) { QuickVitality.UpdateVitality("error in plugin method", m_method.GetName(), "invoking: TextChanged() and caused " + ex.Message + Environment.NewLine + ex.StackTrace); } }
public void KeyDown(IQuickWindow quickWindow, System.Windows.Input.KeyEventArgs e) { try { m_method.KeyDown(quickWindow, e); } catch (Exception ex) { QuickVitality.UpdateVitality("error in plugin method", m_method.GetName(), "invoking: KeyDown() and caused " + ex.Message + Environment.NewLine + ex.StackTrace); } }
public void Invoke(object sender, IQuickWindow quickWindow) { try { m_method.Invoke(sender, quickWindow); } catch (Exception ex) { QuickVitality.UpdateVitality("error in plugin method", m_method.GetName(), "invoking: Invoke() and caused " + ex.Message + Environment.NewLine + ex.StackTrace); } }
public string GetDescription(IQuickWindow quickWindow) { try { return(m_method.GetDescription(quickWindow)); } catch (Exception ex) { QuickVitality.UpdateVitality("error in plugin method", m_method.GetName(), "invoking: GetName() and caused " + ex.Message + Environment.NewLine + ex.StackTrace); return(null); } }
public override bool GetIcon(IQuickWindow quickWindow, out System.Windows.Media.ImageSource icon) { try { var tmp = Icon.ExtractAssociatedIcon(m_fullpath); //获得主线程图标 icon = tmp.ToBitmapSource(); return(true); } catch { } icon = null; return(false); }
public bool GetIcon(IQuickWindow quickWindow, out System.Windows.Media.ImageSource icon) { try { return(m_method.GetIcon(quickWindow, out icon)); } catch (Exception ex) { QuickVitality.UpdateVitality("error in plugin method", m_method.GetName(), "invoking: GetIcon() and caused " + ex.Message + Environment.NewLine + ex.StackTrace); icon = null; return(false); } }
public override void KeyDown(IQuickWindow quickWindow, System.Windows.Input.KeyEventArgs e) { switch (e.Key) { case Key.Enter: // Ctrl+Enter 打开文件夹 if (e.KeyboardDevice.Modifiers == ModifierKeys.Control) { OpenDirectory(); } break; } }
public virtual string GetDescription(IQuickWindow quickWindow) { switch (CurrentDescriptionType) { case DescriptionType.NoResult: return(NO_RESULT_DESCRIPTION); case DescriptionType.NotInited: return(NOT_INITED_YET); default: return(DEFAULT_DESCRIPTION); } }
public void TextChanged(IQuickWindow quickWindow, System.Windows.Controls.TextChangedEventArgs e) { ResetPage(); var timer = GetTimer(quickWindow); timer.Stop(); var arg = quickWindow.GetArgument(); if (arg == null) { quickWindow.ResetMethods(); CurrentDescriptionType = DescriptionType.Default; return; } timer.Start(); }
public void TextChanged(IQuickWindow quickWindow, TextChangedEventArgs e) { if (TabKeyPressed) { TabKeyPressed = false; TextDirty = false; } else { TextDirty = true; } // 在没有参数传进来的时候,因为已经退出了SubModel var arg = quickWindow.GetArgument(); if (arg == null) { quickWindow.ResetMethods(); return; } List <string> matchedFiles = new List <string>(); matchedFiles = GetCurrentPathFileNames(arg); List <QuickRunItem> runItemList = new List <QuickRunItem>(); foreach (var r in matchedFiles) { QuickRunItem item = new QuickRunItem(GetRoot(), Path.GetFileNameWithoutExtension(r), MatchCommonShortcutPath(r) ?? r); runItemList.Add(item); } if (runItemList.Count > 0) { quickWindow.ReplaceMethods(runItemList.ToArray()); } else { quickWindow.ResetMethods(); } }
private void CalcResult(IQuickWindow quickWindow) { QuickCalcScanner calc = new QuickCalcScanner(); if (quickWindow != null) { var arg = quickWindow.GetArgument(); if (arg != null) { try { var result = calc.Eval(arg); GetCache().SetValue(result); } catch { } return; } } GetCache().ClearCache(); }
protected override void Execute(bool openDirectoryOnly, IQuickWindow quickWindow) { string arg = quickWindow.GetArgument(); if (arg == null) { return; } string[] splits = arg.Split(new char[] { ' ', '\t', '\r', '\n' }, 2); string path = m_fullpath; if (openDirectoryOnly) { path = Path.GetDirectoryName(m_fullpath); } string shellarg = splits.Length > 1 ? splits[1] : null; Process.Start(path, shellarg ?? ""); }
private void ReplaceMethods(IQuickWindow quickWindow, int count) { const int bufsize = 260; StringBuilder buf = new StringBuilder(bufsize); List <QuickFindItem> findItemList = new List <QuickFindItem>(); for (int i = 0; i < count; i++) { QuickEverything.Everything_GetResultFullPathNameW(i, buf, bufsize); EVERYTHING_RESULT result = (EVERYTHING_RESULT)QuickEverything.Everything_GetLastError(); if (result != EVERYTHING_RESULT.EVERYTHING_OK) { continue; } QuickFindItem item = new QuickFindItem(GetRoot(), buf.ToString()); findItemList.Add(item); } quickWindow.ReplaceMethods(findItemList.ToArray()); }
private bool TestEverything(IQuickWindow quickWindow) { // 返回引擎是否已经初始化 QuickEverything.Everything_Reset(); QuickEverything.Everything_SetMax(1); QuickEverything.Everything_SetOffset(0); QuickEverything.Everything_SetSearchW("*"); bool success = false; bool startServer = false; int times = 0; do { success = QuickEverything.Everything_QueryW(true); if (success) { quickWindow.UnlockWindow(); int count = QuickEverything.Everything_GetNumResults(); return(count > 0 ? true : false); } else { quickWindow.LockWindow(); if (!startServer) { StartService(); startServer = true; } Thread.Sleep(COUNT_DOWN_TIMEOUT); times++; if (times > MAX_TRYING_TIMES) { return(false); } } } while (!success); Debug.Assert(false, "应该在success的时候就返回了"); return(false); }
private void CompletePathInTextbox(IQuickWindow quickWindow, KeyEventArgs e) { var modifiers = e.KeyboardDevice.Modifiers; string queryPath = quickWindow.GetArgument(); if (queryPath.Length == 0) { return; } if (TextDirty) { ResultList = GetCurrentPathFileNames(queryPath); } if (ResultList.Count == 0) { return; } if (modifiers != ModifierKeys.Shift) { AutoSearchIndex = ++AutoSearchIndex % ResultList.Count; } else if (modifiers == ModifierKeys.Shift) { AutoSearchIndex = --AutoSearchIndex < 0 ? ResultList.Count - 1 : AutoSearchIndex; } string content = quickWindow.GetQueryText(); string replaced = content.Replace(queryPath, ResultList[AutoSearchIndex]); quickWindow.SetQueryText(replaced); var textbox = quickWindow.GetQueryTextBox(); textbox.CaretPosition = textbox.Document.ContentEnd; }
private void UpdatePage(IQuickWindow quickWindow, bool isPageDown) { int backupPage = GetPage(); if (isPageDown) { SetPage(GetPage() + 1); } else { if (GetPage() > 0) { SetPage(GetPage() - 1); } else { return; } } bool success = Query(quickWindow); if (!success) { SetPage(backupPage); return; } if (isPageDown) { quickWindow.Refresh(0); } else { quickWindow.Refresh(MAX_FILE_NUMBER_IN_ONE_QUERY); } }