Nodes in Windows Forms - c#

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?:

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):
You can create almost every layout you want using grids, borders, stackpanels, dockpanels, paths etc.

Related

More views of a form in c#

Let's say I have two "views". Each view has it's own button, which makes other view to appear. All should be managed in one window. So how do I achieve this? Im looking for something like viewController in iOS...
I tried to use one filled, docked panel - but than all classes are active, so it doesn't seem like a good solution. I also tried user classes (like this), it works, but it's complicated and I have big deal sending data between these classes.
There is no such thing as "views" of a form. The concept of what a UIViewController can do in iOS is different than building a properly functioning form in C#. You need to learn some new skills now and approach this from a different perspective.
The basic principle is to build a form with controls (either manually or through code or both), change the properties of those controls manually or through code and use the methods they support. You can do what you want, but it's going to take learning some new things.
Try checking this out:
https://msdn.microsoft.com/en-us/library/360kwx3z(v=vs.90).aspx
It's not 100% clear what you are trying to do, but it sounds like you should look into User Controls or Composite Controls.

Best way to create a multiple windows WPF C# application?

I'm currently working on a school project where I'm asked to develop a C# WPF application. I'm implementing the MVVM design-pattern. This is why my main goal is to avoid using code-behind as much as I can. My main concern is that I'm trying to figure out an effective way around my software's "menu navigation" system.
For example, I'd like to have different windows to update clients, another to manage the employees and so on. My teacher said the best way would be to create an user control and adding it on every single window. How would that work? I would have to be able to detect the click on the user control and opening/loading the correct window according to that.
And if you try to organize your projects in tabs with a TabControl? You can personalize it too!

Reducing Complexities in Single form Application

I've created a win form application which consist of a single form. We have 8 tabs to access the modules of application.
The problem is we are a team of 4 who works on this project. But since it is a single form application, only one person can use the file at a time. Is there anyother way to build application with more than one file?
Please provide some solution.
Firstly, you should probably have a separate UserControl per tab. That will give you 8 files (at least) since you have 8 tabs.
Secondly, you should be using a Model-View-Controller style architecture for Windows Forms applications. That will give you at least one controller, but likely you will have one controller per UserControl (i.e. per tab). You might even have an overall controller that manages the per-tab controllers.
You might only have one data model for the entire app, or you might have one data model per UserControl (tab).
If you did all that, you'd have a few more source files.
However, it's actually difficult to say without knowing anything about your app.
Try using user controls to make each tab modular.
Figure out what are the parameters that each tab accepts and that it exposes and then create user controls that have that behavior.
Here are couple resources to get you started
http://msdn.microsoft.com/en-us/library/aa302342.aspx
User Control vs. Windows Form
User Controls in Windows Forms - Anything similar to ASP.NET User Controls?
Even if this is a giant ball of wax, your source control tools are shoddy and breaking it up into separate classes is hard to do, you can still take advantage of a Form class being a partial class. Which means that you can spread the code over any number of source code files, not just the two files that the designer creates. So a logical organization is to move code that belongs to a particular tab in its own partial class with the same form class name and its own source code file. Some cut+paste required however when you add event handlers with the designer.
Have you considered using MDI?
MSDN Working with MDI...
Examples are in VB.Net but I'm sure it will be easy to use C# if you really want to - I'm not sure why, but... :)

Keeping code tidy on windows forms app with tabs

I'm currently developing an Windows Forms application in C# which will make use of tabs for the GUI. The problem I'm facing though is that the code is becoming untidy.
The reason is that the code for GUI components (such as button clicks) resides on the main form code.
So I'm looking for a way to still handle all the GUI interactions the same way but separate the code in a logical way (e.g. different files). Like having button1_click() reside in another file but work the same way as before.
Thanks :)
You can place each "Tab" into its own UserControl, and handle the events there instead of all within the main form.
As tabs typically each represent something "distinct", this is often fairly simple to implement, and helps clean up your code.

How to change into different sections of your application easily

Im currently trying to create an application that will require 10+ different "pages" with different content and controls, and i need to switch back and forth between them on particular events.
What ive been doing, is just creating all the different sections in grids, and setting their visibility to collapsed, and then when i need to show them, just switch out the visible grid to the new one.
This has several drawbacks, im assuming its very poor from a coding standpoint, and this pretty much dis-allows me from using the designer at all. (i have no idea what performance implications it has, either)
on top of that, every time i switch to the new page, i need to reset all the components (textbox's etc) to their default states, as they dont get reset by becoming invisible :P
on to my question: i need a way to map out all the different pages, provide visually attractive transitions between them, and be able to use a designer to create them (and i dont mean designing it somewhere and then just copying the xaml)
I had looked around, and ran into SketchFlow and it seemed like the perfect solution, i could fade between pages and map everything on a flow chart easily, and then i realized it was only for app prototypes and i couldnt actually compile it as a normal application... and i needed to inherit from a custom Window class aswell.
is there something out there that allows me to do this? or how can i code this to work properly?
note: this ABSOLUTELY needs to stay within one window. i cant venture out into having 10+ different windows that pop up every time i need to change to something. as this happens very frequently
Split the separate sections in individual user controls. This would allow you to design each of them easily. Then on your form use code to create and load a new instance of particular user control that represents the section you need to show, and when transitioning, load the new section and unload the current. this would allow your form to stay relatively lightweight.
An alternative is to create a navigation application and split your sections into separate XAML view and use the standard navigation service to switch between them.
WPF Navigation Overview
Creating Navigation Applications video tutorial
You might wanna convert your "Pages" to usercontrols and use some transitions like mentioned in the below link to switch between controls
http://www.tanguay.info/web/index.php?pg=codeExamples&id=280
for more on using transitions look here
http://www.japf.fr/2009/04/adding-transitions-to-a-mvvm-based-dialog/
or
http://www.japf.fr/2008/07/8/comment-page-1/

Categories