Crainiate Community

Support and discussion for users of Crainiate component software products
Welcome to Crainiate Community Sign in | Join | Help
in Search

How to save flowchart to a xml file when it contains a custom shape?

Last post 09-30-2008 10:03 PM by James Westgate. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 09-28-2008 3:10 PM

    How to save flowchart to a xml file when it contains a custom shape?

    hello,
      I'm trying your ERM Diagram 4.x product.
    I create a complex shape,
    class ActionShape:ComplexShape
      {
      public String vActionType = "";
      public String vActionSecType = "";  
       
      public ActionShape(String actionType, String secType,int seq)
      {  
      vActionType = actionType;
      //Set the shape appearance

      Size = new SizeF(120, 100);
      BorderWidth = 2;

      //Add the internal applicationshape
      SolidElement action = new SolidElement();
      action.Location = new PointF(10, 10);
      action.Height = 25;  
      action.Label = new TextLabel();
      action.Label.Color = Color.Blue;
      action.Label.Text = vActionType+"-"+secType;

      Children.Add("action", action);

      //Add another subshape
      action = new SolidElement();
      action.Location = new PointF(this.Width/2-25, this.Height-30);
      action.Height = 25;
      action.Width = 50;
      action.Label = new TextLabel();  
      action.Label.Text = seq.ToString();  

      Children.Add("actionSeq", action);
      }

      }

     and then I add the complex shape to the flowchart,

    when I tryed to save the flowchart with

    public void SaveToXml(String filename)
      {
      this.flowchart1.Save(@"c:\test.xml", SaveFormat.Xml);  
      }

    then it popup an error say that, the class ActionShape is not marked as serializable.

    when I add [Serializable] at head of ActionShape
    as following:
    [Serializable]
      class ActionShape:ComplexShape
      {
      .......
      }

    then, It can save,
    but when I load it with the following code:
      public void LoadFromXml(String filename)
      {  
      this.flowchart1.Open(filename);
      }

    then, it report that:
    未找到反序列化“WindowsApplication2.ActionShape”类型对象的构造函数。
    means:can not find the deserialization "WindowsApplication2.ActionShape" class's constructor function.

    How should I do?

    Best Regards
    ----------------
    weiqiang
     

    • 121.29.167.99
  • 09-29-2008 4:00 PM In reply to

    • jchau
    • Top 10 Contributor
    • Joined on 05-23-2007
    • Posts 22

    Re: How to save flowchart to a xml file when it contains a custom shape?

    I think you need a Public Sub New() constructor on your custom class.
    • 12.25.73.131
  • 09-30-2008 10:03 PM In reply to

    Re: How to save flowchart to a xml file when it contains a custom shape?

    This is from the "Creating a custom shape" section in the programmer's guide. You need a constructor that accepts serialization info and a context. If there is no additional information, just call the base implementation.
    
    protected Server(SerializationInfo info, StreamingContext context): base(info, context)
    {
    mServerType = (ServerType) Enum.Parse(typeof(ServerType), info.GetString("ServerType"),true);
    mAvailable = info.GetBoolean("Available");
    }
     
    
    public override void GetObjectData(SerializationInfo info, StreamingContext context)
    {
        info.AddValue("ServerType",Convert.ToInt32(ServerType).ToString());
        info.AddValue("Available",mAvailable);
        base.GetObjectData (info, context);
    }
    
    
    • 86.147.176.179
Page 1 of 1 (3 items)