Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How would one make a custom gui in C#

I am interested in making a custom gui in C#, and I would like some advice as how to best go about that. The attached picture is generally what I would like to create - namely drawing text, boxes/backgrounds, pictures, lines, circles, and other gui elements (Like text input fields and the like).

I don't really know where to start, what I have been able to gleam from google searches is that GDI+ and using the paint event might be able to do what I am looking for - but I don't know if that is the way to go about making such a thing, or if it is the wrong tool for the job (aka it is slow/ineffective compared to something else).

//something along the lines of this: 
private void Form1_Paint(object sender, PaintEventArgs e)
{
    System.Drawing.Graphics graphicsObj;

    graphicsObj = this.CreateGraphics();

    Pen myPen = new Pen(System.Drawing.Color.Red, 5);

    Rectangle myRectangle = new Rectangle(20, 20, 250, 200);

    graphicsObj.DrawRectangle(myPen, myRectangle);
}

Thank you for your time, and forgive me if I said anything incorrectly; I am having a hard time even describing to google what I am looking to do--- so your help is really appreciated!!!!

A cool looking node based GUI thing from 3ds max

like image 902
return true Avatar asked Oct 18 '22 11:10

return true


1 Answers

Is WPF an option for you? I would recommend it based on the screenshot you provided. This desktop GUI technology is much better suited than WinForms as your code sample suggests you are using.

  • Learn the basic of WPF and XAML via the link I provided.
  • Then learn about the Canvas panel
  • Then I suggest you learn about Templates

Well, this should get you going. If you have any specific questions I'm sure we' ll be happy to help here at SO.

Update Example of Canvas panel in Items control: https://dannyvanderkraan.wordpress.com/2015/02/12/wpf-listbox-with-arbitrary-positioning-and-custom-shaped-items/

like image 97
Danny van der Kraan Avatar answered Oct 21 '22 07:10

Danny van der Kraan