C
C#12mo 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
Anchy12mo 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
Benana12mo ago
Thank you!
Accord
Accord12mo 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
More Posts
❔ I have trouble understanding AutoSize**Winforms** There is an AutoSize property on most containers, the documentation says that it will m❔ What does the "required" constraint do in route templates?https://learn.microsoft.com/en-us/aspnet/core/fundamentals/routing?view=aspnetcore-7.0#route-templat✅ Why is the trailing dot of a route template optional?Here https://learn.microsoft.com/en-us/aspnet/core/fundamentals/routing?view=aspnetcore-7.0#route-te❔ fluent api naming/designHi all, working on designing a fluent api inspired by EF Core, in this case the IEntityTypeBuilder ❔ Github Actions on .NET SDK 8.0.100-preview.5.23303.2Hello, when I use SDK 6, everything works, but on 8 it does not. Locally it works. ''' name: .NET❔ Trying to setup C# environment for first time. Debian linuxdistro: Debian 12 I installed .net stuff using these instructions: https://learn.microsoft.com/en-us❔ Good way to make sure a user is allowed to do something based on context in ASP.NET?I'm making a website where people can join projects and then post in those projects. Currently, in oForeach loop inside List<T> classOkay so I'm actually quite confused on this. I have a collection of roles that I'd like to store ins❔ CS0103: The name 'HudController' does not exist in the current contextI am using the package SpiderHeck.GameLibs 1.25.0-r.4 from https://nuget.modweaver.org. My IDE (RideEF Error SQLite Error 1: 'no such table: __EFMigrationsHistory'. when i run dotnet ef databas updateiam using linux and vs code .Net 7 was following this tutorial https://www.youtube.com/watch?v=PDiRD