TouchScreen MultiLang UserControl

Introduction

This article is intended to demonstrate how to create a touchscreen UserControl Keypad interface for WinForms. This User Control is easy to use in Winforms.


English

Image1.jpg
.
Korean

Image2.jpg
.
Numeric

Image3.jpg
.

Background

This is a simple and easy to use Multi Language Keypad for Touch Screen.

Using the code

First create a User Control. Create a Class Library project and remove the class file and add the UserControl. Place all the buttons and create the events for all the buttons. Here for example for the buttons A to Z, I have set the same event name.

Declare the Variables:

//
  #region Attributes
        ////////////////////////////////
        public bool capsOn = false;
        public bool hangulOn = false;
        public bool numbersOn = false;
        public string keypaReturnVal = "";
 
        #endregion

User Control Load Event declaration of all the Button Events and in Button:

//
  #region Button & ETC Click Events (
모든클릭 이벤트처리)
        /////////////// Common Functions ////////////////////
        void ShanubtnClearClicks(object sender, EventArgs e)
        {
            keypaReturnVal = "";
       
        }
        ///
<summary>
        /// All Button Click Events
        ///
</summary>
        ///
 
        void ShanubtnClicks(object sender, EventArgs e)
        {
            DevExpress.XtraEditors.SimpleButton button = sender as DevExpress.XtraEditors.SimpleButton;
 
 
            string buttonText = button.Text;
 
            keypaReturnVal = keypaReturnVal + buttonText;
            if (!this.Focused)
                this.Focus();
        }
 
        ///
<summary>
        /// Space Button Click Events
        ///
</summary>
        ///
 
        void ShanubtnSpaceClicks(object sender, EventArgs e)
        {

           //DevExpress.XtraEditors.SimpleButton button = sender as DevExpress.XtraEditors.SimpleButton;
             //string buttonText = button.Text;
 
            keypaReturnVal = keypaReturnVal + " ";
 
            //textBox1.Text = keypaReturnVal;
        }
 
 
        ///
<summary>
        /// BackSpace Button Click Events
        ///
</summary>
        ///
 
        void ShanubtnBackSpaceClicks(object sender, EventArgs e)
        {
 
 
            if (keypaReturnVal.Length > 0)
            {
 
                keypaReturnVal = keypaReturnVal.Remove(keypaReturnVal.Length - 1, 1);
            }
 
        }
        ///
<summary>
        /// Button Caps Lock Loading
        ///
</summary>
        ///
 
        void ShanubtnCapsClicks(object sender, EventArgs e)
        {
            if (hangulOn == true)
            {
                return;
            }
            if (numbersOn == true)
            {
                return;
            }
            if (capsOn == false)
            {
                capsOn = true;
                btnCaps.Text = btnCaps.Text.ToUpper();
                this.btnCaps.Image = global::SHANUPADUC.Properties.Resources.uparrow;
            }
            else
            {

                btnCaps.Text = btnCaps.Text.ToLower();
                this.btnCaps.Image = global::SHANUPADUC.Properties.Resources.arrowdown;
            }
 
            loadCaps();
        }
 
        void ShanubtnLangClicks(object sender, EventArgs e)
        {
            if (hangulOn == false)
            {
                hangulOn = true;
                this.btnLang.Image = global::SHANUPADUC.Properties.Resources.KOR_32;
            }
            else
            {
                hangulOn = false;
                this.btnLang.Image = global::SHANUPADUC.Properties.Resources.ENG_32;
            }
            loadbtnLang();
        }
 
        void ShanubtnNumberClicks(object sender, EventArgs e)
        {
            if (numbersOn == false)
            {
                numbersOn = true;
            }
            else
            {
                numbersOn = false;
            }
            loadbtnNumbers();
        }
        #endregion 

Compile and run the project, add the DLL in your Winform. In Winform we need to make the UC events and need to set the focused TextBox for the keypad button text display in the Textbox. Use this code in the form Initialization.

//
public Form1()
        {
            InitializeComponent();
            WireAllControls(shanukeypaduc1);
        }
 
        private void WireAllControls(Control cont)
        {
            foreach (Control ctl in cont.Controls)
            {
                ctl.Click += ctl_Click;
                if (ctl.HasChildren)
                {
                    WireAllControls(ctl);
                }
               // ctl.DoubleClick += jnkckeypaduc1_DoubleClick;
            }
 
            //toget the Textbox Focued
 
            foreach (TextBox tb in this.Controls.OfType<TextBox>())
            {
                tb.Enter += textBox_Enter;
            }
 
           // jnkcKeyPadcs1.DoubleClick+=new EventHandler(jnkcKeyPadcs1_DoubleClick);
 
        }
 
        //void jnkckeypaduc1_DoubleClick(object sender, EventArgs e)
        //{
        //  //  jnkckeypaduc1.Visible = false;
        //}
 
        void textBox_Enter(object sender, EventArgs e)
        {
            focusedTextbox = (TextBox)sender;
            shanukeypaduc1.keypaReturnVal = focusedTextbox.Text;
        }
 
        private void ctl_Click(object sender, EventArgs e)
        {
            this.InvokeOnClick(this, EventArgs.Empty);
 
            if (focusedTextbox != null)
            {
                // put something in textbox
                focusedTextbox.Text = shanukeypaduc1.keypaReturnVal;
            }
 
            //textBox1.Text = jnkcKeyPadcs1.keypaReturnVal;
        }

Points of Interest

This User Control is simple to Use in Winform. Download it and use it in Winform Touchscreen projects.
 

Up Next
    Ebook Download
    View all
    Learn
    View all