|
Hai, Everyone
I developed a application for entering datas for a company now i want to add multilingual support for the application,i readed about the Form localization but it is not a practical way.
Iam Planning to take translations from my database table. in future admin can add more languages.
My Application have a login form. i created a combobox there named language.
when a my application start the login page will display.
my problem is how can i change language for all form eg:(when a user change combox index i need to change all form's language)
I thing you understand what is my problem is.
Can anyone Please Help me To Do it?
Arunkumar.T
|
|
|
|
|
Some way or another your are going to end up storing a collections of string elements (to be mapped onto your GUI) that relate to many language versions.
EnterButton => English:"Enter",Spanish:...
Localization I think is the only way you can achieve such effect...
Maybe look at http://ondotnet.com/pub/a/dotnet/2002/09/30/manager.html[^], a four part series that could help?
|
|
|
|
|
Since you want the values to be retrieved from a database rather than using a resource file you will need to method to map the display values to the contents of the database. You can do this by either using the LCID as a key to lookup values or by creating a separate database table for each language and changing the connection string based on the LCID. I prefer the former method.
No comment
|
|
|
|
|
You can set the Current UI Culture of a thread by
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("de-DE");
Note that a new thread inherits the UI Culture from Windows, not from the parent thread; i.e. you have to set it again.
For forms which are already displayed, you'll need an event and an event handler for a "UICultureChanged" event.
|
|
|
|
|
Create a interface ITranslateable with one method : void Translate().
Let each Form implement the interface. When a form is loaded (load event) you call the interface method. Also when the language is changed you call the interface method for each active form (keep a reference!). In the implementation of the method you call a database search for each control that needs translation: ie comboBox2.Text = Database.getTranslation("Form3.comboBox2").
In the database you have a table with all gui-objects (ie. "Form3.comboBox2"), and a table with an entry for each gui-object/language combination.
Also when you get data from the database (to fill a grid or so) the data must be translated? It can be done in the same table (ie "tablename.objectname").
|
|
|
|
|
Arunkumar.Koloth wrote: Iam Planning to take translations from my database table. in future admin can
add more languages.
Internationalization is NOT only about language transalation.
You need to research the issues involved first and AFTER that then consider how to design/implement it.
|
|
|
|
|
I have the following code:
IKernel kernal = new StandardKernel();
kernal.Bind<ILocationComponent>().To<LocationCom>();
kernal.Bind<IComponent>().To<LocationCom>();
kernal.Bind<IComponent>().To<MovementnCom>();
package = kernal.Get<ComponentPackage>();
package.Get<MovementnCom>().Force = new Vector2(10,10);
package.Get<LocationCom>().Position = new Vector2(2,2);
LocationCom:
[Family("Location")]
class LocationCom : BaseComponent, ILocationComponent
{
public Vector2 Position { get; set; }
}
MovementCom:
[Family("Movement")]
class MovementCom : BaseComponent, IRealtimeComponent
{
private readonly ILocationComponent locationCom;
public Vector2 Force { get; set; }
[Inject]
public MovementCom(ILocationComponent locationCom)
{
this.locationCom = locationCom;
}
public void Update(GameTime gameTime)
{
locationCom.Position += Force * (float)gameTime.ElapsedGameTime.TotalSeconds;
}
}
ComponentPackage:
public ComponentPackage(IEnumerable<IComponent> components)
{
foreach (var component in components)
{
Add(component);
}
}
The idea is that the movement component will get a reference to location component when injected
into the package.
The problem is that MovementCom receives a new instance of LocationCom, thus when it applies
force it is applying it to an unrelated position (not inside the package).
Does Ninject resolve this issue or would I have to write some "adaptor" code for the dependencies to work, I am fairly new to using an IOC container so it is likely to be an easy question 
|
|
|
|
|
Ninject? Never heard of it. I'd be willing to bet these guys[^] have though.
|
|
|
|
|
Hi all,
We are working in developing a Help desk application and i need to be able to remotely diagnose the client Pc's basic problems,
like i need to check the network connectivity, hard disk capacity, anti-virus status, Windows Performance reports. any ideas on how to do this things ?
Thanks For your cooperation in advance
|
|
|
|
|
Mohammed NAeem wrote: like i need to check the network connectivity, hard disk capacity, anti-virus status, Windows Performance reports. any ideas on how to do this things ?
Install a small application on the client PC that collects this data and generates a report. It's not possible to "remotely" verify the status of my anti-virus, it doesn't broadcast it's status to strangers.
Bastard Programmer from Hell
|
|
|
|
|
Hi,
I know this may be asking a lot, I found this code class and it makes little sense to me in some places, so I was looking for some help deciphering it. It is designed to query a serial port and communicate with a microchip.
Some of the confusing parts
private const uint COMMAND_LOAD_RAM_AND_RUN = 1;
private const uint COMMAND_LOAD_EEPROM_AND_RUN = 3;
lfsrData[0] = 0xF9;
for (int i = 1; i < 251; ++i)
lfsrData[i] = (byte)(0xFE | (IterateLFSR() ? 1 : 0));
byte[] buffer = new byte[258];
for (int i = 0; i < 258; ++i)
buffer[i] = 0xF9;
This part really throws me ...
for (int i = 0; i < 250; ++i)
{
if (ReceiveBit(false, 100) != IterateLFSR())
throw new ApplicationException("Receiving LFSR data failed!");
}
byte version = 0;
for (int i = 0; i < 8; ++i)
{
version >>= 1;
version += (byte)(ReceiveBit(false, 100) ? 128 : 0);
}
And here is the whole class itself, thank you for reading.
using System;
using System.Collections.Generic;
using System.Text;
using System.IO.Ports;
using System.IO;
using System.Threading;
namespace PrBooter
{
public class Booter
{
public Booter(string portName)
{
m_SerialPort = new SerialPort(portName, 115200, Parity.None, 8, StopBits.One);
m_SerialPort.ReadTimeout = 3000;
}
#region Constants
private const uint COMMAND_LOAD_RAM_AND_RUN = 1;
private const uint COMMAND_LOAD_EEPROM_AND_RUN = 3;
#endregion
private SerialPort m_SerialPort = null;
#region Public stuff
public static string[] GetPortNames()
{
return SerialPort.GetPortNames();
}
public string PortName
{
get { return m_SerialPort.PortName; }
set
{
if (m_SerialPort.IsOpen)
throw new InvalidOperationException("Cannot set PortName while Serial is open!");
m_SerialPort.PortName = value;
}
}
public void ResetPr()
{
m_SerialPort.DtrEnable = true;
Thread.Sleep(10);
m_SerialPort.DtrEnable = false;
}
public void Reprogram(string filename)
{
Stream s = File.OpenRead(filename);
try
{
Reprogram(s);
}
finally
{
s.Close();
}
}
public void Reprogram(Stream stream)
{
try
{
m_SerialPort.Open();
byte[] programData = new byte[(int)stream.Length];
stream.Read(programData, 0, (int)programData.Length);
StartComm(COMMAND_LOAD_EEPROM_AND_RUN);
SendProgram(programData);
if (ReceiveBit(true, 5000))
throw new ApplicationException("EEPROM Programming Failed!");
if (ReceiveBit(true, 2500))
throw new ApplicationException("EEPROM Verification Failed!");
}
finally
{
m_SerialPort.Close();
}
}
public void Boot(string filename)
{
Stream s = File.OpenRead(filename);
try
{
Boot(s);
}
finally
{
s.Close();
}
}
public void Boot(Stream stream)
{
try
{
m_SerialPort.Open();
byte[] programData = new byte[(int)stream.Length];
stream.Read(programData, 0, (int)programData.Length);
StartComm(COMMAND_LOAD_RAM_AND_RUN);
SendProgram(programData);
}
finally
{
m_SerialPort.Close();
}
}
#endregion
#region High level protocol
private void SendProgram(byte[] programData)
{
int longCount = (programData.Length + 3) >> 2;
TransmitEncodedLong((uint)longCount);
for (int i = 0; i < longCount; ++i)
{
int byteIdx = (i << 2);
uint x = (uint)(
(programData[byteIdx + 3] << 24) |
(programData[byteIdx + 2] << 16) |
(programData[byteIdx + 1] << 8) |
(programData[byteIdx]));
TransmitEncodedLong(x);
}
m_SerialPort.BaseStream.Flush();
if (ReceiveBit(true, 2500))
{
throw new ApplicationException("RAM Checksum failed!");
}
}
private int StartComm(uint command)
{
ResetPr();
Thread.Sleep(90);
ResetLFSR();
byte[] lfsrData = new byte[251];
lfsrData[0] = 0xF9;
for (int i = 1; i < 251; ++i)
lfsrData[i] = (byte)(0xFE | (IterateLFSR() ? 1 : 0));
m_SerialPort.Write(lfsrData, 0, 251);
byte[] buffer = new byte[258];
for (int i = 0; i < 258; ++i)
buffer[i] = 0xF9;
m_SerialPort.Write(buffer, 0, 258);
m_SerialPort.BaseStream.Flush();
for (int i = 0; i < 250; ++i)
{
if (ReceiveBit(false, 100) != IterateLFSR())
throw new ApplicationException("Receiving LFSR data failed!");
}
byte version = 0;
for (int i = 0; i < 8; ++i)
{
version >>= 1;
version += (byte)(ReceiveBit(false, 100) ? 128 : 0);
}
TransmitEncodedLong(command);
return version;
}
#endregion
#region Low level protocol
private bool ReceiveBit(bool echoOn, int msecs)
{
unchecked
{
DateTime entered = System.DateTime.Now;
while (!echoOn | DateTime.Now - entered < TimeSpan.FromMilliseconds(msecs))
{
if (echoOn)
{
m_SerialPort.Write(new byte[] { 0xF9 }, 0, 1);
Thread.Sleep(25);
}
if (!echoOn || m_SerialPort.BytesToRead > 0)
{
byte receivedBit = (byte)(m_SerialPort.ReadByte() - 0xFE);
if (receivedBit > 1)
{
throw new ApplicationException("Receiving bit failed!");
}
return receivedBit == 1;
}
}
throw new TimeoutException("Receiving bit in echo mode timed out!");
}
}
private void TransmitEncodedLong(uint data)
{
byte[] buffer = new byte[11];
for (int i = 0; i < 11; ++i)
{
buffer[i] = (byte)(0x92 | ((byte)(i == 10 ? 255 : 0) & 0x60) | (data & 1) | (data & 2) << 2 | (data & 4) << 4);
data >>= 3;
}
m_SerialPort.Write(buffer, 0, 11);
}
#endregion
#region Linear Feedback Shift Register
private byte _LFSR = 80;
private void ResetLFSR()
{
_LFSR = 80;
}
private bool IterateLFSR()
{
unchecked
{
bool result = (_LFSR & 1) == 1;
_LFSR = (byte)((_LFSR << 1) | (_LFSR >> 7 ^ _LFSR >> 5 ^ _LFSR >> 4 ^ _LFSR >> 1) & 1);
return result;
}
}
#endregion
}
}
|
|
|
|
|
This is a bit too much to answer in a forum like this, but the answers to all your questions can be found quite easily by reading a C# reference. Get hold of a book or online tutorial and work your way through it, or take a look here[^].
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Thank you for the reply.
Being self taught, I have holes in my knowledge. Most of the methods, make sense on a literal reading of them, but I was hoping to hear why this might be necessary to interact with the microchip. I have also not ever seen the >> or ? and : used in c sharp, and that was also throwing me such as in this part
version >>= 1;
version += (byte)(ReceiveBit(false, 100) ? 128 : 0);
I will check out that link, I can always learn more.
|
|
|
|
|
turbosupramk3 wrote: Being self taught, I have holes in my knowledge
That's fine, but you need to fill those gaps in the right way.
turbosupramk3 wrote: I have also not ever seen the >> or ? and : used in c sharp
They are part of the standard set of operators in the language, which you should really learn before trying to write or debug (someone else's) programs.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
>>[^]
?:[^]
Btw, I don't like that code (the whole thing, not these two lines in particular, but they're guilty as well). It keeps converting integers to bools and then back to integers again. Why not just stick with integers? That would clean up a lot of the noise.
|
|
|
|
|
If these bits are confusing you, then you need to go back and start with the C# basics - there is nothing there I would not expect anyone halfway trained in C# to have problems with.
private const uint COMMAND_LOAD_RAM_AND_RUN = 1;
private const uint COMMAND_LOAD_EEPROM_AND_RUN = 3; Just declares two constant values so that you can use names in your code instead of relying on magic numbers.
lfsrData[0] = 0xF9;
for (int i = 1; i < 251; ++i)
lfsrData[i] = (byte)(0xFE | (IterateLFSR() ? 1 : 0)); Presets a buffer of 251 bytes with a specific sequence: the first byte will be 0xF9, all teh others will be 0xFE or 0xFF, depending on how the IterateLFSR method works. Which is dependant on the value of _LFSR, which depends on when you last called ResetLFSR - and I'm not going to try to follow your code to work that out!
byte[] buffer = new byte[258];
for (int i = 0; i < 258; ++i)
buffer[i] = 0xF9;
Just declares a byte array and fills it with a simple hex value.
for (int i = 0; i < 250; ++i)
{
if (ReceiveBit(false, 100) != IterateLFSR())
throw new ApplicationException("Receiving LFSR data failed!");
}
byte version = 0;
for (int i = 0; i < 8; ++i)
{
version >>= 1;
version += (byte)(ReceiveBit(false, 100) ? 128 : 0);
} Just seems to be a way of clocking in eight bit data on a serial line, with a varying prefix bit that I can't be bothered to work out. Followed by chucking the data you just received away.
To be honest, it's a bit rubbish. Someone has tried to use mnemonics for special values, and then ignored that and hardwired magic numbers such as 0xF9 in anyway, without trying to explain why.
Go back where you got it, and see if there is any design documentation which might explain why they are doing this!
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Thank you for the reply.
Being self taught, I have holes in my knowledge. Most of the methods, make sense on a literal reading of them, but I was hoping to hear why this might be necessary to interact with the microchip. I have also not ever seen the >> or ? and : used in c sharp, and that was also throwing me such as in this part
version >>= 1;
version += (byte)(ReceiveBit(false, 100) ? 128 : 0);
Unfortunately there was no documentation, I did message the person, but they have not been active recently and I did not receive a reply.
|
|
|
|
|
>> and ? are standard bits of C#: you can find out about them quite easily if you google for C# Operators, which will take you to MSDN[^] - a good place to start if there is any C# or .NET thing you don't understand.
">>" is a SHIFT operator. It moves a value one bit to the right, effectively dividing it by two. So 20 hex would become 10 hex, 10 hex would become 08 hex, and so forth. The bottom bit is discarded.
"?" is a short hand for an if...then...else... with a value returned. The condition is to the left of the "?", the true value is to the right, and the false value is to the right of the ":". So:
version += (byte)(ReceiveBit(false, 100) ? 128 : 0); could be written as:
if (ReceiveBit(false, 100))
{
version += (byte) 128;
}
else
{
version += (byte) 0;
}
[edit]Typos: I hate this keyboard - OriginalGriff[/edit]
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Great!
I found this link also before I saw your reply. I did not know that c sharp had built in bit operators like the microchip does.
This should be enough to make me successful, thank you!
http://www.functionx.com/csharp/Lesson05.htm[^]
|
|
|
|
|
You're welcome!
(But you should consider a course or a book on C# and .NET anyway - you will have missed a lot by self learning)
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Some people self-learn C# by reading the C# spec and following Eric Lipperts blog - obviously not the OP though.
|
|
|
|
|
Self learning from language spec is one thing (and a PITA it can be, I've done it often enough) but you just miss so many things which are implicit in a language, rather than part of the grammar. If you follow a structured program, you get introduced to the reasons behind what you are learning as well as the language elements. Unless you follow one of those "Learn XXX in 7 days!!!" books, in which case the main lesson is "Don't waste your money on books with multiple exclamation marks".
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Many introduction books contain severe errors though ("value types go on the stack" and such), do you know one that doesn't?
|
|
|
|
|
No - but I suspect they say that as a simplification (lies-to-children[^]) that will do because it is (sort of) correct and (sort of) explains why there is a distinction between value and reference types without potentially confusing people with more than they are ready for at that stage. Hopefully, they later correct that - but I suspect that either most authors forget to do that bit, or most readers don't get that far...
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
I would like to maybe even take a class. This was my first OO language (and really my first real language period), which is why I couldn't read a spec and learn a language. Maybe that'd be possible if this was my 3rd or 4th language that I was learning?
I found out some information by grouping together a bunch of posted information that shows the code is instantiating a protocol, with linear feedback shift register verification.
I'm still trying to get used to this short hand of if/then/else and I can't seem to get the long hand version translation of the first code block? The second code block is my 4th attempt, I'm just not sure how they are setting lfsrData array value to 0xFE (254) or if true 1 else 0. That logic is escaping me?
lfsrData[i] = (byte)(0xFE | (IterateLFSR() ? 1 : 0));
lfsrData[i] = (((byte)(0xFE)) || (
if (IterateLFSR())
{
lfsrData[i] = 1;
}
else
{
lfsrData[i] = 0;
}
))
Quote: First the Propeller Tool seems to open the serial port in 115200-8-N-1 mode. After toggling the DTR line to reset the Propeller, it transmits 0xF9 followed by a sequence of 0xFEs and 0xFFs. This sequence is followed by a large block of 0xF9s. I'm sure all this corresponds to the 250 iterations of the LFSR but I don't see how. When I tried to duplicate the LFSR in Python I couldn't get anything even remotely close. Then the Propeller responds with a similar (but different) block of 0xFEs and 0xFFs. Again I'm
sure this corresponds to the LFSR somehow. The Propeller then sends 2 bytes 0xFE 0xFE which I believe is the version number?
After this the Propeller Tools sends a command byte (RAM or EEPROM) followed immediately by block of data which corresponds to the binary image of the program. I haven't spent alot of time analyzing the format of the this data, but it doesn't seem to directly match up with the bytecodes of the program. Something weird is going on here and I think has to do with how the Propeller is "reading" the serial data.
Finally the Propeller Tool sends 0xF9 periodically (every 50msec seems to work) until the Propeller responds with 0xFE. This acknowledgment protocol can be repeated twice more if the command code was programming to the EEPROM.
The $F9 (249) is the 'calibration pulse'. The start pulse is a short (one) pulse while the two zero bits in the $F9 (249) is a long (zero) pulse. After that, the least significant bit of the LFSR is sent by the Tool, one per character, for 250 bits, with the $FF (255) being a short (one) pulse and the $FE (254) being a long (zero) pulse. Then the Propeller sends back the next 250 bits in the LFSR, also one bit per byte by echoing the $F9 (249) characters, changing them to $F8 (248) to indicate that they were processed properly.
After all the LFSR bits, the Tool and the Propeller shift into a 3 bits per byte mode with each bit cell being 3 bits and the start bit counting as one bit of the first cell (which is always zero). As you might expect, a one is a short (1 zero pulse time) and a zero is a long (2 zero pulse times) and the Propeller echos the data. There's a mix of 8 bit and 32 bit sequences, etc
|
|
|
|
|