Exemple #1
0
        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();
        }
Exemple #2
0
        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();
        }