|
Hello
I'm working with Windows Forms and ASP.NET projects using C#.
Today the user interface strings, like labels, messageboxes, etc. are located directly in the cs file within the code. I would like to place these strings separate from the code, but where? My first thought was to use a .resx file.
Localization is currently not an issue and probably never will be, but you never know. So I would like to keep that possibility open or at least not close the door.
Any suggestions?
|
|
|
|
|
Yes, put them in a resource file - If you are using VS2005 you'll find that it does quite a bit to help you access them in a sensible and type safe way as it creates a code behind file for the resource file.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
My website
|
|
|
|
|
Thanks. Do you know of any good articles about this?
|
|
|
|
|
It does everything for you. I can't see that an article would add much. It creates a class with the same name as the resource file with lots of static properties named after the string resource that get the actual string value for you. There is nothing much more complex about it. Visual Studio does the hard work so you don't have to.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
My website
|
|
|
|
|
Hi,
I am developing an application which needs to change the User Interface language of my WinCE device to the selected one from my application.I need to change the device language programmatically.
Can any one help me out in this ??? (I need it urgently)
Thanks.
Jyoti.
|
|
|
|
|
look into the resourcemanager class on MSDN.
You can attach assemblies with translations to your application that each contain the translations for your app.
V.
No hurries, no worries
|
|
|
|
|
Thanks for the quick reply but this is not i m searching for. I need to change WinCE device language programmatically. Manually we can change it from the regional settings. But i have to do it programmatically.
Thanks.
|
|
|
|
|
You don't want to set the language to french, english, chinese via a menu option or something?
|
|
|
|
|
No..i do want to set the language using a combobox. See when i select a language from a combobox from my application, i have to change the application UI language also(i have idea how to do that using ResourceManager and Satellite assemblies)but along with that i also want to change the OS language also.
|
|
|
|
|
Jyoti.Patil wrote: along with that i also want to change the OS language also.
Ok that is much clearer, but unfortunately I can't help you there...
|
|
|
|
|
Hello all,
Finally i got the answer for my question after a lot of R & D.
To change the language of the WinCE device user just has to change the two keys in the device registry.
RegistryKey regKey = Registry.CurrentUser.OpenSubKey("MUI", true);
if (regKey != null)
{
regKey.SetValue("CurLang", 1031); // 1031 is for German
regKey.Flush();
regKey.Close();
}
regKey = Registry.LocalMachine.OpenSubKey(@"nls\overrides", true);
if(regKey != null)
{
regKey.SetValue("LCID", 1031);
regKey.Flush();
regKey.Close();
}
and then add the code to restart the device. Without restarting the language change will not get reflected.
Thanks.
|
|
|
|
|
cool thanks for the info !
|
|
|
|
|
Hello. I need to create a service the will simply log all of the downloads that are perfromed with the built in IE downloader. I have no idea where to start though. Please adwise if possible. Thank you.
Assume that I know C#, VS, .NET.
Max V. Pavlov
|
|
|
|
|
I'm searching for technology, that enables to define GUI in text file (xml, properties or sth). The definition will be read at runtime, and GUI will be generated and shown. Changes in definition file will affect on program appearance (for example: adding new field in form definition in file - will affect in form appearance after next application start - without recompilation of all application
Can anyone help me ?
|
|
|
|
|
|
|
Hi All,
I make the reports in my program using crystal report, I design it using the stored procedure the problem is in the procedure which have if condition or execute statement the fields does not appear in the design of the crystal report.
merwa
|
|
|
|
|
I have an application. it has two forms. first form - mainForm is big and some images are loading into mainForm. second form - loginForm should be showed while mainForm is invisible is loading.
loginForm has a label that has "Loading...".
all is working but this label on the loginForm is not visible few seconds and I guess apllication is not response, but then all is ok. label is visible and formLogin to. after loading of maiForm is complete , loginForm should be hide..
can I fix waiting of showing of the label on the formLogin? is there somethig like "Application.ProcessMessagess" in Delphi?
thanx!
--
"Success is simple. Do what's right, the right way, at the right time."
best regards,
tradakad
|
|
|
|
|
Application.DoEvents.
Getting your init to happen on another thread, is even better.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thanx!
I tryed - but it doesnt work
it is my loginForm
public partial class frmLoading : Form
{
private int pointCount = 0;
private int iterationsCount = 0;
public frmLoading()
{
InitializeComponent();
}
private void frmLoading_Load(object sender, EventArgs e)
{
Application.DoEvents();
}
private void frmLoading_Shown(object sender, EventArgs e)
{
Application.DoEvents();
tmrProcess.Enabled = true;
}
private void tmrProcess_Tick(object sender, EventArgs e)
{
Application.DoEvents();
if (iterationsCount <= 2)
{
if (pointCount <= 10)
{
lblLoadingText.Text += ".";
pointCount++;
tmrProcess.Enabled = true;
}
else
{
lblLoadingText.Text = "Loading";
iterationsCount++;
pointCount = 0;
}
}
}
}
--
"Success is simple. Do what's right, the right way, at the right time."
best regards,
tradakad
|
|
|
|
|
Hello,
tradakad wrote: private void tmrProcess_Tick(object sender, EventArgs e)
{
Application.DoEvents();
if (iterationsCount <= 2)
{
if (pointCount <= 10)
{
lblLoadingText.Text += ".";
pointCount++;
tmrProcess.Enabled = true;
}
else
{
lblLoadingText.Text = "Loading";
iterationsCount++;
pointCount = 0;
}
}
}
You should call the DoEvents at the end of the code!
tradakad wrote: private void frmLoading_Shown(object sender, EventArgs e)
{
Application.DoEvents();
tradakad wrote: private void frmLoading_Load(object sender, EventArgs e)
{
Application.DoEvents();
}
I don't think that this is neccessary!
Apart from that, you are using the Forms.Timer which is running in the GUI Thread.
So the Timer is influenced from the action in you thread and might be throwing the Tick event not as expected (delayed)!
You could use a System.Threading or System.Timers Timer, which are running in an own thread.
Therefore you would have to invoke the Form if you want to change the Text, from the elapsed event for example!
All the best,
Martin
|
|
|
|
|
I tryed this.
private int pointCount = 0;
private int iterationsCount = 0;
public System.Timers.Timer tmrLoading = new System.Timers.Timer();
public frmLoading()
{
InitializeComponent();
}
private void frmLoading_Load(object sender, EventArgs e)
{
tmrLoading.Interval = 100;
}
private void frmLoading_Shown(object sender, EventArgs e)
{
tmrLoading.Start();
tmrLoading.Elapsed +=new System.Timers.ElapsedEventHandler(tmrLoading_Elapsed);
}
void tmrLoading_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
Application.DoEvents();
if (iterationsCount <= 2)
{
if (pointCount <= 10)
{
this.lblLoadingText.Text += ".";
pointCount++;
tmrLoading.Start();
}
else
{
this.lblLoadingText.Text = "Loading";
iterationsCount++;
pointCount = 0;
}
}
//throw new Exception("The method or operation is not implemented.");
}
but i had an error in this row
- this.lblLoadingText.Text += ".";
"Cross-thread operation not valid: Control 'lblLoadingText' accessed from a thread other than the thread it was created on"
what i do incorrect?
--
"Success is simple. Do what's right, the right way, at the right time."
best regards,
tradakad
|
|
|
|
|
Like I said, you have to invoke the method.
Invoke() is a member of control.
this.Invoke ... when this is your Form
All the best,
Martin
|
|
|
|
|
Hello,
I would add a method which sets the Text, and check there if Invoke is required.
private delegate void SetLoadingTextDelegate(string actText, bool append);
privat void SetLoadingText(string actText, bool append)
{
if(InvokeRequired)
{
Invoke(new SetLoadingTextDelegate(EnableTimer), new object[] {actText, append});
return;
}
if(append)
{
this.lblLoadingText.Text += actText;
}
else
{
this.lblLoadingText.Text = actText;
}
}
void tmrLoading_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
if (iterationsCount <= 2)
{
if (pointCount <= 10)
{
SetLoadingText(".", true);
pointCount++;
tmrLoading.Start();
}
else
{
SetLoadingText("Loading", false);
iterationsCount++;
pointCount = 0;
}
}
Application.DoEvents();
}
Hope it helps!
All the best,
Martin
|
|
|
|
|
aha.. i tryed to use property but not method...
ok. i'll it to. thanx!
but why thys code dont work?
public partial class frmLoading : Form
{
private int pointCount = 0;
// private int iterationsCount = 0;
private System.Timers.Timer tmrLoad = new System.Timers.Timer();
public frmLoading()
{
InitializeComponent();
}
private void frmLoading_Shown(object sender, EventArgs e)
{
tmrLoad.Interval = 1000;
ChangeLabelText();
}
private void ChangeLabelText()
{
for (; ; )
{
if (pointCount <= 10)
{
lblLoadingText.Text += ".";
tmrLoad.Start();
pointCount++;
Application.DoEvents();
}
else
{
lblLoadingText.Text = "Loading";
iterationsCount++;
pointCount = 0;
}
}
}
}
main form --------------------
private void frmMain_Load(object sender, EventArgs e)
{
this.Visible = false;
}
private void frmMain_Shown(object sender, EventArgs e)
{
frm.Visible = true;
LoadSettings();
LoadImages();
LoadControlsPositions();
frm.Dispose();
this.Visible = true;
}
--
"Success is simple. Do what's right, the right way, at the right time."
best regards,
tradakad
|
|
|
|