VBAndCs / sVB-Small-Visual-Basic

Small Visual Basic (sVB) is an educational programming language, created by Eng. Mohammad Hamdy as an evolved version of Microsoft Small Basic (SB). It is meant to be easier and more powerful at the same time, to introduce programming basics to kids and beginners of any age, provided that they can use the English keyboard on the Windows OS.
Other
233 stars 16 forks source link

Text alignment on labels and buttons ... #28

Closed boa2145 closed 1 year ago

boa2145 commented 1 year ago

Hello Mohammad,

How can I align the text on a label (right and middle) and button (left and right) justified? I see that the text of a button is always in the middle, but the text of label is always on the left, if the size of a label bigger than the length of the caption.

Regards ... Gregor

VBAndCs commented 1 year ago

@boa2145 sVB uses a small windows forms framework for simplicity. Copying all the DotNET framework to sVB will just complicate it for kids. I only provided the LeftToRight property because it is important for Arabic and some other languages. But, I opened back doors to get full access of controls, as they are actually WPF controls, so you can change controls properties by:

  1. Modifying the control xaml file in the sVB\Bin\ToolBox folder, but this will affect all instances of the controol you draw from the toolbox.
  2. Modifying the form design in the form.xaml file, but your changes will be overwritten by the form designer when you make any changes in the design.
  3. Adding a style file in the project folder and apply it on whatever controls you want by using the SetStyle or SetResourceDictionary methods (see the sVB book for more details and samples). This is the perfect solution that allows you not only to change any property that is not available in sVB, but also change the control template itself to change who it looks and behave (for example, the form designer of sVB is actually a ListBox with a modified template). This is an advanced topic that requires to understand Xaml and its resource dictionaries and styles. In fact one of sVB porpoises is to push developers towards DotNET and WPF.

Note: You can set the width or height properties to -1 to make the label (or any other control) have an auto width or auto height.

boa2145 commented 1 year ago

Hello Mohammad, Thanks for your reply. I see that the label and button has only some properties. It is okay for me and I understand the LeftToRight property for other languages. At the moment I am testing the form designer of sVB and there are a lot of questions which are driving through my head.

  1. Is it possible to extend the number of fonts, because I prefer old fonts like "Typewriter" and other fonts from old typewriters (1960s and 1970s) resp. retro or vintage fonts.

  2. Does sVB has the option to save the file automatically after a number of minutes? Then I don't always have to save manually.

Regards ... Gregor

VBAndCs commented 1 year ago

Is it possible to extend the number of fonts, because I prefer old fonts like "Typewriter" and other fonts from old typewriters (1960s and 1970s) resp. retro or vintage fonts.

Fonts are defined on the user PC, and sVB just shows them. You can install whatever fonts you want on your system, and they will appear in the font dialog, or you can set thee font name directly to the Font property of the control.

Does sVB has the option to save the file automatically after a number of minutes? Then I don't always have to save manually.

sVB saves the design eveyy time you switch to the code editor, and saves the code and design when you run the program. But you should always save code manually after maling changes. I always press Ctrl+S after pressing Enter. It became a second nature of me :D