Click here to Skip to main content
15,886,518 members
Articles / Mobile Apps / Windows Phone 7

Arabic Controls in Window phone 7

Rate me:
Please Sign up or sign in to vote.
4.31/5 (9 votes)
12 May 2012CPOL6 min read 30.5K   556   11  
Make your Application windows phone 7 support for Bi-Directional right to left
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Arabic.Controls;
using Microsoft.Phone.Shell;
using Arabic.Utils;
using System.Windows.Media.Imaging;
using System.Reflection;
using Arabic.Control;


namespace PhoneApp1
{
    public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        public Arabic.Controls.ArabicShape crAr;
        public MainPage()
        {
            InitializeComponent();
            ApplicationGlobals.Instance.Orientation = this.Orientation;
            this.keyboard.FirstInitialize();
            
            lblUserName.Text = "أسم المستخدم";
            lblPassword.Text = "كلمة المرور";
        }
        private void Scroll(double value)
        {
            this.SlideKeyFrame.Value = value;
            this.ScrollTextStoryboard.Begin();
        }

        private void keyboard_KeyboardShow(object sender, EventArgs e)
        {
            this.Scroll(this.keyboard.Height);


        }

        private void textBlock1(object sender, EventArgs e)
        {
            this.textBlock.FocusText();
            this.rTLTextBox1.Defocus();
        }


        private void textBlock2(object sender, EventArgs e)
        {
            this.rTLTextBox1.FocusText();
            this.textBlock.Defocus();
        }

        private void keyboard_KeyboardHide(object sender, EventArgs e)
        {
            this.Scroll(0);
            this.textBlock.Defocus();
            //this.rTLTextBox1.Defocus();
        }
        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            this.keyboard.InitializeKeyboard();
            this.keyboard.KeyboardHide += new EventHandler(keyboard_KeyboardHide);
            this.keyboard.KeyboardShow += new EventHandler(keyboard_KeyboardShow);
            this.textBlock.GotFocus += new RoutedEventHandler(textBlock1);
            this.rTLTextBox1.GotFocus += new RoutedEventHandler(textBlock2);

            


            this.textBlock.SetKeyboard(this.keyboard);
            this.rTLTextBox1.SetKeyboard(this.keyboard);

            UpdateTextLayout();
           

            crAr = new Arabic.Controls.ArabicShape();//Intilize  Arabic Shape Class

            listBox1.Items.Add("إختبار عربي");
            /*Here to make Control Display Arabic items corectly*/
            listBox1.Items.Add(crAr.DisplayArabic("إختبار عربي"));

            btnClose.Content = crAr.DisplayArabic("دخول");
        }

        private void PhoneApplicationPage_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (SIP.Instance.Visible && e.GetPosition(keyboard).Y < 0)
            {
                e.Handled = true;
                this.keyboard.Dismiss();
            }
        }
        private void UpdateTextLayout()
        {
            this.textBlock.Update();
            this.rTLTextBox1.Update();
        }
        private void PhoneApplicationPage_BackKeyPress(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (SIP.Instance.Visible)
            {
                e.Cancel = true;
                this.keyboard.Dismiss();
            }
            else
            {
                NavigationService.GoBack();
            }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Jordan Jordan
Mobile Developer with deep Experience in Handheld Device Pocket Pc, Smart Phone in Win32, MFC With more than 8 years ago."Arabizer, Hook Function, Poom, Wirless Application, and low level Application". By C++ MFC and win32

http://windowsmobiledn.blog.com/

Comments and Discussions