SWR
SWR
CC#
Created by occluder on 10/1/2024 in #help
✅ Is there a reason to still be using EventArgs and EventHandler<T> for events?
It's not necessary, no. It's just a windows conformance thing. The EventHandler delegate provides two things that can be very useful. 1. The object sender let's the event subscriber know who sent the event. You don't always need this. Sometimes you never need it, and sometimes the type could be guaranteed and defined, but including an object just covers every case. 2. The EventArgs is a base class. If someone decided to override some component class you made that contained events, and wanted to create a new event that internally triggered one of your events, they could do so and pass their derived event data if needed. If they needed to make a specialized EventArgs that held data and needed to pass it to one of your base events, this is possible because the base type is still EventArgs. Events in C# are designed with an external subscriber in mind. We have no idea what they will use the event for, but we want to give them the option to do anything they need and not add any restrictions. So yes, you can make an event of any delegate type, but it may hurt your scalability or subscribers to your events.
3 replies
CC#
Created by HD-Fr0sT on 9/9/2024 in #help
Can you use winAPI gdi and wpf with each other in c#?
What kinds of graphics are you trying to do?
11 replies
CC#
Created by HD-Fr0sT on 9/9/2024 in #help
Can you use winAPI gdi and wpf with each other in c#?
This whole thing feels like an XY problem though. What are you actually trying to do?
11 replies
CC#
Created by HD-Fr0sT on 9/9/2024 in #help
Can you use winAPI gdi and wpf with each other in c#?
No. But I believe you can import a WinForms control into a wpf window. Then you can use System.Graphics stuff on that, which is just a managed wrapper for gdi anyway.
11 replies
CC#
Created by twistw00d on 6/6/2024 in #help
-1 in array?
Sharing the actual code sample might help. Also yeah, it sounds like it's using the String.IndexOf method, which returns -1 if it cannot find a match to some string pattern
13 replies
CC#
Created by Imagine Wagons on 10/4/2023 in #help
❔ Im a beginner doing a graphical assignment in windows forms
Looks like a bunch of ellipses
16 replies
CC#
Created by Relevant on 10/4/2023 in #help
❔ Improving performance for Process.Start
Using asynchronous data streams may be your fastest choice, but it can be annoying to set up.
14 replies
CC#
Created by Relevant on 10/4/2023 in #help
❔ Improving performance for Process.Start
Without seeing your code, this is the best suggestion I can offer you https://stackoverflow.com/questions/4291912/process-start-how-to-get-the-output
14 replies
CC#
Created by Imagine Wagons on 10/4/2023 in #help
❔ Im a beginner doing a graphical assignment in windows forms
Why is it supposed to look like what it looks like? What is the assignment exactly? We can't help you if we don't know why something is right or wrong
16 replies
CC#
Created by Livid on 9/25/2023 in #help
✅ Winforms
Anchor style will change how your button resizes with your window. If that's not what you want, try looking at the Dock property
12 replies
CC#
Created by MadMan on 9/23/2023 in #help
❔ Is it efficient and worth doing?
That's a reasonable choice imo
15 replies
CC#
Created by MadMan on 9/23/2023 in #help
❔ Is it efficient and worth doing?
For window interaction, C# doesn't add enough of a significant extra cost to warrant doing this. However, yes it is possible. If you're doing it for fun, go ahead, but the practicality of this is questionable, and I believe the technical debt to your app that you are introducing would be higher than the invisible gains you are receiving.
15 replies
CC#
Created by Will on 9/23/2023 in #help
✅ Drawing WPF image from byte array
What are you trying to draw?
10 replies
CC#
Created by Will on 9/23/2023 in #help
✅ Drawing WPF image from byte array
You probably can, but if you're doing that, you're better off just rendering to a DX surface.
10 replies
CC#
Created by Will on 9/23/2023 in #help
✅ Drawing WPF image from byte array
But if you want to access the GPU, then wpf will not give you any practical ways to do that. You're better off using GL, DirectX, or vulkan.
10 replies
CC#
Created by Will on 9/23/2023 in #help
✅ Drawing WPF image from byte array
You can render directly to a wpf control by drawing to it's bitmap handle in a paint event. To be clear, that's how it works in win forms at least. Wpf is slightly different but it's the same idea.
10 replies
CC#
Created by Will on 9/23/2023 in #help
✅ Drawing WPF image from byte array
Yes and no. You're asking two separate questions.
10 replies
CC#
Created by K3YS on 9/23/2023 in #help
❔ visual studio windows form app, how can i allow a panel to extend out of the form itsself?
This is a dumb question maybe, but what's wrong with the default behavior of a scroll bar in the combo box? This scales better than your idea. What happens when your combo box extends past your monitor?
58 replies
CC#
Created by Mysel on 9/23/2023 in #help
❔ Foreach on two different lists
Just another way to do exactly what you asked for. But yes, do a structure if you can
23 replies