Beispiel #1
0
        /// <summary>
        /// Shows code browser window with provided filter selection.
        /// </summary>
        private bool ShowBrowser(CodeModelFilterFlags filter)
        {
            var fileName = _shellSelectionService.GetActiveFileName();

            if (string.IsNullOrEmpty(fileName))
            {
                return(false);
            }

            var languageSet = _languageService.GetExtensionLanguage(Path.GetExtension(fileName));

            if ((languageSet == null) || (languageSet.Type == LanguageType.Unknown))
            {
                _messageService.ShowError($"{this.Name} request cannot be processed.\r\n\r\nThis non-code file type is not supported.", false);
                return(true);
            }

            if (!_fileProcessor.IsDocumentValid(null, out _))
            {
                _messageService.ShowError($"{this.Name} request cannot be processed.\r\n\r\nFile code model cannot be determined.", false);
                return(true);
            }

            _dialogService.ShowDialog <CodeBrowserWindow, CodeBrowserViewModel>($"{this.Name}'s collecting file information...", filter);
            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// Sets current file bookmark.
        /// </summary>
        /// <param name="number">Bookmark number.</param>
        /// <returns>Whether bookmark's been set or not.</returns>
        public bool SetBookmark(int number)
        {
            if ((number < 1) || (number > 10))
            {
                throw new ArgumentOutOfRangeException(nameof(number));
            }

            var fileName = _shellSelectionService.GetActiveFileName();

            if (string.IsNullOrEmpty(fileName))
            {
                return(false);
            }

            var position = _shellSelectionService.GetActiveFilePosition();

            if (position.IsEmpty())
            {
                return(false);
            }

            _log.LogMessage($"Setting '{fileName}' bookmark # {number}", LOG_CATEGORY);
            List <Bookmark> bookmarks;

            if (_bookmarks.ContainsKey(fileName))
            {
                bookmarks = _bookmarks[fileName];
            }
            else
            {
                bookmarks = new List <Bookmark>(4);
                _bookmarks.Add(fileName, bookmarks);
            }

            var bookmark = bookmarks.FirstOrDefault(b => (b.Number == number) && (b.Type == BookmarkType.Local));

            if (bookmark != null)
            {
                var line = GetBookmarkLine(fileName, bookmark);

                if ((line == position.Line) && (bookmark.Column == position.Column))
                {
                    bookmarks.Remove(bookmark);
                    if (bookmarks.Count == 0)
                    {
                        _bookmarks.Remove(fileName);
                    }

                    _shellStatusBarService.SetStatusBarText($"Cleared bookmark {number}");
                    _log.LogMessage($"Bookmark # {number} cleared", LOG_CATEGORY);
                }
                else
                {
                    bookmark.Line   = position.Line;
                    bookmark.Column = position.Column;

                    _shellStatusBarService.SetStatusBarText($"Updated bookmark {number}");
                    _log.LogMessage($"Bookmark # {number} updated", LOG_CATEGORY);
                }
            }
            else
            {
                bookmarks.Add(new Bookmark(BookmarkType.Local, number, position.Line, position.Column));

                _shellStatusBarService.SetStatusBarText($"Set bookmark {number}");
                _log.LogMessage($"Bookmark # {number} set", LOG_CATEGORY);
            }

            DoChanged(fileName, number, BookmarkType.Local);
            return(true);
        }