|
Correcting Univotes now. Luckily my jedi powers are OK, so you'll gain more then you lost
|
|
|
|
|
Now look[^] what you've done.
The best things in life are not things.
|
|
|
|
|
"/U0061" gives the string /U0061; I think you mean "\U0061".
The best things in life are not things.
|
|
|
|
|
yea, sorry about that mistake.
|
|
|
|
|
if what you have is a six-character string containing a real backslash, a U, and four hex digits, then you could turn that into a single character like so, however this situation is rare, it would typically occur only if you plan on writing your own C# compiler!
string s=@"\U0061";
int uni;
if (s==null || s.Length!=6 || s[0]!='\\' || s[1]!='U' ||
!int.TryParse(s.Substring(2, 4), NumberStyles.HexNumber, null, out uni))
throw new Exception("Bad unicode string in: "+s);
char c=(char)uni;
log("uni="+uni.ToString("X4"));
log("c="+c);
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.
modified on Wednesday, May 11, 2011 1:23 PM
|
|
|
|
|
Is there a real problem here?
As noted you have a simple character one which will be in string if the string is created correctly.
However you CANNOT use a single C# data type 'char', to represent the entire supported character set range.
So if that is your goal you will fail.
Read up on "surrogate pairs" to find out why.
|
|
|
|
|
Hi experts,
I'm creating a custom control DerivedPanel . It's derived from System.Windows.Forms.Panel . There are no other controls on DerivedPanel . Instead it draws custom items called Devices .
I'd like to resemble the selection behaviour of Windows XP's desktop. That includes holding the CTRL button down while dragging a selection rectangle. That should cause each Device within the rectangle to toggle its selection state.
For the CTRL key, I used
protected override void OnKeyDown(KeyEventArgs e)
{
Console.WriteLine("OnKeyDown: " + e.KeyValue.ToString());
base.OnKeyDown(e);
if (e.Control)
{
Console.WriteLine("Setting XOR devices...");
_selectionXoringDevices.AddRange(_project.Devices.SelectedDevices);
}
else
Console.WriteLine("Lazying...");
}
Now the problem is that as long as I'm holding down the CTRL key, this event keeps firing over and over again.
I need it to fire once on keypress.
Funny enough, the corresponding OnKeyUp() works just that way.
How can I get a method to execute once on pressing down the CTRL key?
Edit: I need this to work in .NET 2.0.
Ciao,
luker
modified on Thursday, May 12, 2011 2:06 AM
|
|
|
|
|
You might put your current handler code inside a test:
if (!KeyEventArgs.IsRepeat) {
}
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.
|
|
|
|
|
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.
|
|
|
|
|