예제 #1
0
 public HexMarkerService(WpfHexView wpfHexView, HexTagAggregator <HexMarkerTag> tagAggregator, VSTC.IEditorFormatMap editorFormatMap, IThemeService themeService)
 {
     if (wpfHexView == null)
     {
         throw new ArgumentNullException(nameof(wpfHexView));
     }
     if (tagAggregator == null)
     {
         throw new ArgumentNullException(nameof(tagAggregator));
     }
     if (editorFormatMap == null)
     {
         throw new ArgumentNullException(nameof(editorFormatMap));
     }
     if (themeService == null)
     {
         throw new ArgumentNullException(nameof(themeService));
     }
     this.wpfHexView                  = wpfHexView;
     this.tagAggregator               = tagAggregator;
     this.editorFormatMap             = editorFormatMap;
     this.themeService                = themeService;
     textMarkerAdornmentLayer         = wpfHexView.GetAdornmentLayer(PredefinedHexAdornmentLayers.TextMarker);
     negativeTextMarkerAdornmentLayer = wpfHexView.GetAdornmentLayer(PredefinedHexAdornmentLayers.NegativeTextMarker);
     markerElements = new List <MarkerElement>();
     useReducedOpacityForHighContrast = wpfHexView.Options.GetOptionValue(DefaultWpfHexViewOptions.UseReducedOpacityForHighContrastOptionId);
     onRemovedDelegate                     = OnRemoved;
     wpfHexView.Closed                    += WpfHexView_Closed;
     wpfHexView.LayoutChanged             += WpfHexView_LayoutChanged;
     wpfHexView.Options.OptionChanged     += Options_OptionChanged;
     tagAggregator.BatchedTagsChanged     += TagAggregator_BatchedTagsChanged;
     editorFormatMap.FormatMappingChanged += EditorFormatMap_FormatMappingChanged;
 }
예제 #2
0
        void UpdateEnabled()
        {
            var newEnabled = wpfHexView.Options.ShowColumnLines();

            if (newEnabled == enabled)
            {
                return;
            }
            enabled = newEnabled;

            if (enabled)
            {
                if (adornmentLayer == null)
                {
                    adornmentLayer = wpfHexView.GetAdornmentLayer(PredefinedHexAdornmentLayers.ColumnLineSeparator);
                }
                HookEnabledEvents();
            }
            else
            {
                UnhookEnabledEvents();
            }

            DelayRecreateColumnLines();
        }
예제 #3
0
 void UpdateEnableState()
 {
     enabled = wpfHexView.Options.IsHighlightCurrentLineEnabled();
     if (enabled)
     {
         if (adornmentLayer == null)
         {
             adornmentLayer = wpfHexView.GetAdornmentLayer(PredefinedHexAdornmentLayers.CurrentLineHighlighter);
         }
         if (!hasHookedEvents)
         {
             RegisterEnabledEvents();
             isActive         = wpfHexView.HasAggregateFocus;
             selectionIsEmpty = wpfHexView.Selection.IsEmpty;
             isActive         = wpfHexView.HasAggregateFocus;
             UpdateLineElementBrushes();
             PositionLineElement();
         }
     }
     else
     {
         adornmentLayer?.RemoveAllAdornments();
         if (hasHookedEvents)
         {
             UnregisterEnabledEvents();
         }
     }
 }
예제 #4
0
        void UpdateEnabled()
        {
            var newEnabled = wpfHexView.Options.HighlightActiveColumn();

            if (newEnabled == enabled)
            {
                return;
            }
            enabled = newEnabled;

            if (enabled)
            {
                if (adornmentLayer == null)
                {
                    adornmentLayer = wpfHexView.GetAdornmentLayer(PredefinedHexAdornmentLayers.ActiveColumnHighlighter);
                }
                HookEnabledEvents();
            }
            else
            {
                UnhookEnabledEvents();
            }

            DelayRecreateRectangles();
        }
 protected override void OnEnabledCore()
 {
     if (adornmentLayer is null)
     {
         adornmentLayer = wpfHexView.GetAdornmentLayer(PredefinedHexAdornmentLayers.BackgroundImage);
     }
     wpfHexView.LayoutChanged += WpfHexView_LayoutChanged;
 }
        void WpfHexView_LayoutChanged(object sender, HexViewLayoutChangedEventArgs e)
        {
            if (adornmentTagInfos.Count > 0)
            {
                currentLineIdentityTags.Clear();
                foreach (var line in wpfHexView.HexViewLines)
                {
                    currentLineIdentityTags.Add(line.IdentityTag);
                }
                foreach (var line in e.NewOrReformattedLines)
                {
                    currentLineIdentityTags.Remove(line.IdentityTag);
                }
                for (int i = adornmentTagInfos.Count - 1; i >= 0; i--)
                {
                    var adornmentInfo = adornmentTagInfos[i];
                    if (!currentLineIdentityTags.Contains(adornmentInfo.LineIdentityTag))
                    {
                        layer.RemoveAdornmentsByTag(adornmentInfo);
                    }
                }
                currentLineIdentityTags.Clear();

                foreach (var line in e.TranslatedLines)
                {
                    var tags = line.GetAdornmentTags(providerTag);
                    if (tags.Count == 0)
                    {
                        continue;
                    }

                    foreach (var identityTag in tags)
                    {
                        var adornmentInfo = identityTag as AdornmentTagInfo;
                        Debug.Assert(adornmentInfo != null);
                        if (adornmentInfo == null)
                        {
                            continue;
                        }
                        var bounds = line.GetAdornmentBounds(identityTag);
                        Debug.Assert(bounds != null);
                        if (bounds == null)
                        {
                            continue;
                        }

                        adornmentInfo.Initialize();
                        UpdateAdornmentUIState(line, adornmentInfo, bounds.Value);
                    }
                }
            }

            foreach (var line in e.NewOrReformattedLines)
            {
                var tags = line.GetAdornmentTags(providerTag);
                if (tags.Count == 0)
                {
                    continue;
                }

                foreach (var identityTag in tags)
                {
                    var adornmentInfo = identityTag as AdornmentTagInfo;
                    Debug.Assert(adornmentInfo != null);
                    if (adornmentInfo == null)
                    {
                        continue;
                    }
                    var bounds = line.GetAdornmentBounds(identityTag);
                    if (bounds == null)
                    {
                        continue;
                    }

                    if (layer == null)
                    {
                        layer = wpfHexView.GetAdornmentLayer(PredefinedHexAdornmentLayers.IntraTextAdornment);
                        // Can't do this in the ctor since Selection hasn't been initialized yet
                        wpfHexView.Selection.SelectionChanged += Selection_SelectionChanged;
                    }

                    adornmentInfo.Initialize();
                    UpdateAdornmentUIState(line, adornmentInfo, bounds.Value);
                    bool added = AddAdornment(adornmentInfo, line);
                    if (!added)
                    {
                        continue;
                    }
                    adornmentInfo.LineIdentityTag = line.IdentityTag;
                    UpdateIsSelected(adornmentInfo, line);
                }
            }
        }