Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Undo Manage with SVGNode (Read 1822 times)
SemiHum
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 2
Joined: Jun 6th, 2012
Undo Manage with SVGNode
Jun 13th, 2012 at 1:21am
Print Post  
I have a class MySvgNode extended from MindFusion.Diagramming.SVGNode.As the API says,I should override following methods for undo manager
protected override void SaveProperties(DiagramItemProperties props)
protected override void RestoreProperties(DiagramItemProperties props)
protected override DiagramItemProperties CreateProperties()
I tried to use either base class's method or implement MyProperties extended from DiagramItemProperties.But neither works.
Would you help to give some reference or a simple sample even better to show how to extends a SVGNode working with UndoManager?
I'm using version 5.6.4
Thanks~
SemiHum
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Undo Manage with SVGNode
Reply #1 - Jun 13th, 2012 at 8:44am
Print Post  
It seems there was a bug with undo and SvgNode inheritance, which is now fixed in this version:
https://mindfusion.eu/_beta/fcnet581_svgfix.zip

With this build, you can implement undo of custom properties like this:
Code
Select All
class MySvgNode : SvgNode
{
	public string MyProperty { get; set; }

	protected override DiagramItemProperties CreateProperties()
	{
		return new MySvgNodeProperties();
	}

	protected override void SaveProperties(DiagramItemProperties props)
	{
		base.SaveProperties(props);

		var myProps = (MySvgNodeProperties)props;
		myProps.MyProperty = MyProperty;
	}

	protected override void RestoreProperties(DiagramItemProperties props)
	{
		base.RestoreProperties(props);

		var myProps = (MySvgNodeProperties)props;
		MyProperty = myProps.MyProperty;
	}

	public override void Draw(MindFusion.Drawing.IGraphics graphics, RenderOptions options)
	{
		base.Draw(graphics, options);
		graphics.DrawString(MyProperty, Font, Brushes.Black, Bounds);
	}
}

class MySvgNodeProperties : SvgNodeProperties
{
	public string MyProperty { get; set; }
} 



Alternatively, you could work around the problem by not calling base methods; then you would have to add code to save/restore any additional base properties you need, such as Font, Text, SvgContent.

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


I Love MindFusion!

Posts: 2
Joined: Jun 6th, 2012
Re: Undo Manage with SVGNode
Reply #2 - Jun 18th, 2012 at 4:43am
Print Post  
Thanks.It works and helps a lot.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint