0

So I have experience in C++ and I am now messing around in C# .NET with the Windows Forms. I know how to create a new Form, which I can use as a new window. And that you can also create user control, a component or a normal class.

Now I made an application in C++ but I want to convert it to C# .NET. In C++ I made the whole gui myself. But I want to do that now in C# .NET for practice.

In that application, the user could create nodes (Like you can in unreal engine 4 in the blueprints, see example picture)

Now I am unsure what would be the best way to do this in Windows forms.

Making a new form doesn't seem like the correct way. Because the nodes have to be inside of the main screen. And you should be able to move the grid which hold the nodes. So nodes shouldnt be able to exit the main screen that holds them.

Is it better to create it from scratch myself in a class? Or can I achieve this with a user control or component class? I do not understand what the best use of these classes are and what they are used for.

So I want to make something like this, and the question is what is the best type of class to make the nodes with?: enter image description here

Alexander S.
  • 158
  • 2
  • 16
  • 3
    For something like that, i would advise you to use [WPF](https://msdn.microsoft.com/es-es/library/ms754130(v=vs.110).aspx) instead of Winforms. – Pikoh Nov 29 '16 at 12:40
  • So you want the 'nodes' to be moveable? How do you plan to do the connecting lines. Imo they are the hardes psrt.. Yes, adding a `UserControl node' is what I would recommend which get added to a doublebuffered Panel subclass.. - And yes, it looks like a bit of a stretch for winforms. – TaW Nov 29 '16 at 12:40
  • Agree, WPF will greatly simplify this, E.g. [How to create and connect custom user buttons/controls with lines using windows forms](http://stackoverflow.com/questions/15819318/how-to-create-and-connect-custom-user-buttons-controls-with-lines-using-windows) – Alex K. Nov 29 '16 at 12:41
  • Fair explanation, but it's still too broad. You can use `UserControl` or custom class. In simplest approach it can be just one control which will draw everything (I guess this is the closest approach to how you do it in C++), handle mouse events (to move children), etc. Why winforms btw? It's outdated as for 2016. – Sinatr Nov 29 '16 at 12:41
  • Hmm thanks I will look into WPF, sounds promising. @TaW In C++ I could create the line just by rendering bezierlines that had references to the nodes they where connected to. So when 1 node was finished it send a signal to the bezierline which would send a signal to the next node to start or reset, etc. – Alexander S. Nov 29 '16 at 12:45
  • @Sinatr I am new to .Net and I opened windows forms and started messing around with it. But I didn't now it was outdated. – Alexander S. Nov 29 '16 at 12:47
  • This is entirely too common to waste your time on reinventing that wheel. Or at least find out how they built that wheel. [Look here](http://stackoverflow.com/questions/2005274/free-or-open-source-diagramming-component-for-winforms). – Hans Passant Nov 29 '16 at 12:54
  • 'Outdated' is in the eyes of the beholder. Still the vast majority of projects are written in winforms. In terms of acceptance in the field WPF is a glaring failure despite all of its modern advantages and the glitz it supports.. But this doesn't mean I would advise against WPF here. - The bezier lines are not the problem, if you are happy without routing them around nodes automatically.. But a semi-automatic way is also possible with some (but not too much) effort.. – TaW Nov 29 '16 at 12:55

1 Answers1

1

I think you should use WPF to obtain node-base UI. I developed a program with such an interface in WPF and it was pretty simple (I didn't have any experience in WPF):

enter image description here

You can create almost every layout you want using grids, borders, stackpanels, dockpanels, paths etc.

Paviel Kraskoŭski
  • 1,429
  • 9
  • 16