|
|
Those are for ASP.NET. Assuming they did it the right way, Windows Forms applications are still localized a little differently.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
You should start by reading Developing World-Ready Applications[^] in the .NET Framework SDK.
Basically, in whatever language you develop your application, that text (and other objects which have an associated TypeConverter ) is your neutral resource language and is compiled into your primary assembly (the assembly that contains the IL modules compiled from your code. Any other languages you develop are put into satellite assemblies.
If you're using VS.NET this is very easy (but, until "Whidbey", pretty inefficient at runtime for larger applications). Develop your forms and controls, then select the top-level control (like the Form or UserControl ) and find the Localized property (this is actually a design-time property; it is not defined on the class). Set that to true then find the Language property (again, a design-time property). Set that to something else and change the text, positions and sizes of controls, etc.
If you want to see what VS.NET is doing behind the scenes, click Project->Show hidden files from the menu. You'll see a lot of .ResX files nested underneat your control class files. The neutral resource .ResX will not have an ISO lang/locale identifier (like MyClass.resx) while the others will (like MyClass.de-DE.resx or MyClass.es.resx, which are resource files for Germany (German language) and the Spanish language (no locale), respectively.
When you compile your application, satellite assemblies are created. If you then look into your source code, expand the hidden regions and you'll see lots of calls to ResourceManager.GetString or ResourceManager.GetObject (actually, an instance of ResourceManager typically named resources ).
When the CultureInfo.CurrentUICulture (not CurrentCulture , which is used for formatting dates, times, and numbers - it specifies the locale, not the language) is set the ResourceManager will try to find a language for that. If any locale is specified in that CultureInfo instance, that locale will be used if it exists. If not the fallback is the language. If a satellite assembly doesn't exist for that, the neutral resources - those inside your primary assembly - are used.
To make this faster, in your AssemblyInfo.cs file (actually, wherever is fine) define the assembly-level attribute NeutralResourcesLanguage set to the "lang-locale" for the language in which your project is developed, like "en-US" for US English. If the ResourceManager needs to find those reosurces, it will not not to go probing for them (which is especially slow if deploying your managed application using touchless deployment across the Internet or even an intranet).
Be sure to read that link I gave you, as well as some of the classes you'll be using like ResourceManager and CultureInfo . Taking a look at what VS.NET does (because that's about what you'd do if you did it manually) is also extremely helpful.
If you use VS.NET to do this your clients can even localize your application without the source using winres.exe from the .NET Framework SDK, or a separate localization team if you have such an entity. You can use this if you do it manually, but you must understand what is required that winres.exe looks for, which you can learn by looking to see what VS.NET does.
Here's the catch: VS.NET declares instantiates the ResourceManager in InitializeComponents . If you want to support switching languages in the middle of the application (which you can do by setting CultureInfo.CurrentUICulture , then you'll need to re-initialize - not re-instantiate - your controls. To do this efficiently you'll need to break VS.NET's design-time support by abstracting the initialization out of InitializeComponents , leaving only the instantiation in there (or more the instantiation to another method). This means you can call a method to re-initialize the controls (how you trigger this is up to you). This is pretty uncommon for larger projects, as many problems can occur and since most people don't need to switch languages in the middle of a Windows session.
Note, too, that MUI (multi-user interfaces API) automatically sets CultureInfo.CurrentUICulture (actually, the property is initialized from the current MUI language). So, if a user is using a German Windows installation or the German MUI as I sometimes do, CultureInfo.CurrentUICulture would automatically be set to "de-DE" so your application - if localized for "de-DE" or just "de" - would automatically display your German text and control positions, sizes, etc.
If you'd like more information about how "Whidbey" is improving efficency while using the designer to localize applications, read my blog entry at http://blogs.msdn.com/heaths/archive/2004/10/05/237987.aspx[^].
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
|
You should look over the System.Drawing and System.Drawing.Drawing2D namespaces. C# has a rich API for drawing many of the things you mention (e.g. gradients, buttons, etc.) Here is a short tutorial on some basic drawing/painting functions: http://www.c-sharpcorner.com/2/gdi_plus.asp[^]
You should also look into Pens, Brushes, Patterns, and Alpha Blending (Transparency)[^].
Best Regards.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
I am using a security dongle (clients request) and am having some problems with it. They have released a .net component to talk to the device. I have tried speaking to them about my problem, but they are on the other side of the planet, and communication is way to slow.
Ok, this code works 100% in any C# program, except asp.net. I am not going to give you the code I am using, as it would be of no use in this problem. The dll attempts to connect to a USB port on the computer. However, in asp.net this fails.
So my question is this: The asp.net page does not actually need to connect to the device, as all it needs to do is store some information on there. What sort of component should I make that can be called from asp.net? I have not used COM or windows services, or anything else like that, so am not sure if one of these could help me. Please let me know how I can call a method in a remote object to do this work for me?
|
|
|
|
|
Is the asp.net executing on the local machine or on a remote server ?
Due to obvious security issues you can't access the local file system from a webpage and nor can you access any device.
The only workaround would be to use a smart client.
"Do not inflate plain things into marvels, but reduce marvels to plain things." - Francis Bacon
|
|
|
|
|
What do you mean by a smart client? The asp.net is on the local machine.
|
|
|
|
|
A smart client is like half way between asp.net and windows forms :
example[^]
Since its local I would think about the permisions of the asp.net user and the runtime security policy. Perhaps if you give it full permission and full trust and see if that works ?
"Do not inflate plain things into marvels, but reduce marvels to plain things." - Francis Bacon
|
|
|
|
|
HI,
I have some 5 lines of text already entered into the text file.
Is there any possible way to enter the next line as the first line and not just append it to the end.
Regards,
Sukanya
|
|
|
|
|
|
I have to this programmatically in C#.
I already have written some text into the file using C#. I want insert the next line as the first line of the text file.
but by default it always inserts it at the end.
pls help
I am working on that
Regards
Sukanya
|
|
|
|
|
You'll have to read the entire file, append your text on the beginning and then write the whole file again.
This space for rent!
My Blog
|
|
|
|
|
Try using a StreamWriter to write to your file. The underlying stream, which is accessible through the BaseStream property provides a Position property which should allow you to position at the front of the stream/file.
www.troschuetz.de
|
|
|
|
|
In short, you cannot INSERT anything anywhere you want in a text file in a single, simple operation. Unless, of course, you want to APPEND to the end of the file.
If you want to insert text as the first lines in the file, you'll have to do one of two things:
1) Open the file; Read the entire contents of the text file into memory; Close the file; Reopen it as a new file; Write out the text you want to insert at the beginning of the file; Write out the contents that you saved; Close the file
2) Rename the file to some temporary name; Open a new file with the name you want; Write out the text you want to insert; Open the temporary file; Read it in, line by line, and write it out to the new file, line by line; Close both files
Method 1 will work very fast is better on samller files. Method 2 will work better for very large files, or files that you can't know the size of ahead of time, or files that exceed RAM capacity, but is slower.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I'm trying to find the most effecient way/most elegant way to do this. I have a Combo box that has a list of network types (all corresponding to System.Net.NetworkInformation.InterfaceType ). Now I have an if statement that is dependent on what is selected in this combo box. e.g. if "Ethernet" is selected it will be if(interfaces[i].Type == InterfaceType.Ethernet) . Now I know I could just do a massive if nesting but I want to know what you guys think would be best.
Matt Newman
Even the very best tools in the hands of an idiot will produce something of little or no value. - Chris Meech on Idiots
|
|
|
|
|
It depends what you want to do. If you are just setting a variable or two based on the result, I'd build a hashtable of type to return value, and set it in one line.
Either way, I'd always use a switch over massive if/else blocks.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Basically I am enumerating all of the network adapters on the system and then allowing the user to specify which type to view (only the type selected are shown). It is really only used once.
Matt Newman
Even the very best tools in the hands of an idiot will produce something of little or no value. - Chris Meech on Idiots
|
|
|
|
|
I reckon the trick is to make the value associated with the strings in the drop down equal the enum value, if that's all you need. Or, better yet, use Enum.Parse to make an enum value out of the string, and use Enum.(whatever the method is that returns a string array from an enum ) to populate it.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Keep in mind that InterfaceType has a backing value type of Int32. My experience with Windows Forms is limited, but if you could get an index value of some type from the combobox, you could cast that value to a variable of type InterfaceType.
i.e.:
InterfaceType selectedType = (InterfaceType) val;
(where val is the index number pulled in through the combobox)
Then you'd only have one conditional statement checking for equality:
if (interfaces[i].Type == selectedType)
Hope this helps!
~ Levi
|
|
|
|
|
Good idea... but this is the index list (of all InterfaceTypes)
94 AsymmetricDsl
37 Atm
20 BasicIsdn
6 Ethernet
26 Ethernet3MegaBit
69 FastEthernetFx
62 FastEthernetT
15 Fddi
48 GenericModem
117 GigaBitEthernet
144 HighPerformanceSerialBus
114 IPOverAtm
63 Isdn
24 Loopback
143 MultiRateSymmetricDsl
23 Ppp
21 PrimaryIsdn
95 RateAdaptDsl
28 Slip
96 SymmetricDsl
9 TokenRing
131 Tunnel
1 Unknown
97 VeryHighSpeedDsl
71 Wireless80211
So I cant just do 0 -> 0 1->1 etc
Matt Newman
Even the very best tools in the hands of an idiot will produce something of little or no value. - Chris Meech on Idiots
|
|
|
|
|
From what I understand about Combobox controls in .NET:
- The Add() method accepts an object as a parameter, and the object's ToString() return value is what actually gets displayed in the Combobox.
- The SelectedItem property returns the object (not the ToString() result) that is selected.
Perhaps it would be possible to create a new struct containing an InterfaceType field, a string field, and a simple ToString() method to make this work. When you use the SelectedItem property of the Combobox to return the currently selected object, you could simply read back its InterfaceType field.
Like I said, I've not used Windows Forms since VB6, so hopefully somebody will correct me if I am in error.
Good luck!
~ Levi
|
|
|
|
|
|
hello,
i have a dynamic control that i add the control collection.
this control is being loaded from ascx.
if i want to change, while postback, the ascx i load, i retrieve a message that i can't since
so what i want to do is to be able to delete control viewstate while postback.
can i do so?
many thanks,
Eran.
|
|
|
|
|
Your question belongs in the ASP.NET forum.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|