Click here to Skip to main content
15,924,367 members
Home / Discussions / C#
   

C#

 
AnswerRe: Help with client-server application that send images to a client Pin
Mbah Dhaim22-May-09 1:13
Mbah Dhaim22-May-09 1:13 
QuestionCoordinates problem Pin
Silvyster22-May-09 0:08
Silvyster22-May-09 0:08 
AnswerRe: Coordinates problem Pin
molesworth22-May-09 0:12
molesworth22-May-09 0:12 
GeneralRe: Coordinates problem Pin
Silvyster22-May-09 0:32
Silvyster22-May-09 0:32 
GeneralRe: Coordinates problem Pin
molesworth22-May-09 0:51
molesworth22-May-09 0:51 
GeneralRe: Coordinates problem Pin
Silvyster22-May-09 1:13
Silvyster22-May-09 1:13 
GeneralRe: Coordinates problem Pin
OriginalGriff22-May-09 1:27
mveOriginalGriff22-May-09 1:27 
GeneralRe: Coordinates problem Pin
molesworth22-May-09 1:38
molesworth22-May-09 1:38 
Silvyster wrote:
from what i understand the locations in the C# controls such as a form and a panel are by pixelsand of the INT data type.


The problem you'll have is that unless you're moving your object exactly along the X or Y direction, or at 45 degrees, you won't have an integer number of pixels in each direction.

What you need to do is something like :-

float ratio = (float)(y2 - y1) / (float)(x2 - x1);    // note : this is dY / dX, not as in previous post

int step = (x2 > x1)? 1 : -1;

float newFloatY = y1;
int newX = x1;

for (int loop=x1; loop!=x2; loop+=step)
{
    newX++;
    newFloatY += ratio;

    int newY = (int)(newFloatY);

    // position object at newX, newY...
}

You'll need to modify it if you want to move by 1 pixel in Y, and cope with special cases like moving exactly horizontally or vertically, but those are "left as an exercise for the reader"... Smile | :)

There are three kinds of people in the world - those who can count and those who can't...

Questioncreate Timers dynamically Pin
Member 305788721-May-09 23:50
Member 305788721-May-09 23:50 
AnswerRe: create Timers dynamically Pin
musefan22-May-09 0:03
musefan22-May-09 0:03 
GeneralRe: create Timers dynamically Pin
Member 305788722-May-09 0:25
Member 305788722-May-09 0:25 
GeneralRe: create Timers dynamically Pin
musefan22-May-09 0:31
musefan22-May-09 0:31 
GeneralRe: create Timers dynamically Pin
DaveyM6922-May-09 0:43
professionalDaveyM6922-May-09 0:43 
GeneralRe: create Timers dynamically Pin
musefan22-May-09 0:46
musefan22-May-09 0:46 
AnswerRe: create Timers dynamically Pin
DaveyM6922-May-09 0:18
professionalDaveyM6922-May-09 0:18 
GeneralRe: create Timers dynamically Pin
Member 305788722-May-09 4:47
Member 305788722-May-09 4:47 
GeneralRe: create Timers dynamically Pin
DaveyM6922-May-09 6:23
professionalDaveyM6922-May-09 6:23 
GeneralRe: create Timers dynamically Pin
mell mell28-Dec-18 6:24
mell mell28-Dec-18 6:24 
Questioni cant get a class i made- description inside- win app Pin
dinbrca3521-May-09 23:35
dinbrca3521-May-09 23:35 
AnswerRe: i cant get a class i made- description inside- win app Pin
musefan21-May-09 23:58
musefan21-May-09 23:58 
Questiondatagridview column Pin
michaelgr121-May-09 23:28
michaelgr121-May-09 23:28 
AnswerRe: datagridview column Pin
Mycroft Holmes21-May-09 23:48
professionalMycroft Holmes21-May-09 23:48 
GeneralRe: datagridview column Pin
michaelgr122-May-09 1:42
michaelgr122-May-09 1:42 
GeneralRe: datagridview column Pin
Mycroft Holmes22-May-09 2:45
professionalMycroft Holmes22-May-09 2:45 
QuestionSecurity "string" encrypt Pin
evangile21-May-09 22:56
evangile21-May-09 22:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.