2014年6月25日 星期三

How to change Windows Form language at runtime

When we were developed an oversea product, it must exist a requirement that switch UI language at runtime. Windows Form of .Net has already provide a localization framework for you, it's very easy to complete a multi-language application if you follow the correct way. The framework is also allow you to switch to specified language at runtime.

We must have a concept, the texts of an application are kinds of resource, change the display language is just change the resource we use. For this reason,  the following notes are useful for developing a multi-language application.
  1. Content of different languages are defined in their specified resource file.
  2. Use index key to retrieve the text in program.
  3. Set the current language (culture) to get the text with correct language.
The MSDN article has explained localization steps of a windows form application very clearly:

Walkthrough: Localizing Windows Forms

http://msdn.microsoft.com/en-us/library/y99d1cd3(v=vs.110).aspx

But the method of the article is just workable in the beginning of application, we still don't know how to change the language at runtime. I have a solution for this issue.

Example: Press the button and change to corresponding language.



Source code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void BtnChinese_Click(object sender, EventArgs e)
        {
            ChangeLanguage("zh-TW");
        }

        private void BtnEnglish_Click(object sender, EventArgs e)
        {
            ChangeLanguage("en-US");
        }


        private void ChangeLanguage(string lang)
        {
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(lang);
            ComponentResourceManager res = new ComponentResourceManager(typeof(Form1));
            ChangeLanguage(this, res);
        }

        private void ChangeLanguage(Control ctrl, ComponentResourceManager res)
        {
            res.ApplyResources(ctrl, ctrl.Name, Thread.CurrentThread.CurrentUICulture);
            foreach (Control c in ctrl.Controls)
            {
                ChangeLanguage(c, res);
            }
        }
    }
}

2007年10月28日 星期日

Comparison of TeeChart and Dandus

TeeChart for .Net and Dandus .Net are all web chart component running on Asp.Net. Both of them provide abundant Web Chart alinity. I studied the difference of them recently., there is insight as follows.

After 3 hourse test for TeeChart for .Net and Dandus .Net, and summary the experence of TeeChart for .NET v3 EVALUATION. I strongly think that TeeChart is not a good Web Chart Tool, and suggest to use Dandus. Below is the defects of TeeChart:
  1. Not only TeeChart ActiveX v8 Evaluation or TeeChart for .NET v3 EVALUATION, there exists serious problems after installation. Maybe someone says these bugs are only in Evaluation version, but what I care is the quality of production. A valuation version which everyone can download is so miserably, I dare not to believe the formal version would be good?
    Simply list the problems of Evaluation below:
    1. TeeChart ActiveX v8 Evaluation: Installed menu includes previous version (v7.0) unrunable function.
    2. TeeChart ActiveX v8 Evaluation: The Example project is for VS.NET 2003, not for VS.NET 2005
    3. TeeChart ActiveX v8 Evaluation: There is no any comment in Example source code.
    4. TeeChart for .NET v3 EVALUATION: All demo of Example project will be crashed. The component itself have bugs.
  2. TeeChart for .NET don't support Ajax, so every interactive between server and client have to use Post back. Not only its technique falls behind, but also the using impressions is more poor.
  3. TeeChart ActiveX and TeeChart for.NET are all have no the idea of .Net DataSource concept, its data source can't directly set the DataBinding which use .Net configure
  4. So far I could not find a simple method to copy the WebChart to the clipboard.
  5. Above is I think a more serious problem, other minors problem is as follows, although it is said minor, but it may become important in future:
    1. Art design is worst than Dandus.
    2. No convinent toolbar upon the Web Chart.
    3. The example and teaching compare to Dandus are obviously worse. These are bad for problem-solving in future.

Consolution, I think TeeChart is not a good WebChart on Asp.Net. Maybe it had good performance on Delphi platform or others. But ASP.Net is a whole new, complete different framework. It's not a very professional viewpoint to think it will also be good in ASP.Net just because the express in the past.

Finally, I think Dandus is more better than TeeChart in WebChart tools.

first post

Test