Beispiel #1
0
 public DocumentViewer(IWpfCommandManager wpfCommandManager, IDocumentViewerServiceImpl documentViewerServiceImpl, IMenuManager menuManager, DocumentViewerControl documentViewerControl)
 {
     if (wpfCommandManager == null)
     {
         throw new ArgumentNullException(nameof(wpfCommandManager));
     }
     if (documentViewerServiceImpl == null)
     {
         throw new ArgumentNullException(nameof(documentViewerServiceImpl));
     }
     if (menuManager == null)
     {
         throw new ArgumentNullException(nameof(menuManager));
     }
     if (documentViewerControl == null)
     {
         throw new ArgumentNullException(nameof(documentViewerControl));
     }
     this.wpfCommandManager         = wpfCommandManager;
     this.documentViewerServiceImpl = documentViewerServiceImpl;
     this.documentViewerControl     = documentViewerControl;
     menuManager.InitializeContextMenu(documentViewerControl.TextView.VisualElement, MenuConstants.GUIDOBJ_DOCUMENTVIEWERCONTROL_GUID, new GuidObjectsProvider(this), new ContextMenuInitializer(documentViewerControl.TextView));
     // Prevent the tab control's context menu from popping up when right-clicking in the textview host margin
     menuManager.InitializeContextMenu(documentViewerControl, Guid.NewGuid());
     wpfCommandManager.Add(ControlConstants.GUID_DOCUMENTVIEWER_UICONTEXT, documentViewerControl);
     documentViewerControl.TextView.Properties.AddProperty(typeof(DocumentViewer), this);
     documentViewerControl.TextView.TextBuffer.Properties.AddProperty(DocumentViewerExtensions.DocumentViewerTextBufferKey, this);
 }
Beispiel #2
0
        public DnHexBox(IMenuManager menuManager, IHexEditorSettings hexEditorSettings)
        {
            this.hexEditorSettings = hexEditorSettings;
            SetBinding(Control.FontFamilyProperty, new Binding("FontFamily")
            {
                Source = hexEditorSettings
            });
            SetBinding(Control.FontSizeProperty, new Binding("FontSize")
            {
                Source = hexEditorSettings
            });
            SetResourceReference(Control.BackgroundProperty, HexBoxThemeHelper.GetBackgroundResourceKey(ColorType.HexText));
            SetResourceReference(Control.ForegroundProperty, HexBoxThemeHelper.GetForegroundResourceKey(ColorType.HexText));
            SetResourceReference(HexBox.OffsetForegroundProperty, HexBoxThemeHelper.GetForegroundResourceKey(ColorType.HexOffset));
            SetResourceReference(HexBox.Byte0ForegroundProperty, HexBoxThemeHelper.GetForegroundResourceKey(ColorType.HexByte0));
            SetResourceReference(HexBox.Byte1ForegroundProperty, HexBoxThemeHelper.GetForegroundResourceKey(ColorType.HexByte1));
            SetResourceReference(HexBox.ByteErrorForegroundProperty, HexBoxThemeHelper.GetForegroundResourceKey(ColorType.HexByteError));
            SetResourceReference(HexBox.AsciiForegroundProperty, HexBoxThemeHelper.GetForegroundResourceKey(ColorType.HexAscii));
            SetResourceReference(HexBox.CaretForegroundProperty, HexBoxThemeHelper.GetBackgroundResourceKey(ColorType.HexCaret));
            SetResourceReference(HexBox.InactiveCaretForegroundProperty, HexBoxThemeHelper.GetBackgroundResourceKey(ColorType.HexInactiveCaret));
            SetResourceReference(HexBox.SelectionBackgroundProperty, HexBoxThemeHelper.GetBackgroundResourceKey(ColorType.HexSelection));
            SetResourceReference(Control.FontStyleProperty, HexBoxThemeHelper.GetFontStyleResourceKey(ColorType.HexText));
            SetResourceReference(Control.FontWeightProperty, HexBoxThemeHelper.GetFontWeightResourceKey(ColorType.HexText));

            menuManager.InitializeContextMenu(this, MenuConstants.GUIDOBJ_HEXBOX_GUID, null, new ContextMenuInitializer());

            BytesGroupCount = null;
            BytesPerLine    = null;
            UseHexPrefix    = null;
            ShowAscii       = null;
            LowerCaseHex    = null;
            AsciiEncoding   = null;

            InstallBindings();
        }
Beispiel #3
0
        public DnHexBox(IMenuManager menuManager, IHexEditorSettings hexEditorSettings)
        {
            this.hexEditorSettings = hexEditorSettings;
            SetBinding(Control.FontFamilyProperty, new Binding("FontFamily") { Source = hexEditorSettings });
            SetBinding(Control.FontSizeProperty, new Binding("FontSize") { Source = hexEditorSettings });
            SetResourceReference(Control.BackgroundProperty, HexBoxThemeHelper.GetBackgroundResourceKey(ColorType.HexText));
            SetResourceReference(Control.ForegroundProperty, HexBoxThemeHelper.GetForegroundResourceKey(ColorType.HexText));
            SetResourceReference(HexBox.OffsetForegroundProperty, HexBoxThemeHelper.GetForegroundResourceKey(ColorType.HexOffset));
            SetResourceReference(HexBox.Byte0ForegroundProperty, HexBoxThemeHelper.GetForegroundResourceKey(ColorType.HexByte0));
            SetResourceReference(HexBox.Byte1ForegroundProperty, HexBoxThemeHelper.GetForegroundResourceKey(ColorType.HexByte1));
            SetResourceReference(HexBox.ByteErrorForegroundProperty, HexBoxThemeHelper.GetForegroundResourceKey(ColorType.HexByteError));
            SetResourceReference(HexBox.AsciiForegroundProperty, HexBoxThemeHelper.GetForegroundResourceKey(ColorType.HexAscii));
            SetResourceReference(HexBox.CaretForegroundProperty, HexBoxThemeHelper.GetBackgroundResourceKey(ColorType.HexCaret));
            SetResourceReference(HexBox.InactiveCaretForegroundProperty, HexBoxThemeHelper.GetBackgroundResourceKey(ColorType.HexInactiveCaret));
            SetResourceReference(HexBox.SelectionBackgroundProperty, HexBoxThemeHelper.GetBackgroundResourceKey(ColorType.HexSelection));
            SetResourceReference(Control.FontStyleProperty, HexBoxThemeHelper.GetFontStyleResourceKey(ColorType.HexText));
            SetResourceReference(Control.FontWeightProperty, HexBoxThemeHelper.GetFontWeightResourceKey(ColorType.HexText));

            menuManager.InitializeContextMenu(this, MenuConstants.GUIDOBJ_HEXBOX_GUID, null, new ContextMenuInitializer());

            BytesGroupCount = null;
            BytesPerLine = null;
            UseHexPrefix = null;
            ShowAscii = null;
            LowerCaseHex = null;
            AsciiEncoding = null;

            InstallBindings();
        }
Beispiel #4
0
        public ReplEditorUI(ReplEditorOptions options, IThemeManager themeManager, IWpfCommandManager wpfCommandManager, IMenuManager menuManager, ITextEditorSettings textEditorSettings)
        {
            this.dispatcher = Dispatcher.CurrentDispatcher;
            this.options    = (options ?? new ReplEditorOptions()).Clone();
            this.textEditor = new NewTextEditor(themeManager, textEditorSettings);
            this.textEditor.TextArea.Document = new TextDocument();
            this.textEditor.TextArea.Document.UndoStack.SizeLimit = 100;
            this.textEditor.TextArea.LeftMargins.Insert(0, new FrameworkElement {
                Margin = new Thickness(LEFT_MARGIN, 0, 0, 0)
            });
            this.textEditor.TextArea.TextEntering   += TextArea_TextEntering;
            this.textEditor.TextArea.PreviewKeyDown += TextArea_PreviewKeyDown;
            AddBinding(ApplicationCommands.Paste, (s, e) => Paste(), (s, e) => e.CanExecute      = CanPaste && IsAtEditingPosition);
            AddBinding(ApplicationCommands.Cut, (s, e) => CutSelection(), (s, e) => e.CanExecute = CanCutSelection && IsAtEditingPosition);

            if (this.options.TextEditorCommandGuid != null)
            {
                wpfCommandManager.Add(this.options.TextEditorCommandGuid.Value, textEditor);
            }
            if (this.options.TextAreaCommandGuid != null)
            {
                wpfCommandManager.Add(this.options.TextAreaCommandGuid.Value, textEditor.TextArea);
            }
            if (this.options.MenuGuid != null)
            {
                menuManager.InitializeContextMenu(this.textEditor, this.options.MenuGuid.Value, new GuidObjectsCreator(this), new ContextMenuInitializer(textEditor, textEditor));
            }
        }
Beispiel #5
0
 public void Initialize(IMenuManager menuManager, TextEditorControl textEditorControl)
 {
     this.textEditorControl = textEditorControl;
     this.wpfCommandManager.Add(CommandConstants.GUID_TEXTEDITOR_UICONTEXT, textEditorControl);
     this.wpfCommandManager.Add(CommandConstants.GUID_TEXTEDITOR_UICONTEXT_TEXTEDITOR, textEditorControl.TextEditor);
     this.wpfCommandManager.Add(CommandConstants.GUID_TEXTEDITOR_UICONTEXT_TEXTAREA, textEditorControl.TextEditor.TextArea);
     menuManager.InitializeContextMenu(this.textEditorControl, MenuConstants.GUIDOBJ_TEXTEDITORCONTROL_GUID, new GuidObjectsCreator(this), new ContextMenuInitializer());
 }
Beispiel #6
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();
        }
        public void Initialize(DependencyObject d)
        {
            var fwe = d as FrameworkElement;

            if (fwe == null)
            {
                return;
            }

            menuManager.InitializeContextMenu(fwe, MenuConstants.GUIDOBJ_UNKNOWN_GUID);
        }
Beispiel #8
0
 public TabGroup(TabGroupManager tabGroupManager, IMenuManager menuManager, IWpfFocusManager wpfFocusManager, TabGroupManagerOptions options)
 {
     this.options = options;
     this.tabContentAttached = new WeakEventList<TabContentAttachedEventArgs>();
     this.tabGroupManager = tabGroupManager;
     this.wpfFocusManager = wpfFocusManager;
     this.tabControl = new TabControl();
     this.tabControl.DataContext = this;
     tabControl.SetStyle(options.TabControlStyle ?? "FileTabGroupTabControlStyle");
     this.tabControl.SelectionChanged += TabControl_SelectionChanged;
     if (options.InitializeContextMenu != null)
         this.contextMenuCreator = options.InitializeContextMenu(menuManager, this, this.tabControl);
     else if (options.TabGroupGuid != Guid.Empty)
         this.contextMenuCreator = menuManager.InitializeContextMenu(this.tabControl, options.TabGroupGuid, new GuidObjectsCreator(this));
 }
        IDnSpyWpfTextView CreateTextViewImpl(ITextViewModel textViewModel, ITextViewRoleSet roles, IEditorOptions parentOptions, TextViewCreatorOptions options, Func <IGuidObjectsProvider> createGuidObjectsProvider = null)
        {
            var guidObjectsProvider = new GuidObjectsProvider(options?.CreateGuidObjects, createGuidObjectsProvider?.Invoke());
            var wpfTextView         = new WpfTextView(textViewModel, roles, parentOptions, editorOptionsFactoryService, commandManager, smartIndentationService, formattedTextSourceFactoryService, viewClassifierAggregatorService, textAndAdornmentSequencerFactoryService, classificationFormatMapService, editorFormatMapService, adornmentLayerDefinitionService, lineTransformProviderService, spaceReservationStackProvider, wpfTextViewConnectionListenerServiceProvider, bufferGraphFactoryService, wpfTextViewCreationListeners);

            guidObjectsProvider.WpfTextView = wpfTextView;

            if (options?.MenuGuid != null)
            {
                menuManager.InitializeContextMenu(wpfTextView.VisualElement, options.MenuGuid.Value, guidObjectsProvider, new ContextMenuInitializer(wpfTextView));
            }

            TextViewCreated?.Invoke(this, new TextViewCreatedEventArgs(wpfTextView));

            return(wpfTextView);
        }
Beispiel #10
0
        SearchManager(IImageManager imageManager, ILanguageManager languageManager, IThemeManager themeManager, ISearchSettings searchSettings, IFileSearcherCreator fileSearcherCreator, IMenuManager menuManager, IWpfCommandManager wpfCommandManager, IFileTabManager fileTabManager)
        {
            this.fileTabManager = fileTabManager;
            this.searchControl  = new SearchControl();
            this.vmSearch       = new SearchControlVM(imageManager, fileSearcherCreator, fileTabManager.FileTreeView, searchSettings)
            {
                Language       = languageManager.Language,
                BackgroundType = BackgroundType.Search,
            };
            this.searchControl.DataContext = this.vmSearch;

            menuManager.InitializeContextMenu(this.searchControl.ListBox, MenuConstants.GUIDOBJ_SEARCH_GUID, new GuidObjectsCreator());
            wpfCommandManager.Add(CommandConstants.GUID_SEARCH_CONTROL, this.searchControl);
            wpfCommandManager.Add(CommandConstants.GUID_SEARCH_LISTBOX, this.searchControl.ListBox);
            languageManager.LanguageChanged += LanguageManager_LanguageChanged;
            themeManager.ThemeChanged       += ThemeManager_ThemeChanged;
            searchSettings.PropertyChanged  += SearchSettings_PropertyChanged;
            fileTabManager.FileTreeView.FileManager.CollectionChanged += FileManager_CollectionChanged;

            this.searchControl.SearchListBoxDoubleClick += (s, e) => FollowSelectedReference();
            var cmds    = wpfCommandManager.GetCommands(CommandConstants.GUID_SEARCH_LISTBOX);
            var command = new RelayCommand(a => FollowSelectedReference());

            cmds.Add(command, ModifierKeys.None, Key.Enter);
            cmds.Add(command, ModifierKeys.Control, Key.Enter);
            cmds.Add(command, ModifierKeys.Shift, Key.Enter);

            Add(SearchType.TypeDef, Key.T);
            Add(SearchType.FieldDef, Key.F);
            Add(SearchType.MethodDef, Key.M);
            Add(SearchType.PropertyDef, Key.P);
            Add(SearchType.EventDef, Key.E);
            Add(SearchType.ParamDef, Key.J);
            Add(SearchType.Local, Key.I);
            Add(SearchType.ParamLocal, Key.N);
            Add(SearchType.Resource, Key.R);
            Add(SearchType.Member, Key.U);
            Add(SearchType.Any, Key.B);
            Add(SearchType.Literal, Key.L);

            Add(SearchLocation.AllFiles, Key.G);
            Add(SearchLocation.SelectedFiles, Key.S);
            Add(SearchLocation.AllFilesInSameDir, Key.D);
            Add(SearchLocation.SelectedType, Key.Q);
        }
Beispiel #11
0
 public TabGroup(TabGroupManager tabGroupManager, IMenuManager menuManager, IWpfFocusManager wpfFocusManager, TabGroupManagerOptions options)
 {
     this.options                = options;
     this.tabContentAttached     = new WeakEventList <TabContentAttachedEventArgs>();
     this.tabGroupManager        = tabGroupManager;
     this.wpfFocusManager        = wpfFocusManager;
     this.tabControl             = new TabControl();
     this.tabControl.DataContext = this;
     tabControl.SetStyle(options.TabControlStyle ?? "FileTabGroupTabControlStyle");
     this.tabControl.SelectionChanged += TabControl_SelectionChanged;
     if (options.InitializeContextMenu != null)
     {
         this.contextMenuCreator = options.InitializeContextMenu(menuManager, this, this.tabControl);
     }
     else if (options.TabGroupGuid != Guid.Empty)
     {
         this.contextMenuCreator = menuManager.InitializeContextMenu(this.tabControl, options.TabGroupGuid, new GuidObjectsCreator(this));
     }
 }
Beispiel #12
0
        IOutputTextPane Create(Guid guid, string name, object contentTypeObj)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            var vm = OutputBuffers.FirstOrDefault(a => a.Guid == guid);

            Debug.Assert(vm == null || vm.Name == name);
            if (vm != null)
            {
                return(vm);
            }

            var logEditorOptions = new LogEditorOptions {
                MenuGuid          = new Guid(MenuConstants.GUIDOBJ_LOG_TEXTEDITORCONTROL_GUID),
                ContentType       = contentTypeObj as IContentType,
                ContentTypeString = contentTypeObj as string,
                CreateGuidObjects = args => CreateGuidObjects(args),
            };

            logEditorOptions.ExtraRoles.Add(PredefinedDnSpyTextViewRoles.OutputTextPane);
            var logEditor = logEditorProvider.Create(logEditorOptions);

            logEditor.TextView.Options.SetOptionValue(DefaultWpfViewOptions.AppearanceCategory, Constants.Output);

            // Prevent toolwindow's ctx menu from showing up when right-clicking in the left margin
            menuManager.InitializeContextMenu(logEditor.TextViewHost.HostControl, Guid.NewGuid());

            vm = new OutputBufferVM(editorOperationsFactoryService, guid, name, logEditor);
            int index = GetSortedInsertIndex(vm);

            OutputBuffers.Insert(index, vm);
            while (index < OutputBuffers.Count)
            {
                OutputBuffers[index].Index = index++;
            }

            OutputTextPaneUtils.AddInstance(vm, logEditor.TextView);
            return(vm);
        }
Beispiel #13
0
 public GlyphMargin(IMenuManager menuManager, IWpfTextViewHost wpfTextViewHost, IViewTagAggregatorFactoryService viewTagAggregatorFactoryService, IEditorFormatMapService editorFormatMapService, Lazy <IGlyphMouseProcessorProvider, IGlyphMouseProcessorProviderMetadata>[] glyphMouseProcessorProviders, Lazy <IGlyphFactoryProvider, IGlyphMetadata>[] glyphFactoryProviders, IMarginContextMenuService marginContextMenuHandlerProviderService)
 {
     if (menuManager == null)
     {
         throw new ArgumentNullException(nameof(menuManager));
     }
     if (wpfTextViewHost == null)
     {
         throw new ArgumentNullException(nameof(wpfTextViewHost));
     }
     if (viewTagAggregatorFactoryService == null)
     {
         throw new ArgumentNullException(nameof(viewTagAggregatorFactoryService));
     }
     if (editorFormatMapService == null)
     {
         throw new ArgumentNullException(nameof(editorFormatMapService));
     }
     if (glyphMouseProcessorProviders == null)
     {
         throw new ArgumentNullException(nameof(glyphMouseProcessorProviders));
     }
     if (glyphFactoryProviders == null)
     {
         throw new ArgumentNullException(nameof(glyphFactoryProviders));
     }
     this.wpfTextViewHost = wpfTextViewHost;
     this.viewTagAggregatorFactoryService            = viewTagAggregatorFactoryService;
     this.editorFormatMapService                     = editorFormatMapService;
     this.lazyGlyphMouseProcessorProviders           = glyphMouseProcessorProviders;
     this.lazyGlyphFactoryProviders                  = glyphFactoryProviders;
     wpfTextViewHost.TextView.Options.OptionChanged += Options_OptionChanged;
     wpfTextViewHost.TextView.ZoomLevelChanged      += TextView_ZoomLevelChanged;
     IsVisibleChanged += GlyphMargin_IsVisibleChanged;
     UpdateVisibility();
     Width        = MARGIN_WIDTH;
     ClipToBounds = true;
     menuManager.InitializeContextMenu(VisualElement, new Guid(MenuConstants.GUIDOBJ_GLYPHMARGIN_GUID), marginContextMenuHandlerProviderService.Create(wpfTextViewHost, this, PredefinedMarginNames.Glyph), null, new Guid(MenuConstants.GLYPHMARGIN_GUID));
 }
Beispiel #14
0
        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);
        }
Beispiel #15
0
		public ReplEditorUI(ReplEditorOptions options, IThemeManager themeManager, IWpfCommandManager wpfCommandManager, IMenuManager menuManager, ITextEditorSettings textEditorSettings) {
			this.dispatcher = Dispatcher.CurrentDispatcher;
			this.options = (options ?? new ReplEditorOptions()).Clone();
			this.textEditor = new NewTextEditor(themeManager, textEditorSettings);
			this.textEditor.TextArea.AllowDrop = false;
			this.textEditor.TextArea.Document = new TextDocument();
			this.textEditor.TextArea.Document.UndoStack.SizeLimit = 100;
			this.textEditor.TextArea.LeftMargins.Insert(0, new FrameworkElement { Margin = new Thickness(LEFT_MARGIN, 0, 0, 0) });
			this.textEditor.TextArea.TextEntering += TextArea_TextEntering;
			this.textEditor.TextArea.PreviewKeyDown += TextArea_PreviewKeyDown;
			AddBinding(ApplicationCommands.Paste, (s, e) => Paste(), (s, e) => e.CanExecute = CanPaste && IsAtEditingPosition);
			AddBinding(ApplicationCommands.Cut, (s, e) => CutSelection(), (s, e) => e.CanExecute = CanCutSelection && IsAtEditingPosition);

			if (this.options.TextEditorCommandGuid != null)
				wpfCommandManager.Add(this.options.TextEditorCommandGuid.Value, textEditor);
			if (this.options.TextAreaCommandGuid != null)
				wpfCommandManager.Add(this.options.TextAreaCommandGuid.Value, textEditor.TextArea);
			if (this.options.MenuGuid != null)
				menuManager.InitializeContextMenu(this.textEditor, this.options.MenuGuid.Value, new GuidObjectsCreator(this), new ContextMenuInitializer(textEditor, textEditor));
		}
Beispiel #16
0
 public IContextMenuProvider InitializeContextMenu(IMenuManager menuManager, ITabGroup tabGroup, FrameworkElement elem) => menuManager.InitializeContextMenu(elem, tabGroupGuid, new GuidObjectsProvider(this, tabGroup));
Beispiel #17
0
 public IContextMenuCreator InitializeContextMenu(IMenuManager menuManager, ITabGroup tabGroup, FrameworkElement elem)
 {
     return menuManager.InitializeContextMenu(elem, tabGroupGuid, new GuidObjectsCreator(this, tabGroup));
 }
Beispiel #18
0
		SearchManager(IImageManager imageManager, ILanguageManager languageManager, IThemeManager themeManager, ISearchSettings searchSettings, IFileSearcherCreator fileSearcherCreator, IMenuManager menuManager, IWpfCommandManager wpfCommandManager, IFileTabManager fileTabManager) {
			this.fileTabManager = fileTabManager;
			this.searchControl = new SearchControl();
			this.vmSearch = new SearchControlVM(imageManager, fileSearcherCreator, fileTabManager.FileTreeView, searchSettings) {
				Language = languageManager.Language,
				BackgroundType = BackgroundType.Search,
			};
			this.searchControl.DataContext = this.vmSearch;

			menuManager.InitializeContextMenu(this.searchControl.ListBox, MenuConstants.GUIDOBJ_SEARCH_GUID, new GuidObjectsCreator());
			wpfCommandManager.Add(CommandConstants.GUID_SEARCH_CONTROL, this.searchControl);
			wpfCommandManager.Add(CommandConstants.GUID_SEARCH_LISTBOX, this.searchControl.ListBox);
			languageManager.LanguageChanged += LanguageManager_LanguageChanged;
			themeManager.ThemeChanged += ThemeManager_ThemeChanged;
			searchSettings.PropertyChanged += SearchSettings_PropertyChanged;
			fileTabManager.FileTreeView.FileManager.CollectionChanged += FileManager_CollectionChanged;

			this.searchControl.SearchListBoxDoubleClick += (s, e) => FollowSelectedReference();
			var cmds = wpfCommandManager.GetCommands(CommandConstants.GUID_SEARCH_LISTBOX);
			var command = new RelayCommand(a => FollowSelectedReference());
			cmds.Add(command, ModifierKeys.None, Key.Enter);
			cmds.Add(command, ModifierKeys.Control, Key.Enter);
			cmds.Add(command, ModifierKeys.Shift, Key.Enter);

			Add(SearchType.TypeDef, Key.T);
			Add(SearchType.FieldDef, Key.F);
			Add(SearchType.MethodDef, Key.M);
			Add(SearchType.PropertyDef, Key.P);
			Add(SearchType.EventDef, Key.E);
			Add(SearchType.ParamDef, Key.J);
			Add(SearchType.Local, Key.I);
			Add(SearchType.ParamLocal, Key.N);
			Add(SearchType.Resource, Key.R);
			Add(SearchType.Member, Key.U);
			Add(SearchType.Any, Key.B);
			Add(SearchType.Literal, Key.L);

			Add(SearchLocation.AllFiles, Key.G);
			Add(SearchLocation.SelectedFiles, Key.S);
			Add(SearchLocation.AllFilesInSameDir, Key.D);
			Add(SearchLocation.SelectedType, Key.Q);
		}
Beispiel #19
0
		AnalyzerManager(IWpfCommandManager wpfCommandManager, IFileTabManager fileTabManager, ITreeViewManager treeViewManager, IMenuManager menuManager, IThemeManager themeManager, IAnalyzerSettings analyzerSettings, IDotNetImageManager dotNetImageManager, ILanguageManager languageManager, IFileManager fileManager) {
			this.fileTabManager = fileTabManager;

			this.context = new AnalyzerTreeNodeDataContext {
				DotNetImageManager = dotNetImageManager,
				Language = languageManager.SelectedLanguage,
				FileManager = 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);

			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 GuidObjectsCreator(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);
		}
Beispiel #20
0
 public IContextMenuCreator InitializeContextMenu(IMenuManager menuManager, ITabGroup tabGroup, FrameworkElement elem)
 {
     return(menuManager.InitializeContextMenu(elem, tabGroupGuid, new GuidObjectsCreator(this, tabGroup)));
 }
Beispiel #21
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();
        }
		public void Initialize(IMenuManager menuManager, TextEditorControl textEditorControl) {
			this.textEditorControl = textEditorControl;
			this.wpfCommandManager.Add(CommandConstants.GUID_TEXTEDITOR_UICONTEXT, textEditorControl);
			this.wpfCommandManager.Add(CommandConstants.GUID_TEXTEDITOR_UICONTEXT_TEXTEDITOR, textEditorControl.TextEditor);
			this.wpfCommandManager.Add(CommandConstants.GUID_TEXTEDITOR_UICONTEXT_TEXTAREA, textEditorControl.TextEditor.TextArea);
			menuManager.InitializeContextMenu(this.textEditorControl, MenuConstants.GUIDOBJ_TEXTEDITORCONTROL_GUID, new GuidObjectsCreator(this), new ContextMenuInitializer(textEditorControl, textEditorControl.TextEditor));
		}