示例#1
0
 void MemLeakFix()
 {
     uiDispatcher.VerifyAccess();
     for (int i = 0; i < WatchWindowsHelper.NUMBER_OF_WATCH_WINDOWS; i++)
     {
         if (watchContentFactory.TryGetContent(i, out var watchContent))
         {
             var listView = watchContent.VariablesWindowControl.ListView;
             if (listView != null)
             {
                 AutomationPeerMemoryLeakWorkaround.ClearAll(listView);
             }
         }
     }
 }
示例#2
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;
        }
        public void SetTreeView(ITreeView treeView, VariablesWindowKind windowKind)
        {
            var listView = (ListView)treeView?.UIObject;

            if (treeViewContentPresenter.Content == listView)
            {
                return;
            }
            if (treeViewContentPresenter.Content is UIElement oldElem)
            {
                oldElem.PreviewTextInput -= TreeView_PreviewTextInput;
            }
            if (listView != null)
            {
                listView.PreviewTextInput += TreeView_PreviewTextInput;
            }
            treeViewContentPresenter.Content = listView;
            AutomationPeerMemoryLeakWorkaround.SetEmptyCount(listView, GetEmptyCount(windowKind));
            if (listView != null)
            {
                var gridView = (GridView)FindResource("GridView");
                listView.View = gridView;
            }
        }