C
C#17mo ago
Benana

✅ Drawing WFA

Can someone tell me why this doesnt work, the method isn't in the form class but I thought that'd be okay.
3 Replies
Anchy
Anchy17mo ago
please don't post pictures of code it's hard to tell what the issue is as there is not enough details, but you could easily make this an extension method instead of fetching the graphics context yourself you could also use points (like you did while converting) as parameters for your from and to locations your draw function should not really be responsible for converting your strings to points
public static class Draw2DExtensions
{
public static void DrawLine(this Graphics g, Point from, Point to, Color color)
{
using var pen = new Pen(color, 5);
g.DrawLine(pen, from, to);
}
}
public static class Draw2DExtensions
{
public static void DrawLine(this Graphics g, Point from, Point to, Color color)
{
using var pen = new Pen(color, 5);
g.DrawLine(pen, from, to);
}
}
something like that maybe i'm unsure of the logistics of disposing pen in winforms but i vaguely remember you should dispose of them after use
Benana
BenanaOP17mo ago
Thank you!
Accord
Accord17mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server