public FileTreeView(bool isGlobal, IFileTreeNodeFilter filter, IThemeManager themeManager, ITreeViewManager treeViewManager, ILanguageManager languageManager, IFileManager fileManager, IFileTreeViewSettings fileTreeViewSettings, IMenuManager menuManager, IDotNetImageManager dotNetImageManager, IWpfCommandManager wpfCommandManager, IResourceNodeFactory resourceNodeFactory, IAppSettings appSettings, [ImportMany] IEnumerable <Lazy <IDnSpyFileNodeProvider, IDnSpyFileNodeProviderMetadata> > dnSpyFileNodeProviders, [ImportMany] IEnumerable <Lazy <IFileTreeNodeDataFinder, IFileTreeNodeDataFinderMetadata> > mefFinders) { this.languageManager = languageManager; this.themeManager = themeManager; this.fileTreeViewSettings = fileTreeViewSettings; this.appSettings = appSettings; this.context = new FileTreeNodeDataContext(this, resourceNodeFactory, filter ?? FilterNothingFileTreeNodeFilter.Instance) { SyntaxHighlight = fileTreeViewSettings.SyntaxHighlight, SingleClickExpandsChildren = fileTreeViewSettings.SingleClickExpandsTreeViewChildren, ShowAssemblyVersion = fileTreeViewSettings.ShowAssemblyVersion, ShowAssemblyPublicKeyToken = fileTreeViewSettings.ShowAssemblyPublicKeyToken, ShowToken = fileTreeViewSettings.ShowToken, Language = languageManager.Language, UseNewRenderer = appSettings.UseNewRenderer_FileTreeView, DeserializeResources = fileTreeViewSettings.DeserializeResources, CanDragAndDrop = isGlobal, }; var options = new TreeViewOptions { AllowDrop = true, IsVirtualizing = true, VirtualizationMode = VirtualizationMode.Recycling, TreeViewListener = this, RootNode = new RootNode { DropNodes = OnDropNodes, DropFiles = OnDropFiles, }, }; this.fileTreeNodeGroups = new FileTreeNodeGroups(); this.dnSpyFileNodeProviders = dnSpyFileNodeProviders.OrderBy(a => a.Metadata.Order).ToArray(); this.TreeView = treeViewManager.Create(new Guid(TVConstants.FILE_TREEVIEW_GUID), options); this.TreeView.SelectionChanged += TreeView_SelectionChanged; this.FileManager = fileManager; this.DotNetImageManager = dotNetImageManager; this.dispatcher = Dispatcher.CurrentDispatcher; this.FileManager.SetDispatcher(AddAction); fileManager.CollectionChanged += FileManager_CollectionChanged; languageManager.LanguageChanged += LanguageManager_LanguageChanged; themeManager.ThemeChanged += ThemeManager_ThemeChanged; fileTreeViewSettings.PropertyChanged += FileTreeViewSettings_PropertyChanged; appSettings.PropertyChanged += AppSettings_PropertyChanged; this.WpfCommands = wpfCommandManager.GetCommands(CommandConstants.GUID_FILE_TREEVIEW); if (isGlobal) { menuManager.InitializeContextMenu((FrameworkElement)this.TreeView.UIObject, new Guid(MenuConstants.GUIDOBJ_FILES_TREEVIEW_GUID), new GuidObjectsProvider(this.TreeView)); wpfCommandManager.Add(CommandConstants.GUID_FILE_TREEVIEW, (UIElement)TreeView.UIObject); } this.nodeFinders = mefFinders.OrderBy(a => a.Metadata.Order).ToArray(); InitializeFileTreeNodeGroups(); }
public override void Run() { using (TreeViewOptions optionsDialog = new TreeViewOptions((Properties)PropertyService.Get("ICSharpCode.TextEditor.Document.Document.DefaultDocumentAggregatorProperties", new Properties()), AddInTree.GetTreeNode("/SharpDevelop/Dialogs/OptionsDialog"))) { optionsDialog.FormBorderStyle = FormBorderStyle.FixedDialog; optionsDialog.Owner = (Form)WorkbenchSingleton.Workbench; optionsDialog.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm); } }
public DocumentTreeView(bool isGlobal, IDocumentTreeNodeFilter filter, ITreeViewService treeViewService, IDecompilerService decompilerService, IDsDocumentService documentService, IDocumentTreeViewSettings documentTreeViewSettings, IMenuService menuService, IDotNetImageService dotNetImageService, IWpfCommandService wpfCommandService, IResourceNodeFactory resourceNodeFactory, IAppSettings appSettings, [ImportMany] IEnumerable <Lazy <IDsDocumentNodeProvider, IDsDocumentNodeProviderMetadata> > dsDocumentNodeProvider, [ImportMany] IEnumerable <Lazy <IDocumentTreeNodeDataFinder, IDocumentTreeNodeDataFinderMetadata> > mefFinders, ITreeViewNodeTextElementProvider treeViewNodeTextElementProvider) { this.decompilerService = decompilerService; this.documentTreeViewSettings = documentTreeViewSettings; this.appSettings = appSettings; this.context = new DocumentTreeNodeDataContext(this, resourceNodeFactory, filter ?? FilterNothingDocumentTreeNodeFilter.Instance, treeViewNodeTextElementProvider) { SyntaxHighlight = documentTreeViewSettings.SyntaxHighlight, SingleClickExpandsChildren = documentTreeViewSettings.SingleClickExpandsTreeViewChildren, ShowAssemblyVersion = documentTreeViewSettings.ShowAssemblyVersion, ShowAssemblyPublicKeyToken = documentTreeViewSettings.ShowAssemblyPublicKeyToken, ShowToken = documentTreeViewSettings.ShowToken, Decompiler = decompilerService.Decompiler, UseNewRenderer = appSettings.UseNewRenderer_DocumentTreeView, DeserializeResources = documentTreeViewSettings.DeserializeResources, CanDragAndDrop = isGlobal, }; var options = new TreeViewOptions { AllowDrop = true, IsVirtualizing = true, VirtualizationMode = VirtualizationMode.Recycling, TreeViewListener = this, RootNode = new RootNode { DropNodes = OnDropNodes, DropFiles = OnDropFiles, }, }; this.documentTreeNodeGroups = new DocumentTreeNodeGroups(); this.dsDocumentNodeProvider = dsDocumentNodeProvider.OrderBy(a => a.Metadata.Order).ToArray(); this.TreeView = treeViewService.Create(new Guid(TreeViewConstants.DOCUMENT_TREEVIEW_GUID), options); this.TreeView.SelectionChanged += TreeView_SelectionChanged; this.DocumentService = documentService; this.DotNetImageService = dotNetImageService; this.dispatcher = Dispatcher.CurrentDispatcher; this.DocumentService.SetDispatcher(AddAction); documentService.CollectionChanged += DocumentService_CollectionChanged; decompilerService.DecompilerChanged += DecompilerService_DecompilerChanged; documentTreeViewSettings.PropertyChanged += DocumentTreeViewSettings_PropertyChanged; appSettings.PropertyChanged += AppSettings_PropertyChanged; this.WpfCommands = wpfCommandService.GetCommands(ControlConstants.GUID_DOCUMENT_TREEVIEW); if (isGlobal) { menuService.InitializeContextMenu(this.TreeView.UIObject, new Guid(MenuConstants.GUIDOBJ_DOCUMENTS_TREEVIEW_GUID), new GuidObjectsProvider(this.TreeView)); wpfCommandService.Add(ControlConstants.GUID_DOCUMENT_TREEVIEW, TreeView.UIObject); } this.nodeFinders = mefFinders.OrderBy(a => a.Metadata.Order).ToArray(); InitializeDocumentTreeNodeGroups(); }
public override void Run() { using (TreeViewOptions optionsDialog = new TreeViewOptions(AddInTree.GetTreeNode("/SharpDevelop/Dialogs/OptionsDialog"))) { optionsDialog.FormBorderStyle = FormBorderStyle.FixedDialog; optionsDialog.Owner = WorkbenchSingleton.MainForm; if (optionsDialog.ShowDialog(WorkbenchSingleton.MainForm) == DialogResult.OK) { PropertyService.Save(); } } }
public override void Run() { PropertyService propertyService = (PropertyService)ServiceManager.Services.GetService(typeof(PropertyService)); IProperties proterties = (IProperties)propertyService.GetProperty("NetFocus.DataStructure.TextEditor.Document.DefaultDocumentProperties", new DefaultProperties()); IAddInTreeNode treeNode = AddInTreeSingleton.AddInTree.GetTreeNode("/DataStructure/Dialogs/OptionsDialog"); using (TreeViewOptions optionsDialog = new TreeViewOptions(proterties, treeNode)) { optionsDialog.FormBorderStyle = FormBorderStyle.FixedDialog; optionsDialog.Owner = (Form)WorkbenchSingleton.Workbench; optionsDialog.ShowDialog(); } }
ITreeView CreateTreeView(AppSettingsPageVM rootVM) { var options = new TreeViewOptions { CanDragAndDrop = false, SelectionMode = SelectionMode.Single, ForegroundBrushResourceKey = "AppSettingsTreeViewForeground", RootNode = rootVM, }; var treeView = treeViewService.Create(new Guid("99334011-E467-456F-A0DF-BD4DBD0F0519"), options); treeView.UIObject.Padding = new Thickness(0, 2, 0, 2); treeView.UIObject.BorderThickness = new Thickness(1); treeView.UIObject.SetResourceReference(Control.BorderBrushProperty, "AppSettingsTreeViewBorder"); treeView.UIObject.SetResourceReference(Control.ForegroundProperty, "AppSettingsTreeViewForeground"); treeView.UIObject.SetResourceReference(Control.BackgroundProperty, "AppSettingsTreeViewBackground"); return(treeView); }
///// <summary> ///// Render the treeview to two levels - the root album and its direct children. If the AlbumIdsToCheck property ///// has items in its collection, make sure every album in the collection is rendered, no matter how deep in the album heirarchy ///// they may be. If the albumToSelect parameter is specified, then make sure this album is rendered and ///// selected/checked, no matter how deep in the hierarchy it may be. ///// </summary> //public void BindTreeView() //{ // //BindTreeView(null); //} ///// <summary> ///// Render the treeview to two levels - the root album and its direct children. If the <see cref="CheckedAlbumIds" /> property ///// has items in its collection, make sure every album in the collection is rendered, no matter how deep in the album heirarchy ///// they may be. If the <paramref name="albumToSelect" /> parameter is specified, then make sure this album is rendered and ///// selected/checked, no matter how deep in the hierarchy it may be. ///// </summary> ///// <param name="albumToSelect">An album to be selected, checked, and made visible. The treeview is automatically expanded as ///// needed to ensure this album is visible.</param> //public void BindTreeView(IAlbum albumToSelect) //{ // //this._albumToSelect = albumToSelect; // //DataBindTreeView(); // //this._albumToSelect = null; // //this.AlbumIdsToCheck.Clear(); //} #endregion #region Private Methods /// <summary> /// Gets a JSON-formatted string of data that can be assigned to the data property of a /// jsTree jQuery instance. /// </summary> /// <returns>A string formatted as JSON.</returns> /// <exception cref="System.InvalidOperationException">Thrown when one or more business rules /// are violated.</exception> private string GetTreeData() { #region Validation if (!this.AllowMultiCheck && this.SelectedAlbumIds.Count > 1) { throw new InvalidOperationException("The property AllowMultiCheck must be false when multiple album IDs have been assigned to the property SelectedAlbumIds."); } if (!SecurityActionEnumHelper.IsValidSecurityAction(this.RequiredSecurityPermissions)) { throw new InvalidOperationException("The property GalleryServer.Web.Controls.albumtreeview.RequiredSecurityPermissions must be assigned before the TreeView can be rendered."); } #endregion TreeViewOptions tvOptions = new TreeViewOptions() { SelectedAlbumIds = SelectedAlbumIds, NumberOfLevels = NumberOfLevels, NavigateUrl = NavigateUrl, EnableCheckboxPlugin = EnableCheckboxPlugin, IncludeAlbum = IncludeAlbum, RequiredSecurityPermissions = RequiredSecurityPermissions, AlbumId = AlbumId, RootNodesPrefix = RootNodesPrefix, Galleries = Galleries }; Entity.TreeView tv = AlbumTreeViewBuilder.GetAlbumsAsTreeView(tvOptions); //if (_nodesToCheckIds == null) // _nodesToCheckIds = new List<string>(tv.NodesToCheckIdArray.Count); //_nodesToCheckIds.AddRange(tv.NodesToCheckIdArray); return(tv.ToJson()); }
AnalyzerService(IWpfCommandService wpfCommandService, IDocumentTabService documentTabService, ITreeViewService treeViewService, IMenuService menuService, IAnalyzerSettings analyzerSettings, IDotNetImageService dotNetImageService, IDecompilerService decompilerService, ITreeViewNodeTextElementProvider treeViewNodeTextElementProvider) { this.documentTabService = documentTabService; context = new AnalyzerTreeNodeDataContext { DotNetImageService = dotNetImageService, Decompiler = decompilerService.Decompiler, TreeViewNodeTextElementProvider = treeViewNodeTextElementProvider, DocumentService = documentTabService.DocumentTreeView.DocumentService, ShowToken = analyzerSettings.ShowToken, SingleClickExpandsChildren = analyzerSettings.SingleClickExpandsChildren, SyntaxHighlight = analyzerSettings.SyntaxHighlight, UseNewRenderer = analyzerSettings.UseNewRenderer, AnalyzerService = this, }; var options = new TreeViewOptions { CanDragAndDrop = false, TreeViewListener = this, }; TreeView = treeViewService.Create(ANALYZER_TREEVIEW_GUID, options); context.TreeView = TreeView; documentTabService.DocumentTreeView.DocumentService.CollectionChanged += DocumentService_CollectionChanged; documentTabService.DocumentModified += DocumentTabService_FileModified; decompilerService.DecompilerChanged += DecompilerService_DecompilerChanged; analyzerSettings.PropertyChanged += AnalyzerSettings_PropertyChanged; menuService.InitializeContextMenu(TreeView.UIObject, new Guid(MenuConstants.GUIDOBJ_ANALYZER_TREEVIEW_GUID), new GuidObjectsProvider(TreeView)); wpfCommandService.Add(ControlConstants.GUID_ANALYZER_TREEVIEW, TreeView.UIObject); var cmds = wpfCommandService.GetCommands(ControlConstants.GUID_ANALYZER_TREEVIEW); var command = new RelayCommand(a => ActivateNode()); cmds.Add(command, ModifierKeys.Control, Key.Enter); cmds.Add(command, ModifierKeys.Shift, Key.Enter); }
AnalyzerManager(IWpfCommandManager wpfCommandManager, IFileTabManager fileTabManager, ITreeViewManager treeViewManager, IMenuManager menuManager, IThemeManager themeManager, IAnalyzerSettings analyzerSettings, IDotNetImageManager dotNetImageManager, ILanguageManager languageManager) { this.fileTabManager = fileTabManager; this.context = new AnalyzerTreeNodeDataContext { DotNetImageManager = dotNetImageManager, Language = languageManager.Language, FileManager = fileTabManager.FileTreeView.FileManager, ShowToken = analyzerSettings.ShowToken, SingleClickExpandsChildren = analyzerSettings.SingleClickExpandsChildren, SyntaxHighlight = analyzerSettings.SyntaxHighlight, UseNewRenderer = analyzerSettings.UseNewRenderer, AnalyzerManager = this, }; var options = new TreeViewOptions { CanDragAndDrop = false, TreeViewListener = this, }; this.TreeView = treeViewManager.Create(ANALYZER_TREEVIEW_GUID, options); fileTabManager.FileTreeView.FileManager.CollectionChanged += FileManager_CollectionChanged; fileTabManager.FileModified += FileTabManager_FileModified; languageManager.LanguageChanged += LanguageManager_LanguageChanged; themeManager.ThemeChanged += ThemeManager_ThemeChanged; analyzerSettings.PropertyChanged += AnalyzerSettings_PropertyChanged; menuManager.InitializeContextMenu((FrameworkElement)this.TreeView.UIObject, new Guid(MenuConstants.GUIDOBJ_ANALYZER_TREEVIEW_GUID), new GuidObjectsProvider(this.TreeView)); wpfCommandManager.Add(CommandConstants.GUID_ANALYZER_TREEVIEW, (UIElement)this.TreeView.UIObject); var cmds = wpfCommandManager.GetCommands(CommandConstants.GUID_ANALYZER_TREEVIEW); var command = new RelayCommand(a => ActivateNode()); cmds.Add(command, ModifierKeys.Control, Key.Enter); cmds.Add(command, ModifierKeys.Shift, Key.Enter); }
/// <summary> /// Gets a JSON-formatted string of data that can be assigned to the data property of a /// jsTree jQuery instance. /// </summary> /// <returns>A string formatted as JSON.</returns> /// <exception cref="System.InvalidOperationException">Thrown when one or more business rules /// are violated.</exception> private string GetTreeData() { #region Validation if (!this.AllowMultiCheck && this.SelectedAlbumIds.Count > 1) { throw new InvalidOperationException("The property AllowMultiCheck must be false when multiple album IDs have been assigned to the property SelectedAlbumIds."); } if (!SecurityActionEnumHelper.IsValidSecurityAction(this.RequiredSecurityPermissions)) { throw new InvalidOperationException("The property GalleryServerPro.Web.Controls.albumtreeview.RequiredSecurityPermissions must be assigned before the TreeView can be rendered."); } #endregion TreeViewOptions tvOptions = new TreeViewOptions() { SelectedAlbumIds = SelectedAlbumIds, NavigateUrl = NavigateUrl, EnableCheckboxPlugin = EnableCheckboxPlugin, RequiredSecurityPermissions = RequiredSecurityPermissions, RootAlbumId = RootAlbumId, RootAlbumPrefix = RootAlbumPrefix, Galleries = Galleries }; TreeView tv = AlbumTreeViewBuilder.GetAlbumsAsTreeView(tvOptions); //if (_nodesToCheckIds == null) // _nodesToCheckIds = new List<string>(tv.NodesToCheckIdArray.Count); //_nodesToCheckIds.AddRange(tv.NodesToCheckIdArray); return tv.ToJson(); }
/// <summary> /// Generates a <see cref="TreeView" /> instance corresponding to the settings specified in <paramref name="tvOptions" />. /// </summary> /// <param name="tvOptions">The treeview options.</param> /// <returns>An instance of <see cref="TreeView" />.</returns> public static TreeView GetAlbumsAsTreeView(TreeViewOptions tvOptions) { AlbumTreeViewBuilder tvBuilder = new AlbumTreeViewBuilder(tvOptions); return tvBuilder.Generate(); }
/// <summary> /// Render the treeview with the first two levels of albums that are viewable to the logged on user. /// </summary> /// <param name="tvOptions">The treeview options.</param> /// <returns>Task<TreeView>.</returns> private async Task <TreeView> Generate(TreeViewOptions tvOptions) { Options = tvOptions; Tree.EnableCheckBoxPlugin = Options.EnableCheckboxPlugin; foreach (IAlbum rootAlbum in await GetTopAlbums()) { if (!Options.UserController.IsUserAuthorized(SecurityActions.ViewAlbumOrMediaObject, await Options.UserController.GetGalleryServerRolesForUser(), rootAlbum.Id, rootAlbum.GalleryId, rootAlbum.IsPrivate, rootAlbum.IsVirtualAlbum)) { continue; } // Add root node. TreeNode rootNode = new TreeNode(); string albumTitle = GetTopAlbumTitle(rootAlbum); rootNode.Text = albumTitle; rootNode.ToolTip = albumTitle; rootNode.Id = String.Concat("tv_", rootAlbum.Id.ToString(CultureInfo.InvariantCulture)); rootNode.DataId = rootAlbum.Id.ToString(CultureInfo.InvariantCulture); rootNode.Expanded = (Options.NumberOfLevels > 1); if (rootAlbum.Parent is NullGalleryObject) { rootNode.AddCssClass("jstree-root-node"); } if (!String.IsNullOrEmpty(Options.NavigateUrl)) { //var url = rootAlbum.IsVirtualAlbum ? Options.NavigateUrl : Utils.AddQueryStringParameter(Options.NavigateUrl, String.Concat("aid=", rootAlbum.Id.ToString(CultureInfo.InvariantCulture))); var url = rootAlbum.IsVirtualAlbum ? Options.NavigateUrl : string.Concat(Options.NavigateUrl, "?aid=", rootAlbum.Id.ToString(CultureInfo.InvariantCulture)); rootNode.NavigateUrl = url; } // If it has a nav URL, it's always selectable & won't have a checkbox. If not, then it's selectable if the user has permission if (string.IsNullOrEmpty(rootNode.NavigateUrl)) { rootNode.Selectable = !rootAlbum.IsVirtualAlbum && Options.UserController.IsUserAuthorized(Options.RequiredSecurityPermissions, await GetRoles(), rootAlbum.Id, rootAlbum.GalleryId, rootAlbum.IsPrivate, SecurityActionsOption.RequireOne, rootAlbum.IsVirtualAlbum); if (Options.EnableCheckboxPlugin) { rootNode.ShowCheckBox = rootNode.Selectable; } } else { rootNode.Selectable = true; } // Select and check this node if needed. if (Options.SelectedAlbumIds.Contains(rootAlbum.Id)) { rootNode.Selected = true; } Tree.Nodes.Add(rootNode); // Add the first level of albums below the root album. var childAlbums = rootAlbum.GetChildGalleryObjects(GalleryObjectType.Album, !Options.UserController.IsAuthenticated); if (Options.NumberOfLevels == 1) { rootNode.HasChildren = childAlbums.Any(); } else { BindAlbumToTreeview(childAlbums.ToSortedList(), rootNode, false); } // Only display the root node if it is selectable or we added any children to it; otherwise, remove it. //if (!rootNode.Selectable && rootNode.Nodes.Count == 0) //{ // Tree.Nodes.Remove(rootNode); //} } // Make sure all specified albums are visible and checked. try { foreach (var albumId in Options.SelectedAlbumIds.Where(id => id > int.MinValue)) { var album = Factory.LoadAlbumInstance(new AlbumLoadOptions(albumId)); if (Options.UserController.IsUserAuthorized(Options.RequiredSecurityPermissions, await GetRoles(), album.Id, album.GalleryId, album.IsPrivate, SecurityActionsOption.RequireOne, album.IsVirtualAlbum)) { BindSpecificAlbumToTreeview(album); } } } catch (InvalidAlbumException ex) { // One of the albums we want to select doesn't exist. Log the event but otherwise continue on gracefully. if (!ex.Data.Contains("Tree_SelectedAlbum_Info")) { ex.Data.Add("Tree_SelectedAlbum_Info", $"Album {ex.AlbumId} was one of the SelectedAlbumIds of the TreeViewOptions object. It may have been deleted by another user just before this code ran."); } AppEventController.LogError(ex); } return(Tree); }
/// <summary> /// Generates a <see cref="TreeView" /> instance corresponding to the settings specified in <paramref name="tvOptions" />. /// </summary> /// <param name="tvOptions">The treeview options.</param> /// <returns>An instance of <see cref="TreeView" />.</returns> public async Task <TreeView> GetAlbumsAsTreeView(TreeViewOptions tvOptions) { return(await Generate(tvOptions)); }
public ITreeView Create(Guid guid, TreeViewOptions options) => new TreeViewImpl(this, themeService, classificationFormatMapService, guid, options);
public TreeViewBuilder(string id) { _treeViewOptions = new TreeViewOptions(); _id = id; }
/// <summary> /// Generates a <see cref="TreeView" /> instance corresponding to the settings specified in <paramref name="tvOptions" />. /// </summary> /// <param name="tvOptions">The treeview options.</param> /// <returns>An instance of <see cref="TreeView" />.</returns> public static TreeView GetAlbumsAsTreeView(TreeViewOptions tvOptions) { return(new AlbumTreeViewBuilder(tvOptions).Generate()); }
public TreeViewImpl(ITreeViewManager treeViewManager, IThemeManager themeManager, IImageManager imageManager, Guid guid, TreeViewOptions options) { this.Guid = guid; this.treeViewManager = treeViewManager; this.imageManager = imageManager; this.treeViewListener = options.TreeViewListener; this.sharpTreeView = new SharpTreeView(); this.sharpTreeView.SelectionChanged += SharpTreeView_SelectionChanged; this.sharpTreeView.CanDragAndDrop = options.CanDragAndDrop; this.sharpTreeView.AllowDrop = options.AllowDrop; this.sharpTreeView.AllowDropOrder = options.AllowDrop; VirtualizingStackPanel.SetIsVirtualizing(this.sharpTreeView, options.IsVirtualizing); VirtualizingStackPanel.SetVirtualizationMode(this.sharpTreeView, options.VirtualizationMode); this.sharpTreeView.SelectionMode = options.SelectionMode; this.sharpTreeView.BorderThickness = new Thickness(0); this.sharpTreeView.ShowRoot = false; this.sharpTreeView.ShowLines = false; if (options.IsGridView) { this.sharpTreeView.ItemContainerStyle = (Style)Application.Current.FindResource(SharpGridView.ItemContainerStyleKey); this.sharpTreeView.Style = (Style)Application.Current.FindResource("SharpTreeViewGridViewStyle"); } else { // Clear the value set by the constructor. This is required or our style won't be used. this.sharpTreeView.ClearValue(ItemsControl.ItemContainerStyleProperty); this.sharpTreeView.Style = (Style)Application.Current.FindResource(typeof(SharpTreeView)); } this.sharpTreeView.GetPreviewInsideTextBackground = () => themeManager.Theme.GetColor(ColorType.SystemColorsHighlight).Background; this.sharpTreeView.GetPreviewInsideForeground = () => themeManager.Theme.GetColor(ColorType.SystemColorsHighlightText).Foreground; // Add the root at the end since Create() requires some stuff to have been initialized this.root = Create(options.RootNode ?? new TreeNodeDataImpl(new Guid(FileTVConstants.ROOT_NODE_GUID))); this.sharpTreeView.Root = this.root.Node; }
public ITreeView Create(Guid guid, TreeViewOptions options) => new TreeViewImpl(this, themeManager, imageManager, guid, options);
/// <summary> /// Initializes a new instance of the <see cref="AlbumTreeViewBuilder"/> class. /// </summary> /// <param name="tvOptions">The treeview options.</param> private AlbumTreeViewBuilder(TreeViewOptions tvOptions) { _tvOptions = tvOptions; _tv = new TreeView(); }
/// <summary> /// Generates a <see cref="TreeView" /> instance corresponding to the settings specified in <paramref name="tvOptions" />. /// </summary> /// <param name="tvOptions">The treeview options.</param> /// <returns>An instance of <see cref="TreeView" />.</returns> public static TreeView GetAlbumsAsTreeView(TreeViewOptions tvOptions) { AlbumTreeViewBuilder tvBuilder = new AlbumTreeViewBuilder(tvOptions); return(tvBuilder.Generate()); }
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; }
partial void Initialize(IJSObject element, TreeViewOptions options) { this.Init(); base.Initialize(); }
public FileTreeView(bool isGlobal, IFileTreeNodeFilter filter, IThemeManager themeManager, ITreeViewManager treeViewManager, ILanguageManager languageManager, IFileManager fileManager, IFileTreeViewSettings fileTreeViewSettings, IMenuManager menuManager, IDotNetImageManager dotNetImageManager, IWpfCommandManager wpfCommandManager, IResourceNodeFactory resourceNodeFactory, IAppSettings appSettings, [ImportMany] IEnumerable <Lazy <IDnSpyFileNodeCreator, IDnSpyFileNodeCreatorMetadata> > dnSpyFileNodeCreators, [ImportMany] IEnumerable <Lazy <IFileTreeNodeDataFinder, IFileTreeNodeDataFinderMetadata> > mefFinders) { this.languageManager = languageManager; this.themeManager = themeManager; this.fileTreeViewSettings = fileTreeViewSettings; this.appSettings = appSettings; this.context = new FileTreeNodeDataContext(this, resourceNodeFactory, filter ?? FilterNothingFileTreeNodeFilter.Instance) { SyntaxHighlight = fileTreeViewSettings.SyntaxHighlight, SingleClickExpandsChildren = fileTreeViewSettings.SingleClickExpandsTreeViewChildren, ShowAssemblyVersion = fileTreeViewSettings.ShowAssemblyVersion, ShowAssemblyPublicKeyToken = fileTreeViewSettings.ShowAssemblyPublicKeyToken, ShowToken = fileTreeViewSettings.ShowToken, Language = languageManager.SelectedLanguage, UseNewRenderer = appSettings.UseNewRenderer_FileTreeView, DeserializeResources = fileTreeViewSettings.DeserializeResources, CanDragAndDrop = isGlobal, }; var options = new TreeViewOptions { AllowDrop = true, IsVirtualizing = true, VirtualizationMode = VirtualizationMode.Recycling, TreeViewListener = this, RootNode = new RootNode { DropNodes = OnDropNodes, DropFiles = OnDropFiles, }, }; this.fileTreeNodeGroups = new FileTreeNodeGroups(); this.dnSpyFileNodeCreators = dnSpyFileNodeCreators.OrderBy(a => a.Metadata.Order).ToArray(); this.treeView = treeViewManager.Create(new Guid(TVConstants.FILE_TREEVIEW_GUID), options); this.fileManager = fileManager; this.dotNetImageManager = dotNetImageManager; var dispatcher = Dispatcher.CurrentDispatcher; this.fileManager.SetDispatcher(a => { if (!dispatcher.HasShutdownFinished && !dispatcher.HasShutdownStarted) { bool callInvoke; lock (actionsToCall) { actionsToCall.Add(a); callInvoke = actionsToCall.Count == 1; } if (callInvoke) { // Always notify with a delay because adding stuff to the tree view could // cause some problems with the tree view or the list box it derives from. dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(CallActions)); } } }); fileManager.CollectionChanged += FileManager_CollectionChanged; languageManager.LanguageChanged += LanguageManager_LanguageChanged; themeManager.ThemeChanged += ThemeManager_ThemeChanged; fileTreeViewSettings.PropertyChanged += FileTreeViewSettings_PropertyChanged; appSettings.PropertyChanged += AppSettings_PropertyChanged; this.wpfCommands = wpfCommandManager.GetCommands(CommandConstants.GUID_FILE_TREEVIEW); if (isGlobal) { menuManager.InitializeContextMenu((FrameworkElement)this.treeView.UIObject, new Guid(MenuConstants.GUIDOBJ_FILES_TREEVIEW_GUID), new GuidObjectsCreator(this.treeView)); wpfCommandManager.Add(CommandConstants.GUID_FILE_TREEVIEW, (UIElement)treeView.UIObject); } this.nodeFinders = mefFinders.OrderBy(a => a.Metadata.Order).ToArray(); InitializeFileTreeNodeGroups(); }