コード例 #1
0
 public HexPopupSpaceReservationAgent(HexSpaceReservationManager spaceReservationManager, WpfHexView wpfHexView, HexLineSpan lineSpan, VSTA.PopupStyles style, UIElement content)
 {
     if (lineSpan.IsDefault)
     {
         throw new ArgumentException();
     }
     if ((style & (VSTA.PopupStyles.DismissOnMouseLeaveText | VSTA.PopupStyles.DismissOnMouseLeaveTextOrContent)) == (VSTA.PopupStyles.DismissOnMouseLeaveText | VSTA.PopupStyles.DismissOnMouseLeaveTextOrContent))
     {
         throw new ArgumentOutOfRangeException(nameof(style));
     }
     this.spaceReservationManager = spaceReservationManager ?? throw new ArgumentNullException(nameof(spaceReservationManager));
     this.wpfHexView = wpfHexView;
     this.lineSpan   = lineSpan;
     this.style      = style;
     this.content    = content ?? throw new ArgumentNullException(nameof(content));
     popup           = new Popup {
         PlacementTarget     = wpfHexView.VisualElement,
         Placement           = PlacementMode.Relative,
         Visibility          = Visibility.Collapsed,
         IsOpen              = false,
         AllowsTransparency  = true,
         UseLayoutRounding   = true,
         SnapsToDevicePixels = true,
     };
 }
コード例 #2
0
        void Closed(WpfHexView hexView)
        {
            Debug.Assert(hexView.IsClosed);
            bool b = hexViews.Remove(hexView);

            Debug.Assert(b);
        }
コード例 #3
0
#pragma warning restore CS0169

        HexViewBackgroundImageService(WpfHexView wpfHexView, IImageSourceService imageSourceService)
            : base(imageSourceService)
        {
            this.wpfHexView = wpfHexView ?? throw new ArgumentNullException(nameof(wpfHexView));
            Initialize();
            wpfHexView.Closed += WpfHexView_Closed;
        }
コード例 #4
0
 public override void HexViewCreated(WpfHexView hexView)
 {
     hexView.VisualElement.CommandBindings.Add(new CommandBinding(ApplicationCommands.Cut, (s, e) => hexView.CommandTarget.Execute(CommandConstants.StandardGroup, (int)StandardIds.Cut), (s, e) => e.CanExecute               = hexView.CommandTarget.CanExecute(CommandConstants.StandardGroup, (int)StandardIds.Cut) == CommandTargetStatus.Handled));
     hexView.VisualElement.CommandBindings.Add(new CommandBinding(ApplicationCommands.Copy, (s, e) => hexView.CommandTarget.Execute(CommandConstants.StandardGroup, (int)StandardIds.Copy), (s, e) => e.CanExecute             = hexView.CommandTarget.CanExecute(CommandConstants.StandardGroup, (int)StandardIds.Copy) == CommandTargetStatus.Handled));
     hexView.VisualElement.CommandBindings.Add(new CommandBinding(ApplicationCommands.Paste, (s, e) => hexView.CommandTarget.Execute(CommandConstants.StandardGroup, (int)StandardIds.Paste), (s, e) => e.CanExecute           = hexView.CommandTarget.CanExecute(CommandConstants.StandardGroup, (int)StandardIds.Paste) == CommandTargetStatus.Handled));
     hexView.VisualElement.CommandBindings.Add(new CommandBinding(ApplicationCommands.SelectAll, (s, e) => hexView.CommandTarget.Execute(CommandConstants.HexEditorGroup, (int)HexEditorIds.SELECTALL), (s, e) => e.CanExecute = hexView.CommandTarget.CanExecute(CommandConstants.HexEditorGroup, (int)HexEditorIds.SELECTALL) == CommandTargetStatus.Handled));
 }
コード例 #5
0
ファイル: HexCaretImpl.cs プロジェクト: pashav15/pashav
 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);
 }
コード例 #6
0
ファイル: HexMouseLocation.cs プロジェクト: idkwim/dnSpy
        public static HexMouseLocation TryCreateTextOnly(WpfHexView wpfHexView, MouseEventArgs e)
        {
            var point = GetTextPoint(wpfHexView, e);
            var line  = wpfHexView.HexViewLines.GetHexViewLineContainingYCoordinate(point.Y);

            if (line == null)
            {
                return(null);
            }
            if (!(line.TextTop <= point.Y && point.Y < line.TextBottom))
            {
                return(null);
            }
            if (!(line.TextLeft <= point.X && point.X < line.TextRight))
            {
                return(null);
            }
            var position = line.GetLinePositionFromXCoordinate(point.X, true);

            if (position == null)
            {
                return(null);
            }

            return(new HexMouseLocation(line, position.Value, point));
        }
コード例 #7
0
        public static HexMouseLocation Create(WpfHexView wpfHexView, MouseEventArgs e, bool insertionPosition)
        {
            HexViewLine hexViewLine;
            int         position;

            var point = GetTextPoint(wpfHexView, e);
            var line  = wpfHexView.HexViewLines.GetHexViewLineContainingYCoordinate(point.Y);

            if (line != null)
            {
                hexViewLine = line;
            }
            else if (point.Y <= wpfHexView.ViewportTop)
            {
                hexViewLine = wpfHexView.HexViewLines.FirstVisibleLine;
            }
            else
            {
                hexViewLine = wpfHexView.HexViewLines.LastVisibleLine;
            }
            if (insertionPosition)
            {
                position = hexViewLine.GetInsertionLinePositionFromXCoordinate(point.X);
            }
            else
            {
                position = hexViewLine.GetVirtualLinePositionFromXCoordinate(point.X);
            }

            return(new HexMouseLocation(hexViewLine, position, point));
        }
コード例 #8
0
 public HexSpaceReservationManagerImpl(WpfHexView wpfHexView)
 {
     this.wpfHexView        = wpfHexView ?? throw new ArgumentNullException(nameof(wpfHexView));
     spaceReservationAgents = new List <HexSpaceReservationAgent>();
     Agents             = new ReadOnlyCollection <HexSpaceReservationAgent>(spaceReservationAgents);
     wpfHexView.Closed += WpfHexView_Closed;
 }
コード例 #9
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;
 }
コード例 #10
0
 public HexSpaceReservationStackImpl(WpfHexView wpfHexView, string[] spaceReservationManagerNames)
 {
     this.wpfHexView = wpfHexView ?? throw new ArgumentNullException(nameof(wpfHexView));
     this.spaceReservationManagerNames = spaceReservationManagerNames ?? throw new ArgumentNullException(nameof(spaceReservationManagerNames));
     spaceReservationManagers          = new HexSpaceReservationManagerImpl[spaceReservationManagerNames.Length];
     wpfHexView.Closed += WpfHexView_Closed;
 }
コード例 #11
0
 public override HexSpaceReservationStack Create(WpfHexView wpfHexView)
 {
     if (wpfHexView is null)
     {
         throw new ArgumentNullException(nameof(wpfHexView));
     }
     return(wpfHexView.Properties.GetOrCreateSingletonProperty(typeof(HexSpaceReservationStackImpl), () => new HexSpaceReservationStackImpl(wpfHexView, spaceReservationManagerNames)));
 }
コード例 #12
0
 public IImageSourceService Create(WpfHexView wpfHexView)
 {
     if (wpfHexView is null)
     {
         throw new ArgumentNullException(nameof(wpfHexView));
     }
     return(Create(backgroundImageOptionDefinitionService.GetOptionDefinition(wpfHexView)));
 }
コード例 #13
0
 public HexViewListener(HexViewOptionsGroupImpl owner, WpfHexView hexView)
 {
     this.owner      = owner;
     this.hexView    = hexView;
     hexView.Closed += HexView_Closed;
     hexView.Options.OptionChanged += Options_OptionChanged;
     owner.InitializeOptions(hexView);
 }
コード例 #14
0
 public HexAdornmentLayerImpl(WpfHexView hexView, HexLayerKind layerKind, MetadataAndOrder <IAdornmentLayersMetadata> info)
 {
     canvas                 = new Canvas();
     HexView                = hexView ?? throw new ArgumentNullException(nameof(hexView));
     this.layerKind         = layerKind;
     Info                   = info;
     adornmentLayerElements = new List <HexAdornmentLayerElementImpl>();
 }
コード例 #15
0
ファイル: HexPopupHelper.cs プロジェクト: pashav15/pashav
        public static Size GetMaxSize(WpfHexView wpfHexView)
        {
            var screen     = new Screen(wpfHexView.VisualElement);
            var screenRect = screen.IsValid ? screen.DisplayRect : SystemParameters.WorkArea;
            var size       = TransformFromDevice(wpfHexView, screenRect.Size);

            return(new Size(size.Width * maxWidthMultiplier, size.Height * maxHeightMultiplier));
        }
コード例 #16
0
 public override CurrentValueHighlighter Get(WpfHexView wpfHexView)
 {
     if (wpfHexView is null)
     {
         throw new ArgumentNullException(nameof(wpfHexView));
     }
     return(wpfHexView.Properties.GetOrCreateSingletonProperty(typeof(CurrentValueHighlighter), () => new CurrentValueHighlighter(wpfHexView)));
 }
コード例 #17
0
 public override HexIntraTextAdornmentService Get(WpfHexView wpfHexView)
 {
     if (wpfHexView == null)
     {
         throw new ArgumentNullException(nameof(wpfHexView));
     }
     return(wpfHexView.Properties.GetOrCreateSingletonProperty(typeof(HexIntraTextAdornmentServiceImpl), () => new HexIntraTextAdornmentServiceImpl(wpfHexView, viewTagAggregatorFactoryService)));
 }
コード例 #18
0
 public override string TryGetGroupName(WpfHexView hexView)
 {
     if (hexView.Roles.Contains(PredefinedHexViewRoles.HexEditorGroup))
     {
         return(PredefinedHexViewGroupNames.HexEditor);
     }
     return(null);
 }
コード例 #19
0
 public override void InstallLineSeparatorService(WpfHexView wpfHexView)
 {
     if (wpfHexView == null)
     {
         throw new ArgumentNullException(nameof(wpfHexView));
     }
     wpfHexView.Properties.GetOrCreateSingletonProperty(typeof(ColumnLineSeparatorService), () => new ColumnLineSeparatorService(wpfHexView, editorFormatMapService));
 }
コード例 #20
0
 public override WpfHexViewHost CreateHost(WpfHexView wpfHexView, bool setFocus)
 {
     if (wpfHexView is null)
     {
         throw new ArgumentNullException(nameof(wpfHexView));
     }
     return(new WpfHexViewHostImpl(wpfHexViewMarginProviderCollectionProvider, wpfHexView, editorOperationsFactoryService, themeService, setFocus));
 }
コード例 #21
0
#pragma warning restore 0169

        public HexToolTipProviderImpl(WpfHexView wpfHexView)
        {
            if (wpfHexView == null)
            {
                throw new ArgumentNullException(nameof(wpfHexView));
            }
            this.wpfHexView         = wpfHexView;
            spaceReservationManager = wpfHexView.GetSpaceReservationManager(PredefinedHexSpaceReservationManagerNames.ToolTip);
        }
コード例 #22
0
        public override void HexViewCreated(WpfHexView hexView)
        {
            if (!hexView.Roles.Contains(PredefinedHexViewRoles.Interactive))
            {
                return;
            }

            new HexKeyProcessorCollection(hexView, keyProcessorProviders);
        }
コード例 #23
0
 public DefaultHexViewMouseProcessor(WpfHexView wpfHexView, HexEditorOperationsFactoryService editorOperationsFactoryService)
 {
     if (wpfHexView == null)
     {
         throw new ArgumentNullException(nameof(wpfHexView));
     }
     this.wpfHexView  = wpfHexView;
     editorOperations = editorOperationsFactoryService.GetEditorOperations(wpfHexView);
 }
コード例 #24
0
        public override void HexViewCreated(WpfHexView hexView)
        {
            if (!hexView.Roles.Contains(PredefinedHexViewRoles.Interactive))
            {
                return;
            }

            new HexViewMouseProcessorCollection(hexView, editorOperationsFactoryService, mouseProcessorProviders);
        }
コード例 #25
0
 public override HexViewSearchService Get(WpfHexView wpfHexView)
 {
     if (wpfHexView is null)
     {
         throw new ArgumentNullException(nameof(wpfHexView));
     }
     return(wpfHexView.Properties.GetOrCreateSingletonProperty(typeof(HexViewSearchService),
                                                               () => new HexViewSearchServiceImpl(wpfHexView, hexSearchServiceFactory, searchSettings, messageBoxService, editorOperationsFactoryService)));
 }
コード例 #26
0
 public CurrentLineHighlighter(WpfHexView wpfHexView, VSTC.IEditorFormatMap editorFormatMap)
 {
     this.wpfHexView                   = wpfHexView ?? throw new ArgumentNullException(nameof(wpfHexView));
     this.editorFormatMap              = editorFormatMap ?? throw new ArgumentNullException(nameof(editorFormatMap));
     currentLineHighlighterElement     = new CurrentLineHighlighterElement();
     wpfHexView.Closed                += WpfHexView_Closed;
     wpfHexView.Options.OptionChanged += Options_OptionChanged;
     UpdateEnableState();
 }
コード例 #27
0
        void OptionChanged(WpfHexView hexView, VSTE.EditorOptionChangedEventArgs e)
        {
            var coll = GetCollection(GetSubGroup(hexView));

            if (!coll.HasOption(e.OptionId))
            {
                return;
            }
            coll.SetOptionValue(e.OptionId, hexView.Options.GetOptionValue(e.OptionId));
        }
コード例 #28
0
 public HexViewMouseProcessorCollection(WpfHexView wpfHexView, HexEditorOperationsFactoryService editorOperationsFactoryService, Lazy <HexMouseProcessorProvider, IOrderableTextViewRoleMetadata>[] mouseProcessorProviders)
 {
     this.wpfHexView = wpfHexView;
     wpfHexViewImpl  = wpfHexView as WpfHexViewImpl;
     this.editorOperationsFactoryService = editorOperationsFactoryService;
     this.mouseProcessorProviders        = mouseProcessorProviders;
     allowEventDelegate = AllowMouseEvent;
     wpfHexView.Closed += WpfHexView_Closed;
     Reinitialize();
 }
コード例 #29
0
#pragma warning restore 0169

        HexViewBackgroundImageService(WpfHexView wpfHexView, IImageSourceService imageSourceService)
            : base(imageSourceService)
        {
            if (wpfHexView == null)
            {
                throw new ArgumentNullException(nameof(wpfHexView));
            }
            this.wpfHexView    = wpfHexView;
            wpfHexView.Closed += WpfHexView_Closed;
        }
コード例 #30
0
ファイル: HexPopupHelper.cs プロジェクト: pashav15/pashav
        public static Size TransformToDevice(WpfHexView wpfHexView, Size size)
        {
            var zoomMultiplier    = wpfHexView.ZoomLevel == 0 ? 1 : wpfHexView.ZoomLevel / 100;
            var source            = PresentationSource.FromVisual(wpfHexView.VisualElement);
            var transformToDevice = source?.CompositionTarget.TransformToDevice ?? Matrix.Identity;
            var wpfRect           = transformToDevice.Transform(new Point(size.Width, size.Height));
            var width             = wpfRect.X * zoomMultiplier;
            var height            = wpfRect.Y * zoomMultiplier;

            return(new Size(width, height));
        }
コード例 #31
0
		/// <summary>
		/// Creates a <see cref="HexKeyProcessor"/> or returns null
		/// </summary>
		/// <param name="wpfHexView">Hex view</param>
		/// <returns></returns>
		public abstract HexKeyProcessor GetAssociatedProcessor(WpfHexView wpfHexView);
コード例 #32
0
		/// <summary>
		/// Called after a hex view with the correct role is created
		/// </summary>
		/// <param name="hexView">Hex view</param>
		public abstract void HexViewCreated(WpfHexView hexView);