Example #1
0
        private List <Result> GetContextMenu(MFTSearchRecord record)
        {
            List <Result> contextMenus = new List <Result>();

            if (!record.IsFolder)
            {
                foreach (ContextMenu contextMenu in FindFileContextMenuStorage.Instance.ContextMenus)
                {
                    contextMenus.Add(new Result()
                    {
                        Title  = contextMenu.Name,
                        Action = _ =>
                        {
                            string argument = contextMenu.Argument.Replace("{path}", record.FullPath);
                            try
                            {
                                Process.Start(contextMenu.Command, argument);
                            }
                            catch
                            {
                                context.API.ShowMsg("Can't start " + record.FullPath, string.Empty, string.Empty);
                                return(false);
                            }
                            return(true);
                        },
                        IcoPath = "Images/list.png"
                    });
                }
            }

            return(contextMenus);
        }
Example #2
0
        private Result ConvertMFTSearch(MFTSearchRecord record, string query)
        {
            string icoPath = "Images/file.png";

            if (record.IsFolder)
            {
                icoPath = "Images/folder.png";
            }

            string       name    = Path.GetFileName(record.FullPath);
            FuzzyMatcher matcher = FuzzyMatcher.Create(query);

            return(new Result()
            {
                Title = name,
                Score = matcher.Evaluate(name).Score,
                SubTitle = record.FullPath,
                IcoPath = icoPath,
                Action = _ =>
                {
                    try
                    {
                        Process.Start(record.FullPath);
                    }
                    catch
                    {
                        context.API.ShowMsg("Can't open " + record.FullPath, string.Empty, string.Empty);
                        return false;
                    }
                    return true;
                },
                ContextMenu = GetContextMenu(record)
            });
        }