package com.sabirjan.android;

import com.sabirjan.Dialog.InfoDialog;
import com.sabirjan.DrawUyghurWord.SetUyghurTypeface;
import com.sabirjan.HanziCode.Huoqu_HanZi_Code;
import com.sabirjan.HanziCode.JianChaHanZi;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class HanZi_Code_Activity extends Activity{

	EditText input;
	TextView txt_tishi;
	TextView txt_jieguo;
	@Override
	protected void onCreate(Bundle savedInstanceState) 
	{
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.hanzi_code);
		TextView txt=(TextView)this.findViewById(R.id.txtview_hanzi);
		txt=SetUyghurTypeface.GetTextView(this, txt);
		input=(EditText)this.findViewById(R.id.edit_hanzi);
		txt_tishi=(TextView)this.findViewById(R.id.txtview_tishi);
		txt_tishi=SetUyghurTypeface.GetTextView(this, txt_tishi);
		txt_jieguo=(TextView)this.findViewById(R.id.txtview_jieguo);
		txt_jieguo=SetUyghurTypeface.GetTextView(this, txt_jieguo);
		
		
		
		Button btn=(Button)this.findViewById(R.id.btn_hanzi);
		btn=SetUyghurTypeface.GetButton(this, btn);
		btn.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				if(input.getText().toString().trim().length()>0)
				{
					try
					{
					Huoqu_HanZi_Code cls3=new Huoqu_HanZi_Code();
					JianChaHanZi cls1=new JianChaHanZi();
					String  tmp=cls1.checkNameChese(input.getText().toString());
					if(tmp.trim().length()>0)
					{
						String jieguo=cls3.GetChWordsCode(tmp);
					//System.out.println("CodeNumber="+cls3.GetChWordsCode());
						if(jieguo.length()>0)
						{
							txt_tishi.setVisibility(View.VISIBLE);
							txt_jieguo.setVisibility(View.VISIBLE);
							txt_jieguo.setText(jieguo);	
						}
					}
					}//End try
					catch(Exception ex)
					{
						
					}
					
				
				}
				else
				{
					InfoDialog errorInfo=new InfoDialog(HanZi_Code_Activity.this," ﻛﻪﭼﯘﺭﯗﯓ ،  ﻣﻪﺯﻣﯘﻥ ﻛﯩﺮﮔﯜﺯﯛﭖ ﺋﺎﻧﺪﯨﻦ ﻣﯘﻗﯘﻣﻼﺷﺘﯘﺭﯗﯓ ");
					errorInfo.show();
				}
			}
		});
		Button btn2=(Button)this.findViewById(R.id.btn_qingchu);
		btn2=SetUyghurTypeface.GetButton(this, btn2);
	//	btn2.setWidth(40);
		btn2.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				txt_jieguo.setText("");
				txt_tishi.setVisibility(View.INVISIBLE);
				txt_jieguo.setVisibility(View.INVISIBLE);
				input.setText("");
				
			}
		});
		
		
	}
	
	
	
	

}
