Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Tree Expand/Collapse (Read 5058 times)
newbieDraw
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 24
Joined: Dec 22nd, 2011
Tree Expand/Collapse
Mar 14th, 2013 at 5:39pm
Print Post  
Hi Stoyo,

I have created custom nodes classes with over-ridden draw methods. The expand/collapse button is not visible, and the diagram does not open/collapse as a tree. I have set all relevant properties to true (Expandable, ExpandButtonPosition, ExpandOnIncoming, etc). Kindly help.

Thanks

  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Tree Expand/Collapse
Reply #1 - Mar 14th, 2013 at 5:57pm
Print Post  
Hi,

You can call DrawManipulators from a Draw override to show the expand/collapse button. It's better to override DrawLocal instead of Draw, or otherwise you will lose support for some other features such as rotation and anchor points.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
newbieDraw
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 24
Joined: Dec 22nd, 2011
Re: Tree Expand/Collapse
Reply #2 - Mar 14th, 2013 at 6:04pm
Print Post  
Code
Select All
 public override void Draw(IGraphics graphics, RenderOptions options)
        {
            System.Drawing.Pen blackpen = new System.Drawing.Pen(Color.Black, 0.1f);
            blackpen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
            System.Drawing.Image img = System.Drawing.Image.FromFile(@"C:\temp\segment.png");
            RectangleF rect = new RectangleF(Bounds.X  + Bounds.Width/4, Bounds.Y, Bounds.Width / 2, Bounds.Height / 2);
            graphics.DrawImage(img, rect);
            System.Drawing.Pen graypen = new System.Drawing.Pen(Color.Silver, 0.1f);
            graphics.DrawRectangle(graypen, Bounds.X, Bounds.Y, Bounds.Width, Bounds.Height / 2);
            graphics.DrawRectangle(blackpen, Bounds.X, Bounds.Y + Bounds.Height/2, Bounds.Width, Bounds.Height/2);

            RectangleF stringRect = new RectangleF(Bounds.X, Bounds.Y + Bounds.Height / 2 + Bounds.Height / 16, Bounds.Width, Bounds.Height / 2);
            StringFormat format = new StringFormat();
            format.Alignment = StringAlignment.Center;
            format.LineAlignment = StringAlignment.Center;
            Font font = new Font("Arial", 3, FontStyle.Regular, GraphicsUnit.Pixel);
            System.Drawing.SolidBrush brsh = new System.Drawing.SolidBrush(Color.Black);
            graphics.DrawString(this.Text, font, brsh, stringRect, format);
            this.DrawManipulators(graphics, true);

        } 



I have inserted the code above. Can you please provide a sample - how to implement drawmanipulators().
  
Back to top
 
IP Logged
 
newbieDraw
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 24
Joined: Dec 22nd, 2011
Re: Tree Expand/Collapse
Reply #3 - Mar 14th, 2013 at 6:27pm
Print Post  
I implemented the code and it works; however, only the links collapse, the nodes remain in place. Please let me know how to fix this.

Thanks,

  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Tree Expand/Collapse
Reply #4 - Mar 14th, 2013 at 6:37pm
Print Post  
That should work out of the box with latest release. If using older version, add this to the beginning of your draw override:

Code
Select All
if (!ShouldRender())
    return; 

  
Back to top
 
IP Logged
 
newbieDraw
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 24
Joined: Dec 22nd, 2011
Re: Tree Expand/Collapse
Reply #5 - Mar 14th, 2013 at 7:01pm
Print Post  
Thanks, that works perfectly.

  
Back to top
 
IP Logged
 
newbieDraw
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 24
Joined: Dec 22nd, 2011
Re: Tree Expand/Collapse
Reply #6 - Aug 14th, 2013 at 11:21pm
Print Post  
Stoyo,

I have developed a new node class; the drawing logic is almost same as in the thread above and the node expand and collapse functions are working (i have to click in some blank space next to the node and it works). However, the plus sign is not visible. Please let me know what might be wrong.

Thanks
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Tree Expand/Collapse
Reply #7 - Aug 15th, 2013 at 5:28am
Print Post  
Are you calling DrawManipulators() for the new class as well?
  
Back to top
 
IP Logged
 
newbieDraw
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 24
Joined: Dec 22nd, 2011
Re: Tree Expand/Collapse
Reply #8 - Aug 15th, 2013 at 6:21am
Print Post  
Yes I am calling the drawmanipulators as well. In fact, I imported my previous node classes to this project and they do not show the manipulators either. My previous project was VS2008 .Net 3.5. My current project is VS2012.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Tree Expand/Collapse
Reply #9 - Aug 15th, 2013 at 7:13am
Print Post  
If the VS2008 project showed them, you are probably using a different version of the control in the VS2012 project. Try passing different arguments to DrawManipualtors, and check if there isn't some clip region set at the time you are calling the method.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint