dahall / AeroWizard

Library for easy creation of custom and Aero Wizards. Aero Wizard strictly follows Microsoft guidelines and uses Visual Styles to get visual theming.
MIT License
112 stars 32 forks source link

Right-to-left layout #30

Closed dahall closed 6 years ago

dahall commented 6 years ago

When trying to add multilingual support, I've encountered two issues with right-to-left languages (such as Hebrew):

  1. Round "Back" button is not shown in the upper right corner of the wizard control. Instead, some other random stuff shows up. Button, however, works, so it's a visual problem.
  2. Wizard pages do not mirror their constituents, whilst wizard itself, header and footer do.

Can the problem be alleviated by me, or do I have to wait for a fix? Thank you. Awesome wizard.

Originally posted: 2013-04-13T12:24:51

dahall commented 6 years ago

If you have the time to take the current code base and make the fixes, you will likely resolve it sooner than I am able. Please send me the patches you make so I can update the root.

Originally posted: 2013-04-15T08:00:55

dahall commented 6 years ago

What properties have you changed on the parent form? Localizable = true, RightToLeft = true, RightToLeftLayout = true? I started to look at what happens to the control and form when I change settings like those and would like to know all of what you have changed that have led to the bugs.

Originally posted: 2013-04-15T08:56:01

dahall commented 6 years ago

Will you pull up a Windows Vista/7 OS based wizard (like Devices & Printers | Add a printer) in Hebrew (or another right-to-left language) and send me a screenshot? I have no idea how the final UI is to display.

Originally posted: 2013-04-15T09:30:53

dahall commented 6 years ago

Thank you for quick reaction! Actually you need "Localizable" only when there is more than one language supported. For testing purposes it's sufficient to set RightToLeft = true and RightToLeftLayout = true in the default language. Then, everything on the form, including child windows, should be reversed (mirrored). Windows already does almost everything for you - the horizontal coordination starts from the right and proceeds to the left. So, if you play by the book, everything should be reversed already, like in the attached hebrew "Add printer" screenshot. The problem is with the bitmaps. Generally, their picture may not necessarily be reversed, except special cases, such as "Back" button. Note, that windows knows to reverse the bitmap itself. Another caveat is, when you map windows objects on the screen, always map rectangles, not separate points. This way, layout will be preserved always. So use RectangleToClient/RectangleToScreen instead of PointToClient/PointToScreen in .NET.

Originally posted: 2013-04-15T14:33:28

dahall commented 6 years ago

I don't see the attached screenshot though, so please, tell me how can I communicate it to you. It's PNG image.

Originally posted: 2013-04-15T15:35:31

dahall commented 6 years ago

I didn't think I'd have time to look at this, but it turns out I have. So far I have corrected the title alignment and the mirroring of the WizardPage content. The Back Button weird display is a mystery. Give me another day and I'll attach an updated assembly for you to test. Thanks for finding this problem. It is a significant gap in capability.

Originally posted: 2013-04-15T21:30:20

dahall commented 6 years ago

I have tried about 20 ways to get the Back Button to display correctly with no success. Sorry for the delay. Still working the problem.

Originally posted: 2013-04-30T17:02:06

dahall commented 6 years ago

Send me the code you use to paint the LTR button and maybe I'll come up with the right code for RTL one.

Originally posted: 2013-04-30T18:49:54

dahall commented 6 years ago

The painting code is in ThemeImageButton.cs which then uses routines in VisualStylesRendererExtender.cs. The problem I'm having is that the image seems to not be painting in the space defined by the control.

Originally posted: 2013-05-01T08:38:28

dahall commented 6 years ago

Ok, I've found the bug in your code. Don't use "this.Bounds", because it's in wrong coordinates. Always use the bounds, provided by "OnPaint" directly. The corrected code follows:

protected override void PaintButton(Graphics graphics, Rectangle bounds) { if (Application.RenderWithVisualStyles || DesktopWindowManager.IsCompositionEnabled()) { try { VisualStyleRenderer rnd = new VisualStyleRenderer(StyleClass, StylePart, (int)ButtonState); if (this.IsDesignMode() || !DesktopWindowManager.IsCompositionEnabled()) { rnd.DrawParentBackground(graphics, bounds, this); rnd.DrawBackground(graphics, bounds); } else { rnd.DrawGlassBackground(graphics, bounds, bounds); } return; } ...

Originally posted: 2013-05-01T15:02:00

dahall commented 6 years ago

P.S. Don't forget to invert the image!

Originally posted: 2013-05-01T15:17:07

dahall commented 6 years ago

That did it! Thank you! I need to fix the code that displays the help text at the bottom of the wizard and then I'll update the download. Should be done by tonight.

Originally posted: 2013-05-02T08:35:40

dahall commented 6 years ago

Ah, something else, if I may... The icon, you display at the top, should be scaled according to DPI. The best way is as follows:

titleImageList.ImageSize = SystemInformation.SmallIconSize; // 16, 20, 24 on 100%, 125% and 150% DPI titleImageList.Images.Add(new Icon(value, SystemInformation.SmallIconSize + new Size(1, 1)));

Thank you.

Originally posted: 2013-05-02T08:56:34

dahall commented 6 years ago

When scaling to DPI, are you speaking to the icon between the title text and the back button or the back button?

Originally posted: 2013-05-02T15:17:41

dahall commented 6 years ago

It's the icon between the title text and the back button as can be deduced from the proposed code.

Originally posted: 2013-05-02T15:58:01

dahall commented 6 years ago

Actually, that code provides backup images for the back button in case the Visual Styles fail. That's what led to my confusion. Thank you for the clarification. The code that adjusts that small icon is in the ThemedLabel.cs file. I will take your suggestion and adjust the appropriate code.

Originally posted: 2013-05-03T09:54:30

dahall commented 6 years ago

My bad, looking at the wrong code section. In the code you posted, what is the purpose of adding a "new Size(1, 1)" to the SmallIconSize?

Originally posted: 2013-05-03T10:08:23

dahall commented 6 years ago

If your/my icon lacks some basic size, such as 20x20, then this code ensures, that the larger one, 24x24 is downsized, not the smaller - upsized.

Originally posted: 2013-05-03T11:19:10

dahall commented 6 years ago

Resolved with changeset 72703: * Completed work on support for RTL languages

Originally posted: 2013-05-03T14:06:58

dahall commented 6 years ago

demidov, please let me know if release 1.2.5 appropriately fixes the RTL and DPI problems.

Originally posted: 2013-05-04T15:29:45

dahall commented 6 years ago

Yes, it does. Thank you.

Originally posted: 2013-05-04T21:44:45

dahall commented 6 years ago

Originally posted: 2013-05-03T14:06:58