コード例 #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();
        }
コード例 #2
0
 public IFieldNode Create(FieldDef field) =>
 (IFieldNode)TreeView.Create(new FieldNode(FileTreeNodeGroups.GetGroup(FileTreeNodeGroupType.FieldTreeNodeGroupType), field)).Data;
コード例 #3
0
 public IEventNode Create(EventDef @event) =>
 (IEventNode)TreeView.Create(new EventNode(FileTreeNodeGroups.GetGroup(FileTreeNodeGroupType.EventTreeNodeGroupType), @event)).Data;
コード例 #4
0
 public IPropertyNode Create(PropertyDef property) =>
 (IPropertyNode)TreeView.Create(new PropertyNode(FileTreeNodeGroups.GetGroup(FileTreeNodeGroupType.PropertyTreeNodeGroupType), property)).Data;
コード例 #5
0
 public IMethodNode Create(MethodDef method) =>
 (IMethodNode)TreeView.Create(new MethodNode(FileTreeNodeGroups.GetGroup(FileTreeNodeGroupType.MethodTreeNodeGroupType), method)).Data;
コード例 #6
0
 public ITypeNode CreateNested(TypeDef type) =>
 (ITypeNode)TreeView.Create(new TypeNode(FileTreeNodeGroups.GetGroup(FileTreeNodeGroupType.TypeTreeNodeGroupType), type)).Data;
コード例 #7
0
 public INamespaceNode Create(string name) =>
 (INamespaceNode)TreeView.Create(new NamespaceNode(FileTreeNodeGroups.GetGroup(FileTreeNodeGroupType.NamespaceTreeNodeGroupModule), name, new List <TypeDef>())).Data;
コード例 #8
0
 public IModuleReferenceNode Create(ModuleRef modRef) =>
 (IModuleReferenceNode)TreeView.Create(new ModuleReferenceNode(FileTreeNodeGroups.GetGroup(FileTreeNodeGroupType.ModuleRefTreeNodeGroupReferences), modRef)).Data;
コード例 #9
0
 public IAssemblyReferenceNode Create(AssemblyRef asmRef, ModuleDef ownerModule) =>
 (IAssemblyReferenceNode)TreeView.Create(new AssemblyReferenceNode(FileTreeNodeGroups.GetGroup(FileTreeNodeGroupType.AssemblyRefTreeNodeGroupReferences), ownerModule, asmRef)).Data;
コード例 #10
0
ファイル: FileTreeView.cs プロジェクト: zstreamer/dnSpy
 public ITypeNode Create(TypeDef type)
 {
     return((ITypeNode)TreeView.Create(new TypeNode(FileTreeNodeGroups.GetGroup(FileTreeNodeGroupType.TypeTreeNodeGroupNamespace), type)).Data);
 }
コード例 #11
0
ファイル: FileTreeView.cs プロジェクト: zstreamer/dnSpy
 public IMethodNode CreateProperty(MethodDef method)
 {
     return((IMethodNode)TreeView.Create(new MethodNode(FileTreeNodeGroups.GetGroup(FileTreeNodeGroupType.MethodTreeNodeGroupProperty), method)).Data);
 }
コード例 #12
0
ファイル: FileTreeView.cs プロジェクト: zstreamer/dnSpy
        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();
        }