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


tech.support

Posts: 3343
Joined: Oct 19th, 2005
Re: How to add multiple text to a node?
Reply #15 - Apr 23rd, 2018 at 4:38pm
Print Post  
Try with  -

Code
Select All
if (b != null && b.Shape.ToString() == "MyBlock")
 

  
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 #16 - Apr 24th, 2018 at 3:22am
Print Post  
ShapeNode B = node as ShapeNode;
B not null
ShapeNodeEx B = node as ShapeNodeEx;
B is null

I want to get the data from B
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3343
Joined: Oct 19th, 2005
Re: How to add multiple text to a node?
Reply #17 - Apr 24th, 2018 at 6:08am
Print Post  
You aren't adding ShapeNodeEx-es to diagram.Nodes then, if building diagrams from code. If you are letting users draw interactively, set DiagramView.Behavior = Custom and CustomNodeType = typeof(ShapeNodeEx) to get ShapeNodeEx instances.
  
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 #18 - Apr 25th, 2018 at 1:46am
Print Post  
how to save and open?
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3343
Joined: Oct 19th, 2005
Re: How to add multiple text to a node?
Reply #19 - Apr 25th, 2018 at 7:25am
Print Post  
Call RegisterItemClass() to register your custom type for serialization. Implement either SaveTo / LoadFrom methods for binary serialization or SaveToXml / LoadFromXml ones for XML one. E.g. see these topics -

https://mindfusion.eu/Forum/YaBB.pl?num=1203351980/0#0
https://mindfusion.eu/Forum/YaBB.pl?num=1336836718/3#3
  
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 #20 - Apr 25th, 2018 at 1:10pm
Print Post  
Code (C++)
Select All
        public MainForm()
		{
			InitializeComponent();

            Diagram.RegisterItemClass(typeof(ShapeNodeEx), "ShapeNodeEx", 1);
......
}

        class ShapeNodeEx : ShapeNode
        {
            public ShapeNodeEx(ShapeNode prototype) : base(prototype)
            {
            }
            public ShapeNodeEx()
            {
            }

            public string MoreText { get; set; }

            public override void DrawLocal(Drawing.IGraphics graphics, RenderOptions options)
            {
                base.DrawLocal(graphics, options);

                StringFormat drawFormat = new StringFormat();
                graphics.DrawString(MoreText, new Font("Yahei", 7), Brushes.DarkBlue , (float)(Bounds.Width * .5), (float)(Bounds.Height*.85), drawFormat);
            }

            protected override void SaveTo(System.IO.BinaryWriter writer, PersistContext ctx)
            {
                base.SaveTo(writer, ctx);
            }

            protected override void LoadFrom(System.IO.BinaryReader reader, PersistContext ctx)
            {
                base.LoadFrom(reader, ctx);
            }

        }
 



But the data is disorganized after loading
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3343
Joined: Oct 19th, 2005
Re: How to add multiple text to a node?
Reply #21 - Apr 25th, 2018 at 3:55pm
Print Post  
You must save and load your property values from respective methods implementations -

Code
Select All
protected override void SaveTo(System.IO.BinaryWriter writer, PersistContext ctx)
{
	base.SaveTo(writer, ctx);
	writer.Write(MoreText);
}

protected override void LoadFrom(System.IO.BinaryReader reader, PersistContext ctx)
{
	base.LoadFrom(reader, ctx);
	MoreText = reader.ReadString();
} 

  
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 #22 - Apr 29th, 2018 at 7:40am
Print Post  
Perfect,
Thx
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1 [2] 
Send TopicPrint