Click here to Skip to main content
15,915,703 members
Home / Discussions / C#
   

C#

 
AnswerRe: listview Pin
Kevin Bewley15-Jul-13 5:41
Kevin Bewley15-Jul-13 5:41 
QuestionMVC Grid Pin
_BrijeshSingh8-Jul-13 23:37
_BrijeshSingh8-Jul-13 23:37 
AnswerRe: MVC Grid Pin
Pete O'Hanlon9-Jul-13 0:35
mvePete O'Hanlon9-Jul-13 0:35 
Questiontwo lists with dates and values need to match them Pin
lordoftrades8-Jul-13 21:25
lordoftrades8-Jul-13 21:25 
Questionmd5 hash c# Pin
paulpro1098-Jul-13 17:10
paulpro1098-Jul-13 17:10 
AnswerRe: md5 hash c# Pin
Dave Kreskowiak8-Jul-13 19:04
mveDave Kreskowiak8-Jul-13 19:04 
GeneralRe: md5 hash c# Pin
paulpro10912-Jul-13 15:47
paulpro10912-Jul-13 15:47 
GeneralRe: md5 hash c# Pin
Dave Kreskowiak12-Jul-13 16:17
mveDave Kreskowiak12-Jul-13 16:17 
AnswerRe: md5 hash c# Pin
Manfred Rudolf Bihy8-Jul-13 19:24
professionalManfred Rudolf Bihy8-Jul-13 19:24 
GeneralRe: md5 hash c# Pin
paulpro10912-Jul-13 15:49
paulpro10912-Jul-13 15:49 
AnswerRe: md5 hash c# Pin
Bernhard Hiller8-Jul-13 23:03
Bernhard Hiller8-Jul-13 23:03 
QuestionRe: md5 hash c# Pin
Manfred Rudolf Bihy9-Jul-13 1:53
professionalManfred Rudolf Bihy9-Jul-13 1:53 
AnswerRe: md5 hash c# Pin
paulpro10912-Jul-13 15:51
paulpro10912-Jul-13 15:51 
QuestionThanks for your help Fig. image displayed on the GridControl and XtraReport Pin
nhanlaptrinh8-Jul-13 15:13
nhanlaptrinh8-Jul-13 15:13 
QuestionHow to get rid of interval checkings Pin
leone8-Jul-13 10:49
leone8-Jul-13 10:49 
AnswerRe: How to get rid of interval checkings Pin
Eddy Vluggen9-Jul-13 0:28
professionalEddy Vluggen9-Jul-13 0:28 
Question" System.UriFormatException: Invalid URI : The format of the URI could not be determined " Pin
ChinnuKodali15088-Jul-13 7:06
professionalChinnuKodali15088-Jul-13 7:06 
AnswerRe: " System.UriFormatException: Invalid URI : The format of the URI could not be determined " Pin
Pete O'Hanlon8-Jul-13 7:10
mvePete O'Hanlon8-Jul-13 7:10 
GeneralMessage Closed Pin
8-Jul-13 10:24
professionalChinnuKodali15088-Jul-13 10:24 
GeneralRe: " System.UriFormatException: Invalid URI : The format of the URI could not be determined " Pin
Pete O'Hanlon8-Jul-13 10:29
mvePete O'Hanlon8-Jul-13 10:29 
GeneralRe: " System.UriFormatException: Invalid URI : The format of the URI could not be determined " Pin
ChinnuKodali15088-Jul-13 10:41
professionalChinnuKodali15088-Jul-13 10:41 
GeneralRe: " System.UriFormatException: Invalid URI : The format of the URI could not be determined " Pin
Pete O'Hanlon8-Jul-13 10:44
mvePete O'Hanlon8-Jul-13 10:44 
QuestionMaths for bouncing a ball around a window.. Pin
Kevin Bewley8-Jul-13 4:42
Kevin Bewley8-Jul-13 4:42 
AnswerRe: Maths for bouncing a ball around a window.. Pin
NickPace8-Jul-13 5:10
NickPace8-Jul-13 5:10 
I would use two integer properties for the ball object, called DeltaX and DeltaY. These would represent the number of pixels for the ball to move along the X and Y axis. A good starting point would probably be 3 as a value for both of these variables. When DeltaX is positive, the ball is moving to the right; and when negative, the ball is moving to the left. When DeltaY is positive, the ball is moving down; and when negative, the ball is moving up. When you encounter the edge of the form, simply multiply the appropriate variable by -1 to change its direction.

Something like this:
C#
private bool BallHitBoundary(Ball ball)
{
    /* Check if the game ball hit a form boundary. If so, change the direction of the ball accordingly and
     * return true. Otherwise return false. */
    if (ball.Top <= ClientRectangle.Top || ball.Bottom >= ClientRectangle.Bottom)
    {
        // Game ball hit the top or bottom. Change the Y direction the other way.
        ball.ReverseDeltaY();
        return true;
    }

    if (ball.Left <= ClientRectangle.Left || ball.Right >= ClientRectangle.Right)
    {
        // Game ball hit the left or right side. Change the X direction the other way.
        ball.ReverseDeltaX();
        return true;
    }
    else
    {
        return false;
    }
}

and the ReverseDeltaY() and ReverseDeltaX() are methods for the ball object that simply multiply DeltaY/DeltaX by -1:
XML
/// <summary>
/// Reverses DeltaX by multiplying by -1.
/// </summary>
internal void ReverseDeltaX()
{
    DeltaX *= -1;
}

/// <summary>
/// Reverses DeltaY by multiplying by -1.
/// </summary>
internal void ReverseDeltaY()
{
    DeltaY *= -1;
}


The above is actual code from a project I built to make a Breakout game just for the fun of it. The ball object inherits from a Panel object with a solid circle drawn inside of it. It works good for me.
-NP

Never underestimate the creativity of the end-user.

GeneralRe: Maths for bouncing a ball around a window.. Pin
Kevin Bewley8-Jul-13 5:19
Kevin Bewley8-Jul-13 5:19 

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.