Esempio n. 1
0
        public void ImagesProvider_Test()
        {
            IImagesProvider p = VsAppShell.Current.ExportProvider.GetExportedValue <IImagesProvider>();

            p.Should().NotBeNull();

            p.GetFileIcon("foo.R").Should().NotBeNull();
            p.GetFileIcon("foo.rproj").Should().NotBeNull();
            p.GetFileIcon("foo.rdata").Should().NotBeNull();

            p.GetImage("RProjectNode").Should().NotBeNull();
            p.GetImage("RFileNode").Should().NotBeNull();
            p.GetImage("RDataNode").Should().NotBeNull();
        }
Esempio n. 2
0
        private IEnumerable <RCompletion> GetLocalDirectoryItems(string directory)
        {
            if (Directory.Exists(directory))
            {
                var folderGlyph = _glyphService.GetGlyphThreadSafe(StandardGlyphGroup.GlyphClosedFolder, StandardGlyphItem.GlyphItemPublic);

                foreach (string dir in Directory.GetDirectories(directory))
                {
                    DirectoryInfo di = new DirectoryInfo(dir);
                    if (!di.Attributes.HasFlag(FileAttributes.Hidden) && !di.Attributes.HasFlag(FileAttributes.System))
                    {
                        string dirName = Path.GetFileName(dir);
                        yield return(new RCompletion(dirName, dirName + "/", string.Empty, folderGlyph));
                    }
                }

                foreach (string file in Directory.GetFiles(directory))
                {
                    FileInfo di = new FileInfo(file);
                    if (!di.Attributes.HasFlag(FileAttributes.Hidden) && !di.Attributes.HasFlag(FileAttributes.System))
                    {
                        ImageSource fileGlyph = _imagesProvider?.GetFileIcon(file);
                        string      fileName  = Path.GetFileName(file);
                        yield return(new RCompletion(fileName, fileName, string.Empty, fileGlyph));
                    }
                }
            }
        }
Esempio n. 3
0
        public IReadOnlyCollection <RCompletion> GetEntries(RCompletionContext context)
        {
            List <RCompletion> completions   = new List <RCompletion>();
            ImageSource        folderGlyph   = GlyphService.GetGlyph(StandardGlyphGroup.GlyphClosedFolder, StandardGlyphItem.GlyphItemPublic, _shell);
            string             directory     = null;
            string             userDirectory = null;

            if (_userDirectoryFetchingTask != null)
            {
                _userDirectoryFetchingTask.Wait(500);
                userDirectory = _userDirectoryFetchingTask.IsCompleted ? _userDirectoryFetchingTask.Result : null;
                userDirectory = userDirectory ?? _cachedUserDirectory;
            }

            try {
                if (!string.IsNullOrEmpty(userDirectory))
                {
                    _cachedUserDirectory = userDirectory;
                    directory            = Path.Combine(userDirectory, _directory);
                }
                else
                {
                    directory = Path.Combine(RToolsSettings.Current.WorkingDirectory, _directory);
                }

                if (Directory.Exists(directory))
                {
                    foreach (string dir in Directory.GetDirectories(directory))
                    {
                        DirectoryInfo di = new DirectoryInfo(dir);
                        if (!di.Attributes.HasFlag(FileAttributes.Hidden) && !di.Attributes.HasFlag(FileAttributes.System))
                        {
                            string dirName = Path.GetFileName(dir);
                            completions.Add(new RCompletion(dirName, dirName + "/", string.Empty, folderGlyph));
                        }
                    }

                    foreach (string file in Directory.GetFiles(directory))
                    {
                        FileInfo di = new FileInfo(file);
                        if (!di.Attributes.HasFlag(FileAttributes.Hidden) && !di.Attributes.HasFlag(FileAttributes.System))
                        {
                            ImageSource fileGlyph = _imagesProvider?.GetFileIcon(file);
                            string      fileName  = Path.GetFileName(file);
                            completions.Add(new RCompletion(fileName, fileName, string.Empty, fileGlyph));
                        }
                    }
                }
            } catch (IOException) { } catch (UnauthorizedAccessException) { }

            return(completions);
        }
Esempio n. 4
0
        private IEnumerable <RCompletion> GetLocalDirectoryItems(string userDirectory)
        {
            string directory;

            if (!string.IsNullOrEmpty(userDirectory))
            {
                _cachedUserDirectory = userDirectory;
                directory            = Path.Combine(userDirectory, _directory);
            }
            else
            {
                directory = Path.Combine(RToolsSettings.Current.WorkingDirectory, _directory);
            }

            if (Directory.Exists(directory))
            {
                var folderGlyph = _glyphService.GetGlyphThreadSafe(StandardGlyphGroup.GlyphClosedFolder, StandardGlyphItem.GlyphItemPublic);

                foreach (string dir in Directory.GetDirectories(directory))
                {
                    DirectoryInfo di = new DirectoryInfo(dir);
                    if (!di.Attributes.HasFlag(FileAttributes.Hidden) && !di.Attributes.HasFlag(FileAttributes.System))
                    {
                        string dirName = Path.GetFileName(dir);
                        yield return(new RCompletion(dirName, dirName + "/", string.Empty, folderGlyph));
                    }
                }

                foreach (string file in Directory.GetFiles(directory))
                {
                    FileInfo di = new FileInfo(file);
                    if (!di.Attributes.HasFlag(FileAttributes.Hidden) && !di.Attributes.HasFlag(FileAttributes.System))
                    {
                        ImageSource fileGlyph = _imagesProvider?.GetFileIcon(file);
                        string      fileName  = Path.GetFileName(file);
                        yield return(new RCompletion(fileName, fileName, string.Empty, fileGlyph));
                    }
                }
            }
        }
Esempio n. 5
0
        public void ImagesProvider_Test()
        {
            IImagesProvider p = VsAppShell.Current.GlobalServices.GetService <IImagesProvider>();

            p.Should().NotBeNull();

            p.GetFileIcon("foo.R").Should().NotBeNull();
            p.GetFileIcon("foo.rproj").Should().NotBeNull();
            p.GetFileIcon("foo.rdata").Should().NotBeNull();
            p.GetFileIcon("foo.rd").Should().NotBeNull();
            p.GetFileIcon("foo.rmd").Should().NotBeNull();
            p.GetFileIcon("foo.sql").Should().NotBeNull();

            p.GetImage("RProjectNode").Should().NotBeNull();
            p.GetImage("RFileNode").Should().NotBeNull();
            p.GetImage("RDataFileNode").Should().NotBeNull();
            p.GetImage("RdFileNode").Should().NotBeNull();
            p.GetImage("RMdFileNode").Should().NotBeNull();
            p.GetImage("SQLFileNode").Should().NotBeNull();
            p.GetImage("ProcedureFileNode").Should().NotBeNull();
        }