C
C#14mo ago
Tsjech

✅ PaintEventArgs and Graphics

I have the answers to a question yet i dont get how they can write gr = pea.Graphics; when i try it i cant and i think its cuz gr is not declared, am i wrong or are the answers wrong? the first snippet is the starting code and at the place of the comment is the longer code (that youd need to write urself)
No description
No description
31 Replies
Tsjech
TsjechOP14mo ago
(for context this program should create a red dot on the cursor and make a blue box the height of the cursor that fades to aqua, the amount of times clicked are the amount of shades of blue in the box
Pobiega
Pobiega14mo ago
Please don't share your code as screenshots, use $code instead
MODiX
MODiX14mo ago
Posting Code Snippets To post a code snippet type the following: ```cs // code here ``` Notes: - Get an example by typing $codegif in the chat. - Change the language by replacing cs with the language of your choice (for example sql or cpp). - If your code is too long, you can post it to https://paste.mod.gg/ and share the link.
Pobiega
Pobiega14mo ago
gr is just a variable, and we can't see the declaration of it on the right side but I'd be very concerned about keeping a reference to a graphics object retrieved from an event args outside the event handler for said event
Tsjech
TsjechOP14mo ago
this is from textbook its an image lmao
Pobiega
Pobiega14mo ago
well where is your code
Tsjech
TsjechOP14mo ago
mine?
Pobiega
Pobiega14mo ago
when i try it i cant and i think its...
yes
Tsjech
TsjechOP14mo ago
No description
Tsjech
TsjechOP14mo ago
i know gr isnt declared but its weird the answers dont either, and i dont know how to declare it, cuz Graphics gr = pea.Graphics doesnt work either
Pobiega
Pobiega14mo ago
I can see this is winforms, but this is a highly unorthodox way of doing things normally you create classes for each of your forms, inheriting from Form, instead of creating a local instance of Form whats the error on void teken?
Tsjech
TsjechOP14mo ago
doesnt scherm inherit form form?
Pobiega
Pobiega14mo ago
no, scherm is a variable of type Form
Tsjech
TsjechOP14mo ago
i added a ; 🤦
Tsjech
TsjechOP14mo ago
No description
Tsjech
TsjechOP14mo ago
yep that is it SECOND TIME THIS WEEK ty anyways!
Pobiega
Pobiega14mo ago
I'd highly recommend doing some more practice on variables and variable scopes. These are fundamentals that are the backbone of any code.
Tsjech
TsjechOP14mo ago
variable scopes?
Pobiega
Pobiega14mo ago
$scopes
MODiX
MODiX14mo ago
scope A {
thing a;
scope B {
thing b;
}
}
scope A {
thing a;
scope B {
thing b;
}
}
thing a is available in scope A and scope B thing b is available only in scope B
Pobiega
Pobiega14mo ago
$structure
MODiX
MODiX14mo ago
namespace Namespace;

[Attribute]
public class Class
{
public string PublicField;
private bool _privateField;
protected double protectedField;

public int PublicProperty { get; set; }

public Class() {} // Constructor

public void Method(int parameter)
{
var localVariable = parameter;
}
}
namespace Namespace;

[Attribute]
public class Class
{
public string PublicField;
private bool _privateField;
protected double protectedField;

public int PublicProperty { get; set; }

public Class() {} // Constructor

public void Method(int parameter)
{
var localVariable = parameter;
}
}
Tsjech
TsjechOP14mo ago
oh like that ye i think its cuz the course is imperative programming
Pobiega
Pobiega14mo ago
mhm
Tsjech
TsjechOP14mo ago
so we never use 2 things at once if that makes sense its all line by line
Pobiega
Pobiega14mo ago
no fucking clue why you'd use an OOP GUI framework to practice imperative programming thats... just stupid 🙂
Tsjech
TsjechOP14mo ago
uni 🙂 ty anyways tho
Pobiega
Pobiega14mo ago
Yeah I mean that the course design is stupid
Tsjech
TsjechOP14mo ago
ye exactly we had if statement after like while and paint and shit idrk what they are on
Pobiega
Pobiega14mo ago
Well, if you feel that the thread is over, feel free to $close it
MODiX
MODiX14mo ago
Use the /close command to mark a forum thread as answered
Want results from more Discord servers?
Add your server