buchizo / ClaudiaIDE

This extension can change easily the background image of editor window in Visual Studio.
https://marketplace.visualstudio.com/items?itemName=kbuchi.ClaudiaIDE
641 stars 112 forks source link

Horizontal right alignment with wide source overview bar #101

Closed Parsee1 closed 2 years ago

Parsee1 commented 2 years ago

I'm using map mode for vertial scroll bar in VS2019. Is it possible to have the background image aligned to the left of the source overview bar? See pic: image

buchizo commented 2 years ago

This is by design. You can use "Image horizontal position in ViewBox" property. For example, Image position is slide to left after that double value set 0.1 ~ 0.2 to "Image horizontal position in ViewBox" property in extensions option page.

Parsee1 commented 2 years ago

Indeed I could. But since the images in my slideshow are in different ratios, the calculated right margins differ. The more of the width/height ratio, the more right margin: image image Besides it's also affected by the height of the ViewBox. The more height, the more right margin: image image

So it's an absolute margin to the right, not affected by size of the image or the ViewBox, that's what I'm wishing for. Please consider it ;)

buchizo commented 2 years ago

I think so too. I will try it.

buchizo commented 2 years ago

I remembered why use viewbox property. Normally ClaudiaIDE set background image to WPF Text View host's Panel.BackgroundProperty. In this property does not support margin/padding property.

Unfortunatally, I can not support this request.

Parsee1 commented 2 years ago

I remembered why use viewbox property. Normally ClaudiaIDE set background image to WPF Text View host's Panel.BackgroundProperty. In this property does not support margin/padding property.

Unfortunatally, I can not support this request.

Set ImageBrush's ViewportUnits property to BrushMappingMode.Absolute will do. Also need to set the Viewbox by the actual size of the ImageSource in absolute pixels. So why not?

buchizo commented 2 years ago

@Parsee1 I think BrushMappingMode.Absolute is not solved in this case. If viewport is BrushMappingMode.Absolute, I could not set image to good position in window. However I can set relative positive/negative margin of x/y in viewport position for window size, not per image.

image image

Is this alternative solution?

Parsee1 commented 2 years ago

I tried to set ImageBrush's ViewboxUnitsproperty to BrushMappingMode.Absolute and recalculate the Viewbox in absolute pixels: ViewboxUnits = BrushMappingMode.Absolute, Viewbox = new Rect(new Point(_settings.ViewBoxPointX, _settings.ViewBoxPointY), new Size(newimage.Width, newimage.Height)), Honestly, its not working well... since the actuall offsets are still related to r = max(image.width, image.height) the right margin will be (r * _settings.ViewBoxPointX), which is annoying.

Then I tried Absolute ViewportUnits : ` FrameworkElement f = _wpfTextViewHost as FrameworkElement; // var nib = new ImageBrush(newimage) { ...... Viewport = new Rect(0, 0, f.ActualWidth - _settings.ViewPortWidth, f.ActualHeight - _settings.ViewPortHeight), // ViewportUnits = BrushMappingMode.Absolute // }; .... It actually works. Additionally, the Viewport needs to be repositioned when refreshing or resizing.

So just introduce more options please ;)

However if you're still against introducing more options, then I'm fine with your currect solution as long as its not image related and I rarely change the width of the window.

buchizo commented 2 years ago

I don't want to do re-calc size on resizing, personally. I added new ViewPortPointX/ViewPortPointY properties for relative position in ViewPort.