|
The images overlap because your code causes them to. To tile properly, just do j* width and j * height. You can also create a texturebrush which uses the bitmap and tiles, and then just fill the rectangle with that brush
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
hi, if I only do j*width and j*height, won't it only be tiling from top left to bottom right(diagonally)?
and, it seems that the blurry problem only goes with some bmp files, strange
by the way, I actually want to title all the pictures(not only one) in one picture, something like mosaic, so, texture brush maybe not suitable.
Regards,
unruledboy_at_gmail_dot_com
http://www.xnlab.com
|
|
|
|
|
Hello there. I'm trying to detect which character is produced whenever the user presses a key. For this, I'm using the ToUnicodeEx function, which translates the specified virtual-key code and keyboard state to the corresponding Unicode character, inside a keyboard system wide hook. However, every time the user presses dead keys, such as the ones producing '¨', '~' or '´', strange things happen. Here is sample code of the first version:
private static int KeyboardHookProc(int nCode, Int32 wParam, IntPtr lParam)
{
bool handled = false;
if (nCode >= 0)
{
KeyboardHookStruct MyKeyboardHookStruct = (KeyboardHookStruct)Marshal.PtrToStructure(lParam, typeof(KeyboardHookStruct));
if (s_KeyPress != null && wParam == WM_KEYDOWN)
{
bool isDownShift = ((GetKeyState(VK_SHIFT) & 0x80) == 0x80 ? true : false);
bool isDownCapslock = (GetKeyState(VK_CAPITAL) != 0 ? true : false);
byte[] keyState = new byte[256];
GetKeyboardState(keyState);
System.Text.StringBuilder sbString = new System.Text.StringBuilder();
IntPtr HKL = GetKeyboardLayout(0);
switch (ToUnicodeEx((uint)MyKeyboardHookStruct.VirtualKeyCode,
(uint)MyKeyboardHookStruct.ScanCode,
keyState,
sbString,
5,
(uint)MyKeyboardHookStruct.Flags,
HKL))
{
case 1:
char key = sbString.ToString()[0];
if ((isDownCapslock ^ isDownShift) && Char.IsLetter(key)) key = Char.ToUpper(key);
KeyPressEventArgs e = new KeyPressEventArgs(key);
s_KeyPress.Invoke(null, e);
handled = handled || e.Handled;
break;
}
}
}
if (handled)
return -1;
return CallNextHookEx(s_KeyboardHookHandle, nCode, wParam, lParam);
}
With this code I faced the following problem: Whenever I tried to type "á" in notepad, which requires '´' to be pressed before 'a', the result would be "´´a". Although the captured character by ToUnicodeEx was 'á', I can't admit that my application prevents the user from using characters such as 'á'.
So, I worked around this problem by avoiding ToUnicodeEx to be called whenever a dead key is pressed. This way, I can avoid the ToUnicodeEx function from messing with the keyboard state. Here is the current version code:
private static int KeyboardHookProc(int nCode, Int32 wParam, IntPtr lParam)
{
bool handled = false;
if (nCode >= 0)
{
KeyboardHookStruct MyKeyboardHookStruct = (KeyboardHookStruct)Marshal.PtrToStructure(lParam, typeof(KeyboardHookStruct));
if (s_KeyPress != null && wParam == WM_KEYDOWN)
{
bool isDownShift = ((GetKeyState(VK_SHIFT) & 0x80) == 0x80 ? true : false);
bool isDownCapslock = (GetKeyState(VK_CAPITAL) != 0 ? true : false);
byte[] keyState = new byte[256];
GetKeyboardState(keyState);
System.Text.StringBuilder sbString = new System.Text.StringBuilder();
IntPtr HKL = GetKeyboardLayout(0);
if (!IsDeadKey((uint)MyKeyboardHookStruct.VirtualKeyCode))
{
switch (ToUnicodeEx((uint)MyKeyboardHookStruct.VirtualKeyCode,
(uint)MyKeyboardHookStruct.ScanCode,
keyState,
sbString,
5,
(uint)MyKeyboardHookStruct.Flags,
HKL))
{
case 1:
char key = sbString.ToString()[0];
if ((isDownCapslock ^ isDownShift) && Char.IsLetter(key)) key = Char.ToUpper(key);
KeyPressEventArgs e = new KeyPressEventArgs(key);
s_KeyPress.Invoke(null, e);
handled = handled || e.Handled;
break;
}
}
}
}
if (handled)
return -1;
return CallNextHookEx(s_KeyboardHookHandle, nCode, wParam, lParam);
}
static bool IsDeadKey(uint key)
{
if ((MapVirtualKey(key, 2) & 2147483648) == 2147483648)
{
return true;
}
else
{
return false;
}
}
I though this solution would solve my problem, but I was wrong. The result has improved, but it's not quite what I wanted. Now, typing 'á' in notepad results in 'a'. Notice that the accent '´' is missing.
Does anyone know how to work around this issue? My current method already captures the correct character, but prevents the user from producing characters with accents or diacritics. I think the KeyboardHookProc method just need a few changes, but I can't figure them out.
Thanks in advance.
PS: I tried the solution described in the following link: http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/7c038b72-3ae3-4b9e-9e21-33c7ccea735c. However, the result is quite the same as in my current version. That code only erases the keyboard buffer, which deletes the accents, therefore not allowing the user to use them.
|
|
|
|
|
Hi am try to write an inventory software, i want to interface that software with a cash register so that i can account for sale made .i want to know how i can read data from the cash register pls help me.u can specify the cash register that i might be easy to use pls help ASAP
if(me){
throw new Exception("hello there");
}
|
|
|
|
|
What are you asking for ? Do you have a cash register ? Do you plan to buy one, based on what someone suggests here ? Do they have google where you live ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
yes am planing to buy a cash register based on what someone suggests here.
if(me){
throw new Exception("hello there");
}
|
|
|
|
|
There are too many unknowns, but today I'm in a great mood. So, I'll try not to be witty.
To begin with this project, you need to first be able to interact with the device.
Your device will have a firmware, which will support a set of escape sequences that can be passed to it (and it will interpret these as special commands). The device manual (for programmers) should have a mention of these sequences and instructions for interfacing with the firmware from your program (most of them usually show examples *only* in 'C'). After you've incorporated all such commands within your code, you have complete control over the device and off you go.
But, I see you have a little bit of studying to do about the device and the commands it supports before you can start with it.
The accounting part you mentioned about, business logic of your app, and UI, etc., is WAY OUT of the scope of this discussion.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Rajesh R Subramanian wrote: but today I'm in a great mood. So, I'll try not to be witty.
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
hi,
i know a little abt sending commands i have worked sending at commmand's mostly, and i have seen many cash registers with serial ports but i don't know if they support at commands,but what i want really is to the info of evry item sold thru that cash register.u can specify any model of cash register i want to be sure a cash register to go for before buying one thanks
if(me){
throw new Exception("hello there");
}
|
|
|
|
|
solomonope wrote: what i want really is to the info of evry item sold thru that cash register
What you realy want is the barcode info cross referenced to the stock item / price. I do not think that this is normally held at the register - a scanner talks to a PC or similar, which tells the register how much to charge. The info you are looking for would normally be part of the PC app, as it interfaces with orders, managment reports, stock control, etc. etc. etc.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
I'm finding it hard to read your post. Try and use a period, comma or some punctuation after every 800 consequent words.
If I were allowed to hazard a guess, you are wanting to log the information of all the transactions involving the cash register? If yes, where are you stuck?
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
I am developing an application in C#. The application is deployed on 3 machines. The database is at the single machine that is server. Now when i save an image from system 1, it saves to the directory of system 1. When i access the same image from system 2 it gives error. It does not show because it try to pick image from its own disk. I do not want to save the image in database as a blog. I want to store image in directory and want to access from any system where my windows application is deployed.
Any suggestion..............
Do good and have good.
|
|
|
|
|
If you read a Bitmap, then copy it to a new one, then Dispose of the original, I think you get rid of the file lock on the original file. other option - make a copy of the image when you want to read it, and delete the copies when they are closed.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Thanks for your reply. The problem is the file path. How should i read the file from network which doesnot create any rights and permission issues. I want to read the file from the system where it is stored and my exe can be on any system in the LAN.
Do good and have good.
|
|
|
|
|
Oh. OK, that's another question. Well, one way to do it, would be to have a webservice on the server, and have your application pointed to that. that would sidestep any issues with access to the file paths.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Thanks a lot. I will look for webservice now.
Do good and have good.
|
|
|
|
|
|
Here[^]
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Don't delete your question, it's rude and it makes the forums look messy
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hello,
Currently im hanging on one Problem. I wrote a class inherting from grid. Each grid has the property
children. How can i get an notification when a new children added to the grid. I need somethink like a
event which occours when the children-cout changed. I hope you understand what i mean.
Thanks in advanced
|
|
|
|
|
You posted this in the Silverlight forum. Is this a Silverlight issue or a Win Forms one?
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Hej i am writing a abstract class with a method that takes
an expression parameter to point to a field....
The field it self is not present in this base class so the the
expression needs to use the subclass so i need to have that type present in the
method definition and the current way i am doing this is..
abstract class foo<SubClass>
{
public void bar(Expression <Func<SubClass , object >> Expression);
}
As you see i need to pass in the subclass type from the subclass to the base class
witch is not ideal since i am not going to be writing the subclass
so my question is how can i use the type of the subclass without passing it as a
parameter.
Thanks for answers in advance .. Patrik
|
|
|
|
|
Hi,
I have a Network drive ("Z:\") mapped to a path say something like ("\\af.sistun.com\storage\MyFolder")which I can detect using the drive info class.
Now considering the DriveInfo class object network holds the drive info about the drive "Z:",
how can I get the full network path that lies beneath "Z:\" i.e. "\\af.sistun.com\storage\MyFolder". After having explored the properties of the DriveInfo class I tried some googling but the examples revealed some ugly MFC type code. Is there some C# way to acheve this?
Thanks for reading this.
Best Regards,
Sid
|
|
|
|
|
No, that's why people are using interop, because they have to.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hi Christian,
Thanks for your reply. Can you please help me with the use of Interop.
Which dll, which method do I need to use here.
I am bad with unmanaged code.
Best Regards,
Sid
|
|
|
|
|