Esempio n. 1
0
        private void ExecuteCommand(object sender, EventArgs args)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            if (_fileListWorker == null)
            {
                Debug.WriteLine("Missing worker");
                return;
            }

            if (_recentFiles == null)
            {
                // TODO: populate from visual studio recent files
                // also a hidden project called Miscellaneous Files has a list of candidates
                // for now though only have our files as recents
                _recentFiles = new List <string>();
            }

            var filteredListProvider = new FilteredListProvider(_fileListWorker.GetRootPath(), _recentFiles);

            _fileListWorker.ProcessFiles((wfiles) => filteredListProvider.SetFiles(wfiles));

            var imageService = Package.GetGlobalService(typeof(SVsImageService)) as IVsImageService2;

            var wnd = new FileListWindow(filteredListProvider, this, imageService);

            DTE ide = Package.GetGlobalService(typeof(DTE)) as DTE;

            wnd.Owner  = HwndSource.FromHwnd(new IntPtr(ide.MainWindow.HWnd)).RootVisual as System.Windows.Window;
            wnd.Width  = wnd.Owner.Width / 2;
            wnd.Height = (2 * wnd.Owner.Height) / 3;

            wnd.ShowDialog();
        }
        public FileListWindow(FilteredListProvider filteredListProvider, OpenFileFromDirPackage package, IVsImageService2 imageService)
        {
            this.package = package;
            this.filteredListProvider = filteredListProvider;
            this.imageService         = imageService;

            InitializeComponent();

            filterTextBox.Text = "";
            filterTextBox.Focus();

            UpdateListBox("");
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            try
            {
                var root   = @"/home/ibob/prj/yama";
                var recent = new List <string>()
                {
                    @"/home/ibob/prj/yama/test/unit/vector2.cpp", @"/home/ibob/prj/yama/test/unit/vector3.cpp", @"/home/ibob/prj/yama/test/unit/quaternion.cpp"
                };
                var w = new FileListWorker(root);
                FilteredListProvider f = null;

                while (true)
                {
                    var cmd = Console.ReadLine();
                    if (cmd == "q")
                    {
                        break;
                    }
                    else if (cmd == "load")
                    {
                        f = new FilteredListProvider(root, recent);
                        w.ProcessFiles((List <string> wfiles) => f.SetFiles(wfiles));
                        Console.WriteLine("loaded");
                    }
                    else
                    {
                        if (f == null)
                        {
                            continue;
                        }
                        var list = f.GetFilteredEntries(cmd);
                        foreach (var e in list)
                        {
                            var relativePath = Path.GetDirectoryName(e.fullPath.Substring(root.Length + 1));
                            Console.WriteLine($"{e.filename} ({relativePath}) {e.matchType}");
                        }
                    }
                    Console.WriteLine();
                }

                w.Join();
            }
            catch (Exception e)
            {
                Console.WriteLine($"Exception: {e}");
            }
        }