0

i am working on a visual editor which allow user create a behavior tree easily. i want to write this program with c# windows forms application. it will looks like this pic: enter image description here

i have tried to derive a class named NodeBase from UserControl,which combines a line shape,a rectangle shape and a label. it looks like this:

enter image description here

you see, the child2 node covers the child1 node from the line part even if i set the BackColor of NodeBase to Transparent

any suggestion on how to implements the first picture would be graceful

cloud
  • 505
  • 1
  • 8
  • 21
  • Related: [Winforms: Making a control transparent](http://stackoverflow.com/a/9359642/815938) – kennyzx Nov 26 '14 at 12:05
  • `UserControl` for children is ok. Container should be a custom [user-drawn](http://msdn.microsoft.com/en-us/library/b818z6z6.aspx) control, which has collection of children (tree-alike or a simple list of nodes and each node contains list of connections). It will be a task of this control to query children bounds, calculate and draw connections, **not** `UserControl` should do it. – Sinatr Nov 26 '14 at 13:36
  • winforms doesn't support anything and is completely worthless. You're looking for [WPF](http://www.codeproject.com/Articles/17025/Custom-TreeView-Layout-in-WPF). – Federico Berasategui Nov 26 '14 at 13:41
  • @HighCore maybe i will try WPF later. it is much easier dealing with UI things using WPF than winforms,right? – cloud Nov 26 '14 at 13:48
  • @Sinatr i know what you are saying, user-drawn control can fit my need,though it need much more work – cloud Nov 26 '14 at 13:49

1 Answers1

0

Have you considered using the TreeView class? TreeView nodes can be TreeViews, and there are a lot of properties that you can set to adjust the appearance of the control to your requirements.

Resource
  • 524
  • 4
  • 16
  • can TreeView class implement the first picture? – cloud Nov 26 '14 at 11:58
  • I would think so - that's what I would do. You will need to write some code to make it happen. This tutorial will get you started: http://www.dotnetperls.com/treeview – Resource Nov 26 '14 at 12:06
  • See also here: http://msdn.microsoft.com/en-us/library/windows/desktop/bb760013(v=vs.85).aspx. For example, the TVS_HASLINES property would appear to be relevant. – Resource Nov 26 '14 at 12:08
  • thanks very much, i would try it,and i will let you know if i succeed or not. – cloud Nov 26 '14 at 12:14
  • i've tried `TreeView` class. using TVS_HASLINES property does not fit my need. i've also tried other properties, and got the result that simple `TreeView` class can hardly implements the first picture – cloud Nov 26 '14 at 13:13
  • I'm sorry to hear that, cloud. I thought that a combination of the TreeView and TreeNode ForeColor and BackColor properties with the ability to use images for nodes, ability to join nodes with lines etc would give you what you need. – Resource Nov 26 '14 at 13:20