public void ShowInfoBar(SuggestionResult result, string fileType)
        {
            if (Settings.IsFileTypeIgnored(result.Matches))
            {
                return;
            }

            _fileType = fileType;
            int count = result.Extensions.Count(e => e.Category != SuggestionFileModel.GENERAL);

            var host = GetInfoBarHost();

            if (host != null)
            {
                string matches = string.Join(", ", result.Matches);
                string message = $"{count} extensions supporting {matches} files are found";

                if (result.Extensions.Count() == 1)
                {
                    message = $"{count} extension supporting {matches} files is found";
                }

                _suggestionResult = result;
                CreateInfoBar(host, message);
            }
        }
        public SuggestionResult GetSuggestions(string filePath, out IEnumerable<string> fileTypes)
        {
            var fileModel = GetCurrentFileModel();
            var suggestions = GetSuggestedExtensions(fileModel, filePath, out fileTypes);

            if (!suggestions.Any())
                return null;

            SuggestionResult result = new SuggestionResult
            {
                Extensions = suggestions,
                Matches = fileTypes.Where(f => !string.IsNullOrEmpty(f))
            };

            return result;
        }
        public SuggestionResult GetSuggestions(string filePath, out IEnumerable <string> fileTypes)
        {
            var fileModel   = GetCurrentFileModel();
            var suggestions = GetSuggestedExtensions(fileModel, filePath, out fileTypes);

            if (!suggestions.Any())
            {
                return(null);
            }

            SuggestionResult result = new SuggestionResult
            {
                Extensions = suggestions,
                Matches    = fileTypes.Where(f => !string.IsNullOrEmpty(f))
            };

            return(result);
        }
示例#4
0
        private async System.Threading.Tasks.Task ShowSuggestions(object sender, EventArgs e)
        {
            var dte = ServiceProvider.GetService(typeof(DTE)) as DTE2;

            SuggestionResult result;

            if (dte.ActiveDocument != null && !string.IsNullOrEmpty(dte.ActiveDocument.FullName))
            {
                string fileName = Path.GetFileName(dte.ActiveDocument.FullName);
                IEnumerable <string> fileTypes;
                result = SuggestionHandler.Instance.GetSuggestions(fileName, out fileTypes);
            }
            else
            {
                result = new SuggestionResult
                {
                    Extensions = SuggestionHandler.Instance.GetCurrentFileModel().Extensions[SuggestionFileModel.GENERAL],
                    Matches    = new string[0]
                };
            }

            if (result != null)
            {
                InstallerDialog       dialog = new InstallerDialog(result.Extensions);
                var                   hwnd   = new IntPtr(dte.MainWindow.HWnd);
                System.Windows.Window window = (System.Windows.Window)HwndSource.FromHwnd(hwnd).RootVisual;
                dialog.Owner = window;
                dialog.NeverShowAgainForSolution = Settings.IsFileTypeIgnored(result.Matches);
                var test = dialog.ShowDialog();

                Settings.IgnoreFileType(result.Matches, dialog.NeverShowAgainForSolution);

                if (!test.HasValue || !test.Value)
                {
                    return;
                }

                ExtensionInstaller installer = new ExtensionInstaller(_package, _repository, _manager);
                await installer.InstallExtensions(dialog.SelectedExtensions);
            }
        }
        public void ShowInfoBar(SuggestionResult result, string fileType)
        {
            if (Settings.IsFileTypeIgnored(result.Matches))
                return;

            _fileType = fileType;
            int count = result.Extensions.Count(e => e.Category != SuggestionFileModel.GENERAL);

            var host = GetInfoBarHost();

            if (host != null)
            {
                string matches = string.Join(", ", result.Matches);
                string message = $"{count} extensions supporting {matches} files are found";

                if (result.Extensions.Count() == 1)
                    message = $"{count} extension supporting {matches} files is found";

                _suggestionResult = result;
                CreateInfoBar(host, message);
            }
        }
        private async System.Threading.Tasks.Task ShowSuggestions(object sender, EventArgs e)
        {
            var dte = ServiceProvider.GetService(typeof(DTE)) as DTE2;

            SuggestionResult result;

            if (dte.ActiveDocument != null && !string.IsNullOrEmpty(dte.ActiveDocument.FullName))
            {
                string fileName = Path.GetFileName(dte.ActiveDocument.FullName);
                IEnumerable<string> fileTypes;
                result = SuggestionHandler.Instance.GetSuggestions(fileName, out fileTypes);
            }
            else
            {
                result = new SuggestionResult
                {
                    Extensions = SuggestionHandler.Instance.GetCurrentFileModel().Extensions[SuggestionFileModel.GENERAL],
                    Matches = new string[0]
                };
            }

            if (result != null)
            {
                InstallerDialog dialog = new InstallerDialog(result.Extensions);
                var hwnd = new IntPtr(dte.MainWindow.HWnd);
                System.Windows.Window window = (System.Windows.Window)HwndSource.FromHwnd(hwnd).RootVisual;
                dialog.Owner = window;
                dialog.NeverShowAgainForSolution = Settings.IsFileTypeIgnored(result.Matches);
                var test = dialog.ShowDialog();

                Settings.IgnoreFileType(result.Matches, dialog.NeverShowAgainForSolution);

                if (!test.HasValue || !test.Value)
                    return;

                ExtensionInstaller installer = new ExtensionInstaller(_package, _repository, _manager);
                await installer.InstallExtensions(dialog.SelectedExtensions);
            }
        }