TX Words: Right to Left

Text Control supports right to left text rendering for languages such as Arabic or Hebrew. Most often, users working with "RTL languages", also prefer an application view with a right-to-left orientation. This sample shows how to implement a button that restarts the program in the opposite application view.

The source code for this example is contained in the following directories:

  • %USERPROFILE%\Documents\TX Text Control 32.0.NET for Windows Forms\CSharp\TX Words\Right To Left
  • %USERPROFILE%\Documents\TX Text Control 32.0.NET for Windows Forms\VB.NET\TX Words\Right To Left

Using the Sample

To change the application view, click the Right to Left button. It opens a message box where the user can confirm the view change by restarting the program. After the application is restarted, the orientation of the sample is changed to right to left.

Image

The Code Behind

When clicking the Right to Left button, the requested layout will be saved as Settings property value before the application is restarted.

private void RightToLeftFormLayout_Click(object sender, System.EventArgs e) {
        bool bIsRightToLeft = (bool)(sender as RibbonButton).Tag;
        if (SaveDirtyDocumentBeforeReset(bIsRightToLeft)) {
                Properties.Settings.Default.RightToLeft = bIsRightToLeft ? RightToLeft.No : RightToLeft.Yes;
                SaveRecentFiles();
                Application.Restart();
        }
}

After that, this layout is loaded when the application is initialized for restart.

public MainWindow() {
        InitializeComponent();
        // Get and set saved application settings.
        LoadRightToLeftSettings();
        LoadRecentFiles();
}

It updates both the RightToLeftLayout property value of the application and that of the ribbon.

private void LoadRightToLeftSettings() {
        this.RightToLeftLayout =
        m_rbnRibbon.RightToLeftLayout = (this.RightToLeft = Properties.Settings.Default.RightToLeft) == RightToLeft.Yes;
}