예제 #1
0
 GlyphMarginProvider(IMenuService menuService, HexViewTagAggregatorFactoryService viewTagAggregatorFactoryService, HexEditorFormatMapService editorFormatMapService, [ImportMany] IEnumerable <Lazy <HexGlyphMouseProcessorProvider, IGlyphMouseProcessorProviderMetadata> > glyphMouseProcessorProviders, [ImportMany] IEnumerable <Lazy <HexGlyphFactoryProvider, IGlyphMetadata> > glyphFactoryProviders, HexMarginContextMenuService marginContextMenuHandlerProviderService)
 {
     this.menuService = menuService;
     this.viewTagAggregatorFactoryService         = viewTagAggregatorFactoryService;
     this.editorFormatMapService                  = editorFormatMapService;
     this.glyphMouseProcessorProviders            = VSUTIL.Orderer.Order(glyphMouseProcessorProviders).ToArray();
     this.glyphFactoryProviders                   = VSUTIL.Orderer.Order(glyphFactoryProviders).ToArray();
     this.marginContextMenuHandlerProviderService = marginContextMenuHandlerProviderService;
 }
예제 #2
0
        public HexGlyphMargin(IMenuService menuService, WpfHexViewHost wpfHexViewHost, HexViewTagAggregatorFactoryService viewTagAggregatorFactoryService, HexEditorFormatMapService editorFormatMapService, Lazy <HexGlyphMouseProcessorProvider, IGlyphMouseProcessorProviderMetadata>[] glyphMouseProcessorProviders, Lazy <HexGlyphFactoryProvider, IGlyphMetadata>[] glyphFactoryProviders, HexMarginContextMenuService marginContextMenuHandlerProviderService)
        {
            if (menuService is null)
            {
                throw new ArgumentNullException(nameof(menuService));
            }
            canvas              = new Canvas();
            glyphFactories      = new Dictionary <Type, GlyphFactoryInfo>();
            childCanvases       = Array.Empty <Canvas>();
            this.wpfHexViewHost = wpfHexViewHost ?? throw new ArgumentNullException(nameof(wpfHexViewHost));
            this.viewTagAggregatorFactoryService = viewTagAggregatorFactoryService ?? throw new ArgumentNullException(nameof(viewTagAggregatorFactoryService));
            this.editorFormatMapService          = editorFormatMapService ?? throw new ArgumentNullException(nameof(editorFormatMapService));
            lazyGlyphMouseProcessorProviders     = glyphMouseProcessorProviders ?? throw new ArgumentNullException(nameof(glyphMouseProcessorProviders));
            lazyGlyphFactoryProviders            = glyphFactoryProviders ?? throw new ArgumentNullException(nameof(glyphFactoryProviders));

            var binding = new Binding {
                Path   = new PropertyPath(Panel.BackgroundProperty),
                Source = canvas,
            };

            canvas.SetBinding(DsImage.BackgroundBrushProperty, binding);

            wpfHexViewHost.HexView.Options.OptionChanged += Options_OptionChanged;
            wpfHexViewHost.HexView.ZoomLevelChanged      += HexView_ZoomLevelChanged;
            canvas.IsVisibleChanged += GlyphMargin_IsVisibleChanged;
            UpdateVisibility();
            canvas.Width        = MARGIN_WIDTH;
            canvas.ClipToBounds = true;
            menuService.InitializeContextMenu(VisualElement, new Guid(MenuConstants.GUIDOBJ_GLYPHMARGIN_GUID), marginContextMenuHandlerProviderService.Create(wpfHexViewHost, this, PredefinedHexMarginNames.Glyph), null, new Guid(MenuConstants.GLYPHMARGIN_GUID));
        }