|
i am making a program wherein i have a replica of a keyboard. The user will tap any key on the keyboard on what he would like to type. He can select the input language to English,Japanese Hiragana and Japanese Katakana. I'm using Sendkey.Sendwait to send the character tapped by the user to the textbox. My problem is when I select Hiragana or Katakana for the input language and type, sometimes the characters that I type will disappear. It will appear when the user will tap again a key to the keyboard. Please help me...
below is a snippet of my code...this will just display the alphabets...when the letter is tap...
if (m_LastStr!=null && m_LastStr.EndsWith(" ")) // added for the correction asked by anand
{
SendKeys.SendWait(m_LastStr + "\n");
SendKeys.Flush();
m_LastStr = null;
}
if (((Button)sender).Text[0] > 'A' && ((Button)sender).Text[0] < 'Z') // to handle shift effect
{
m_LastStr = m_LastStr + ((Button)sender).Text.ToLower();
SendKeys.SendWait(m_LastStr);
}
else
{
m_LastStr = m_LastStr + ((Button)sender).Text;
SendKeys.SendWait(m_LastStr);
}
SendKeys.Flush();
|
|
|
|
|
How to generate XML report using SQL Server Reporting Services?
|
|
|
|
|
|
|
I am working with Digital Elevation Models, and some of these are very large and very slow to access.
The files currently are in text format 10,000 rows and 8000 columns , and I was considering that as all items the file contains are positive numbers (ranging from 0 being sealevel to 4000 being highest peak) there must be a much better format to store these for file size and access speed.
What would you suggest as the best file format for this -two bytes for each number, or singles, or doubles or....? The key thing is fast access to the array of data in the file.
Thanks for any suggestions.
|
|
|
|
|
Hi,
a binary file will provide access much much faster than anything text-oriented.
use BinaryWriter/BinaryReader for this.
Warnings with binary files:
- you are responsible for consistent file contents; from the outside, it looks like just a collection of bytes, there is no way to recognize its structure;
- portability is limited to systems that have the exact same data representation; e.g. x86 stores multibyte values in "little-endian" mode (least sighificant byte first), other systems may use
"big-endian" hence not correctly interpret the same file.
Luc Pattyn [Forum Guidelines] [My Articles]
I use ListBoxes for line-oriented text, and PictureBoxes for pictures, not drawings.
modified on Friday, June 10, 2011 12:27 PM
|
|
|
|
|
Binary, as Luc said. And you should probably use short (Int16) values.
Also, can you read and write a group of them at a time?
|
|
|
|
|
For the simplest code you could use two bytes for each value:
value = data[0] + data[1] * 256;
You only need 12 bits to store each value (0 to 4095), so for the smallest file size you could pack two values in three bytes:
Bit usage:
11111111 11112222 22222222
pack:
data[0] = (byte)value1;<br />
data[1] = (byte)(((value1 >> 8) << 4) + (value2 & 15));<br />
data[2] = (byte)(value2 >> 4);
unpack:
value1 = data[0] + ((data[1] >> 4) << 8);<br />
value2 = (data[1] & 15) + (data[2] << 4);
Despite everything, the person most likely to be fooling you next is yourself.
modified on Wednesday, January 14, 2009 12:34 AM
|
|
|
|
|
As people have mentioned, binary packed 16 bits per datapoint. Keep in mind your raw data is around 150MB.
You could have a fiddle with the Bitmap classes if you are uncomfortable with packing data yourself - treating them as a heightmap. May give performance benefits if GDI doesnt have a problem with the image size.
|
|
|
|
|
Thanks all for the suggestions, the bitmap idea could be very helpful as it would maintain the structure of the file.
I don't know if the code to get a pixel value from a bitmap is efficient. As the file only has to be created once write speed is not relevent, but read time critical.
|
|
|
|
|
Reanalyse wrote: Smallest and fastest way
Usually the two requirements go in the opposite direction.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi all,
I am trying to use an ActiveX object in my c# application. The ActiveX object is installed in my pc and works properly in my c++ application. but when i tried to drag and drop the ocx from the toolbox to a winform in my c# application, an error poped up and said the ocx wasn't registered properly. so i tried to use reflection for dynamically innovating it't members and properties.
firstly, i created a class inherited from AxHost.
The type of ocx has been created as follow:
ocxType = Type.GetTypeFromCLSID(new Guid("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxxx")); // guid of the ocx object registered in my pc
then in order to use the methods of this ocx, i used Type.Invokemember to do the job.
ocxType.InvokeMember("MethodName", BindingFlags.InvokeMethod, null, this.GetOcx(), null); // "MethodName" is coming from the description documtation of the ocx object
I tested the program and it executed successfully.
However, when i tried to invoke the properties, unknown name exception was thrown all the time. but what confused me the most is that invoking the event in this way seemed not working at all.
so here are my questions:
what is the proper way to use the Ocx object in C# application?
Are there any disadvantages of invoking members of ocx in this way?
How can I bind all the information including event?
Thank you soo much for all the help,
angral
modified on Tuesday, January 13, 2009 8:59 PM
|
|
|
|
|
I am not at all sure that this will cure your problems, but a long time ago I had troubles using an ActiveX object. If my memory serves I used the VS commandline tool 'aximp'.
While you are waiting for someone who really knows what to do, you might look up the help for this tool.
Sorry I couldn't be more help.
Henry Minute
If you open a can of worms, any viable solution *MUST* involve a larger can.
|
|
|
|
|
Thanks Henry,
that AXIMP.exe is a very handy tool.
I will experiment it right away.
Cheers
angral
|
|
|
|
|
Is there a way to insert a video\animation into a c# application that is officially supported by the .net framework (meaning I won't be dependent on a third-party component)?
|
|
|
|
|
|
Hi All,
Im currently studying the asp.net tutorials for Data access . Ie datasets, datatables and SQL stuff as per the following link.
http://www.asp.net/learn/data-access/tutorial-01-cs.aspx[^]
However I find that much of the tutorials centre on using the help wizard to do things for you rather than being able to hard code it yourself.
Does someone know of any other sites which enables you to learn the above by hard coding rather than relying on the wizard. Thanks
Best Regards
modified on Tuesday, January 13, 2009 7:54 PM
|
|
|
|
|
Dig further; there are TONS of places, including here, that show you how to hard code this stuff.
"Well, we're getting "F"'d at work. WPF, WCF, and WWF... WTF?" --John Simmons
|
|
|
|
|
Hi.
In my app I have a ListView (in Detail view) with owner drawn items/subitems. It works fine except when the user double clicks the vertical line between the column headers to resize the column. The column width becomes all wrong. So I need some way to give autoresize the width of the subitems, but I haven't found any. The only solution I have thought of is to catch a double click on the headers and handle the resize myself, but since the double click event is not sent for column clicks this solution will be messy. So, does anyone know a less ugly solution to this problem?
modified on Wednesday, January 14, 2009 3:28 PM
|
|
|
|
|
Hello
I new to Programming so please bare with me
I am trying to write a Theatre Booking system in C# but I hit a slight problem.
The Problem is that the seating argument that is used in the theatre has Row A-H with 15 seats and J-P with 18 seats. On The form there is a separate Box for row letter and a separate box seat number When the Operator selects a seat location eg (A5) I want to be able to run a check on it to see whether it is valid. For example seat A5 would return no value because it is a possible combination as for A17 I want it to return a value “Seat Not Possible”. How do I go about this?
I thought of using a statement like [ “If (TB1 <= 7 & TB2 < = 15) Return Message “Seat Choice Valid” else Return Message “Invalid Choice of seats” // “If (TB1 >= 7 & TB2 <= 18 Return Message “Seat Choice Valid” else Return Message “Invalid Choice of seats” ]. Would this work ?
Problem Here is I than need to assign all the row letters to number for example A=1, B=2, C=3 ect How would I do this, could I use an array to assign Values or can I use multiple If statements. I thought about using an If statement similar too [ “IF (TB1 = A) do A = 1;” // “else If (TB1 = B) do B = 2” // else “IF (TB1 = C) do C = 3;” // “else If (TB1 = D) do D = 4” ect ]. Would this work ?
I would appreciate any help on this matter as I have come to a dead end.
|
|
|
|
|
tswright1041 wrote: [ “IF (TB1 = A) do A = 1;” // “else If (TB1 = B) do B = 2” // else “IF (TB1 = C) do C = 3;” // “else If (TB1 = D) do D = 4” ect ].
I'm going to say no because that would be an assignment operator not a comparator operator, use == this isn't VB
|
|
|
|
|
I think the ideal solution here is to not give them the ability to choose an invalid seat combination in the first place. Something like a dropdown that has the Box Rows and a dynamic dropdown for the Box Seats that only populates with valid seat numbers.
|
|
|
|
|
Or have a Dictionary<char,Hashset<int>>
if ( dic [ row ].Contains [ number ] ) ...
|
|
|
|
|
Technically speaking, what your asking about is an algorithm. If you think about it purely analytically, you basically have these rules (I assume, I could have interperated your question incorrectly):
Available Rows: A - P
Available Seats: 1 - 18
Rule: Row between A and H, Seat geater than 15 = invalid
Rule: One assignment per Row/Seat combination
If your creating a booking system, the ultimate result of a booking is that you track which row/seat is assigned somewhere (in my example, a dictionary mapping a key(the row) to a list of ints (the seats):
class TheaterBooking
{
const char MAX_ROW = 'P';
const int MAX_SEAT = 18;
IDictionary<char,IList<int>> m_bookedSeats;
public TheaterBooking()
{
m_bookedSeats = new Dictionary<char,IList<int>>();
}
public bool IsValidNewBooking(char row, int seat)
{
if (row > MAX_ROW) throw new ArgumentException("Invalid row specified.", row);
if (seat > MAX_SEAT) throw new ArgumentException("Invalid seat number specified.", seat);
if (!IsValidSeat(row, seat))
return false;
if (IsAlreadyBooked(row, seat))
return false;
return true;
}
private bool IsValidSeat(char row, int seat)
{
if (row <= 'H' && seat > 15)
return false;
return true;
}
private bool IsAlreadyBooked(char row, int seat)
{
IList<int> filledSeats;
if (m_bookedSeats.TryGetValue(row, out filledSeats))
{
if (filledSeats.Contains(seat))
return false;
}
return true;
}
}
modified on Tuesday, January 13, 2009 8:44 PM
|
|
|
|
|
I added the code that you kindly sent to me to my project. But How dose it no witch seats are booked. I guess there must be some code like DictionaryName.Add (Var1,Var2 ); But Some how you need to declare the Keys and Ints. Were Var 1 is the key and Var 2 is Ints. Can you help?
|
|
|
|