Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 10 Replies) How to add multiple text to a node? (Read 9437 times)
Gu Wenwei
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 49
Joined: May 2nd, 2017
How to add multiple text to a node?
May 5th, 2017 at 2:48am
Print Post  
How to add multiple text to a node
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: How to add multiple text to a node?
Reply #1 - May 5th, 2017 at 8:29am
Print Post  
Use either TableNode with multiple cells or CompositeNode with multiple TextComponents. If you prefer ShapeNodes, you could set CustomDraw = Additional and draw more text by calling e.Graphics.DrawString from DrawNode event handler.
  
Back to top
 
IP Logged
 
Gu Wenwei
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 49
Joined: May 2nd, 2017
Re: How to add multiple text to a node?
Reply #2 - Oct 12th, 2017 at 5:30am
Print Post  
Excuse me, can you give me an example?
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: How to add multiple text to a node?
Reply #3 - Oct 12th, 2017 at 5:47am
Print Post  
For TableNodes check ClassDiagram or InteractiveTable examples. For CompositeNodes check the Scripting and Demo (EmployeeNode.cs) examples. For custom drawing example see e.g. https://mindfusion.eu/Forum/YaBB.pl?num=1355256377/3#3 , you will need to set node's CustomDraw property to get the event raised.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
Gu Wenwei
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 49
Joined: May 2nd, 2017
Re: How to add multiple text to a node?
Reply #4 - Oct 15th, 2017 at 9:20am
Print Post  
Can Override Shape to Add multiple text?
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: How to add multiple text to a node?
Reply #5 - Oct 16th, 2017 at 5:33am
Print Post  
You can create a custom node class and override its DrawLocal method -

Code
Select All
class ShapeNodeEx : ShapeNode
{
	public string MoreText { get; set; }

	public override void DrawLocal(IGraphics graphics, RenderOptions options)
	{
		base.DrawLocal(graphics, options);
		graphics.DrawString(MoreText, EffectiveFont, Brushes.Black, 1, 1);
	}
} 



Alternatively keep an array of strings as value of Tag property, and draw them in a loop from DrawNode event handler with CusotmDraw property set.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
Gu Wenwei
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 49
Joined: May 2nd, 2017
Re: How to add multiple text to a node?
Reply #6 - Dec 20th, 2017 at 2:09pm
Print Post  
how to Create a ShapeNodeEx?
Cannot that:
ShapeNodeEx b = diagram.Factory.CreateShapeNode(pt, new SizeF(20, 20));
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: How to add multiple text to a node?
Reply #7 - Dec 20th, 2017 at 4:01pm
Print Post  
Code
Select All
var b = new ShapeNodeEx();
b.Bounds = new RectangleF(...);
diagram.Nodes.Add(b); 



Regards,
Slavcho
  
Back to top
 
IP Logged
 
Gu Wenwei
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 49
Joined: May 2nd, 2017
Re: How to add multiple text to a node?
Reply #8 - Mar 10th, 2018 at 1:04pm
Print Post  
How do I put the position of SHAPE in the center?
  

pic_001.png ( 1 KB | 127 Downloads )
pic_001.png
Back to top
 
IP Logged
 
Gu Wenwei
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 49
Joined: May 2nd, 2017
Re: How to add multiple text to a node?
Reply #9 - Mar 11th, 2018 at 3:25am
Print Post  
b.TextFormat.Alignment = StringAlignment.Center;
b.TextFormat.LineAlignment = StringAlignment.Center;
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: How to add multiple text to a node?
Reply #10 - Mar 12th, 2018 at 8:44am
Print Post  
Use the DrawString overload that takes a Rectangle and StringFormat arguments, passing node.GetLocalBounds() and your StringFormat as values.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
Gu Wenwei
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 49
Joined: May 2nd, 2017
Re: How to add multiple text to a node?
Reply #11 - Mar 13th, 2018 at 2:51am
Print Post  
thx
  
Back to top
 
IP Logged
 
Gu Wenwei
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 49
Joined: May 2nd, 2017
Re: How to add multiple text to a node?
Reply #12 - Apr 22nd, 2018 at 1:30pm
Print Post  
how to convert diagram.Nodes to ShapeNodeEx?
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: How to add multiple text to a node?
Reply #13 - Apr 23rd, 2018 at 5:37am
Print Post  
Nodes could contain instances of multiple types. You can use the as operator to determine type while looping over the collection -
Code
Select All
foreach (var node in diagram.Nodes)
{
    var exNode = node as ShapeNodeEx;
    if (exNode != null)
        ...
}
 



or get filtered collection using Linq's OfType extension -
Code
Select All
var exNodes = diagram.Nodes.OfType<ShapeNodeEx>();
 

  
Back to top
 
IP Logged
 
Gu Wenwei
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 49
Joined: May 2nd, 2017
Re: How to add multiple text to a node?
Reply #14 - Apr 23rd, 2018 at 12:28pm
Print Post  
        private void LoadFCSfile(string fn)
        {
            diagramView.LoadFromFile(fn);
            bool btag = false, bp = false;
            foreach (DiagramNode node in diagram.Nodes)
            {
                if (node is ControlNode)
                {
                    btag = true;
                }
                else
                {
                    ShapeNodeEx b = node as ShapeNodeEx;
                    if (b.Shape.ToString() == "MyBlock")  //b is null, ShapeNode b, OK
                    {
                        bp = true;
                    }
                }
            }
        }

b is null
when ShapeNodeEx is ShapeNode, OK
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint