|
I am using DrawBezier to display a user defined bezier curve. I need the x,y values along the curve (not just points used to create the curve but each point along the curve). I have the mathematical formula but if the graphics is generating the points to paint is there a way to access the x,y locations of points it is painting? Thanks
|
|
|
|
|
Why don't you make your own method for that. May be the following code might help. If my memory serves me correctly, I've copied this code from a book by Charles Petzold on Windows forms programming.
<br />
<br />
public void DrawBezier(Graphics grfx, Pen pen, Point p0, Point p1, Point p2, Point p3)<br />
{<br />
Point[] curve = new Point[100];<br />
<br />
for (int i = 0; i < curve.Length; i++)<br />
{<br />
float u = (float) i / (curve.Length - 1);<br />
<br />
float y=((1-u)*(1-u)*(1-u)* p0.Y) + <br />
(3*u* (1-u)*(1-u)* p1.Y) + <br />
(3*u*u* (1-u)* p2.Y) + <br />
(u*u*u* p3.Y); <br />
<br />
float x=((1-u)*(1-u)*(1-u)* p0.X) + <br />
(3*u* (1-u)*(1-u)* p1.X) + <br />
(3*u*u* (1-u)* p2.X) + <br />
(u*u*u * p3.X);<br />
<br />
<br />
curve[i] = new Point((int) Math.Round(x), (int) Math.Round(y));<br />
}<br />
grfx.DrawLines(pen, curve);<br />
<br />
}<br />
|
|
|
|
|
My question is pretty easy, but i couldn't find any solution. how can i press a key\mouse button? as in...when my program runs it'll type "hello"..or click the left mouse button...any ideas?
|
|
|
|
|
Hello,
sharpiesharpie wrote: My question is pretty easy,
I would like to help, but I don't understand the question.
Maybe if you don't use ".." and finish the sentence I (or somebody else) can help.
All the best,
Martin
|
|
|
|
|
just press a key, make the program click the mouse, press a key etc.
|
|
|
|
|
Hello,
Again I'm not sure if I understand your question correct.
But I'm trying to answer.
If it's limited to a special control, you could use the KeyPress event of that control like:
if (e.KeyChar == yourcharacter)
{
//If you whant to click a button, you could use the PerformClick method.
yourbutton.PerformClick();
}
Hope it helps!
All the best,
Martin
|
|
|
|
|
:\
i don't mean clicking a button in my form...i mean clicking the mouse\keys...the physical ones...like the auto clickers for games like MUOnline, or VistaTask...just click a keyboard key\mouse.
|
|
|
|
|
SendKeys.Send()?
You want to click the physical keys though? Maybe make something out of lego?
Russell
|
|
|
|
|
err...what's SendKeys? and no..not lego >_>
and what about clicking the mouse?
|
|
|
|
|
^
Hopefully explains something about SendKeys.
I'm not sure if it will send key presses to a different app though. I assume you are trying to write an app to autoclick into another process. You want to be a bit careful doing this as some games will ban you for such behaviour.
Russ
|
|
|
|
|
Hello,
Mabe this freewaretool helsp you.
It's not C#.
It can be programend in a kind of script language.
Can simulate mouseclicks and keypress, and much more!
All the best,
Martin
|
|
|
|
|
how can i get the data that i am entering in a text box and display it as a subitem in a list control?
|
|
|
|
|
err..ListBox1.Items.Add(textBox1.Text);
|
|
|
|
|
thank you. can you also tell me how to make it enter for a particular field like row=0, column=3.
|
|
|
|
|
Hello everybody,
Basically the problem is that the UTF8Encoder is not able to get this char '²'.
Is this a known fact, or am I doing something wrong?
This is what I do in a test routine:
using (FileStream fs = File.OpenRead(filename))
{
byte[] b = new byte[10000];
UTF8Encoding temp = new UTF8Encoding(false,true);
int l=0;
FileStream fw= File.Open("copy.txt",System.IO.FileMode.Create);
while ((l = fs.Read(b,0,b.Length)) > 0)
{
string s= temp.GetString(b, 0, l);
Console.WriteLine(s);
}
fw.Close();
}
Thanks for your time and help
All the best,
Martin
|
|
|
|
|
Can your console output the character even if it is read correctly? If your console code page does not support it your program won't display it.
UTF8 is multibyte, so your read operation might split the byte stream in the middle of a character. Create a StreamReader with Encoding.UTF8 to avoid having to deal with this manually.
Edit: Are you sure your file is actually UTF-8 encoded?
|
|
|
|
|
Hello,
First, thanks for youre time!
Actually I started by using a StreamReader, with the result that the complete line was there but without the '²' character.
Any other suggestions?
All the best,
Martin
|
|
|
|
|
First of all, check the source file (in my experience the most likely error). The character should be encoded with the byte sequence C2 B2.
As a quick hack to test it rename the input file so it has a bin extension and load it in Visual Studio - you should now see the byte content in a hex format.
|
|
|
|
|
Hmm,
I did the test with following result "B2" and no character is shown.
When I open it with the "TotalComander" Bin style, it's also "B2" but the '²' is shown.
So uses UTF8 really multibyte, or only for special characters?
Thanks again for your time and patiance.
All the best,
Martin
|
|
|
|
|
UTF-8 use more than one byte for anything over Unicode character 127. Some refers to these as special, others refer to English characters as special.
|
|
|
|
|
|
Hello,
It really looks like the file isn't really UTF8. (It's a XML file with a discribtion that says its UTF8 formated )
But I don't know wich encode I have to use.
Is there a way to find this out?
All the best,
Martin
|
|
|
|
|
Yes, this is seen before - it's an invalid XML file, a lot of programs spit those out.
A fair guess is the local ANSI codepage whereever the file was saved. For most Western European languages, this would be the Windows codepage 1252 (or use Encoding.Default if the encoding is the same on the machine reading and writing the file).
|
|
|
|
|
Bulls Eye
Thanks very much!
I'm now using the GetEncoder method, and "Windows-1252" as the parameter.
All the best,
Martin
|
|
|
|
|
I NEED TO USE the MaskedTextBox but i have 4 problem with it
1- my format 2ill be it that style(number1,number2)
first i don't know how may digits will be in number1
number2 will have only 3digit
i don't know how to make number1 with no fixed digits
2-i need the style that he make in textbox like(_____,____)not to appear because my client know how they will write the numbers but i used that control for validation
3- if i didn't right any digit in numer1 it add automitc 0
4- in number2 if i write 33 it appear like that ,330
plz answer me tody i wantto finish that task today
ma_refay
|
|
|
|