Пример #1
0
        public void CustomizeBookmarkStyles(object args)
        {
            var solutionFilePath = Control.Dte?.Solution?.FileName;

            new CustomizeBookmarkStylesWindow(Control.CodeDocumentViewModel, solutionFilePath).ShowDialog();
            BookmarkHelper.ApplyBookmarks(Control.CodeDocumentViewModel, solutionFilePath);
        }
Пример #2
0
        private void BackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            try
            {
                var result = e.Result as BackgroundWorkerResult;

                if (result?.CodeItems == null)
                {
                    LogHelper.Log($"CodeNav for '{DocumentHelper.GetName(_window)}' updated, no results");
                    return;
                }

                // Filter all null items from the code document
                SyntaxMapper.FilterNullItems(result.CodeItems);

                // Do we need to update the DataContext?
                var areEqual = AreDocumentsEqual(CodeDocumentViewModel.CodeDocument, result.CodeItems);
                if (result.ForceUpdate == false && areEqual)
                {
                    LogHelper.Log($"CodeNav for '{DocumentHelper.GetName(_window)}' updated, document did not change");

                    // Should the margin be shown and are there any items to show, if not hide the margin
                    VisibilityHelper.SetMarginWidth(_column, CodeDocumentViewModel.CodeDocument);

                    return;
                }

                // Set the new list of codeitems as DataContext
                CodeDocumentViewModel.CodeDocument = result.CodeItems;
                _cache = result.CodeItems;

                // Set currently active codeitem
                HighlightHelper.SetForeground(CodeDocumentViewModel.CodeDocument);

                // Should the margin be shown and are there any items to show, if not hide the margin
                VisibilityHelper.SetMarginWidth(_column, CodeDocumentViewModel.CodeDocument);

                // Apply current visibility settings to the document
                VisibilityHelper.SetCodeItemVisibility(CodeDocumentViewModel.CodeDocument);

                // Sync all regions
                OutliningHelper.SyncAllRegions(OutliningManager, TextView, CodeDocumentViewModel.CodeDocument);

                // Sort items
                CodeDocumentViewModel.SortOrder = Settings.Default.SortOrder;
                SortHelper.Sort(CodeDocumentViewModel);

                // Apply bookmarks
                LoadBookmarksFromStorage();
                BookmarkHelper.ApplyBookmarks(CodeDocumentViewModel, Dte?.Solution?.FileName);

                LogHelper.Log($"CodeNav for '{DocumentHelper.GetName(_window)}' updated");
            }
            catch (ObjectDisposedException ex)
            {
                LogHelper.Log($"CodeNav: RunWorkerCompleted exception: {ex.Message}");
                LogHelper.Log("RunWorkerCompleted exception", ex);
            }
        }
Пример #3
0
 public void Test_Show_Hide_Bookmark_Tour()
 {
     TourHelper.OpenToursListWindow();
     TourHelper.SelectMayanHistoryTour();
     TourHelper.PauseTour();
     Assert.IsTrue(BookmarkHelper.IsBookmarkExpanded());
     BookmarkHelper.HideBookmark();
     Assert.IsFalse(BookmarkHelper.IsBookmarkExpanded());
 }
Пример #4
0
 public void bookmark_should_be_opened_second_time()
 {
     TourHelper.OpenToursListWindow();
     TourHelper.SelectMayanHistoryTour();
     TourHelper.CloseBookmark();
     TourHelper.OpenToursListWindow();
     TourHelper.StartPortusTour();
     Assert.IsTrue(BookmarkHelper.IsBookmarkExpanded());
 }
Пример #5
0
        public void DeleteBookmark(object args)
        {
            try
            {
                BookmarkHelper.ClearBookmark(this);

                Control.CodeDocumentViewModel.RemoveBookmark(Id);

                SaveToSolutionStorage();

                NotifyOfPropertyChange("BookmarksAvailable");
            }
            catch (Exception e)
            {
                LogHelper.Log("CodeItem.DeleteBookmark", e);
            }
        }
Пример #6
0
 private void LoadBookmarkStyles()
 {
     foreach (var style in BookmarkHelper.GetBookmarkStyles(_codeDocumentViewModel, _solutionFilePath))
     {
         var item = new Label
         {
             BackColor = ColorHelper.ToDrawingColor(style.BackgroundColor),
             ForeColor = ColorHelper.ToDrawingColor(style.ForegroundColor),
             Text      = "Method",
             Width     = 50,
             Height    = 50,
             Margin    = new Padding(0, 0, 3, 3),
             TextAlign = System.Drawing.ContentAlignment.MiddleCenter
         };
         item.Click += BookmarkStyle_Click;
         bookmarkStylesFlowLayoutPanel.Controls.Add(item);
     }
 }
Пример #7
0
        public void Bookmark(object args)
        {
            try
            {
                var bookmarkStyle = args as BookmarkStyle;

                BookmarkHelper.ApplyBookmark(this, bookmarkStyle);

                Control.CodeDocumentViewModel.AddBookmark(Id,
                                                          BookmarkHelper.GetIndex(BookmarkStyles, bookmarkStyle));

                SaveToSolutionStorage();

                ContextMenuIsOpen = false;

                NotifyOfPropertyChange("BookmarksAvailable");
            }
            catch (Exception e)
            {
                LogHelper.Log("CodeItem.Bookmark", e);
            }
        }
        public async Task UpdateDocumentAsync(bool forceUpdate = false)
        {
            await Microsoft.VisualStudio.Shell.ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            var activeDocument = DocumentHelper.GetActiveDocument(Dte);

            if (activeDocument == null)
            {
                return;
            }

            CodeDocumentViewModel.FilePath = activeDocument.FullName;

            // Do we need to change the side where the margin is displayed
            if (_margin?.MarginSide != null &&
                _margin?.MarginSide != Settings.Default.MarginSide &&
                Dte != null)
            {
                var filename = activeDocument.FullName;
                Dte.ExecuteCommand("File.Close");
                Dte.ExecuteCommand("File.OpenFile", filename);
            }

            try
            {
                if (forceUpdate)
                {
                    _cache = null;
                    CodeDocumentViewModel.CodeDocument.Clear();
                }

                // Do we have a cached version of this document
                if (_cache != null)
                {
                    CodeDocumentViewModel.CodeDocument = _cache;
                }

                // If not show a loading item
                if (!CodeDocumentViewModel.CodeDocument.Any())
                {
                    CodeDocumentViewModel.CodeDocument = CreateLoadingItem();
                }

                var codeItems = await SyntaxMapper.MapDocumentAsync(activeDocument, this, _workspace);

                if (codeItems == null)
                {
                    // CodeNav for document updated, no results
                    return;
                }

                // Filter all null items from the code document
                SyntaxMapper.FilterNullItems(codeItems);

                // Sort items
                CodeDocumentViewModel.SortOrder = Settings.Default.SortOrder;
                SortHelper.Sort(codeItems, Settings.Default.SortOrder);

                // Set currently active codeitem
                HighlightHelper.SetForeground(codeItems);

                // Set the new list of codeitems as DataContext
                CodeDocumentViewModel.CodeDocument = codeItems;
                _cache = codeItems;

                // Apply current visibility settings to the document
                VisibilityHelper.SetCodeItemVisibility(CodeDocumentViewModel);

                // Apply bookmarks
                LoadBookmarksFromStorage();
                BookmarkHelper.ApplyBookmarks(CodeDocumentViewModel, Dte?.Solution?.FileName);

                // Apply history items
                LoadHistoryItemsFromStorage();
                HistoryHelper.ApplyHistoryIndicator(CodeDocumentViewModel);
            }
            catch (Exception e)
            {
                LogHelper.Log("Error running UpdateDocument", e);
            }

            try
            {
                // Sync all regions
                OutliningHelper.SyncAllRegions(OutliningManagerService, TextView, CodeDocumentViewModel.CodeDocument);

                // Should the margin be shown and are there any items to show, if not hide the margin
                VisibilityHelper.SetMarginHeight(_row, CodeDocumentViewModel.CodeDocument);
            }
            catch (Exception e)
            {
                LogHelper.Log("Error finishing UpdateDocument", e);
            }
        }
Пример #9
0
 public BookmarkHelper GetBookmarkHelper()
 {
     return(_bookmarkHelper ?? (_bookmarkHelper = new BookmarkHelper()));
 }
Пример #10
0
 private void okButton_Click(object sender, EventArgs e)
 {
     BookmarkHelper.SetBookmarkStyles(_codeDocumentViewModel, bookmarkStylesFlowLayoutPanel.Controls, _solutionFilePath);
     Close();
 }
Пример #11
0
        public void ClearBookmarks()
        {
            BookmarkHelper.ClearBookmarks(this);

            NotifyOfPropertyChange("BookmarksAvailable");
        }