Example #1
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();
        }
Example #2
0
 public HexCaretLayer(HexCaretImpl hexCaret, HexAdornmentLayer layer, VSTC.IClassificationFormatMap classificationFormatMap, VSTC.IClassificationTypeRegistryService classificationTypeRegistryService)
 {
     if (hexCaret == null)
     {
         throw new ArgumentNullException(nameof(hexCaret));
     }
     if (layer == null)
     {
         throw new ArgumentNullException(nameof(layer));
     }
     if (classificationFormatMap == null)
     {
         throw new ArgumentNullException(nameof(classificationFormatMap));
     }
     if (classificationTypeRegistryService == null)
     {
         throw new ArgumentNullException(nameof(classificationTypeRegistryService));
     }
     overwriteMode = true;
     this.hexCaret = hexCaret;
     this.layer    = layer;
     this.classificationFormatMap    = classificationFormatMap;
     activeCaretClassificationType   = classificationTypeRegistryService.GetClassificationType(CTC.ThemeClassificationTypeNames.HexCaret);
     inactiveCaretClassificationType = classificationTypeRegistryService.GetClassificationType(CTC.ThemeClassificationTypeNames.HexInactiveCaret);
     valuesCaretGeometry             = new CaretGeometry();
     asciiCaretGeometry = new CaretGeometry();
     layer.HexView.Selection.SelectionChanged += Selection_SelectionChanged;
     layer.HexView.VisualElement.AddHandler(GotKeyboardFocusEvent, new KeyboardFocusChangedEventHandler(VisualElement_GotKeyboardFocus), true);
     layer.HexView.VisualElement.AddHandler(LostKeyboardFocusEvent, new KeyboardFocusChangedEventHandler(VisualElement_LostKeyboardFocus), true);
     layer.HexView.VisualElement.IsVisibleChanged += VisualElement_IsVisibleChanged;
     classificationFormatMap.ClassificationFormatMappingChanged += ClassificationFormatMap_ClassificationFormatMappingChanged;
     AddAdornment();
 }
Example #3
0
 public HexCaretImpl(WpfHexView hexView, HexAdornmentLayer caretLayer, VSTC.IClassificationFormatMap classificationFormatMap, VSTC.IClassificationTypeRegistryService classificationTypeRegistryService)
 {
     if (hexView == null)
     {
         throw new ArgumentNullException(nameof(hexView));
     }
     if (caretLayer == null)
     {
         throw new ArgumentNullException(nameof(caretLayer));
     }
     if (classificationFormatMap == null)
     {
         throw new ArgumentNullException(nameof(classificationFormatMap));
     }
     if (classificationTypeRegistryService == null)
     {
         throw new ArgumentNullException(nameof(classificationTypeRegistryService));
     }
     this.hexView                   = hexView;
     imeState                       = new ImeState();
     preferredXCoordinate           = 0;
     __preferredYCoordinate         = 0;
     hexView.Options.OptionChanged += Options_OptionChanged;
     hexView.VisualElement.AddHandler(UIElement.GotKeyboardFocusEvent, new KeyboardFocusChangedEventHandler(VisualElement_GotKeyboardFocus), true);
     hexView.VisualElement.AddHandler(UIElement.LostKeyboardFocusEvent, new KeyboardFocusChangedEventHandler(VisualElement_LostKeyboardFocus), true);
     hexView.LayoutChanged      += HexView_LayoutChanged;
     hexView.BufferLinesChanged += HexView_BufferLinesChanged;
     hexView.ZoomLevelChanged   += HexView_ZoomLevelChanged;
     hexCaretLayer = new HexCaretLayer(this, caretLayer, classificationFormatMap, classificationTypeRegistryService);
     InputMethod.SetIsInputMethodSuspended(hexView.VisualElement, true);
 }
Example #4
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();
         }
     }
 }
Example #5
0
 public HexSelectionLayer(HexSelectionImpl hexSelection, HexAdornmentLayer layer, VSTC.IEditorFormatMap editorFormatMap)
 {
     if (hexSelection == null)
     {
         throw new ArgumentNullException(nameof(hexSelection));
     }
     if (layer == null)
     {
         throw new ArgumentNullException(nameof(layer));
     }
     if (editorFormatMap == null)
     {
         throw new ArgumentNullException(nameof(editorFormatMap));
     }
     markerElementRemovedCallBack = (tag, element) => OnMarkerElementRemoved();
     this.hexSelection            = hexSelection;
     this.layer           = layer;
     this.editorFormatMap = editorFormatMap;
     hexSelection.HexView.Options.OptionChanged += Options_OptionChanged;
     hexSelection.SelectionChanged        += HexSelection_SelectionChanged;
     hexSelection.HexView.LayoutChanged   += HexView_LayoutChanged;
     editorFormatMap.FormatMappingChanged += EditorFormatMap_FormatMappingChanged;
     UpdateUseReducedOpacityForHighContrastOption();
     UpdateBackgroundBrush();
 }
Example #6
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();
        }
Example #7
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;
 }
 protected override void OnEnabledCore()
 {
     if (adornmentLayer == null)
     {
         adornmentLayer = wpfHexView.GetAdornmentLayer(PredefinedHexAdornmentLayers.BackgroundImage);
     }
     wpfHexView.LayoutChanged += WpfHexView_LayoutChanged;
 }
Example #9
0
 public TextLayer(HexAdornmentLayer adornmentLayer)
 {
     if (adornmentLayer == null)
     {
         throw new ArgumentNullException(nameof(adornmentLayer));
     }
     lines = new List <LineInfo>();
     adornmentLayer.AddAdornment(VSTE.AdornmentPositioningBehavior.OwnerControlled, (HexBufferSpan?)null, null, this, null);
 }
Example #10
0
 public HexSelectionLayer(HexSelectionImpl hexSelection, HexAdornmentLayer layer, VSTC.IEditorFormatMap editorFormatMap)
 {
     markerElementRemovedCallBack = (tag, element) => OnMarkerElementRemoved();
     this.hexSelection            = hexSelection ?? throw new ArgumentNullException(nameof(hexSelection));
     this.layer           = layer ?? throw new ArgumentNullException(nameof(layer));
     this.editorFormatMap = editorFormatMap ?? throw new ArgumentNullException(nameof(editorFormatMap));
     hexSelection.HexView.Options.OptionChanged += Options_OptionChanged;
     hexSelection.SelectionChanged        += HexSelection_SelectionChanged;
     hexSelection.HexView.LayoutChanged   += HexView_LayoutChanged;
     editorFormatMap.FormatMappingChanged += EditorFormatMap_FormatMappingChanged;
     UpdateBackgroundBrush();
 }
Example #11
0
 public HexSelectionImpl(WpfHexView hexView, HexAdornmentLayer selectionLayer, VSTC.IEditorFormatMap editorFormatMap)
 {
     if (selectionLayer == null)
     {
         throw new ArgumentNullException(nameof(selectionLayer));
     }
     if (editorFormatMap == null)
     {
         throw new ArgumentNullException(nameof(editorFormatMap));
     }
     HexView = hexView ?? throw new ArgumentNullException(nameof(hexView));
     HexView.GotAggregateFocus  += HexView_GotAggregateFocus;
     HexView.LostAggregateFocus += HexView_LostAggregateFocus;
     hexSelectionLayer           = new HexSelectionLayer(this, selectionLayer, editorFormatMap);
     ActivationTracksFocus       = true;
 }
        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);
                }
            }
        }