Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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());
            }
        }
Exemplo n.º 3
0
        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 ?? "");
        }
Exemplo n.º 4
0
        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();
        }
Exemplo n.º 5
0
        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();
            }
        }
Exemplo n.º 6
0
        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();
        }
Exemplo n.º 7
0
        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 ?? "");
        }
Exemplo n.º 8
0
        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;
        }