Exemple #1
0
        public SearchAndResultsControl()
        {
            InitializeComponent();
            typingConcurrentOperation.DisplayResults += (r, moreAvailable) => DisplaySearchResults(r, moreAvailable);
            typingConcurrentOperation.SearchComplete += TypingConcurrentOperation_SearchComplete;

            VirtualizingPanel.SetIsVirtualizing(resultsList, SettingsService.EnableTreeViewVirtualization);

            this.Unloaded += SearchAndResultsControl_Unloaded;
        }
 /// <summary>
 /// Updates ItemsOwner object
 /// </summary>
 private void Initialize_ItemsOwner()
 {
     ItemsOwner = new VirtualizingStackPanel
     {
         Width            = this.Width,
         Height           = this.Height,
         FocusVisualStyle = null,
     };
     VirtualizingPanel.SetIsVirtualizing(ItemsOwner, true);
     VirtualizingPanel.SetCacheLengthUnit(ItemsOwner, VirtualizationCacheLengthUnit.Item);
     VirtualizingPanel.SetCacheLength(ItemsOwner, new VirtualizationCacheLength(2));
     VirtualizingPanel.SetVirtualizationMode(ItemsOwner, VirtualizationMode.Recycling);
     UpdateFrameworkElement(ItemsOwner, RenderSize, new Rect(RenderSize));
     ChildrenGrid.Children.Add(ItemsOwner);
 }
Exemple #3
0
        public TreeViewImpl(ITreeViewServiceImpl treeViewService, IThemeService themeService, IClassificationFormatMapService classificationFormatMapService, Guid guid, TreeViewOptions options)
        {
            Guid = guid;
            this.treeViewService    = treeViewService;
            treeViewListener        = options.TreeViewListener;
            classificationFormatMap = classificationFormatMapService.GetClassificationFormatMap(AppearanceCategoryConstants.UIMisc);
            classificationFormatMap.ClassificationFormatMappingChanged += ClassificationFormatMap_ClassificationFormatMappingChanged;
            foregroundBrushResourceKey = options.ForegroundBrushResourceKey ?? "TreeViewForeground";
            sharpTreeView = new SharpTreeView();
            sharpTreeView.SelectionChanged += SharpTreeView_SelectionChanged;
            sharpTreeView.CanDragAndDrop    = options.CanDragAndDrop;
            sharpTreeView.AllowDrop         = options.AllowDrop;
            sharpTreeView.AllowDropOrder    = options.AllowDrop;
            VirtualizingPanel.SetIsVirtualizing(sharpTreeView, options.IsVirtualizing);
            VirtualizingPanel.SetVirtualizationMode(sharpTreeView, options.VirtualizationMode);
            AutomationPeerMemoryLeakWorkaround.SetInitialize(sharpTreeView, true);
            sharpTreeView.SelectionMode   = options.SelectionMode;
            sharpTreeView.BorderThickness = new Thickness(0);
            sharpTreeView.ShowRoot        = false;
            sharpTreeView.ShowLines       = false;

            if (options.IsGridView)
            {
                sharpTreeView.SetResourceReference(ItemsControl.ItemContainerStyleProperty, SharpGridView.ItemContainerStyleKey);
                sharpTreeView.SetResourceReference(FrameworkElement.StyleProperty, "SharpTreeViewGridViewStyle");
            }
            else
            {
                // Clear the value set by the constructor. This is required or our style won't be used.
                sharpTreeView.ClearValue(ItemsControl.ItemContainerStyleProperty);
                sharpTreeView.SetResourceReference(FrameworkElement.StyleProperty, typeof(SharpTreeView));
            }

            sharpTreeView.GetPreviewInsideTextBackground = () => themeService.Theme.GetColor(ColorType.SystemColorsHighlight).Background;
            sharpTreeView.GetPreviewInsideForeground     = () => themeService.Theme.GetColor(ColorType.SystemColorsHighlightText).Foreground;

            // Add the root at the end since Create() requires some stuff to have been initialized
            root = Create(options.RootNode ?? new TreeNodeDataImpl(new Guid(DocumentTreeViewConstants.ROOT_NODE_GUID)));
            sharpTreeView.Root = root.Node;
        }
Exemple #4
0
        private static void ResetVisualState(ContentPresenter objectToPrint, PrintCapabilities printCaps, bool wasVirtualized)
        {
            objectToPrint.Width = double.NaN;
            objectToPrint.UpdateLayout();
            objectToPrint.LayoutTransform = new ScaleTransform(1, 1);
            Size size = new Size(printCaps.PageImageableArea.ExtentWidth,
                                 printCaps.PageImageableArea.ExtentHeight);

            objectToPrint.Measure(size);
            objectToPrint.Arrange(new Rect(new Point(printCaps.PageImageableArea.OriginWidth,
                                                     printCaps.PageImageableArea.OriginHeight), size));

            if (!wasVirtualized)
            {
                return;
            }
            var dg = objectToPrint.FindChild <DataGrid>();

            dg.EnableRowVirtualization    = true;
            dg.EnableColumnVirtualization = true;
            VirtualizingPanel.SetIsVirtualizing(dg, true);
        }
Exemple #5
0
        private static bool LoadVirtualizedRows(ContentPresenter content, int rowCount)
        {
            DataGrid dg;

            if (!content.TryFindChild <DataGrid>(out dg))
            {
                return(false);
            }
            if (dg == null)
            {
                return(false);
            }
            if (dg.Items.Count == 0)
            {
                return(false);
            }

            if (!dg.EnableRowVirtualization)
            {
                return(false);
            }
            dg.EnableRowVirtualization    = false;
            dg.EnableColumnVirtualization = false;
            VirtualizingPanel.SetIsVirtualizing(dg, false);

            for (int i = 0; i < dg.Items.Count; i++)
            {
                dg.ScrollIntoView(dg.Items[i]);
                if (i == rowCount)
                {
                    break;
                }
            }
            dg.ScrollIntoView(dg.Items[0]);
            return(true);
        }
Exemple #6
0
        public BuildControl(Build build, string logFilePath)
        {
            InitializeComponent();

            UpdateWatermark();

            searchLogControl.ExecuteSearch = searchText =>
            {
                var search  = new Search(Build);
                var results = search.FindNodes(searchText);
                return(results);
            };
            searchLogControl.ResultsTreeBuilder  = BuildResultTree;
            searchLogControl.WatermarkDisplayed += () => UpdateWatermark();

            findInFilesControl.ExecuteSearch      = FindInFiles;
            findInFilesControl.ResultsTreeBuilder = BuildFindResults;

            VirtualizingPanel.SetIsVirtualizing(treeView, SettingsService.EnableTreeViewVirtualization);

            DataContext = build;
            Build       = build;

            LogFilePath = logFilePath;

            if (build.SourceFilesArchive != null)
            {
                // first try to see if the source archive was embedded in the log
                sourceFileResolver = new SourceFileResolver(build.SourceFilesArchive);
            }
            else
            {
                // otherwise try to read from the .zip file on disk if present
                sourceFileResolver = new SourceFileResolver(logFilePath);
            }

            sharedTreeContextMenu = new ContextMenu();
            copyAllItem           = new MenuItem()
            {
                Header = "Copy All"
            };
            copyAllItem.Click += (s, a) => CopyAll();
            sharedTreeContextMenu.Items.Add(copyAllItem);

            var contextMenu = new ContextMenu();

            contextMenu.Opened += ContextMenu_Opened;
            copyItem            = new MenuItem()
            {
                Header = "Copy"
            };
            copySubtreeItem = new MenuItem()
            {
                Header = "Copy subtree"
            };
            sortChildrenItem = new MenuItem()
            {
                Header = "Sort children"
            };
            copyNameItem = new MenuItem()
            {
                Header = "Copy name"
            };
            copyValueItem = new MenuItem()
            {
                Header = "Copy value"
            };
            viewItem = new MenuItem()
            {
                Header = "View"
            };
            preprocessItem = new MenuItem()
            {
                Header = "Preprocess"
            };
            hideItem = new MenuItem()
            {
                Header = "Hide"
            };
            copyItem.Click         += (s, a) => Copy();
            copySubtreeItem.Click  += (s, a) => CopySubtree();
            sortChildrenItem.Click += (s, a) => SortChildren();
            copyNameItem.Click     += (s, a) => CopyName();
            copyValueItem.Click    += (s, a) => CopyValue();
            viewItem.Click         += (s, a) => Invoke(treeView.SelectedItem as ParentedNode);
            preprocessItem.Click   += (s, a) => Preprocess(treeView.SelectedItem as Project);
            hideItem.Click         += (s, a) => Delete();
            contextMenu.Items.Add(viewItem);
            contextMenu.Items.Add(preprocessItem);
            contextMenu.Items.Add(copyItem);
            contextMenu.Items.Add(copySubtreeItem);
            contextMenu.Items.Add(sortChildrenItem);
            contextMenu.Items.Add(copyNameItem);
            contextMenu.Items.Add(copyValueItem);
            contextMenu.Items.Add(hideItem);

            var existingTreeViewItemStyle = (Style)Application.Current.Resources[typeof(TreeViewItem)];
            var treeViewItemStyle         = new Style(typeof(TreeViewItem), existingTreeViewItemStyle);

            treeViewItemStyle.Setters.Add(new Setter(TreeViewItem.IsExpandedProperty, new Binding("IsExpanded")
            {
                Mode = BindingMode.TwoWay
            }));
            treeViewItemStyle.Setters.Add(new Setter(TreeViewItem.IsSelectedProperty, new Binding("IsSelected")
            {
                Mode = BindingMode.TwoWay
            }));
            treeViewItemStyle.Setters.Add(new Setter(TreeViewItem.VisibilityProperty, new Binding("IsVisible")
            {
                Mode = BindingMode.TwoWay, Converter = new BooleanToVisibilityConverter()
            }));
            treeViewItemStyle.Setters.Add(new EventSetter(MouseDoubleClickEvent, (MouseButtonEventHandler)OnItemDoubleClick));
            treeViewItemStyle.Setters.Add(new EventSetter(PreviewMouseRightButtonDownEvent, (MouseButtonEventHandler)OnPreviewMouseRightButtonDown));
            treeViewItemStyle.Setters.Add(new EventSetter(RequestBringIntoViewEvent, (RequestBringIntoViewEventHandler)TreeViewItem_RequestBringIntoView));
            treeViewItemStyle.Setters.Add(new EventSetter(KeyDownEvent, (KeyEventHandler)OnItemKeyDown));

            treeView.ContextMenu          = contextMenu;
            treeView.ItemContainerStyle   = treeViewItemStyle;
            treeView.KeyDown             += TreeView_KeyDown;
            treeView.SelectedItemChanged += TreeView_SelectedItemChanged;
            treeView.GotFocus            += (s, a) => ActiveTreeView = treeView;

            ActiveTreeView = treeView;

            searchLogControl.ResultsList.ItemContainerStyle   = treeViewItemStyle;
            searchLogControl.ResultsList.SelectedItemChanged += ResultsList_SelectionChanged;
            searchLogControl.ResultsList.GotFocus            += (s, a) => ActiveTreeView = searchLogControl.ResultsList;
            searchLogControl.ResultsList.ContextMenu          = sharedTreeContextMenu;

            findInFilesControl.GotFocus += (s, a) => ActiveTreeView = findInFilesControl.ResultsList;
            findInFilesControl.ResultsList.ItemContainerStyle = treeViewItemStyle;
            findInFilesControl.ResultsList.GotFocus          += (s, a) => ActiveTreeView = findInFilesControl.ResultsList;
            findInFilesControl.ResultsList.ContextMenu        = sharedTreeContextMenu;

            if (archiveFile != null)
            {
                filesTab.Visibility       = Visibility.Visible;
                findInFilesTab.Visibility = Visibility.Visible;
                PopulateFilesTab();
                filesTree.ItemContainerStyle = treeViewItemStyle;

                var filesNote = new TextBlock();
                var text      =
                    @"This log contains the full text of projects and imported files used during the build.
You can use the 'Files' tab in the bottom left to view these files and the 'Find in Files' tab for full-text search.
For many nodes in the tree (Targets, Tasks, Errors, Projects, etc) pressing SPACE or ENTER or double-clicking 
on the node will navigate to the corresponding source code associated with the node.

More functionality is available from the right-click context menu for each node.
Right-clicking a project node may show the 'Preprocess' option if the version of MSBuild was at least 15.3.";
                build.Unseal();
                build.AddChild(new Note {
                    Text = text
                });
                build.Seal();
            }

            breadCrumb.SelectionChanged += BreadCrumb_SelectionChanged;

            Loaded += BuildControl_Loaded;

            preprocessedFileManager = new PreprocessedFileManager(this, sourceFileResolver);
        }
 public GridAwareItemsControl()
 {
     VirtualizingPanel.SetIsVirtualizing(this, false);
 }