Ejemplo n.º 1
0
        public static IEnumerable <FileViewer> GetFileViewers(FilePath filePath, Project ownerProject)
        {
            string mimeType  = DesktopService.GetMimeTypeForUri(filePath);
            var    viewerIds = new HashSet <string> ();

            foreach (var b in GetDisplayBindings(filePath, mimeType, ownerProject))
            {
                var vb = b as IViewDisplayBinding;
                if (vb != null)
                {
                    yield return(new FileViewer(vb));
                }
                else
                {
                    var eb  = (IExternalDisplayBinding)b;
                    var app = eb.GetApplication(filePath, mimeType, ownerProject);
                    if (viewerIds.Add(app.Id))
                    {
                        yield return(new FileViewer(app));
                    }
                }
            }

            foreach (var app in DesktopService.GetApplications(filePath))
            {
                if (viewerIds.Add(app.Id))
                {
                    yield return(new FileViewer(app));
                }
            }
        }
Ejemplo n.º 2
0
        public async Task <IEnumerable <FileViewer> > GetFileViewers(FilePath filePath, Project ownerProject)
        {
            var result = new List <FileViewer> ();

            string mimeType       = desktopService.GetMimeTypeForUri(filePath);
            var    viewerIds      = new HashSet <string> ();
            var    fileDescriptor = new FileDescriptor(filePath, mimeType, ownerProject);

            foreach (var b in await IdeServices.DocumentControllerService.GetSupportedControllers(fileDescriptor))
            {
                result.Add(new FileViewer(b));
            }

            foreach (var eb in GetDisplayBindings(filePath, mimeType, ownerProject).OfType <IExternalDisplayBinding> ())
            {
                var app = eb.GetApplication(filePath, mimeType, ownerProject);
                if (viewerIds.Add(app.Id))
                {
                    result.Add(new FileViewer(app));
                }
            }

            foreach (var app in desktopService.GetApplications(filePath))
            {
                if (viewerIds.Add(app.Id))
                {
                    result.Add(new FileViewer(app));
                }
            }
            return(result);
        }
        /// <summary>
        /// Returns the pre-defined file viewers.
        /// </summary>
        public static IEnumerable <OpenWithFileViewer> GetFileViewers(
            FilePath filePath,
            string mimeType,
            Project ownerProject)
        {
            var viewerIds = new HashSet <string> ();

            foreach (var b in GetDisplayBindings(filePath, mimeType, ownerProject))
            {
                if (b is PreferencesDisplayBinding)
                {
                    continue;
                }
                if (b is IOpenWithDisplayBinding)
                {
                    continue;
                }
                var vb = b as IViewDisplayBinding;
                if (vb != null)
                {
                    yield return(new OpenWithFileViewer(vb));
                }
                else
                {
                    var eb  = (IExternalDisplayBinding)b;
                    var app = eb.GetApplication(filePath, mimeType, ownerProject);
                    if (viewerIds.Add(app.Id))
                    {
                        yield return(new OpenWithFileViewer(app));
                    }
                }
            }

            if (filePath.IsNullOrEmpty)
            {
                yield break;
            }

            foreach (var app in DesktopService.GetApplications(filePath))
            {
                if (viewerIds.Add(app.Id))
                {
                    yield return(new OpenWithFileViewer(app));
                }
            }
        }
Ejemplo n.º 4
0
        public FileViewer[] GetFileViewers(FilePath fileName)
        {
            List <FileViewer> list = new List <FileViewer> ();

            string mimeType = DesktopService.GetMimeTypeForUri(fileName);

            foreach (IDisplayBinding bin in DisplayBindingService.GetBindingsForMimeType(mimeType))
            {
                list.Add(new FileViewer(bin));
            }

            foreach (var app in DesktopService.GetApplications(fileName))
            {
                list.Add(new FileViewer(app));
            }

            return(list.ToArray());
        }