Exemplo n.º 1
0
        internal static void InitializeTreeView(SharpTreeView treeView)
        {
            // Clear the value set by the constructor. This is required or our style won't be used.
            treeView.ClearValue(ItemsControl.ItemContainerStyleProperty);

            treeView.GetPreviewInsideTextBackground = () => Themes.Theme.GetColor(ColorType.SystemColorsHighlight).InheritedColor.Background.GetBrush(null);
            treeView.GetPreviewInsideForeground = () => Themes.Theme.GetColor(ColorType.SystemColorsHighlightText).InheritedColor.Foreground.GetBrush(null);
        }
Exemplo n.º 2
0
		internal static void InitializeTreeView(SharpTreeView treeView)
		{
			// Clear the value set by the constructor. This is required or our style won't be used.
			treeView.ClearValue(ItemsControl.ItemContainerStyleProperty);

			treeView.GetPreviewInsideTextBackground = () => Themes.Theme.GetColor(dntheme.ColorType.SystemColorsHighlight).InheritedColor.Background.GetBrush(null);
			treeView.GetPreviewInsideForeground = () => Themes.Theme.GetColor(dntheme.ColorType.SystemColorsHighlightText).InheritedColor.Foreground.GetBrush(null);

			VirtualizingStackPanel.SetIsVirtualizing(treeView, true);
			// VirtualizationMode.Recycling results in slower scrolling but less memory usage.
			// In my simple test, 225MB vs 280MB (165 loaded assemblies, selected method was
			// [mscorlib]System.String::Format(string, object), scroll up and down, release, then
			// keep doing it a number of times).
			// VirtualizationMode.Standard: all created items are freed once the scrolling stops
			// which can sometimes result in the UI not responding to input. Doesn't seem to be a
			// problem with the treeview, though. More of a problem with the CIL editor which has
			// to use Recycling.
			// SharpTreeView defaults to Recycling, so we must explicitly set it to Standard.
			VirtualizingStackPanel.SetVirtualizationMode(treeView, VirtualizationMode.Standard);
		}
Exemplo n.º 3
0
		internal static void InitializeTreeView(SharpTreeView treeView, bool isGridView = false) {
			if (isGridView)
				treeView.ItemContainerStyle = (Style)App.Current.TryFindResource(SharpGridView.ItemContainerStyleKey);
			else {
				// Clear the value set by the constructor. This is required or our style won't be used.
				treeView.ClearValue(ItemsControl.ItemContainerStyleProperty);
			}

			treeView.GetPreviewInsideTextBackground = () => Themes.Theme.GetColor(ColorType.SystemColorsHighlight).InheritedColor.Background.GetBrush(null);
			treeView.GetPreviewInsideForeground = () => Themes.Theme.GetColor(ColorType.SystemColorsHighlightText).InheritedColor.Foreground.GetBrush(null);
		}
Exemplo n.º 4
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;
			VirtualizingStackPanel.SetIsVirtualizing(sharpTreeView, options.IsVirtualizing);
			VirtualizingStackPanel.SetVirtualizationMode(sharpTreeView, options.VirtualizationMode);
			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;
		}