- Welcome, Guest. Please Login or Register
MindFusion  
  We have released initial version of MindFusion.Scheduling library for HTML5 & JavaScript.  
  HomeHelpSearchLoginRegister   
     
     
   
 
Pages: 1 2  Send Topic Print  
How to add multiple text to a node?
Read 1048 times

Gu Wenwei   Offline
YaBB Newbies
*
Posts: 33
I Love MindFusion!


   
     
 
How to add multiple text to a node?
May 5th, 2017 at 3:48am
 
How to add multiple text to a node
 
 
 
IP Logged    
 
     

Slavcho   Offline
God Member
*****
Posts: 1412
Gender: male
tech.support


   
     
 
Re: How to add multiple text to a node?
Reply #1 - May 5th, 2017 at 9:29am
 
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.
 
 
 
IP Logged    
 
     

Gu Wenwei   Offline
YaBB Newbies
*
Posts: 33
I Love MindFusion!


   
     
 
Re: How to add multiple text to a node?
Reply #2 - Oct 12th, 2017 at 6:30am
 
Excuse me, can you give me an example?
 
 
 
IP Logged    
 
     

Slavcho   Offline
God Member
*****
Posts: 1412
Gender: male
tech.support


   
     
 
Re: How to add multiple text to a node?
Reply #3 - Oct 12th, 2017 at 6:47am
 
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
 
 
 
IP Logged    
 
     

Gu Wenwei   Offline
YaBB Newbies
*
Posts: 33
I Love MindFusion!


   
     
 
Re: How to add multiple text to a node?
Reply #4 - Oct 15th, 2017 at 10:20am
 
Can Override Shape to Add multiple text?
 
 
 
IP Logged    
 
     

Slavcho   Offline
God Member
*****
Posts: 1412
Gender: male
tech.support


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

Code:
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
 
 
 
IP Logged    
 
     

Gu Wenwei   Offline
YaBB Newbies
*
Posts: 33
I Love MindFusion!


   
     
 
Re: How to add multiple text to a node?
Reply #6 - Dec 20th, 2017 at 2:09pm
 
how to Create a ShapeNodeEx?
Cannot that:
ShapeNodeEx b = diagram.Factory.CreateShapeNode(pt, new SizeF(20, 20));
 
 
 
IP Logged    
 
     

Slavcho   Offline
God Member
*****
Posts: 1412
Gender: male
tech.support


   
     
 
Re: How to add multiple text to a node?
Reply #7 - Dec 20th, 2017 at 4:01pm
 
Code:
var b = new ShapeNodeEx();
b.Bounds = new RectangleF(...);
diagram.Nodes.Add(b); 



Regards,
Slavcho
 
 
 
IP Logged    
 
     

Gu Wenwei   Offline
YaBB Newbies
*
Posts: 33
I Love MindFusion!


   
     
 
Re: How to add multiple text to a node?
Reply #8 - Mar 10th, 2018 at 1:04pm
 
How do I put the position of SHAPE in the center?
 
 

pic_001.png (1 KB | 11 )
pic_001.png
 
IP Logged    
 
     

Gu Wenwei   Offline
YaBB Newbies
*
Posts: 33
I Love MindFusion!


   
     
 
Re: How to add multiple text to a node?
Reply #9 - Mar 11th, 2018 at 3:25am
 
b.TextFormat.Alignment = StringAlignment.Center;
b.TextFormat.LineAlignment = StringAlignment.Center;
 
 
 
IP Logged    
 
     

Slavcho   Offline
God Member
*****
Posts: 1412
Gender: male
tech.support


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

Regards,
Slavcho
 
 
 
IP Logged    
 
     

Gu Wenwei   Offline
YaBB Newbies
*
Posts: 33
I Love MindFusion!


   
     
 
Re: How to add multiple text to a node?
Reply #11 - Mar 13th, 2018 at 3:51am
 
thx
 
 
 
IP Logged    
 
     

Gu Wenwei   Offline
YaBB Newbies
*
Posts: 33
I Love MindFusion!


   
     
 
Re: How to add multiple text to a node?
Reply #12 - Apr 22nd, 2018 at 2:30pm
 
how to convert diagram.Nodes to ShapeNodeEx?
 
 
 
IP Logged    
 
     

Slavcho   Offline
God Member
*****
Posts: 1412
Gender: male
tech.support


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



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

 
 
 
IP Logged    
 
     

Gu Wenwei   Offline
YaBB Newbies
*
Posts: 33
I Love MindFusion!


   
     
 
Re: How to add multiple text to a node?
Reply #14 - Apr 23rd, 2018 at 1:28pm
 
        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
 
 
 
IP Logged    
 
     
Pages: 1 2  Send Topic Print