|
Your dog wants steak wrote:
any help with the algorithm which helps me determine the vertices would be greatly appreciated.
Surely you were given the mathematics behind this in your class? If so then it should be fairly easy to translate that into code. Is there any particular part of the translation you are having trouble with?
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
|
|
|
|
|
Nope no help with the math part in class, Im stuck with a math teacher in computer aided desing class who thinks we should learn to program in c# little applets that dont do squat. In this case he wants us to program a little program that calculates the vertices of a n sided polygon given the radius and the center. Big big problem even more because we learned to program on c++, only two clases and he thinks this is "easy". Well if you know of some place else where i could find help with my little math project... greatly appreciated
|
|
|
|
|
Okay, my high school maths is a bit shakey these days but I'll give it a go.
The method that draws polygons takes an array of Point objects as each of the points. So for n vertices you need n points (although strictly speaking the first and last point are the same windows will draw the final vertex back to the starting point for you)
A complete rotation is 2*Math.PI. So each step will be:
rotationStep = (2*Math.PI)/numVertices
start the currentRotation at 0.0
for each point the
x = centreX + (sin(currentRotation)*radius)<br />
y = centreY + (cos(currentRotation)*radius)
You should now have a Point array which you can pass to the System.Drawing.Graphics.DrawPolygon() method.
Hopefully this maths should be enough to get you going.
Good luck with your class.
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
|
|
|
|
|
me thinks u mixed cos and sin:
Colin Angus Mackay wrote:
x = centreX + (sin(currentRotation)*radius)<br />
y = centreY + (cos(currentRotation)*radius)
should be:
x = centreX + (cos(currentRotation)*radius)<br />
y = centreY + (sin(currentRotation)*radius)<br />
there are no facts, only interpretations
|
|
|
|
|
But like I said "my high school maths is a bit shakey these days", so, at least I did warn that the answer might not be completely valid.
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
|
|
|
|
|
don't get angry, high school sucks anyway. and it doesn't matter for his polygon i think, but a math teacher might get annoyed
there are no facts, only interpretations
|
|
|
|
|
yoaz wrote:
don't get angry
I didn't.
yoaz wrote:
it doesn't matter for his polygon i think
Because it is circular, rather than ellipsoidal I think that's also correct.
yoaz wrote:
but a math teacher might get annoyed
Quite probably.
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
|
|
|
|
|
I'm having problems enlarging images using the Graphics object. The quality of the enlarged images is bad. I get the best results by setting the interpolation mode to nearest neighbor and pixel offset mode to high quality. Even then, the image is grainy. Here's an example:
protected override void OnPaint(PaintEventArgs e)
{
if(this.image != null)
{
RectangleF source = new RectangleF(0f,0f,0f,0f)
RectangleF dest = new RectangleF(0f,0f,0f,0f)
dest.X = e.ClipRectangle.X;
dest.Y = e.ClipRectangle.Y;
dest.Width = e.ClipRectangle.Width;
dest.Height = e.ClipRectangle.Height;
source.X = dest.X / zoom;
source.Y = dest.Y / zoom;
source.Width = dest.Width / zoom;
source.Height = dest.Height / zoom;
e.Graphics.InterpolationMode =
InterpolationMode.NearestNeighbor;
e.Graphics.PixelOffsetMode =
PixelOffsetMode.HighQuality;
e.Graphics.DrawImage(image, dest, source,
GraphicsUnit.Pixel);
}
if(deleg != null)
deleg(this, e);
base.OnPaint(e);
}
Basically, what I'm looking for is something like a simple pixel resize. I've tried doing this manually, but with bigger images it takes a lot of resources. Any ideas?
|
|
|
|
|
jacal99 wrote:
the application gole is to hook the keyboard when the service starts and create a file on d:\123.txt and save all the pressed keys in this file
It sounds like you are creating spyware. If that is the case, do you really expect much help?
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
|
|
|
|
|
i never thought how you response ... in my mind this was for only for learning pourpose ... not for a sh*t things
Mazhar Hussain
|
|
|
|
|
jacal99 wrote:
in my mind this was for only for learning pourpose
If you can explain why you would need to learn this, if not for learning to creating spyware, then someone might help.
Perhaps your goal is to learn how to use Windows Services (rather than capturing keys). If that is the case then there are many other things a service could be doing that would teach you how they work.
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
|
|
|
|
|
hi
i want design setup for my program.but i dont know what i do?
please help me
thanks
|
|
|
|
|
Hi,
You mean that you want to create a setup file for your program.Am i right ?
In VS.Net you can see Setup and Deployment once you start a new project. ie, File -> New Project -> setup and deployement. Form there you can choose setup project template. Once you choose this template then IDE will give you a file system tab with three folder called application folder, user desktop and user program menu.
Once you seen this much information then you can add your project(application ) into this using File ->Add -> projects -> Existing project.
Here you need to mention the directory where you kept your project and select the solution file and press ok once you locate the solution file.
Now you added your project file to the setup project. You can see the project file if you click on the solution explorer.
Now right click the application folder which is listed in the file system tab and choose add then the project output.
Application Folder -> Add -> project output. Hold the ctrl key and select all information except Debug symbol and source files. Then click ok to continue.
Then use ctrl+F5 to build your setup. Now you can view the setup file is there in Debug folder of your setup project. I know that this is not sufficient. But still you need to adjust with this. Better go for microsoft site their you will get step by step explanation with screen shots.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Can anyone give me a simple example of how to send information (eg the data stored in a Color variable) from an MDIChild to an MDI Parent?
THanks
Finn
|
|
|
|
|
Forms have a property called MdiParent . When the form is being used as an MDI Child it is used to access the parent. You must cast the value returned to the correct class, unless all you are interested in is only the functionality exposed by .NET.
Assuming your parent form class is called MyForm , and the value is accessed through a property called SomeProperty the code might look something like this:
MyForm parent = (MyForm)this.MdiParent;
parent.SomeProperty = someValue;
Does this help?
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
|
|
|
|
|
yes it does!
thanks!
|
|
|
|
|
i'm looking for e component in c# that in like a textbox but it just accept 0 and 1 input's .
|
|
|
|
|
catch the keypress event and discard all keys that are not 1 and 0 by setting Handled to true. look her for more information: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWindowsFormsControlClassKeyPressTopic.asp
|
|
|
|
|
hi.
started with a little hyperlink import tool 2 my mysql db ... now i am stocked.
problem :
i have an string[] with paths of the *.url files my prog found in a given directory. now i would like
to read out the title/name of the hyperlink an also its webadress so i can later import those infos. all things i´ve tried didnt really solve my wishes or went completly wrong.
anyone out here, who can give me a hint ? for me, it looks like i didnt find the right class/method to manage the url/bookmark file handling. tried also google and different c# sites but seems no one ever works with urls or its so easy ...
any help or idea very welcome
|
|
|
|
|
The file is quite a simple format, based on the same format of the Windows 3.1 (remember that far back??) .ini files.
The contents of url file to, say, my blog would look like this:
[DEFAULT]
BASEURL=http:
[InternetShortcut]
URL=http:
Modified=D077362AE99DC401F2
As you can see the title isn't here, that's because it is the same as the .url filename (without the .url extension).
So, all you need to do is to open the .url file as a text file, read until the line
[InternetShortcut] and then look for a line starting "URL=", everything after that on that line is the URL you are looking for.
I would give you a link, but for some reason the MSDN website is playing up at the moment, so I cannot find what I'm looking for.
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
|
|
|
|
|
damn it ... until the [Default] i was already but it seems wrong to me so i deleted the code and try another way
thx for the clearance.
|
|
|
|
|
I have a rich textbox with bold text on my form and I want to copy it over into a textbox in a word document. The problem is that when I do it, it looses it's formating and is not bold anymore.
How would I go about copying text while preserving the same style that it had.
Also, how would I store Rich text in access database and not have it loose the formating.
Thanks
|
|
|
|
|
IIRC, there's no direct way to insert RTF text into a word document.
I had to perform a similar task once and had to resort to copying the RTF from the RichTextBox to the clipboard, set the target Range in the Word document and then perform a Paste to insert the RTF.
Afterwards, I've restored the clipboard contents.
Regards,
mav
|
|
|
|
|
right hello
I have loaded the contents of a picturebox into a bitmap variable...
Bitmap bmp = new Bitmap(pictureBox1.Image);
like so...
when someone clicks on the image how can i get the XY coordinates of the pixel that was clicked.. and then do a GetPixel on the location?
I cant use Mouse event args e.x/e.y because that gives me the position of the click on the whole screen... not the position of the click on the picturebox...
any ideas?
ps. i cant just find the xy position of the click on the screen and then trace it back to the form and the position of the picturebox becase of form borders and different XP Styles...
Thanks in advanced.
Finn
|
|
|
|
|
If you're handling the MouseDown event of the PictureBox control, the X and Y properties return corrdinates relative to the upper left corner of the PictureBox , not the screen. If you're accessing the static X and Y properties of the MousePosition class, you can translate them in to coordinates on your PictureBox by calling the PictureBox 's PointToClient method (inherited from Control ). There is also a PointToScreen to translate the other way.
Charlie
if(!curlies){ return; }
|
|
|
|