|
Hi,
check this..[^]
may it helps you
Thanks,
Sun Rays
To get something you must have to try once.
My Articles
|
|
|
|
|
This is pretty close to being totally unrelated to his question
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.
|
|
|
|
|
He meant well.
Anyway, my grateful thanks for all the replies.
|
|
|
|
|
ROTFL
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
As an addendum to what CG was saying you could also save them to MemoryStreams and hash them. From there, it's a simple matter of comparing the byte arrays. I wouldn't personally use this method, I'm just including it for completeness' sake. I would do as CG said, and try to use the PictureBox's Tag property
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
Hi,
I'm trying to encrypt a string in c# that would be decrypted with perl. The problem is that in the perl script there is not IV specified so, when I encrypt the result is not readable be the perl decryptor.
Is there any workaround to know who perl auto generate the IV (I suppose that's what it does) ?
C# Code to Encrypt :
private string strCryptoMessage(string strOrig, string strKey)
{
System.Security.Cryptography.RijndaelManaged rj = new System.Security.Cryptography.RijndaelManaged();
rj.Mode = System.Security.Cryptography.CipherMode.CBC;
rj.Key = Encoding.UTF8.GetBytes(strKey);
byte[] bOrig = Encoding.UTF8.GetBytes(strOrig);
System.IO.MemoryStream ms = new System.IO.MemoryStream();
System.Security.Cryptography.CryptoStream cs = new System.Security.Cryptography.CryptoStream(ms, rj.CreateEncryptor(), System.Security.Cryptography.CryptoStreamMode.Write);
cs.Write(bOrig, 0, bOrig.Length);
cs.FlushFinalBlock();
string bResult = Convert.ToBase64String(ms.ToArray());
ms.Flush();
return bResult;
}
Perl Code To Encrypt :
#!/opt/local/bin/perl -w
use IO::Socket;
use IO::Handle;
use MIME::Base64;
use Data::Dumper;
use POSIX;
use Getopt::Long;
use strict;
require Crypt::CBC;
my $msg = "MESSAGE_TO_ENCRYPT";
my $enc_key = "SAME_AS_strKey";
my $enc_alg = "Rijndael";
my $cipher = Crypt::CBC->new({
'key' => $enc_key,
'cipher' => $enc_alg,
});
my $encrypted_msg = $cipher->encrypt($msg);
print "$msg\n";
my $encoded_msg = encode_base64($encrypted_msg, '');
print "$encoded_msg\n";
Both should generate the same result, but I think that the perl Crypt::CBC generate the IV code using the key in some way.
|
|
|
|
|
I want to do a tile by myself, I can see that the result image is very blurry, and the positions of each piece are not correct(overlapped partly), why?
Bitmap bitmap = new Bitmap(2000, 2000, PixelFormat.Format32bppArgb);<br />
using (Graphics graphic = Graphics.FromImage(bitmap))<br />
{<br />
Bitmap image = (Bitmap)Bitmap.FromFile(@"background.bmp");<br />
for (int j = 0; j < 15; j++)<br />
{<br />
graphic.DrawImageUnscaled(image, (j % 4) * image.Width, (j / 4) * image.Height, image.Width, image.Height);<br />
}<br />
}<br />
bitmap.Save(@"a.png", ImageFormat.Png);<br />
Regards,
unruledboy_at_gmail_dot_com
http://www.xnlab.com
|
|
|
|
|
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.
|
|
|
|
|