Click here to Skip to main content
15,904,416 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to calculate in c# the possibility of this game Pin
OriginalGriff22-Aug-20 22:43
mveOriginalGriff22-Aug-20 22:43 
GeneralRe: How to calculate in c# the possibility of this game Pin
Exoskeletor22-Aug-20 22:57
Exoskeletor22-Aug-20 22:57 
GeneralRe: How to calculate in c# the possibility of this game Pin
OriginalGriff22-Aug-20 23:05
mveOriginalGriff22-Aug-20 23:05 
GeneralRe: How to calculate in c# the possibility of this game Pin
Exoskeletor22-Aug-20 23:28
Exoskeletor22-Aug-20 23:28 
GeneralRe: How to calculate in c# the possibility of this game Pin
Luc Pattyn23-Aug-20 12:51
sitebuilderLuc Pattyn23-Aug-20 12:51 
GeneralRe: How to calculate in c# the possibility of this game Pin
Exoskeletor23-Aug-20 13:01
Exoskeletor23-Aug-20 13:01 
GeneralRe: How to calculate in c# the possibility of this game Pin
Luc Pattyn23-Aug-20 13:03
sitebuilderLuc Pattyn23-Aug-20 13:03 
GeneralRe: How to calculate in c# the possibility of this game Pin
Exoskeletor23-Aug-20 13:06
Exoskeletor23-Aug-20 13:06 
GeneralRe: How to calculate in c# the possibility of this game Pin
trønderen23-Aug-20 13:28
trønderen23-Aug-20 13:28 
GeneralRe: How to calculate in c# the possibility of this game Pin
Exoskeletor23-Aug-20 13:33
Exoskeletor23-Aug-20 13:33 
GeneralRe: How to calculate in c# the possibility of this game Pin
Luc Pattyn23-Aug-20 15:57
sitebuilderLuc Pattyn23-Aug-20 15:57 
GeneralRe: How to calculate in c# the possibility of this game Pin
Exoskeletor24-Aug-20 0:35
Exoskeletor24-Aug-20 0:35 
GeneralRe: How to calculate in c# the possibility of this game Pin
Richard MacCutchan24-Aug-20 1:04
mveRichard MacCutchan24-Aug-20 1:04 
GeneralRe: How to calculate in c# the possibility of this game Pin
Exoskeletor24-Aug-20 1:10
Exoskeletor24-Aug-20 1:10 
GeneralRe: How to calculate in c# the possibility of this game Pin
Eddy Vluggen24-Aug-20 12:52
professionalEddy Vluggen24-Aug-20 12:52 
GeneralRe: How to calculate in c# the possibility of this game Pin
Exoskeletor24-Aug-20 23:22
Exoskeletor24-Aug-20 23:22 
GeneralRe: How to calculate in c# the possibility of this game Pin
Luc Pattyn24-Aug-20 7:48
sitebuilderLuc Pattyn24-Aug-20 7:48 
GeneralRe: How to calculate in c# the possibility of this game Pin
Exoskeletor24-Aug-20 23:22
Exoskeletor24-Aug-20 23:22 
GeneralRe: How to calculate in c# the possibility of this game Pin
trønderen26-Aug-20 0:50
trønderen26-Aug-20 0:50 
GeneralRe: How to calculate in c# the possibility of this game Pin
Exoskeletor23-Aug-20 19:23
Exoskeletor23-Aug-20 19:23 
QuestionHow do I load a block on a form at startup Pin
Brian_TheLion22-Aug-20 18:56
Brian_TheLion22-Aug-20 18:56 
AnswerRe: How do I load a block on a form at startup Pin
BillWoodruff22-Aug-20 19:12
professionalBillWoodruff22-Aug-20 19:12 
AnswerRe: How do I load a block on a form at startup Pin
OriginalGriff22-Aug-20 20:48
mveOriginalGriff22-Aug-20 20:48 
Don't just draw the block like that - partly because it'll disappear when you minimize the form or drag another form over the top, and partly because you need to Dispose of all Graphics contexts you create as soon as you are finished with them. The best way of doing that is via a using block:
C#
using (Graphics gs = this.CreateGraphics())
    {
    using (Brush b = new SolidBrush(Color.Red))
        {
        using (Pen p = new Pen(b))
            {
            gs.DrawRectangle(p, Goal);
            ...
            }
        }
    ...
    }
Note that that also applies to Pens, Brushes, and other Graphics elements.

If you want to draw on your form, then handle the Form.Paint event and use the graphics context provided:
C#
private void FrmMain_Paint(object sender, PaintEventArgs e)
    {
    using (Brush b = new SolidBrush(Color.Red))
        {
        using (Pen p = new Pen(b))
            {
            e.Graphics.DrawRectangle(p, Goal);
            }
        }
    }

"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!

GeneralRe: How do I load a block on a form at startup Pin
Brian_TheLion23-Aug-20 14:33
Brian_TheLion23-Aug-20 14:33 
AnswerRe: How do I load a block on a form at startup Pin
Luc Pattyn23-Aug-20 2:49
sitebuilderLuc Pattyn23-Aug-20 2:49 

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.