|
Thank you Luc,
this seems to be exactly like what I'm looking for. Unfortunately, I'm bound to .NET 2.0 and forgot to mention that in my original question, which I edited.
Can you think of another way of getting exactly one keypress?
Ciao,
luker
|
|
|
|
|
you can construct IsRepeat yourself by remembering the last key down (both KeyValue and Time), then compare the old ones with the new ones; when the TimeSpan is less than some value (maybe set to SystemInformation.KeyboardDelay) it is likely to be an auto-repeat.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
I kind of worked around it by using a boolean to remember whether CTRL is pressed or not.
Ciao,
luker
|
|
|
|
|
This would have been my solution.
|
|
|
|
|
Hi
I need some help regarding Regex as my knowledge of it is rather poor. I have a string like the following:
"John Doe, john@bleh.com, (H) 0412623423234, (W) 1290034589345, Jane Doe, jane@bleh.com, (H) 041235423234, (W) 1290034589345"
What I need to do is to retrieve each Email address as well as each Home and Work number separately. After retrieving the separate values I would then like to store the related ones together as one comma-separated property like in the following example:
customer.Email = "john@bleh.com,jane@bleh.com";<br />
customer.HomePhone = "0412623423234,041235423234";
I already used a Regex pattern to retrieve all the email addresses in the string, but it seems to be a bit more tricky with the different phone numbers. Any advice/help?
|
|
|
|
|
You may find this solution just made for you Helpful.
string Text = "John Doe, john@bleh.com, (H) 0412623423234, (W) 1290034589345, Jane Doe, ";
Regex HomePhoneRegex = new Regex(@"\(H\)[ ]*\d{13}");
Regex WorkPhoneRegex = new Regex(@"\(W\)[ ]*\d{13}");
Regex EmailRegex = new Regex(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*");
String HomePhone = String.Empty;
String WorkPhone = String.Empty;
String Email = String.Empty;
if (HomePhoneRegex.Matches(Text).Count == 1)
{
HomePhone = HomePhoneRegex.Matches(Text)[0].Value.Replace("(H)", String.Empty).Trim();
}
if (WorkPhoneRegex.Matches(Text).Count == 1)
{
WorkPhone = WorkPhoneRegex.Matches(Text)[0].Value.Replace("(W)", String.Empty).Trim();
}
if (EmailRegex.Matches(Text).Count == 1)
{
Email = EmailRegex.Matches(Text)[0].ToString();
}
Regards,
Hiren.
-"I don't know, I don't care, and it doesn't make any difference".
|
|
|
|
|
Thanks that did help
|
|
|
|
|
You're welcome.
Glad it helped you.
Regards,
Hiren.
-"I don't know, I don't care, and it doesn't make any difference".
|
|
|
|
|
Expresso[^] is a rather nifty tool that I found. It's ideal to test you're Regex on some sample text
|
|
|
|
|
I am using this tool every time I need fun with Regex.
Regards,
Hiren.
-"I don't know, I don't care, and it doesn't make any difference".
|
|
|
|
|
We also have a RegEx forum.
|
|
|
|
|
Hello Everybody,
I have generate a problem while Set the Contrast value and Briteness of GIF Image.
problem generating while executing this line.
BitmapData bmData = gifimage.LockBits(new Rectangle(0, 0, gifimage.Width, gifimage.Height),ImageLockMode.ReadWrite,PixelFormat.Format24bppRgb);
If you can think then I Can.
|
|
|
|
|
that is totally unclear, please learn to describe the situation properly, provide details about what you want to do, show more code (and in PRE tags!), and provide detailed problem description (not just "problem generating").
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Hello Sir,
Actually i have an image which format is gif. and i want to change it's contrast so i want to try code for changing is contrast. but it generate an error.
If you can think then I Can.
|
|
|
|
|
I asked you to show more code, you didn't.
I asked you to be more explicit about errors/exceptions you are getting, you didn't.
I will disregard your questions from now on.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
The error message is given below :
SetPixel is not supported for images with indexed pixel formats.
Code is :
Image imagepreview = null ;
imagepreview = new Bitmap("C:\\giffile.gif");
BitmapData bmData = imagepreview.LockBits(new Rectangle(0, 0, imagepreview.Width, imagepreview.Height),
ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
If you can think then I Can.
modified on Thursday, May 12, 2011 12:17 AM
|
|
|
|
|
Luc asked you to put your code in <pre></pre> tags, yet still you don't bother. You have been a member here long enough to at least read the guidelines.
The best things in life are not things.
|
|
|
|
|
Your code doesn't compile but when that is fixed it works fine for me.
So what's the problem? You're not calling SetPixel so how do you get a SetPixel error?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
This is working fine with jpeg ,bmp image format but if your format is gif it is not working fine.
If you can think then I Can.
|
|
|
|
|
Like I said in my other post below...
"I just tried LockBits on a 8bppIndexed GIF and it worked fine getting the bits as 24bppRGB."
Here's the code:
Bitmap imagepreview = new Bitmap(@"D:\path\ASTRO2.GIF");
BitmapData bmData = imagepreview.LockBits(new Rectangle(0, 0, imagepreview.Width, imagepreview.Height),
ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
imagepreview.UnlockBits(bmData);
Maybe your image is a different format. Mine is 8bpp indexed.
Regardless, unless you're working with 8bpp grayscale images, you're not going to be able to apply brightness and/or contrast to the pixels as 24bpp. You'd need to manipulate the color table.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Gif images use an indexed pixel format. You just cannot try to lock bits if the pixel format you give does not match the one of the image.
|
|
|
|
|
Not true.
From the docs: "The pixel format of the temporary buffer does not have to be the same as the pixel format of this Bitmap object. "
I just tried LockBits on a 8bppIndexed GIF and it worked fine getting the bits as 24bppRGB.
Of course that's not going to work out for the processing the OP wants to do on the pixels
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Maybe you are right, I have never tried to lock bits using a different pixel format than the one defined on the bitmap. Also on the docs you can find this:
"passing the incorrect pixel format for a bitmap will throw an System.ArgumentException", here is the page[^].
Mark Salsbery wrote: Of course that's not going to work out for the processing the OP wants to do on
the pixels
Agree... Actually, it would be good to know what he wants to do.
|
|
|
|
|
I have a desktop application where user can enter a virtual directory path (like http://localhost/MySite, or http://MyMachine/MySite). The path will always be local (both virtual and physical directories located on that machine itself). I should then open "MySite" in a browser, but before that I need to fetch some settings from its web.config file. For that I should know the physical location of web.config file (which is the root of "MySite") so that I can open it.
So the question is: how do I get the physical location of "MySite"? Or is there any other approach to what I want to achieve? Please remember, I have a Winform application which has nothing to do with the site "MySite", it just gets its URL through an editbox.
I am new to .Net, so please forgive any stupidity.
It's better to know some of the questions than all of the answers.
Pravin.
|
|
|
|
|
I don't think you can, and this is why: your local web server somehow knows where the root of the local web is, it is like an application setting to it. Example: I am using XAMPP (=Apache) to serve a local PHP-based web site, it holds its root location deep inside a configuration file called "httpd.conf"; I am also using another web server serving an ASP.NET-based web site, it uses a different web root, stored in a different way. How could an application external to all these web servers know where to look for your web root(s)?
Maybe this would work for you: organize an application setting "webroot" for your WinForm, initially "webroot" is empty. Have your app obtain its "webroot" from its setting, when getting a value, just use it; when getting no value, ask the user to locate the web root, and update the setting. That is harassing the user only once (and causing a major problem when you decide to move the web root, unless you also provide a button "Update Web Root Location" which basically empties "webroot".
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|