C
C#9mo 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
Tsjech9mo 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
Pobiega9mo ago
Please don't share your code as screenshots, use $code instead
MODiX
MODiX9mo 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
Pobiega9mo 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
Tsjech9mo ago
this is from textbook its an image lmao
Pobiega
Pobiega9mo ago
well where is your code
Tsjech
Tsjech9mo ago
mine?
Pobiega
Pobiega9mo ago
when i try it i cant and i think its...
yes
Tsjech
Tsjech9mo ago
No description
Tsjech
Tsjech9mo 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
Pobiega9mo 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
Tsjech9mo ago
doesnt scherm inherit form form?
Pobiega
Pobiega9mo ago
no, scherm is a variable of type Form
Tsjech
Tsjech9mo ago
i added a ; 🤦
Tsjech
Tsjech9mo ago
No description
Tsjech
Tsjech9mo ago
yep that is it SECOND TIME THIS WEEK ty anyways!
Pobiega
Pobiega9mo 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
Tsjech9mo ago
variable scopes?
Pobiega
Pobiega9mo ago
$scopes
MODiX
MODiX9mo 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
Pobiega9mo ago
$structure
MODiX
MODiX9mo 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
Tsjech9mo ago
oh like that ye i think its cuz the course is imperative programming
Pobiega
Pobiega9mo ago
mhm
Tsjech
Tsjech9mo ago
so we never use 2 things at once if that makes sense its all line by line
Pobiega
Pobiega9mo ago
no fucking clue why you'd use an OOP GUI framework to practice imperative programming thats... just stupid 🙂
Tsjech
Tsjech9mo ago
uni 🙂 ty anyways tho
Pobiega
Pobiega9mo ago
Yeah I mean that the course design is stupid
Tsjech
Tsjech9mo ago
ye exactly we had if statement after like while and paint and shit idrk what they are on
Pobiega
Pobiega9mo ago
Well, if you feel that the thread is over, feel free to $close it
MODiX
MODiX9mo ago
Use the /close command to mark a forum thread as answered
Want results from more Discord servers?
Add your server
More Posts